EncodedSubmitSmBuilder

Struct EncodedSubmitSmBuilder 

Source
pub struct EncodedSubmitSmBuilder<'a, E> { /* private fields */ }
Available on crate features encoding and alloc only.
Expand description

Builder for creating encoded SubmitSm messages.

Created using EncodedSubmitSmExt::encode.

Implementations§

Source§

impl<'a, E> EncodedSubmitSmBuilder<'a, E>

Source

pub fn encoder<U>(self, encoder: U) -> EncodedSubmitSmBuilder<'a, U>

Sets a custom encoder.

Source

pub fn gsm7bit_unpacked(self) -> EncodedSubmitSmBuilder<'a, Gsm7BitUnpacked>

Sets the Gsm7BitUnpacked encoder.

Examples found in repository?
examples/submit_sm_encode.rs (line 36)
16fn main() -> Result<(), Box<dyn core::error::Error>> {
17    // c-spell: disable
18    let message = r##"Hello world!
19
20@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà
21
22^{}\[~]|€"##;
23    // c-spell: enable
24
25    let sm = SubmitSm::builder()
26        .source_addr_ton(Ton::Unknown)
27        .source_addr_npi(Npi::Unknown)
28        .source_addr(COctetString::from_str("12345")?)
29        .destination_addr(COctetString::from_str("491701234567")?)
30        // data_coding will be overridden by the encoding builder to match the encoder.
31        .data_coding(DataCoding::default())
32        // short_message will be overridden by `short_message` of the encoding builder.
33        .short_message(OctetString::from_str("Hi, I am a short message.")?)
34        .build()
35        .encode(message)
36        .gsm7bit_unpacked()
37        .fallback(Ucs2::new())
38        .build()?;
39
40    println!(
41        "Encoded: short_message_len = {}, data_coding = {:?}, short_message = {:?}",
42        sm.short_message().len(),
43        sm.data_coding,
44        sm.short_message()
45    );
46
47    Ok(())
48}
Source

pub fn ucs2(self) -> EncodedSubmitSmBuilder<'a, Ucs2>

Sets the Ucs2 encoder.

Source

pub fn latin1(self) -> EncodedSubmitSmBuilder<'a, Latin1>

Sets the Latin1 encoder.

Source

pub fn fallback<U>( self, encoder: U, ) -> EncodedSubmitSmBuilder<'a, Fallback<E, U>>

Sets a fallback encoder.

Examples found in repository?
examples/submit_sm_encode.rs (line 37)
16fn main() -> Result<(), Box<dyn core::error::Error>> {
17    // c-spell: disable
18    let message = r##"Hello world!
19
20@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà
21
22^{}\[~]|€"##;
23    // c-spell: enable
24
25    let sm = SubmitSm::builder()
26        .source_addr_ton(Ton::Unknown)
27        .source_addr_npi(Npi::Unknown)
28        .source_addr(COctetString::from_str("12345")?)
29        .destination_addr(COctetString::from_str("491701234567")?)
30        // data_coding will be overridden by the encoding builder to match the encoder.
31        .data_coding(DataCoding::default())
32        // short_message will be overridden by `short_message` of the encoding builder.
33        .short_message(OctetString::from_str("Hi, I am a short message.")?)
34        .build()
35        .encode(message)
36        .gsm7bit_unpacked()
37        .fallback(Ucs2::new())
38        .build()?;
39
40    println!(
41        "Encoded: short_message_len = {}, data_coding = {:?}, short_message = {:?}",
42        sm.short_message().len(),
43        sm.data_coding,
44        sm.short_message()
45    );
46
47    Ok(())
48}
Source§

impl<'a, E> EncodedSubmitSmBuilder<'a, E>
where E: Encoder + 'a,

Source

pub fn build(self) -> Result<SubmitSm, EncodeError<E::Error>>

Builds the encoded SubmitSm message.

Examples found in repository?
examples/submit_sm_encode.rs (line 38)
16fn main() -> Result<(), Box<dyn core::error::Error>> {
17    // c-spell: disable
18    let message = r##"Hello world!
19
20@£$¥èéùìòÇØøÅåΔ_ΦΓΛΩΠΨΣΘΞÆæßÉ !"#¤%&'()*+,-./0123456789:;<=>?¡ABCDEFGHIJKLMNOPQRSTUVWXYZÄÖÑܧ¿abcdefghijklmnopqrstuvwxyzäöñüà
21
22^{}\[~]|€"##;
23    // c-spell: enable
24
25    let sm = SubmitSm::builder()
26        .source_addr_ton(Ton::Unknown)
27        .source_addr_npi(Npi::Unknown)
28        .source_addr(COctetString::from_str("12345")?)
29        .destination_addr(COctetString::from_str("491701234567")?)
30        // data_coding will be overridden by the encoding builder to match the encoder.
31        .data_coding(DataCoding::default())
32        // short_message will be overridden by `short_message` of the encoding builder.
33        .short_message(OctetString::from_str("Hi, I am a short message.")?)
34        .build()
35        .encode(message)
36        .gsm7bit_unpacked()
37        .fallback(Ucs2::new())
38        .build()?;
39
40    println!(
41        "Encoded: short_message_len = {}, data_coding = {:?}, short_message = {:?}",
42        sm.short_message().len(),
43        sm.data_coding,
44        sm.short_message()
45    );
46
47    Ok(())
48}

Trait Implementations§

Source§

impl<'a, E: Debug> Debug for EncodedSubmitSmBuilder<'a, E>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, E> !Freeze for EncodedSubmitSmBuilder<'a, E>

§

impl<'a, E> RefUnwindSafe for EncodedSubmitSmBuilder<'a, E>
where E: RefUnwindSafe,

§

impl<'a, E> Send for EncodedSubmitSmBuilder<'a, E>
where E: Send,

§

impl<'a, E> Sync for EncodedSubmitSmBuilder<'a, E>
where E: Sync,

§

impl<'a, E> Unpin for EncodedSubmitSmBuilder<'a, E>
where E: Unpin,

§

impl<'a, E> UnwindSafe for EncodedSubmitSmBuilder<'a, E>
where E: UnwindSafe,

Blanket Implementations§

§

impl<T> Any for T
where T: 'static + ?Sized,

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> Borrow<T> for T
where T: ?Sized,

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

impl<T> BorrowMut<T> for T
where T: ?Sized,

§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, U> Into<U> for T
where U: From<T>,

§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.