Struct sbd::message::Message
[−]
[src]
pub struct Message { // some fields omitted }
An SBD message.
Methods
impl Message
[src]
fn from_path<P: AsRef<Path>>(path: P) -> Result<Message>
Reads in a message from a file path.
Examples
use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap();
fn read_from<R: Read>(readable: R) -> Result<Message>
Reads in a message from an object that implements Read
.
Per the specification, oversized and undersized messages will result in an error.
Examples
use std::fs::File; use sbd::message::Message; let mut file = File::open("data/0-mo.sbd").unwrap(); let message = Message::read_from(file).unwrap();
fn len(&self) -> usize
Returns the overall message length of the SBD message.
This value includes the initial three bytes, whereas the overall_message_length
value in the SBD header does not include those bytes.
Examples
use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap(); assert_eq!(59, message.len());
fn is_mobile_originated(&self) -> bool
Returns true if this message is mobile originated.
This is deteremined by the set of information elements in this message.
Examples
use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap(); assert!(message.is_mobile_originated());
fn is_mobile_terminated(&self) -> bool
Returns true if this message is mobile terminated.
This is deteremined by the set of information elements in this message.
Examples
use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap(); assert!(!message.is_mobile_terminated());
fn into_information_elements(self) -> HashMap<u8, InformationElement>
Convert this message into its information elements.
This allows extraction of components of the information elements easily.
Examples
use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap(); let information_elements = message.into_information_elements(); assert_eq!(2, information_elements.len());
fn write_to<W: Write>(&self, w: &mut W) -> Result<()>
Write this message back to a object that can Write
.
Examples
use std::io::Cursor; use sbd::message::Message; let message = Message::from_path("data/0-mo.sbd").unwrap(); let mut cursor = Cursor::new(Vec::new()); message.write_to(&mut cursor);
impl Message
[src]
fn into_mobile_originated(self) -> Result<MobileOriginated>
Convert a message into a mobile originated message.
Returns an error if this message isn't really mobile originated.
Examples
use sbd::message::Message; use sbd::mobile_originated; let message = Message::from_path("data/0-mo.sbd").unwrap(); message.into_mobile_originated().unwrap();