pub enum PacketLengthStrategy {
Fixed(usize),
LengthByte {
index: usize,
offset: usize,
},
}Expand description
Stratégie utilisée pour déterminer la longueur totale d’une trame.
Variants§
Fixed(usize)
La trame a une longueur totale fixe (en-tête inclus).
§Exemple
Pour un protocole dont chaque trame fait toujours 8 octets :
let strategy = PacketLengthStrategy::Fixed(8);LengthByte
Un octet situé à la position index dans le buffer indique le nombre
d’octets restants après lui-même. offset est ajouté à cette valeur
pour obtenir la longueur totale de la trame.
Longueur totale = buffer[index] as usize + offset
§Exemple
Pour un protocole dont l’octet à l’index 2 indique la taille du payload, et où la trame totale inclut 3 octets de structure supplémentaires (en-tête + octet de longueur + CRC) :
let strategy = PacketLengthStrategy::LengthByte { index: 2, offset: 3 };Trait Implementations§
Source§impl Clone for PacketLengthStrategy
impl Clone for PacketLengthStrategy
Source§fn clone(&self) -> PacketLengthStrategy
fn clone(&self) -> PacketLengthStrategy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreimpl Copy for PacketLengthStrategy
Source§impl Debug for PacketLengthStrategy
impl Debug for PacketLengthStrategy
impl Eq for PacketLengthStrategy
Source§impl PartialEq for PacketLengthStrategy
impl PartialEq for PacketLengthStrategy
Source§fn eq(&self, other: &PacketLengthStrategy) -> bool
fn eq(&self, other: &PacketLengthStrategy) -> bool
Tests for
self and other values to be equal, and is used by ==.impl StructuralPartialEq for PacketLengthStrategy
Auto Trait Implementations§
impl Freeze for PacketLengthStrategy
impl RefUnwindSafe for PacketLengthStrategy
impl Send for PacketLengthStrategy
impl Sync for PacketLengthStrategy
impl Unpin for PacketLengthStrategy
impl UnsafeUnpin for PacketLengthStrategy
impl UnwindSafe for PacketLengthStrategy
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more