ActionEncoder

Trait ActionEncoder 

pub trait ActionEncoder<'a> {
    type A: CodedAction;
    type UA: UncodedAction<'a>;
    type K: ?Sized;
    type Err: Error;

    // Required methods
    fn encode(&'a self, action: Self::UA) -> Result<Self::A, Self::Err>;
    fn encode_raw(
        &self,
        port_name: impl AsRef<Self::K>,
    ) -> Result<Self::A, Self::Err>;
    fn decode(&'a self, coded_action: Self::A) -> Result<Self::UA, Self::Err>;
    fn lookup(
        &'a self,
        port_name: impl AsRef<Self::K>,
    ) -> Result<Self::UA, Self::Err>;
}
Expand description

Encoder and decoder between UncodedAction and CodedAction.

This trait implementors should have all information about this device’s topology (name, ports, port mode, neighbors). The interface may be enriched.

Required Associated Types§

type A: CodedAction

type UA: UncodedAction<'a>

type K: ?Sized

lookup key

type Err: Error

Required Methods§

fn encode(&'a self, action: Self::UA) -> Result<Self::A, Self::Err>

fn encode_raw( &self, port_name: impl AsRef<Self::K>, ) -> Result<Self::A, Self::Err>

fn decode(&'a self, coded_action: Self::A) -> Result<Self::UA, Self::Err>

fn lookup( &'a self, port_name: impl AsRef<Self::K>, ) -> Result<Self::UA, Self::Err>

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§

§

impl<'a> ActionEncoder<'a> for &'a SwitchSpec

§

type A = u16

§

type UA = IbAction<'a>

§

type K = RawAction

§

type Err = Error

§

impl<'a> ActionEncoder<'a> for PortInfoBase

§

type A = usize

§

type UA = TypedAction<'a>

§

type K = str

§

type Err = Error