Encode

Trait Encode 

Source
pub trait Encode: Length {
    // Required method
    fn encode(&self, dst: &mut [u8]) -> usize;
}
Expand description

Trait for encoding SMPP values into a slice.

§Implementation


struct Foo {
    a: u8,
    b: u16,
    c: u32,
}

impl Length for Foo {
    fn length(&self) -> usize {
        self.a.length() + self.b.length() + self.c.length()
    }
}

impl Encode for Foo {
    fn encode(&self, dst: &mut [u8]) -> usize {
        let mut size = 0;

        size += self.a.encode(&mut dst[size..]);
        size += self.b.encode(&mut dst[size..]);
        size += self.c.encode(&mut dst[size..]);

        size
    }
}

let foo = Foo {
    a: 0x01,
    b: 0x0203,
    c: 0x04050607,
};

let buf = &mut [0u8; 1024];

assert!(buf.len() >= foo.length());

let size = foo.encode(buf);

let expected = &[0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07];

assert_eq!(size, 7);
assert_eq!(&buf[..size], expected);

Required Methods§

Source

fn encode(&self, dst: &mut [u8]) -> usize

Encode a value to a slice

Implementors are allowed to panic if the slice is not big enough to hold the encoded value. If dst.len() < Length::length

Implementations on Foreign Types§

Source§

impl Encode for u8

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl Encode for u16

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl Encode for u32

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl<T: Encode> Encode for &[T]

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl<T: Encode> Encode for Option<T>

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl<T: Encode> Encode for Vec<T>

Available on crate feature alloc only.
Source§

fn encode(&self, dst: &mut [u8]) -> usize

Source§

impl<T: Encode, const N: usize> Encode for Vec<T, N>

Source§

fn encode(&self, dst: &mut [u8]) -> usize

Implementors§

Source§

impl Encode for CommandId

Source§

impl Encode for CommandStatus

Source§

impl Encode for rusmpp_core::pdus::owned::Pdu

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::tlvs::borrowed::TlvValue<'_>

Source§

impl Encode for TlvTag

Source§

impl Encode for rusmpp_core::tlvs::owned::TlvValue

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::borrowed::DestAddress<'_>

Source§

impl Encode for AddrSubunit

Source§

impl Encode for AlertOnMessageDelivery

Source§

impl Encode for Ansi41Specific

Source§

impl Encode for BearerType

Source§

impl Encode for BroadcastAreaFormat

Source§

impl Encode for BroadcastAreaSuccess

Source§

impl Encode for BroadcastChannelIndicator

Source§

impl Encode for BroadcastMessageClass

Source§

impl Encode for CongestionState

Source§

impl Encode for DataCoding

Source§

impl Encode for DeliveryFailureReason

Source§

impl Encode for DestAddrNpResolution

Source§

impl Encode for DestFlag

Source§

impl Encode for DisplayTime

Source§

impl Encode for DpfResult

Source§

impl Encode for EncodingContentType

Source§

impl Encode for ErrorCodeNetworkType

Source§

impl Encode for GsmFeatures

Source§

impl Encode for Indicator

Source§

impl Encode for InterfaceVersion

Source§

impl Encode for IntermediateNotification

Source§

impl Encode for ItsReplyType

Source§

impl Encode for LanguageIndicator

Source§

impl Encode for MCDeliveryReceipt

Source§

impl Encode for MessageState

Source§

impl Encode for MessageType

Source§

impl Encode for MessagingMode

Source§

impl Encode for MoreMessagesToSend

Source§

impl Encode for MsAvailabilityStatus

Source§

impl Encode for MsValidityBehavior

Source§

impl Encode for NetworkType

Source§

impl Encode for Npi

Source§

impl Encode for NumberOfMessages

Source§

impl Encode for PayloadType

Source§

impl Encode for Presentation

Source§

impl Encode for PrivacyIndicator

Source§

impl Encode for ReplaceIfPresentFlag

Source§

impl Encode for Screening

Source§

impl Encode for SetDpf

Source§

impl Encode for SmeOriginatedAcknowledgement

Source§

impl Encode for SubaddressTag

Source§

impl Encode for Ton

Source§

impl Encode for TypeOfMessage

