Trait isotp_rs::IsoTpFrame

source ·
pub trait IsoTpFrame: Sized + Send {
    // Required methods
    fn decode<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>;
    fn encode(self, padding: Option<u8>) -> Vec<u8>;
    fn from_data<T: AsRef<[u8]>>(
        data: T,
        flow_ctrl: Vec<FlowControlContext>,
    ) -> Result<Vec<Self>, Error>;
    fn single_frame<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>;
    fn flow_ctrl_frame(
        state: FlowControlState,
        suppress_positive: bool,
        st_min: u8,
    ) -> Result<Self, Error>;

    // Provided method
    fn default_flow_ctrl_frame() -> Self { ... }
}
Expand description

ISO-TP frame trait define.

Required Methods§

source

fn decode<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>

Decode frame from origin data like 02 10 01.

§Parameters
  • data - the source data.
§Return

A struct that implements IsoTpFrame if parameters are valid.

source

fn encode(self, padding: Option<u8>) -> Vec<u8>

Encode frame to data.

§Parameters
  • padding - the padding value when the length of return value is insufficient.
§Returns

The encoded data.

source

fn from_data<T: AsRef<[u8]>>( data: T, flow_ctrl: Vec<FlowControlContext>, ) -> Result<Vec<Self>, Error>

Encoding full multi-frame from original data.

§Parameters
  • data - original data

  • flow_ctrl - the flow control context(added one default)

§Returns

The frames contain either a SingleFrame or a multi-frame sequence starting

with a FirstFrame and followed by at least one FlowControlFrame.

source

fn single_frame<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>

New single frame from data.

  • data - the single frame data
§Returns

A new SingleFrame if parameters are valid.

source

fn flow_ctrl_frame( state: FlowControlState, suppress_positive: bool, st_min: u8, ) -> Result<Self, Error>

New flow control frame from data.

§Parameters
  • state - FlowControlState
  • st_min - separation time minimum
  • suppress_positive - true if suppress positive else false
§Returns

A new FlowControlFrame if parameters are valid.

Provided Methods§

Object Safety§

This trait is not object safe.

Implementors§