WIP: towards no_std, zerocopy, field parsing #1
Loading…
Reference in New Issue
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.
tally
branch 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 aField
trait. See below.macro_use
with explicit imports in each fileno_std
use
all 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.2ec4c231c2
tocd614c0956
Just 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 data
pub struct RawField<'a> {
pub r#type: &'a str,
nitpick: I don't think
r#type
is super clear, could beraw_type
or 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_index
for 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
TYPE
is 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
Step 1:
From your project repository, check out a new branch and test the changes.Step 2:
Merge the changes and update on Gitea.