WIP: towards no_std, zerocopy, field parsing #1
Loading…
x
Reference in New Issue
Block a user
No description provided.
Delete Branch "somethings"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
A collection of changes aimed at no-std support and efficient decoding of just what the client is interested in. Maybe.
tallybranch this is less impactful than when I started on oldmain- maybe this fully-zero-copy isn't necessary. But then, bit shifts are very cheap...raw_fields) and a somewhat experimental rich parsing based on aFieldtrait. See below.macro_usewith explicit imports in each fileno_stduseall the std stuffField parsing
I'm not too sure about this - I was approaching it from the direction of "make parsing for just the fields you need as cheap as possible" with an eye for embedded no_std tally devices which only care about a few of the possible field types. But I don't know how nice this is in practice given with my current
.fields<F>()iterator you'd need to iterate over the packet's fields N times for every N types of field you were interested in, which seems a bit sad.&[u8], add field parsing a419a78a0a2ec4c231c2tocd614c0956Just doing a high-level read of things and leaving thoughts
@ -0,0 +2,4 @@/// An uninterpreted ATEM protocol field - a 4-ascii character type plus variable length datapub struct RawField<'a> {pub r#type: &'a str,nitpick: I don't think
r#typeis super clear, could beraw_typeor similar?@ -0,0 +26,4 @@#[derive(Debug)]pub struct PrvI {pub m_e_index: u8,nitpick: Super a personal preference thing but I prefer not to contract names and instead write e.g.
mix_effect_indexfor clarity.@ -0,0 +60,4 @@}}pub trait Field<'a>: Sized {suggestion: File clarity could be improved by moving this trait definition up to before any of the implementations of this trait.
@ -0,0 +61,4 @@}pub trait Field<'a>: Sized {const TYPE: &'static str;nitpick: I don't think
TYPEis clear, as to me this suggests "integer" or "string" or similar, whereas it's more to do with the name/label of the field@ -60,0 +116,4 @@////// Returns None if this is a packet without fields.pub fn raw_fields(&self) -> RawFields {// TODO: do we only ever get newsessionid during the handshake (i.e. not in a packet with fields)?iirc, yes.... in normal operation. If we see something from the ATEM we don't like (e.g. it sending us a handshake acknowledgement out-of-sequence) or if our connection to the ATEM times out then we should destroy our held state about the connection and recreate it and gain a new session Id (which is what is implemented on main). So yeah, outside of the handshake we don't need to handle a new session (I believe)
@ -115,0 +170,4 @@if remain == 0 {return None;} else if remain < 8 {// TODO: is 8 indeed the minimum size for something here? (i.e. no field data)12 bytes is the minimum packet length, if a packet is more than 12 bytes then the field data will always be aligned to 8 bytes iirc
Checkout
From your project repository, check out a new branch and test the changes.