Trait dash7_alp::codec::Codec

source ·
pub trait Codec: Sized {
    type Error;

    // Required methods
    fn encoded_size(&self) -> usize;
    unsafe fn encode_in(&self, out: &mut [u8]) -> usize;
    fn decode(out: &[u8]) -> Result<WithSize<Self>, WithOffset<Self::Error>>;

    // Provided method
    fn encode(&self) -> Box<[u8]> { ... }
}
Expand description

Trait implemented by any item that is encodable to a byte array and decodable from a byte array.

Required Associated Types§

Required Methods§

source

fn encoded_size(&self) -> usize

Computes the number of bytes required to encode the item.

source

unsafe fn encode_in(&self, out: &mut [u8]) -> usize

Encode the item into a given byte array.

§Safety

You have to ensure there is enough space in the given array (compared to what encoded_size returns) or this method will panic.

§Panics

Panics if the given out array is too small.

source

fn decode(out: &[u8]) -> Result<WithSize<Self>, WithOffset<Self::Error>>

Attempt to decode a byte array to produce an item. May return the item with the bytes consumed, a request for more bytes or a parsing error

Provided Methods§

source

fn encode(&self) -> Box<[u8]>

Allocate a byte array of the right size and encode the item in it.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Codec for Chunk

source§

impl Codec for dash7_alp::spec::v1_2::action::Action

source§

impl Codec for Logic

source§

impl Codec for dash7_alp::spec::v1_2::action::status::Status

source§

impl Codec for dash7_alp::spec::v1_2::operand::indirect_interface::IndirectInterface

source§

impl Codec for dash7_alp::spec::v1_2::operand::interface_configuration::InterfaceConfiguration

source§

impl Codec for dash7_alp::spec::v1_2::operand::interface_status::InterfaceStatus

source§

impl Codec for Permission

source§

impl Codec for Query

source§

impl Codec for dash7_alp::sub_iot::v0::action::Action

source§

impl Codec for dash7_alp::sub_iot::v0::operand::interface_configuration::InterfaceConfiguration

source§

impl Codec for dash7_alp::wizzilab::v5_3::action::Action

source§

impl Codec for dash7_alp::wizzilab::v5_3::action::status::Status

source§

impl Codec for TxStatus

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::indirect_interface::IndirectInterface

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::interface_configuration::InterfaceConfiguration

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::interface_status::InterfaceStatus

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::interface_tx_status::InterfaceTxStatus

source§

impl Codec for CopyFile

source§

impl Codec for FileDataAction

source§

impl Codec for FileIdAction

source§

impl Codec for FilePropertiesAction

source§

impl Codec for dash7_alp::spec::v1_2::action::forward::Forward

source§

impl Codec for dash7_alp::spec::v1_2::action::indirect_forward::IndirectForward

source§

impl Codec for Nop

source§

impl Codec for PermissionRequest

source§

impl Codec for QueryAction

source§

impl Codec for ReadFileData

source§

impl Codec for RequestTag

source§

impl Codec for ResponseTag

source§

impl Codec for dash7_alp::spec::v1_2::dash7::InterfaceConfiguration

source§

impl Codec for dash7_alp::spec::v1_2::dash7::InterfaceStatus

source§

impl Codec for dash7_alp::spec::v1_2::dash7::Qos

source§

impl Codec for FileHeader

source§

impl Codec for dash7_alp::spec::v1_2::operand::action_status::ActionStatus

source§

impl Codec for FileOffset

source§

impl Codec for dash7_alp::spec::v1_2::operand::indirect_interface::NonOverloadedIndirectInterface

source§

impl Codec for dash7_alp::spec::v1_2::operand::indirect_interface::OverloadedIndirectInterface

source§

impl Codec for BitmapRangeComparison

source§

impl Codec for ComparisonWithOtherFile

source§

impl Codec for ComparisonWithValue

source§

impl Codec for ComparisonWithZero

source§

impl Codec for NonVoid

source§

impl Codec for StringTokenSearch

source§

impl Codec for dash7_alp::sub_iot::v0::action::forward::Forward

source§

impl Codec for dash7_alp::sub_iot::v0::dash7::InterfaceConfiguration

source§

impl Codec for Flow

source§

impl Codec for dash7_alp::wizzilab::v5_3::action::forward::Forward

source§

impl Codec for dash7_alp::wizzilab::v5_3::action::indirect_forward::IndirectForward

source§

impl Codec for dash7_alp::wizzilab::v5_3::dash7::interface_tx_status::InterfaceTxStatus

source§

impl Codec for dash7_alp::wizzilab::v5_3::dash7::InterfaceConfiguration

source§

impl Codec for dash7_alp::wizzilab::v5_3::dash7::InterfaceStatus

source§

impl Codec for dash7_alp::wizzilab::v5_3::dash7::Qos

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::action_status::ActionStatus

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::indirect_interface::NonOverloadedIndirectInterface

source§

impl Codec for dash7_alp::wizzilab::v5_3::operand::indirect_interface::OverloadedIndirectInterface

source§

impl Codec for InterfaceFinalStatus