Trait IsoTpFrame

Source
pub trait IsoTpFrame: Send {
    // Required methods
    fn decode<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>
       where Self: Sized;
    fn encode(self, padding: Option<u8>) -> Vec<u8> ;
    fn from_data<T: AsRef<[u8]>>(data: T) -> Result<Vec<Self>, Error>
       where Self: Sized;
    fn single_frame<T: AsRef<[u8]>>(data: T) -> Result<Self, Error>
       where Self: Sized;
    fn flow_ctrl_frame(
        state: FlowControlState,
        block_size: u8,
        st_min: u8,
    ) -> Result<Self, Error>
       where Self: Sized;

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

ISO-TP frame trait define.

Required Methods§

Source

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

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) -> Result<Vec<Self>, Error>
where Self: Sized,

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>
where Self: Sized,

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, block_size: u8, st_min: u8, ) -> Result<Self, Error>
where Self: Sized,

New flow control frame from data.

§Parameters
  • state - FlowControlState
  • block_size - the block size
  • st_min - separation time minimum
§Returns

A new FlowControlFrame if parameters are valid.

Provided Methods§

Source

fn default_flow_ctrl_frame() -> Self
where Self: Sized,

Implementors§