pub trait Pdu {
type Header: GenericHeader + Default;
// Required methods
fn calculate_length(&self) -> Result<u16, DISError>;
fn header(&self) -> &Self::Header;
fn header_mut(&mut self) -> &mut Self::Header;
fn serialize(&mut self, buf: &mut BytesMut) -> Result<(), DISError>;
fn deserialize<B: Buf>(buf: &mut B) -> Result<Self, DISError>
where Self: Sized;
fn deserialize_without_header<B: Buf>(
buffer: &mut B,
pdu_header: Self::Header,
) -> Result<Self, DISError>
where Self: Sized;
fn as_any(&self) -> &dyn Any;
// Provided method
fn finalize(&mut self) { ... }
}Required Associated Types§
type Header: GenericHeader + Default
Required Methods§
Sourcefn calculate_length(&self) -> Result<u16, DISError>
fn calculate_length(&self) -> Result<u16, DISError>
§Errors
Will return DISError if the calculated PDU length is greater than the maximum allowed size
fn header(&self) -> &Self::Header
fn header_mut(&mut self) -> &mut Self::Header
Sourcefn serialize(&mut self, buf: &mut BytesMut) -> Result<(), DISError>
fn serialize(&mut self, buf: &mut BytesMut) -> Result<(), DISError>
§Errors
Will return DISError if serialization fails, especially if the dynamically calculated PDU
length is greater than the maximum allowed size
Sourcefn deserialize<B: Buf>(buf: &mut B) -> Result<Self, DISError>where
Self: Sized,
fn deserialize<B: Buf>(buf: &mut B) -> Result<Self, DISError>where
Self: Sized,
§Errors
Will return DISError if the PDU header provided is invalid
Sourcefn deserialize_without_header<B: Buf>(
buffer: &mut B,
pdu_header: Self::Header,
) -> Result<Self, DISError>where
Self: Sized,
fn deserialize_without_header<B: Buf>(
buffer: &mut B,
pdu_header: Self::Header,
) -> Result<Self, DISError>where
Self: Sized,
§Errors
Will return DISError if the PDU header provided is invalid