Source§

impl Encode for TypeOfNetwork

Source§

impl Encode for UnitOfTime

Source§

impl Encode for UnitsOfTime

Source§

impl Encode for UssdServiceOp

Source§

impl Encode for rusmpp_core::values::owned::DestAddress

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::command::owned::Command

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::AlertNotification

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindReceiver

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindReceiverResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindTransceiver

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindTransceiverResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindTransmitter

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BindTransmitterResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BroadcastSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::BroadcastSmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::CancelBroadcastSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::CancelSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::DataSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::DataSmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::DeliverSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::DeliverSmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::Outbind

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::QueryBroadcastSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::QueryBroadcastSmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::QuerySm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::QuerySmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::ReplaceSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::SubmitMulti

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::SubmitMultiResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::SubmitSm

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::pdus::owned::SubmitSmResp

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::tlvs::owned::Tlv

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::types::borrowed::AnyOctetString<'_>

Source§

impl Encode for rusmpp_core::types::owned::AnyOctetString

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::BroadcastAreaIdentifier

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::DistributionListName

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::MessagePayload

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::ServiceType

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::SmeAddress

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::Subaddress

Available on crate feature alloc only.
Source§

impl Encode for rusmpp_core::values::owned::UnsuccessSme

Available on crate feature alloc only.
Source§

impl Encode for BroadcastContentType

Source§

impl Encode for BroadcastFrequencyInterval

Source§

impl Encode for BroadcastRepNum

Source§

impl Encode for CallbackNumPresInd

Source§

impl Encode for EsmClass

Source§

impl Encode for ItsSessionInfo

Source§

impl Encode for MsMsgWaitFacilities

Source§

impl Encode for MsValidity

Source§

impl Encode for MsValidityInformation

Source§

impl Encode for NetworkErrorCode

Source§

impl Encode for PriorityFlag

Source§

impl Encode for RegisteredDelivery

Source§

impl Encode for UserMessageReference

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::AlertNotification<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindReceiver<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindReceiverResp<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindTransceiver<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindTransceiverResp<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindTransmitter<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::BindTransmitterResp<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::CancelSm<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::Outbind<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::QueryBroadcastSm<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::QuerySm<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::QuerySmResp<'a>

Source§

impl<'a> Encode for rusmpp_core::pdus::borrowed::ReplaceSm<'a>

Source§

impl<'a> Encode for rusmpp_core::tlvs::borrowed::Tlv<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::BroadcastAreaIdentifier<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::DistributionListName<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::MessagePayload<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::ServiceType<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::SmeAddress<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::Subaddress<'a>

Source§

impl<'a> Encode for rusmpp_core::values::borrowed::UnsuccessSme<'a>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::command::borrowed::Command<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::BroadcastSm<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::BroadcastSmResp<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::CancelBroadcastSm<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::DataSm<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::DataSmResp<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::DeliverSm<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::DeliverSmResp<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::QueryBroadcastSmResp<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::SubmitMulti<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::SubmitMultiResp<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::SubmitSm<'a, N>

Source§

impl<'a, const N: usize> Encode for rusmpp_core::pdus::borrowed::SubmitSmResp<'a, N>

Source§

impl<const MIN: usize, const MAX: usize> Encode for rusmpp_core::types::borrowed::COctetString<'_, MIN, MAX>

Source§

impl<const MIN: usize, const MAX: usize> Encode for rusmpp_core::types::borrowed::OctetString<'_, MIN, MAX>

Source§

impl<const MIN: usize, const MAX: usize> Encode for rusmpp_core::types::owned::COctetString<MIN, MAX>

Available on crate feature alloc only.
Source§

impl<const MIN: usize, const MAX: usize> Encode for rusmpp_core::types::owned::OctetString<MIN, MAX>

Available on crate feature alloc only.
Source§

impl<const N: usize> Encode for rusmpp_core::pdus::borrowed::Pdu<'_, N>

Source§

impl<const N: usize> Encode for rusmpp_core::types::borrowed::EmptyOrFullCOctetString<'_, N>

Source§

impl<const N: usize> Encode for rusmpp_core::types::owned::EmptyOrFullCOctetString<N>

Available on crate feature alloc only.