Medius - Rust LibraryFrames

Frame types

FrameType and DecodedFrame for low-level work

Low-level types for inspecting raw frame traffic: FrameType is the TYPE byte and DecodedFrame is one parsed frame.

VARIANTS
VariantOpcodeMeaning
Move0x01Motion-tagged cursor or wheel movement (PC to box).
Inject0x03Class-tagged button, key, or media override (PC to box).
Reset0x04Clear all injection (PC to box).
Query0x05Request a state snapshot (PC to box).
Resp0x06Reply to a query, with the request's seq echoed (box to PC).
RebootDl0x07Reboot a chip to download or run (PC to box).
Log0x08Unsolicited device diagnostics (box to PC).
Led0x09Drive a status LED (PC to box).
Lock0x0ABlock a physical input (PC to box).
Catch0x0BSubscribe to physical-input events (PC to box).
MotionEvent0x0CAn unsolicited relative-axis catch event, dx/dy/dz (box to PC).
UsageEvent0x0FAn unsolicited held-usage snapshot: button, key, or media (box to PC).
Option0x11Set a persistent box option by id, e.g. imperfect-clone opt-in or movement riding (PC to box).
ClipAppend0x12Append buffered-clip entries to the device ring; seq = append seq (PC to box).
ClipCtrl0x13Start/stop/arm/config buffered clip playback (PC to box).
DECODEDFRAME
FieldTypeDescription
tyFrameTypeWhich opcode this frame carries.
sequ8The sequence byte; a reply echoes the request's value.
payloadVec<u8>The raw payload bytes, already CRC-checked.
EXAMPLE
use medius::{FrameType, DecodedFrame};

// Byte -> variant is fallible; an unknown opcode is an Err.
assert_eq!(FrameType::try_from(0x06), Ok(FrameType::Resp));
assert!(FrameType::try_from(0xFF).is_err());

// Variant -> byte always works.
assert_eq!(u8::from(FrameType::Log), 0x08);

// Read a decoded frame by field: a MOTION_EVENT carrying dx=5, dy=-5, dz=1.
let frame = DecodedFrame { ty: FrameType::MotionEvent, seq: 7, payload: vec![5, 0, 0xFB, 0xFF, 1, 0] };
println!("{:?} seq={} {} bytes", frame.ty, frame.seq, frame.payload.len());

Full wire layout is on the frame page. For everyday work, stay on Requests and Diagnostics instead.