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>
impl<'a, E> EncodedSubmitSmBuilder<'a, E>
Sourcepub fn encoder<U>(self, encoder: U) -> EncodedSubmitSmBuilder<'a, U>
pub fn encoder<U>(self, encoder: U) -> EncodedSubmitSmBuilder<'a, U>
Sets a custom encoder.
Sourcepub fn gsm7bit_unpacked(self) -> EncodedSubmitSmBuilder<'a, Gsm7BitUnpacked>
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}Sourcepub fn ucs2(self) -> EncodedSubmitSmBuilder<'a, Ucs2>
pub fn ucs2(self) -> EncodedSubmitSmBuilder<'a, Ucs2>
Sets the Ucs2 encoder.
Sourcepub fn latin1(self) -> EncodedSubmitSmBuilder<'a, Latin1>
pub fn latin1(self) -> EncodedSubmitSmBuilder<'a, Latin1>
Sets the Latin1 encoder.
Sourcepub fn fallback<U>(
self,
encoder: U,
) -> EncodedSubmitSmBuilder<'a, Fallback<E, U>>
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,
impl<'a, E> EncodedSubmitSmBuilder<'a, E>where
E: Encoder + 'a,
Sourcepub fn build(self) -> Result<SubmitSm, EncodeError<E::Error>>
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}