Struct nmea::Nmea

source ·
pub struct Nmea {
Show 14 fields pub fix_time: Option<NaiveTime>, pub fix_date: Option<NaiveDate>, pub fix_type: Option<FixType>, pub latitude: Option<f64>, pub longitude: Option<f64>, pub altitude: Option<f32>, pub speed_over_ground: Option<f32>, pub true_course: Option<f32>, pub num_of_fix_satellites: Option<u32>, pub hdop: Option<f32>, pub vdop: Option<f32>, pub pdop: Option<f32>, pub geoid_separation: Option<f32>, pub fix_satellites_prns: Option<Vec<u32, 12>>, /* private fields */
}
Expand description

NMEA parser

This struct parses NMEA sentences, including checksum checks and sentence validation.

Examples

use nmea::Nmea;

let mut nmea = Nmea::default();
let gga = "$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76";
// feature `GGA` should be enabled to parse this sentence.
nmea.parse(gga).unwrap();
println!("{}", nmea);

Fields§

§fix_time: Option<NaiveTime>§fix_date: Option<NaiveDate>§fix_type: Option<FixType>§latitude: Option<f64>§longitude: Option<f64>§altitude: Option<f32>

MSL Altitude in meters

§speed_over_ground: Option<f32>§true_course: Option<f32>§num_of_fix_satellites: Option<u32>§hdop: Option<f32>§vdop: Option<f32>§pdop: Option<f32>§geoid_separation: Option<f32>

Geoid separation in meters

§fix_satellites_prns: Option<Vec<u32, 12>>

Implementations§

source§

impl<'a> Nmea

source

pub fn create_for_navigation( required_sentences_for_nav: &[SentenceType] ) -> Result<Nmea, Error<'a>>

Constructs a new Nmea for navigation purposes.

Examples
use nmea::{Nmea, SentenceType};

let mut nmea = Nmea::create_for_navigation(&[SentenceType::RMC, SentenceType::GGA]).unwrap();
let gga = "$GPGGA,092750.000,5321.6802,N,00630.3372,W,1,8,1.03,61.7,M,55.2,M,,*76";
// feature `GGA` should be enabled to parse this sentence.
nmea.parse(gga).unwrap();
println!("{}", nmea);
source

pub fn fix_timestamp(&self) -> Option<NaiveTime>

Returns fix type

source

pub fn fix_type(&self) -> Option<FixType>

Returns fix type

source

pub fn latitude(&self) -> Option<f64>

Returns last fixed latitude in degrees. None if not fixed.

source

pub fn longitude(&self) -> Option<f64>

Returns last fixed longitude in degrees. None if not fixed.

source

pub fn altitude(&self) -> Option<f32>

Returns altitude above WGS-84 ellipsoid, meters.

source

pub fn fix_satellites(&self) -> Option<u32>

Returns the number of satellites use for fix.

source

pub fn hdop(&self) -> Option<f32>

Returns the number fix HDOP

source

pub fn geoid_altitude(&self) -> Option<f32>

Returns the altitude above MSL (geoid), meters.

source

pub fn satellites(&self) -> Vec<Satellite, 58>

Returns used satellites

source

pub fn parse(&mut self, sentence: &'a str) -> Result<SentenceType, Error<'a>>

Parse any NMEA sentence and stores the result of sentences that include:

  • altitude
  • latitude and longitude
  • speed_over_ground
  • and other

The type of sentence is returned if implemented and valid.

source

pub fn parse_for_fix(&mut self, xs: &'a str) -> Result<FixType, Error<'a>>

source

pub fn last_txt(&self) -> Option<&TxtData>

Trait Implementations§

source§

impl Clone for Nmea

source§

fn clone(&self) -> Nmea

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 Nmea

source§

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

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

impl Default for Nmea

source§

fn default() -> Nmea

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Nmea

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Nmea

source§

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

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

impl Serialize for Nmea

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl RefUnwindSafe for Nmea

§

impl Send for Nmea

§

impl Sync for Nmea

§

impl Unpin for Nmea

§

impl UnwindSafe for Nmea

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for Twhere 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 Twhere 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.
source§

impl<T> DeserializeOwned for Twhere T: for<'de> Deserialize<'de>,