tof_dataclasses::serialization

Trait Serialization

Source
pub trait Serialization {
    const HEAD: u16;
    const TAIL: u16;
    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_tofpacket(packet: &TofPacket) -> Result<Self, SerializationError>
       where Self: Sized { ... }
    fn to_bytestream(&self) -> Vec<u8> { ... }
    fn from_slice(
        _slice: &[u8],
        _start_pos: usize,
    ) -> Result<Self, SerializationError>
       where Self: Sized { ... }
    fn to_slice(&self) -> &[u8] 
       where Self: Sized { ... }
}
Expand description

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

Required Associated Constants§

Provided Associated Constants§

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

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_tofpacket(packet: &TofPacket) -> Result<Self, SerializationError>
where Self: Sized,

Decode a serializable directly from a TofPacket

Source

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

Encode a serializable to a bytestream

Source

fn from_slice( _slice: &[u8], _start_pos: usize, ) -> Result<Self, SerializationError>
where Self: Sized,

Source

fn to_slice(&self) -> &[u8]
where Self: Sized,

Construct byte slice out of self.

Can not fail.

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 TofCommand

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 9usize

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 RBCalibrations

Source§

const SIZE: usize = 294_918usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBCalibrationsFlightT

Source§

const SIZE: usize = 18_437usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for RBCalibrationsFlightV

Source§

const SIZE: usize = 55_305usize

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 TofCommandV2

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for MasterTriggerEvent

Source§

const SIZE: usize = 0usize

Source§

const TAIL: u16 = 21_845u16

Source§

const HEAD: u16 = 43_690u16

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 RBEventMemoryView

Source§

const SIZE: usize = 18_530usize

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for TofEvent

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

impl Serialization for TofEventHeader

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 43usize

Source§

impl Serialization for TofEventSummary

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 EVTBLDRHeartbeat

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 156usize

Source§

impl Serialization for HeartBeatDataSink

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 84usize

Source§

impl Serialization for MTBHeartbeat

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 68usize

Source§

impl Serialization for RBPing

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 13usize

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 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 TofPacket

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 0usize

Source§

impl Serialization for TofDetectorStatus

Source§

const HEAD: u16 = 43_690u16

Source§

const TAIL: u16 = 21_845u16

Source§

const SIZE: usize = 44usize