Trait Serialization

Source
pub trait Serialization {
    const HEAD: u16 = 43_690u16;
    const TAIL: u16 = 21_845u16;
    const SIZE: usize = 0usize;

    // Required method
    fn from_bytestream(
        bytestream: &Vec<u8>,
        pos: &mut usize,
    ) -> Result<Self, SerializationError>
       where Self: Sized;

    // Provided methods
    fn verify_fixed(
        stream: &Vec<u8>,
        pos: &mut usize,
    ) -> Result<(), SerializationError> { ... }
    fn from_bytestream_alt(
        bytestream: &Vec<u8>,
        pos: &mut usize,
    ) -> Result<Self, SerializationError>
       where Self: Sized { ... }
    fn to_bytestream(&self) -> Vec<u8>  { ... }
}
Expand description

Encode/decode structs to Vec::<u8> to write to a file or send over the network

Provided Associated Constants§

Source

const HEAD: u16 = 43_690u16

Byte marker to mark beginning of payload

Source

const TAIL: u16 = 21_845u16

Byte marker to mark end of payload

Source

const SIZE: usize = 0usize

The SIZE is the size of the serialized bytestream INCLUDING 4 bytes for head and tail bytes. In case the struct does NOT HAVE a fixed size, SIZE will be 0 (so default value of the trait

Required Methods§

Source

fn from_bytestream( bytestream: &Vec<u8>, pos: &mut usize, ) -> Result<Self, SerializationError>
where Self: Sized,

Decode a serializable from a bytestream

§Arguments:
  • bytestream : bytes including the ones which should be decoded
  • pos : first byte in the bytestream which is part of the expected payload

Provided Methods§

Source

fn verify_fixed( stream: &Vec<u8>, pos: &mut usize, ) -> Result<(), SerializationError>

Verify that the serialized representation of the struct has the correct size, including header + footer.

Will panic for variable sized structs.

Source

fn from_bytestream_alt( bytestream: &Vec<u8>, pos: &mut usize, ) -> Result<Self, SerializationError>
where Self: Sized,

Decode a serializable from a bytestream. This provides an alternative method to get the packet. If not implemented, it will be the same as from_bytestream.

§Arguments:
  • bytestream : bytes including the ones which should be decoded
  • pos : first byte in the bytestream which is part of the expected payload
Source

fn to_bytestream(&self) -> Vec<u8>

Encode a serializable to a bytestream

This shall return a representation of the struct in such a way that to_bytestream and from_bytestream are inverse operations.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl Serialization for TofResponse

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 9usize

Source§

impl Serialization for RBCalibrationFlightT

Source§

const SIZE: usize = 18_437usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBCalibrationFlightV

Source§

const SIZE: usize = 55_305usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBCalibrations

Source§

const SIZE: usize = 294_918usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBEvent

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBEventHeader

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 30usize

Source§

impl Serialization for RBWaveform

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for TelemetryEvent

Source§

impl Serialization for TofEvent

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for TofHit

Source§

const HEAD: u16 = 61_680u16

Source§

const TAIL: u16 = 3_855u16

Source§

const SIZE: usize = 30usize

Source§

impl Serialization for CPUMoniData

Source§

const SIZE: usize = 41usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for DataSinkHB

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 84usize

Source§

impl Serialization for EventBuilderHB

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 156usize

Source§

impl Serialization for MasterTriggerHB

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 68usize

Source§

impl Serialization for LTBMoniData

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 25usize

Source§

impl Serialization for MtbMoniData

Source§

const SIZE: usize = 24usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for PAMoniData

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 133usize

Source§

impl Serialization for PBMoniData

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 93usize

Source§

impl Serialization for RBMoniData

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 151usize

Source§

impl Serialization for AckBfsw

Source§

const HEAD: u16 = 37_099u16

Source§

const TAIL: u16 = 0u16

Source§

const SIZE: usize = 13usize

Source§

impl Serialization for MagnetoMeter

Source§

const HEAD: u16 = 37_099u16

Source§

const TAIL: u16 = 0u16

Source§

const SIZE: usize = 57usize

Source§

impl Serialization for TelemetryPacket

Source§

const HEAD: u16 = 0u16

Source§

const TAIL: u16 = 0u16

Source§

const SIZE: usize = 0usize

Source§

impl Serialization for TelemetryPacketHeader

Source§

const HEAD: u16 = 37_099u16

Source§

const TAIL: u16 = 0u16

Source§

const SIZE: usize = 13usize

Source§

impl Serialization for TofPacket

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 0usize

Source§

impl Serialization for TrackerDAQHSKPacket

Source§

impl Serialization for TrackerDAQTempPacket

Source§

impl Serialization for TrackerEventIDEchoPacket

Source§

impl Serialization for TrackerTempLeakPacket

Source§

impl Serialization for TrackerHeader

Source§

const SIZE: usize = 17usize

Source§

impl Serialization for TofCommand

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for AnalysisEngineConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 65usize

Source§

impl Serialization for DataPublisherConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 24usize

Source§

impl Serialization for LTBThresholdConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 17usize

Source§

impl Serialization for PreampBiasConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 69usize

Source§

impl Serialization for RBChannelMaskConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 14usize

Source§

impl Serialization for RunConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 29usize

Source§

impl Serialization for TOFEventBuilderConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 46usize

Source§

impl Serialization for TofRBConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 25usize

Source§

impl Serialization for TofRunConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 12usize

Source§

impl Serialization for TriggerConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 26usize

Source§

impl Serialization for TofDetectorStatus

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 44usize

Source§

impl Serialization for LiftofRBConfig

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 24usize

Source§

impl Serialization for CRFrame

Source§

impl Serialization for CRFrameObject