pub struct TofPacket {
pub packet_type: PacketType,
pub payload: Vec<u8>,
pub no_write_to_disk: bool,
pub no_send_over_nw: bool,
pub creation_time: Instant,
pub valid: bool,
}
Expand description
The most basic of all packets
A type and a payload. This wraps all other packets.
Format when in bytestream HEAD : u16 PAYLOAD_SIZE : u32 PAYLOAD : [u8;PAYLOAD_SIZE] TAIL : u16
=> Fixed size is 13
Fields§
§packet_type: PacketType
§payload: Vec<u8>
§no_write_to_disk: bool
mark a packet as not eligible to be written to disk
no_send_over_nw: bool
mark a packet as not eligible to be sent over network FIXME - future extension
creation_time: Instant
creation_time for the instance
valid: bool
Implementations§
Source§impl TofPacket
impl TofPacket
pub fn new() -> Self
Sourcepub fn zmq_payload_brdcast(&self) -> Vec<u8>
pub fn zmq_payload_brdcast(&self) -> Vec<u8>
Generate a bytestream of self for ZMQ, prefixed with BRCT so all RBs will see it
Sourcepub fn zmq_payload_rb(&self, rb_id: u8) -> Vec<u8>
pub fn zmq_payload_rb(&self, rb_id: u8) -> Vec<u8>
Generate a bytestream of self for ZMQ, prefixed with RBX, to address only a certain board
Sourcepub fn unpack<T>(&self) -> Result<T, SerializationError>where
T: Packable + Serialization,
pub fn unpack<T>(&self) -> Result<T, SerializationError>where
T: Packable + Serialization,
Unpack the TofPacket and return its content
pub fn age(&self) -> u64
Trait Implementations§
Source§impl From<&CPUMoniData> for TofPacket
impl From<&CPUMoniData> for TofPacket
Source§fn from(moni: &CPUMoniData) -> Self
fn from(moni: &CPUMoniData) -> Self
Source§impl From<&MasterTriggerEvent> for TofPacket
impl From<&MasterTriggerEvent> for TofPacket
Source§fn from(mt: &MasterTriggerEvent) -> TofPacket
fn from(mt: &MasterTriggerEvent) -> TofPacket
Source§impl From<&MtbMoniData> for TofPacket
impl From<&MtbMoniData> for TofPacket
Source§fn from(moni: &MtbMoniData) -> TofPacket
fn from(moni: &MtbMoniData) -> TofPacket
Source§impl From<&RBCalibrations> for TofPacket
impl From<&RBCalibrations> for TofPacket
Source§fn from(calib: &RBCalibrations) -> Self
fn from(calib: &RBCalibrations) -> Self
Source§impl From<&RBEventHeader> for TofPacket
impl From<&RBEventHeader> for TofPacket
Source§fn from(ev_header: &RBEventHeader) -> TofPacket
fn from(ev_header: &RBEventHeader) -> TofPacket
Source§impl From<&RBWaveform> for TofPacket
impl From<&RBWaveform> for TofPacket
FIXME - all these can go away now, because we have the Packable trait! Amazing!
Source§fn from(rbwave: &RBWaveform) -> Self
fn from(rbwave: &RBWaveform) -> Self
Source§impl From<&TofCommand> for TofPacket
impl From<&TofCommand> for TofPacket
Source§fn from(cmd: &TofCommand) -> Self
fn from(cmd: &TofCommand) -> Self
Source§impl From<&TofEventSummary> for TofPacket
impl From<&TofEventSummary> for TofPacket
Source§fn from(tsum: &TofEventSummary) -> Self
fn from(tsum: &TofEventSummary) -> Self
Source§impl From<&mut RBCalibrations> for TofPacket
impl From<&mut RBCalibrations> for TofPacket
Source§fn from(calib: &mut RBCalibrations) -> Self
fn from(calib: &mut RBCalibrations) -> Self
Source§impl FromRandom for TofPacket
impl FromRandom for TofPacket
fn from_random() -> Self
Source§impl PartialEq for TofPacket
impl PartialEq for TofPacket
Implement because TofPacket saves the creation time, which never will be the same for 2 different instances
Source§impl Serialization for TofPacket
impl Serialization for TofPacket
const HEAD: u16 = 43_690u16
const TAIL: u16 = 21_845u16
Source§const SIZE: usize = 0usize
const SIZE: usize = 0usize
Source§fn from_bytestream(
stream: &Vec<u8>,
pos: &mut usize,
) -> Result<Self, SerializationError>
fn from_bytestream( stream: &Vec<u8>, pos: &mut usize, ) -> Result<Self, SerializationError>
Source§fn to_bytestream(&self) -> Vec<u8>
fn to_bytestream(&self) -> Vec<u8>
Source§fn verify_fixed(
stream: &Vec<u8>,
pos: &mut usize,
) -> Result<(), SerializationError>
fn verify_fixed( stream: &Vec<u8>, pos: &mut usize, ) -> Result<(), SerializationError>
Source§fn from_tofpacket(packet: &TofPacket) -> Result<Self, SerializationError>where
Self: Sized,
fn from_tofpacket(packet: &TofPacket) -> Result<Self, SerializationError>where
Self: Sized,
fn from_slice(
_slice: &[u8],
_start_pos: usize,
) -> Result<Self, SerializationError>where
Self: Sized,
Auto Trait Implementations§
impl Freeze for TofPacket
impl RefUnwindSafe for TofPacket
impl Send for TofPacket
impl Sync for TofPacket
impl Unpin for TofPacket
impl UnwindSafe for TofPacket
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoSql for T
impl<T> IntoSql for T
Source§fn into_sql<T>(self) -> Self::Expression
fn into_sql<T>(self) -> Self::Expression
self
to an expression for Diesel’s query builder. Read moreSource§fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
fn as_sql<'a, T>(&'a self) -> <&'a Self as AsExpression<T>>::Expression
&self
to an expression for Diesel’s query builder. Read more