pub struct RadioFrequency(/* private fields */);
Expand description
Represents a VHF, airband radio frequenxy from 118.000 MHz to 137.000 MHz.
Stored internally as the left part and the right part. For example, 118.3MHz is RadioFrequency(118, 300)
.
Implementations§
Source§impl RadioFrequency
impl RadioFrequency
Sourcepub fn new(
left: u16,
right: u16,
) -> Result<RadioFrequency, FsdMessageParseError>
pub fn new( left: u16, right: u16, ) -> Result<RadioFrequency, FsdMessageParseError>
Creates a new RadioFrequency
from two parts
§Example
use fsd_messages::util::RadioFrequency;
let freq = RadioFrequency::new(118, 300).unwrap();
assert_eq!(RadioFrequency(118, 300), freq);
pub fn frequency(&self) -> (u16, u16)
Sourcepub fn to_human_readable_string(&self) -> String
pub fn to_human_readable_string(&self) -> String
Returns the frequency in the form XXX.YYY
§Example
use fsd_messages::util::RadioFrequency;
let freq = RadioFrequency::new(133, 175).unwrap();
let human_readable = freq.to_human_readable_string();
assert_eq!(human_readable, String::from("133.175"));
pub fn try_from_human_readable_string( input: impl AsRef<str>, ) -> Result<RadioFrequency, FsdMessageParseError>
Trait Implementations§
Source§impl Clone for RadioFrequency
impl Clone for RadioFrequency
Source§fn clone(&self) -> RadioFrequency
fn clone(&self) -> RadioFrequency
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl Debug for RadioFrequency
impl Debug for RadioFrequency
Source§impl Display for RadioFrequency
impl Display for RadioFrequency
Source§impl FromStr for RadioFrequency
impl FromStr for RadioFrequency
Source§impl PartialEq for RadioFrequency
impl PartialEq for RadioFrequency
impl Copy for RadioFrequency
impl Eq for RadioFrequency
impl StructuralPartialEq for RadioFrequency
Auto Trait Implementations§
impl Freeze for RadioFrequency
impl RefUnwindSafe for RadioFrequency
impl Send for RadioFrequency
impl Sync for RadioFrequency
impl Unpin for RadioFrequency
impl UnwindSafe for RadioFrequency
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more