### PriorityFlagType Example Usage Source: https://docs.rs/rusmpp/latest/rusmpp/values/enum.PriorityFlagType.html Demonstrates how to create and use PriorityFlagType with examples. ```APIDOC ## §Example ``` use rusmpp_core::values::{GsmSms, PriorityFlag, PriorityFlagType}; let gsm_sms = GsmSms::from(1); assert_eq!(gsm_sms, GsmSms::Priority1); let priority_flag_type = PriorityFlagType::from(gsm_sms); assert!(matches!(priority_flag_type, PriorityFlagType::GsmSms(GsmSms::Priority1))); let priority_flag = PriorityFlag::from(priority_flag_type); assert_eq!(priority_flag, PriorityFlag::new(1)); let priority_flag: PriorityFlag = GsmSms::from(1).into(); assert_eq!(priority_flag, PriorityFlag::new(1)); ``` ``` -------------------------------- ### starts_with Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Checks if the slice starts with a given prefix. ```APIDOC ## pub fn starts_with(&self, needle: &[T]) -> bool where T: PartialEq, ### Description Returns `true` if `needle` is a prefix of the slice or equal to the slice. ### Parameters #### Path Parameters - `needle` (&[T]) - Required - The slice to check as a prefix. ### Response #### Success Response - `bool` - `true` if the slice starts with `needle`, `false` otherwise. ### Examples ```rust let v = [10, 40, 30]; assert!(v.starts_with(&[10])); assert!(v.starts_with(&[10, 40])); assert!(v.starts_with(&v)); assert!(!v.starts_with(&[50])); assert!(!v.starts_with(&[10, 50])); ``` ``` -------------------------------- ### Creating a new QueryBroadcastSmBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.QueryBroadcastSmBuilder.html Initializes a new instance of the QueryBroadcastSmBuilder. This is the starting point for constructing a QueryBroadcastSm PDU. ```rust pub fn new() -> QueryBroadcastSmBuilder ``` -------------------------------- ### Create a new DeliverSmRespBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.DeliverSmRespBuilder.html Initializes a new instance of DeliverSmRespBuilder. This is the starting point for constructing a DeliverSmResp PDU. ```rust pub fn new() -> DeliverSmRespBuilder ``` -------------------------------- ### Create a new BindReceiverRespBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BindReceiverRespBuilder.html Initializes a new instance of BindReceiverRespBuilder. Use this to start building a BindReceiverResp. ```rust pub fn new() -> BindReceiverRespBuilder ``` -------------------------------- ### Create a new DataSmRespBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.DataSmRespBuilder.html Initializes a new instance of DataSmRespBuilder. Use this to start building a DataSmResp. ```rust pub fn new() -> DataSmRespBuilder ``` -------------------------------- ### QuerySmRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.QuerySmRespBuilder.html Creates a new instance of QuerySmRespBuilder. This is the starting point for building a QuerySmResp. ```rust pub fn new() -> QuerySmRespBuilder ``` -------------------------------- ### Create a new BindTransmitterBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BindTransmitterBuilder.html Initializes a new instance of BindTransmitterBuilder. This is the starting point for building a BindTransmitter PDU. ```rust pub fn new() -> BindTransmitterBuilder ``` -------------------------------- ### Create a new OutbindBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.OutbindBuilder.html Initializes a new instance of OutbindBuilder. Use this to start building an Outbind PDU. ```rust pub fn new() -> OutbindBuilder ``` -------------------------------- ### Initialize QuerySmBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.QuerySmBuilder.html Use the `new` function to create a new instance of QuerySmBuilder. This is the starting point for constructing a QuerySm PDU. ```rust pub fn new() -> QuerySmBuilder ``` -------------------------------- ### Simulate SMPP Client-Server Interaction with Rusmpp Source: https://docs.rs/rusmpp/latest/rusmpp/index.html This example demonstrates how to use Rusmpp to simulate a client-server interaction using an in-memory duplex stream. It shows the setup for logging, creating a simulated connection, sending an EnquireLink command from the client, and receiving and responding to it from the server. Ensure the 'tracing' feature is enabled for logging. ```rust use core::error::Error; use futures::{SinkExt, StreamExt}; use rusmpp::{ tokio_codec::{EncodeError, CommandCodec}, Command, CommandId, CommandStatus, Pdu, }; use tokio::io::DuplexStream; use tokio_util::codec::Framed; use tracing::info; #[tokio::main] async fn main() -> Result<(), Box> { // Rusmpp produces a lot of logs while decoding and encoding PDUs. // You can filter them out by setting the `rusmpp` target to `off`, // or by disabling the `tracing` feature. tracing_subscriber::fmt() .with_env_filter("client=info,server=info,rusmpp=trace") .init(); // In-memory duplex stream to simulate a server and client. let (server_stream, client_stream) = tokio::io::duplex(4096); launch_server(server_stream).await?; // The CommandCodec encodes/decodes SMPP commands into/from bytes. let mut framed = Framed::new(client_stream, CommandCodec::new()); // Rusmpp takes care of setting the correct command ID. let command = Command::new(CommandStatus::EsmeRok, 1, Pdu::EnquireLink); info!(target: "client", "EnquireLink sent"); framed.send(command).await?; while let Some(Ok(command)) = framed.next().await { if let CommandId::EnquireLinkResp = command.id() { info!(target: "client", "EnquireLink response received"); break; } } Ok(()) } async fn launch_server(stream: DuplexStream) -> Result<(), Box> { tokio::spawn(async move { let mut framed = Framed::new(stream, CommandCodec::new()); while let Some(Ok(command)) = framed.next().await { if let CommandId::EnquireLink = command.id() { info!(target: "server", "EnquireLink received"); // We can also use the Command::builder() to create commands. let response = Command::builder() .status(CommandStatus::EsmeRok) .sequence_number(command.sequence_number()) .pdu(Pdu::EnquireLinkResp); framed.send(response).await?; info!(target: "server", "EnquireLink response sent"); break; } } Ok::<(), EncodeError>(()) }); Ok(()) } ``` -------------------------------- ### SubmitSmRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.SubmitSmRespBuilder.html Creates a new instance of SubmitSmRespBuilder. Use this as the starting point for building a SubmitSmResp. ```rust pub fn new() -> SubmitSmRespBuilder ``` -------------------------------- ### Deprecated: Get Cause of Error Source: https://docs.rs/rusmpp/latest/rusmpp/decode/struct.DecodeErrorSource.html Deprecated method to get the cause of the error. Replaced by Error::source. ```rust fn cause(&self) -> Option<&dyn Error> ``` -------------------------------- ### Deprecated: Get Description of Error Source: https://docs.rs/rusmpp/latest/rusmpp/decode/struct.DecodeErrorSource.html Deprecated method to get the error description. Use the Display impl or to_string() instead. ```rust fn description(&self) -> &str ``` -------------------------------- ### Get Last Element of a Slice Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Use `last()` to get an optional reference to the last element. Returns `None` if the slice is empty. ```rust let v = [10, 40, 30]; assert_eq!(Some(&30), v.last()); let w: &[i32] = &[]; assert_eq!(None, w.last()); ``` -------------------------------- ### CancelBroadcastSmBuilder new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.CancelBroadcastSmBuilder.html Creates a new instance of CancelBroadcastSmBuilder. This is the starting point for building a CancelBroadcastSm PDU. ```rust pub fn new() -> CancelBroadcastSmBuilder ``` -------------------------------- ### Get First Element of a Slice Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Use `first()` to get an optional reference to the first element. Returns `None` if the slice is empty. ```rust let v = [10, 40, 30]; assert_eq!(Some(&10), v.first()); let w: &[i32] = &[]; assert_eq!(None, w.first()); ``` -------------------------------- ### Outbind::new Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.Outbind.html Creates a new Outbind PDU with the provided system ID and password. ```APIDOC ## `impl Outbind` ### `pub fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, ) -> Outbind` Creates a new instance of `Outbind`. ``` -------------------------------- ### Get Element or Subslice by Index Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Use `get()` with a position or range to safely access elements or subslices. Returns `None` if the index is out of bounds. ```rust let v = [10, 40, 30]; assert_eq!(Some(&40), v.get(1)); assert_eq!(Some(&[10, 40][..]), v.get(0..2)); assert_eq!(None, v.get(3)); assert_eq!(None, v.get(0..4)); ``` -------------------------------- ### OctetString Creation and Basic Operations Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.OctetString.html Demonstrates how to create and interact with OctetString instances, including empty strings and conversions. ```APIDOC ## OctetString An `OctetString` is a sequence of octets not necessarily terminated with a NULL octet `0x00`. It can represent raw binary data and is either fixed-length or explicit-length. ### Creating OctetString Instances - `OctetString::null()`: Creates an empty `OctetString`. - `OctetString::empty()`: Creates an empty `OctetString`. - `OctetString::from_bytes(bytes: Bytes)`: Creates from `Bytes`. - `OctetString::from_bytes_mut(bytes: BytesMut)`: Creates from `BytesMut`. - `OctetString::from_slice(bytes: &[u8])`: Creates from a byte slice `&[u8]`. - `OctetString::from_static_slice(bytes: &'static [u8])`: Creates from a static byte slice `&'static [u8]` without copying. - `OctetString::from_static_str(str: &'static str)`: Creates from a static string slice `&'static str` without copying. - `OctetString::from_vec(bytes: Vec)`: Creates from a `Vec`. - `OctetString::from_string(string: String)`: Creates from a `String`. ### Basic Operations - `len()`: Returns the number of bytes. - `is_empty()`: Checks if the `OctetString` is empty. ### Conversions - `into_bytes()`: Converts to `Bytes`. - `into_vec()`: Converts to `Vec`. - `to_str()`: Interprets as `&str`, returns `Result<&str, Utf8Error>`. ``` -------------------------------- ### Example Implementation of DecodeWithKeyOptional for Foo Source: https://docs.rs/rusmpp/latest/rusmpp/decode/trait.DecodeWithKeyOptional.html An example demonstrating how to implement the DecodeWithKeyOptional trait for a custom enum `Foo`, showing different decoding logic based on the key. ```APIDOC ## Implementation Example for Foo This example shows a concrete implementation of `DecodeWithKeyOptional` for an enum `Foo`. ```rust #[derive(Debug, PartialEq, Eq)] enum Foo { A, B(u16), C(AnyOctetString), } impl DecodeWithKeyOptional for Foo { type Key = u32; fn decode( key: Self::Key, src: &mut BytesMut, length: usize, ) -> Result, DecodeError> { if length == 0 { match key { 0x00000000 => return Ok(Some((Foo::A, 0))), _ => return Ok(None), } } match key { 0x01020304 => { let (a, size) = Decode::decode(src)?; Ok(Some((Foo::B(a), size))) } 0x04030201 => { let (b, size) = AnyOctetString::decode(src, length)?; Ok(Some((Foo::C(b), size))) } _ => Err(DecodeError::unsupported_key(key)), } } } ``` ### Usage Examples #### Decoding Foo::A ```rust // Received over the wire let length = 4; // Key is A let mut buf = BytesMut::from(&[ 0x00, 0x00, 0x00, 0x00, // Key 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, // Rest ][..]); let index = 0; let (key, size) = Decode::decode(&mut buf).unwrap(); let index = index + size; let (foo, size) = Foo::decode(key, &mut buf, length - index) .unwrap() .unwrap(); let index = index + size; let expected = Foo::A; assert_eq!(size, 0); assert_eq!(foo, expected); assert_eq!(&buf[..], &[0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B]); ``` #### Decoding None for Foo::B (length indicates no value) ```rust // Received over the wire let length = 4; // Key is B, but the received length indicates no value let mut buf = BytesMut::from(&[ 0x01, 0x02, 0x03, 0x04, // Key 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, // Rest ][..]); let index = 0; let (key, size) = Decode::decode(&mut buf).unwrap(); let index = index + size; let value = Foo::decode(key, &mut buf, length - index).unwrap(); assert!(value.is_none()); assert_eq!(&buf[..], &[0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B]); ``` #### Decoding Foo::B ```rust // Received over the wire let length = 8; // Key is B let mut buf = BytesMut::from(&[ 0x01, 0x02, 0x03, 0x04, // Key 0x05, 0x06, // Value 0x07, 0x08, 0x09, 0x0A, 0x0B, // Rest ][..]); let index = 0; let (key, size) = Decode::decode(&mut buf).unwrap(); let index = index + size; let (foo, size) = Foo::decode(key, &mut buf, length - index) .unwrap() .unwrap(); let index = index + size; let expected = Foo::B(0x0506); assert_eq!(size, 2); assert_eq!(foo, expected); assert_eq!(&buf[..], &[0x07, 0x08, 0x09, 0x0A, 0x0B]); ``` #### Decoding Foo::C ```rust // Received over the wire let length = 8; // Key is C let mut buf = BytesMut::from(&[ 0x04, 0x03, 0x02, 0x01, // Key 0x05, 0x06, 0x07, 0x08, // Value 0x09, 0x0A, 0x0B, // Rest ][..]); let index = 0; let (key, size) = Decode::decode(&mut buf).unwrap(); let index = index + size; let (foo, size) = Foo::decode(key, &mut buf, length - index) .unwrap() .unwrap(); let index = index + size; let expected = Foo::C(AnyOctetString::from_static_slice(&[0x05, 0x06, 0x07, 0x08])); assert_eq!(size, 4); assert_eq!(foo, expected); assert_eq!(&buf[..], &[0x09, 0x0A, 0x0B]); ``` ``` -------------------------------- ### Get Element or Subslice Unchecked from OctetString Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.OctetString.html Returns a reference to an element or subslice without bounds checking. Use with caution; prefer `get` for safe access. ```rust let v = [10, 40, 30]; // This is an unsafe operation and requires careful handling of indices. // Example: unsafe { &v.get_unchecked(1) }; ``` -------------------------------- ### Create Outbind Instance Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.Outbind.html Constructs a new Outbind instance with the provided system ID and password. This is used to initiate the outbind process. ```rust pub fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, ) -> Outbind ``` -------------------------------- ### BindTransceiverRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BindTransceiverRespBuilder.html Creates a new instance of BindTransceiverRespBuilder. Use this as the starting point for building a BindTransceiverResp. ```rust pub fn new() -> BindTransceiverRespBuilder ``` -------------------------------- ### new Source: https://docs.rs/rusmpp/latest/rusmpp/values/parts/struct.DistributionListNameParts.html Constructs a new DistributionListNameParts instance. ```APIDOC ### impl DistributionListNameParts #### pub const fn new( dest_flag: DestFlag, dl_name: COctetString<1, 21>, ) -> DistributionListNameParts Creates a new `DistributionListNameParts` with the provided destination flag and distribution list name. ``` -------------------------------- ### Get Last Chunk of a Slice Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Use `last_chunk::()` to get an optional array reference to the last `N` items. Returns `None` if the slice is shorter than `N`. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[40, 30]), u.last_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.last_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.last_chunk::<0>()); ``` -------------------------------- ### Get First Chunk of a Slice Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Use `first_chunk::()` to get an optional array reference to the first `N` items. Returns `None` if the slice is shorter than `N`. ```rust let u = [10, 40, 30]; assert_eq!(Some(&[10, 40]), u.first_chunk::<2>()); let v: &[i32] = &[10]; assert_eq!(None, v.first_chunk::<2>()); let w: &[i32] = &[]; assert_eq!(Some(&[]), w.first_chunk::<0>()); ``` -------------------------------- ### Example Implementation of Decode for a Custom Struct Source: https://docs.rs/rusmpp/latest/rusmpp/decode/trait.Decode.html Demonstrates how to implement the `Decode` trait for a custom struct `Foo`. This example shows sequential decoding of nested fields and tracking the total bytes consumed. ```rust #[derive(Debug, PartialEq, Eq)] struct Foo { a: u8, b: u16, c: u32, } impl Decode for Foo { fn decode(src: &mut BytesMut) -> Result<(Self, usize), DecodeError> { let index = 0; let (a, size) = Decode::decode(src)?; let index = index + size; let (b, size) = Decode::decode(src)?; let index = index + size; let (c, size) = Decode::decode(src)?; let index = index + size; Ok((Foo { a, b, c }, index)) } } let mut buf = BytesMut::from(&[0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08][..]); let expected = Foo { a: 0x01, b: 0x0203, c: 0x04050607, }; let (foo, size) = Foo::decode(&mut buf).unwrap(); assert_eq!(size, 7); assert_eq!(foo, expected); assert_eq!(&buf[..], &[0x08]); ``` -------------------------------- ### CommandParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/command/struct.CommandParts.html Creates a new instance of CommandParts with the provided details. ```APIDOC ## impl CommandParts ### pub const fn new( id: CommandId, status: CommandStatus, sequence_number: u32, pdu: Option, ) -> CommandParts Creates a new `CommandParts` instance. ``` -------------------------------- ### Creating a new BindTransceiverBuilder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BindTransceiverBuilder.html Use the `new` function to create an empty builder instance. This is the starting point for configuring a BindTransceiver PDU. ```rust pub fn new() -> BindTransceiverBuilder ``` -------------------------------- ### TypeId Source: https://docs.rs/rusmpp/latest/rusmpp/values/enum.ItsReplyType.html Gets the TypeId of self. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ``` -------------------------------- ### type_id Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/enum.UdhId.html Gets the TypeId of self. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ### Parameters None ### Returns `TypeId` ``` -------------------------------- ### CloneToUninit Implementation (Nightly) Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/concatenation/parts/struct.ConcatenatedShortMessage16BitParts.html Provides an experimental nightly-only API for copying data to uninitialized memory. Use with caution. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) Performs copy-assignment from `self` to `dest`. Read more ``` -------------------------------- ### BindTransmitterRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BindTransmitterRespBuilder.html Creates a new instance of BindTransmitterRespBuilder. Use this as the starting point for building a BindTransmitterResp. ```rust pub fn new() -> BindTransmitterRespBuilder ``` -------------------------------- ### BindReceiverParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.BindReceiverParts.html Creates a new instance of BindReceiverParts with the provided parameters. ```APIDOC ### impl BindReceiverParts #### pub const fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, system_type: COctetString<1, 13>, interface_version: InterfaceVersion, addr_ton: Ton, addr_npi: Npi, address_range: COctetString<1, 41>, ) -> BindReceiverParts ``` -------------------------------- ### OctetString Length Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.OctetString.html Gets the length of the OctetString. ```APIDOC ## Length for OctetString ### Description Returns the length of the OctetString. ### Signature `fn length(&self) -> usize` ``` -------------------------------- ### CancelSmBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.CancelSmBuilder.html Creates a new instance of CancelSmBuilder. Use this as the starting point for building a CancelSm PDU. ```rust pub fn new() -> CancelSmBuilder ``` -------------------------------- ### Length for AnyOctetString Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.AnyOctetString.html Gets the length of an AnyOctetString. ```APIDOC ## fn length(&self) -> usize ### Description Returns the length of the AnyOctetString. ### Method `length` ### Parameters - **self** (&AnyOctetString) - The AnyOctetString. ``` -------------------------------- ### SubmitMultiRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.SubmitMultiRespBuilder.html Creates a new instance of SubmitMultiRespBuilder. Use this as the starting point for building a SubmitMultiResp. ```rust pub fn new() -> SubmitMultiRespBuilder ``` -------------------------------- ### BroadcastSmParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.BroadcastSmParts.html Creates a new instance of BroadcastSmParts with all required fields. ```APIDOC ## impl BroadcastSmParts ### `new` Constructor ```rust pub const fn new( service_type: ServiceType, source_addr_ton: Ton, source_addr_npi: Npi, source_addr: COctetString<1, 21>, message_id: COctetString<1, 65>, priority_flag: PriorityFlag, schedule_delivery_time: EmptyOrFullCOctetString<17>, validity_period: EmptyOrFullCOctetString<17>, replace_if_present_flag: ReplaceIfPresentFlag, data_coding: DataCoding, sm_default_msg_id: u8, tlvs: Vec, ) -> BroadcastSmParts ``` This function constructs a `BroadcastSmParts` object by taking all its fields as arguments. ``` -------------------------------- ### Length Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.DeliverSm.html Gets the length of the DeliverSm value. ```APIDOC ## fn length(&self) -> usize ### Description Returns the length of the DeliverSm value. ### Returns - usize - The length. ``` -------------------------------- ### BroadcastSmRespBuilder::new() Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.BroadcastSmRespBuilder.html Creates a new instance of BroadcastSmRespBuilder. Use this as the starting point for building a BroadcastSmResp. ```rust pub fn new() -> BroadcastSmRespBuilder ``` -------------------------------- ### DataSmBuilder::new Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.DataSmBuilder.html Creates a new instance of DataSmBuilder. ```APIDOC ## DataSmBuilder::new ### Description Creates a new instance of DataSmBuilder. ### Method `pub fn new() -> DataSmBuilder` ``` -------------------------------- ### BroadcastSm Length Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.BroadcastSm.html Gets the length of the BroadcastSm. ```APIDOC ## fn length(&self) -> usize ### Description Returns the length of the BroadcastSm. ``` -------------------------------- ### CommandId::type_id Source: https://docs.rs/rusmpp/latest/rusmpp/enum.CommandId.html Gets the TypeId of the CommandId. ```APIDOC #### fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. Read more ``` -------------------------------- ### Command Construction Source: https://docs.rs/rusmpp/latest/rusmpp/struct.Command.html Provides methods for creating Command instances, including a const constructor and a builder pattern. ```rust pub fn new( status: CommandStatus, sequence_number: u32, pdu: impl Into, ) -> Command ``` ```rust pub const fn new_const( status: CommandStatus, sequence_number: u32, pdu: Pdu, ) -> Command ``` ```rust pub fn builder() -> CommandStatusBuilder ``` -------------------------------- ### Example Usage of Decode Trait Source: https://docs.rs/rusmpp/latest/rusmpp/decode/trait.Decode.html This example demonstrates how the `Decode` trait can be implemented for a custom struct `Foo` and used to decode data from a `BytesMut` buffer. It shows the process of decoding individual fields and accumulating the consumed byte count. ```APIDOC ## Example Implementation ```rust #[derive(Debug, PartialEq, Eq)] struct Foo { a: u8, b: u16, c: u32, } impl Decode for Foo { fn decode(src: &mut BytesMut) -> Result<(Self, usize), DecodeError> { let index = 0; let (a, size) = Decode::decode(src)?; let index = index + size; let (b, size) = Decode::decode(src)?; let index = index + size; let (c, size) = Decode::decode(src)?; let index = index + size; Ok((Foo { a, b, c }, index)) } } let mut buf = BytesMut::from(&[0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08][..]); let expected = Foo { a: 0x01, b: 0x0203, c: 0x04050607, }; let (foo, size) = Foo::decode(&mut buf).unwrap(); assert_eq!(size, 7); assert_eq!(foo, expected); assert_eq!(&buf[..], &[0x08]); ``` ``` -------------------------------- ### SubmitMultiResp Constructors and Methods Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.SubmitMultiResp.html Provides details on how to create and manipulate SubmitMultiResp instances. ```APIDOC ### impl SubmitMultiResp #### pub fn new( message_id: COctetString<1, 65>, unsuccess_sme: Vec, tlvs: Vec, ) -> SubmitMultiResp #### pub fn no_unsuccess(&self) -> u8 #### pub fn unsuccess_sme(&self) -> &[UnsuccessSme] #### pub fn set_unsuccess_sme(&mut self, unsuccess_sme: Vec) #### pub fn push_unsuccess_sme(&mut self, unsuccess_sme: UnsuccessSme) #### pub fn clear_unsuccess_sme(&mut self) #### pub fn tlvs(&self) -> &[Tlv] #### pub fn set_tlvs(&mut self, tlvs: Vec) #### pub fn clear_tlvs(&mut self) #### pub fn push_tlv(&mut self, tlv: impl Into) #### pub fn builder() -> SubmitMultiRespBuilder ``` -------------------------------- ### TlvTag Length Source: https://docs.rs/rusmpp/latest/rusmpp/tlvs/enum.TlvTag.html Method to get the length of a TlvTag. ```APIDOC ## length(&self) -> usize ### Description Returns the length of the TlvTag. ### Method length ### Returns - *usize* - The length. ``` -------------------------------- ### clone_to_uninit Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/concatenation/enum.ConcatenatedShortMessageType.html This is a nightly-only experimental API. Performs copy-assignment from `self` to `dest`. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `clone_to_uninit` ### Parameters - `dest` (*mut u8) - Description of the destination pointer. ``` -------------------------------- ### QueryBroadcastSmParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.QueryBroadcastSmParts.html Creates a new instance of QueryBroadcastSmParts with the provided parameters. ```APIDOC ## impl QueryBroadcastSmParts ### pub const fn new Creates a new `QueryBroadcastSmParts`. #### Parameters - `message_id`: COctetString<1, 65> - `source_addr_ton`: Ton - `source_addr_npi`: Npi - `source_addr`: COctetString<1, 21> - `user_message_reference`: Option #### Returns A new `QueryBroadcastSmParts` instance. ``` -------------------------------- ### TlvValue Length Source: https://docs.rs/rusmpp/latest/rusmpp/tlvs/enum.TlvValue.html Defines how to get the length of a TlvValue. ```APIDOC ### impl Length for TlvValue #### fn length(&self) -> usize Source ``` -------------------------------- ### Length of ReplaceSm Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.ReplaceSm.html Get the length of the ReplaceSm value. ```APIDOC ## length(&self) -> usize ### Description Returns the length of the `ReplaceSm` value. ### Returns The length as a `usize`. ``` -------------------------------- ### try_from Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/enum.UdhId.html Performs the conversion. ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion. ### Method `try_from` ### Parameters - `value` (U) - The value to convert from. ### Returns `Result>::Error>` ``` -------------------------------- ### trim_prefix Source: https://docs.rs/rusmpp/latest/rusmpp/types/struct.COctetString.html Returns a subslice with the optional prefix removed. If the slice starts with the prefix, it returns the subslice after the prefix. If the prefix is empty or the slice does not start with the prefix, it returns the original slice. If the prefix is equal to the original slice, it returns an empty slice. This is an experimental API. ```APIDOC ## trim_prefix ### Description Returns a subslice with the optional prefix removed. If the slice starts with `prefix`, returns the subslice after the prefix. If `prefix` is empty or the slice does not start with `prefix`, simply returns the original slice. If `prefix` is equal to the original slice, returns an empty slice. This is a nightly-only experimental API. ### Method `trim_prefix` ### Parameters #### Path Parameters - **prefix** (SlicePattern + ?Sized) - Required - The prefix pattern to remove. #### Query Parameters None #### Request Body None ### Request Example ```rust #![feature(trim_prefix_suffix)] let v = &[10, 40, 30]; assert_eq!(v.trim_prefix(&[10]), &[40, 30][..]); ``` ### Response #### Success Response - **subslice** (&[T]) - The subslice with the prefix removed or the original slice if the prefix is not found or empty. #### Response Example ```json { "example": "[40, 30]" } ``` ``` -------------------------------- ### Length Implementation Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.MsMsgWaitFacilities.html Provides a method to get the length of MsMsgWaitFacilities. ```APIDOC ## `Length` Trait Implementation ### `length` Method ```rust fn length(&self) -> usize ``` Returns the length of the value. ``` -------------------------------- ### BindReceiverParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.BindReceiverParts.html Creates a new instance of BindReceiverParts. All necessary parameters must be provided. ```rust pub const fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, system_type: COctetString<1, 13>, interface_version: InterfaceVersion, addr_ton: Ton, addr_npi: Npi, address_range: COctetString<1, 41>, ) -> BindReceiverParts ``` -------------------------------- ### impl Any for T Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.ItsSessionInfo.html Provides the `type_id` method to get the `TypeId` of the type. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ### Parameters None ### Response - **TypeId**: The unique identifier for the type. ``` -------------------------------- ### into Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/enum.UdhId.html Calls U::from(self). ```APIDOC ## fn into(self) -> U ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Method `into` ### Parameters None ### Returns U ``` -------------------------------- ### Get Length Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/concatenation/struct.ConcatenatedShortMessage8Bit.html Returns the length of the `ConcatenatedShortMessage8Bit` UDH in bytes. ```rust fn length(&self) -> usize; ``` -------------------------------- ### Into Source: https://docs.rs/rusmpp/latest/rusmpp/values/enum.ItsReplyType.html Calls U::from(self). ```APIDOC ## fn into(self) -> U ### Description Calls `U::from(self)`. That is, this conversion is whatever the implementation of `From for U` chooses to do. ### Method `into` ``` -------------------------------- ### Get Destination Flag Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.SmeAddress.html Retrieves the destination flag associated with the SmeAddress. ```rust pub fn dest_flag(&self) -> DestFlag ``` -------------------------------- ### BindReceiverRespParts Constructor and Methods Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.BindReceiverRespParts.html Provides details on how to create and interact with BindReceiverRespParts instances. ```APIDOC ## Implementations for BindReceiverRespParts ### `impl BindReceiverRespParts` #### `pub const fn new(system_id: COctetString<1, 16>, sc_interface_version: Option) -> BindReceiverRespParts` Creates a new `BindReceiverRespParts` instance. #### `pub fn raw(self) -> (COctetString<1, 16>, Option)` Consumes the `BindReceiverRespParts` instance and returns its raw components. ``` -------------------------------- ### OutbindParts::new Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.OutbindParts.html Constructor for creating a new OutbindParts instance. ```APIDOC ## `new` Constructor ```rust pub const fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, ) -> OutbindParts ``` Creates a new `OutbindParts` with the provided system ID and password. ``` -------------------------------- ### Get ServiceType Value Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.ServiceType.html Returns a reference to the COctetString value of the ServiceType. ```rust pub const fn value(&self) -> &COctetString<1, 6> ``` -------------------------------- ### Command Implementations Source: https://docs.rs/rusmpp/latest/rusmpp/struct.Command.html Available methods for the Command struct. ```APIDOC ## Implementations ### impl Command `pub fn into_parts(self) -> CommandParts` Converts `Self` into its parts. `pub fn from_parts(parts: CommandParts) -> Command` Creates a new instance of `Self` from its parts. ##### Note This may create invalid instances. It’s up to the caller to ensure that the parts are valid. `pub fn new( status: CommandStatus, sequence_number: u32, pdu: impl Into, ) -> Command` `pub const fn new_const( status: CommandStatus, sequence_number: u32, pdu: Pdu, ) -> Command` `pub const fn id(&self) -> CommandId` `pub const fn status(&self) -> CommandStatus` `pub const fn sequence_number(&self) -> u32` `pub const fn pdu(&self) -> Option<&Pdu>` `pub fn set_pdu(&mut self, pdu: impl Into)` `pub fn builder() -> CommandStatusBuilder` ``` -------------------------------- ### Any Trait Implementation Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.NetworkErrorCode.html Provides the `type_id` method to get the `TypeId` of the `NetworkErrorCode`. ```APIDOC ## fn type_id(&self) -> TypeId Gets the `TypeId` of `self`. ``` -------------------------------- ### QuerySm Blanket Implementations Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.QuerySm.html Details blanket implementations for QuerySm, such as Any, Borrow, BorrowMut, CloneToUninit, DecodeWithLength, From, Instrument, Into, ToOwned, TryFrom, TryInto, and WithSubscriber. ```APIDOC ### impl Any for T #### fn type_id(&self) -> TypeId ### impl Borrow for T #### fn borrow(&self) -> &T ### impl BorrowMut for T #### fn borrow_mut(&mut self) -> &mut T ### impl CloneToUninit for T #### unsafe fn clone_to_uninit(&self, dest: *mut u8) ### impl DecodeWithLength for T #### fn decode(src: &mut BytesMut, _length: usize) -> Result<(T, usize), DecodeError> ### impl From for T #### fn from(t: T) -> T ### impl Instrument for T #### fn instrument(self, span: Span) -> Instrumented #### fn in_current_span(self) -> Instrumented ### impl Into for T #### fn into(self) -> U ### impl ToOwned for T #### type Owned = T #### fn to_owned(&self) -> T #### fn clone_into(&self, target: &mut T) ### impl TryFrom for T #### type Error = Infallible #### fn try_from(value: U) -> Result>::Error> ### impl TryInto for T #### type Error = >::Error #### fn try_into(self) -> Result>::Error> ### impl WithSubscriber for T #### fn with_subscriber(self, subscriber: S) -> WithDispatch #### fn with_current_subscriber(self) -> WithDispatch ``` -------------------------------- ### Get IntermediateNotification from RegisteredDelivery Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.RegisteredDelivery.html Retrieves the IntermediateNotification part from a RegisteredDelivery instance. ```rust pub fn intermediate_notification(&self) -> IntermediateNotification ``` -------------------------------- ### PartialEq Implementation Source: https://docs.rs/rusmpp/latest/rusmpp/struct.Command.html Methods for checking equality between Command values. ```APIDOC ## fn eq(&self, other: &Command) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. ### Parameters - `other`: &Command - The other Command value to compare with. ### Returns - bool - True if the values are equal, false otherwise. ``` ```APIDOC ## fn ne(&self, other: &Rhs) -> bool Tests for `!=`. ### Parameters - `other`: &Rhs - The other value to compare with. ### Returns - bool - True if the values are not equal, false otherwise. ``` -------------------------------- ### Get SmeOriginatedAcknowledgement from RegisteredDelivery Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.RegisteredDelivery.html Retrieves the SmeOriginatedAcknowledgement part from a RegisteredDelivery instance. ```rust pub fn sme_originated_acknowledgement(&self) -> SmeOriginatedAcknowledgement ``` -------------------------------- ### Into Implementation Source: https://docs.rs/rusmpp/latest/rusmpp/extra/encoding/gsm7bit/struct.Gsm7BitDefaultAlphabet.html Converts Gsm7BitDefaultAlphabet into another type U, provided U implements From. ```rust fn into(self) -> U; ``` -------------------------------- ### Get MCDeliveryReceipt from RegisteredDelivery Source: https://docs.rs/rusmpp/latest/rusmpp/values/struct.RegisteredDelivery.html Retrieves the MCDeliveryReceipt part from a RegisteredDelivery instance. ```rust pub fn mc_delivery_receipt(&self) -> MCDeliveryReceipt ``` -------------------------------- ### type_id Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/enum.UdhValue.html Gets the `TypeId` of `self`. This method is part of the `Any` trait implementation. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method `type_id` ### Parameters - `self`: A reference to the object. ### Returns - `TypeId`: The type identifier of the object. ``` -------------------------------- ### Ucs2::new Source: https://docs.rs/rusmpp/latest/rusmpp/extra/encoding/ucs2/struct.Ucs2.html Creates a new Ucs2 codec with default settings. ```APIDOC ## Ucs2::new ### Description Creates a new `Ucs2` codec. ### Method `pub const fn new() -> Ucs2` ### Defaults - `allow_split_character`: `false` ``` -------------------------------- ### CloneToUninit (Nightly Only) Source: https://docs.rs/rusmpp/latest/rusmpp/values/enum.PriorityFlagType.html Performs copy-assignment from `self` to `dest`. This is a nightly-only experimental API. ```APIDOC ## unsafe fn clone_to_uninit(&self, dest: *mut u8) ### Description Performs copy-assignment from `self` to `dest`. ### Method `clone_to_uninit` ### Note This is a nightly-only experimental API. ``` -------------------------------- ### Udh::length Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/struct.Udh.html Gets the length of the Udh, excluding the length field itself. ```APIDOC ## Udh::length ### Description Returns the UDH length (excluding the length field itself). ### Signature ```rust pub const fn length(&self) -> u8 ``` ### Returns The length of the Udh as a `u8`. ``` -------------------------------- ### Building the QueryBroadcastSm PDU Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/builders/struct.QueryBroadcastSmBuilder.html Finalizes the construction of the QueryBroadcastSm PDU using the configured builder. ```rust pub fn build(self) -> QueryBroadcastSm ``` -------------------------------- ### Get Udh Value Source: https://docs.rs/rusmpp/latest/rusmpp/udhs/struct.Udh.html Returns an optional reference to the UDH value. ```rust pub fn value(&self) -> Option<&UdhValue> ``` -------------------------------- ### Get BindTransceiverResp Builder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.BindTransceiverResp.html Returns a builder for constructing a BindTransceiverResp instance. ```rust pub fn builder() -> BindTransceiverRespBuilder ``` -------------------------------- ### QueryBroadcastSm Constructor and Methods Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.QueryBroadcastSm.html Provides methods for creating and manipulating QueryBroadcastSm instances, including constructors and accessors for user message reference. ```APIDOC ## impl QueryBroadcastSm ### `pub fn new( message_id: COctetString<1, 65>, source_addr_ton: Ton, source_addr_npi: Npi, source_addr: COctetString<1, 21>, user_message_reference: Option, ) -> QueryBroadcastSm` Creates a new QueryBroadcastSm instance. ### `pub fn user_message_reference_tlv(&self) -> Option<&Tlv>` Returns the TLV for the user message reference, if present. ### `pub fn user_message_reference(&self) -> Option` Returns the user message reference, if present. ### `pub fn set_user_message_reference(&mut self, user_message_reference: Option)` Sets the user message reference. ### `pub fn builder() -> QueryBroadcastSmBuilder` Returns a builder for creating QueryBroadcastSm instances. ``` -------------------------------- ### QuerySm Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.QuerySm.html Creates a new QuerySm PDU with the specified message ID, source address TON, NPI, and source address. ```APIDOC ## impl QuerySm ### pub fn new( message_id: COctetString<1, 65>, source_addr_ton: Ton, source_addr_npi: Npi, source_addr: COctetString<1, 21>, ) -> QuerySm ``` -------------------------------- ### Get AlertNotification Builder Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.AlertNotification.html Returns a builder for constructing an AlertNotification instance. ```rust pub fn builder() -> AlertNotificationBuilder ``` -------------------------------- ### SubmitMultiParts::new Constructor Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/parts/struct.SubmitMultiParts.html Creates a new instance of SubmitMultiParts with all required fields. ```APIDOC ## `impl SubmitMultiParts` ### `pub const fn new(...) -> SubmitMultiParts` Constructs a new `SubmitMultiParts` PDU. #### Parameters * `service_type`: `ServiceType` * `source_addr_ton`: `Ton` * `source_addr_npi`: `Npi` * `source_addr`: `COctetString<1, 21>` * `number_of_dests`: `u8` * `dest_address`: `Vec` * `esm_class`: `EsmClass` * `protocol_id`: `u8` * `priority_flag`: `PriorityFlag` * `schedule_delivery_time`: `EmptyOrFullCOctetString<17>` * `validity_period`: `EmptyOrFullCOctetString<17>` * `registered_delivery`: `RegisteredDelivery` * `replace_if_present_flag`: `ReplaceIfPresentFlag` * `data_coding`: `DataCoding` * `sm_default_msg_id`: `u8` * `sm_length`: `u8` * `short_message`: `OctetString<0, 255>` * `tlvs`: `Vec` #### Returns A new `SubmitMultiParts` instance. ``` -------------------------------- ### Get BroadcastSmResp TLVs Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.BroadcastSmResp.html Retrieves a slice of the TLVs associated with the BroadcastSmResp. ```rust pub fn tlvs(&self) -> &[Tlv] ``` -------------------------------- ### TypeId Implementation Source: https://docs.rs/rusmpp/latest/rusmpp/extra/encoding/gsm7bit/struct.Gsm7BitDefaultAlphabet.html Gets the TypeId of the Gsm7BitDefaultAlphabet. This is part of the Any trait implementation. ```rust fn type_id(&self) -> TypeId; ``` -------------------------------- ### Create BindReceiver Instance Source: https://docs.rs/rusmpp/latest/rusmpp/pdus/struct.BindReceiver.html Constructs a new BindReceiver instance with the provided parameters. Ensure all parts are valid before creating the instance. ```rust pub const fn new( system_id: COctetString<1, 16>, password: COctetString<1, 9>, system_type: COctetString<1, 13>, interface_version: InterfaceVersion, addr_ton: Ton, addr_npi: Npi, address_range: COctetString<1, 41>, ) -> BindReceiver ```