Struct wte_mt_rx_parser::mt_structured::MtStructured

source ·
pub struct MtStructured {
Show 16 fields pub header: String, pub id: String, pub sequence_number: usize, pub message_type: char, pub format_flag: char, pub beacon: [u8; 15], pub signal_strength: [char; 2], pub lat_degrees: u8, pub lat_minutes: u8, pub lat_seconds: u8, pub n: char, pub long_degrees: u16, pub long_minutes: u8, pub long_seconds: u8, pub w: char, pub checksum: u16,
}
Expand description

MT Serial Out Packet Format.

Fields§

§header: String

Header, should be MT1.

§id: String

UUU - Three character MT-RX configurable ID – by default this is 001.

§sequence_number: usize

NNN - Three decimal digit cycling packet sequence number from 000 to 511. This sequence number

§message_type: char

T - Single character message type ‘T’ or ‘A’ (test or distress alert)

§format_flag: char

F - Single character format flag S or L (short or long) – this relates to the 406 beacon transmission specification.

§beacon: [u8; 15]

15 character hex code used to define beacon owner and beacon capabilities as per the 406 beacon specification.

§signal_strength: [char; 2]

SS - Two character signal strength indication – 00 if not used.

§lat_degrees: u8

11 - Two decimal character latitude degrees.

§lat_minutes: u8

22 - Two decimal character latitude minutes.

§lat_seconds: u8

33 - Two decimal character latitude seconds.

§n: char

N - is N or S.

§long_degrees: u16

444 - Three decimal character longitude degrees.

§long_minutes: u8

22 - Two decimal character longitude minutes.

§long_seconds: u8

55 - Two decimal character longitude seconds.

§w: char

W - is W or E.

§checksum: u16

YYYY - Four character checksum (calculated from M – the first character). If all location characters are ‘-’ then there is no location information available.

Implementations§

source§

impl MtStructured

source

pub fn is_mt(message: &str) -> bool

Returns whether message is a valid MT(1) message.

§Examples
use wte_mt_rx_parser::mt_structured::MtStructured;
println!("is it MT1? {}", MtStructured::is_mt("MT1001000AL400C592753572B323433212S1723756E4706"));
source

pub fn parse(message: &str) -> Result<MtStructured, ParseError>

Tries to parse a “MT Serial Out Packet Format” message.

§Notes
  • Checksum is not calculated here.
§Examples
use wte_mt_rx_parser::mt_structured::MtStructured;
let parsed = MtStructured::parse("MT1001000AL400C592753572B323433212S1723756E4706").unwrap();
// ...
§Message format

Data provided should be in the following format:

  • MT1UUUNNNTFHHHHHHHHHHHHHHHSS112233N4445566WYYYY

Trait Implementations§

source§

impl Clone for MtStructured

source§

fn clone(&self) -> MtStructured

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for MtStructured

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq for MtStructured

source§

fn eq(&self, other: &MtStructured) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for MtStructured

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

type Error = Infallible

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

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

Performs the conversion.
source§

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.
source§

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

Performs the conversion.