Skip to main content

Tone

Struct Tone 

Source
pub struct Tone {
    pub modulation: u16,
    pub modulation_divided_by_three: bool,
    pub volume: u8,
    pub duration: u16,
    pub frequencies: Vec<u16>,
}
Expand description

One tone report (RFC 4733 section 4.3.3, Figure 2).

Fields§

§modulation: u16

The modulation frequency in Hz, 9 bits; 0 for none.

§modulation_divided_by_three: bool

Whether the modulation frequency is to be divided by three (the T bit).

§volume: u8

The power level in dBm0 with the sign dropped, 0 to 63.

§duration: u16

How long the tone lasts from the packet’s timestamp, in timestamp units. Never 0.

§frequencies: Vec<u16>

The frequencies added together, in Hz, 12 bits each; 0 is silence, none is a period of silence.

Implementations§

Source§

impl Tone

Source

pub fn marshal(&self) -> Result<Bytes>

The payload. The reserved bits before each frequency are zero (section 4.3.3: “The sender MUST set it to zero”). A field out of its range, or a duration of 0 (“not permitted”), is refused.

Source

pub fn unmarshal(payload: &[u8]) -> Option<Tone>

The tone in payload, the reserved bits ignored (section 4.3.3: “the receiver MUST ignore it”). None for a payload too short or of an odd length, and for a tone of duration 0, which “SHOULD be ignored”.

Trait Implementations§

Source§

impl Clone for Tone

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Tone

Source§

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

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

impl Default for Tone

Source§

fn default() -> Self

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

impl Eq for Tone

Source§

impl PartialEq for Tone

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Tone

Auto Trait Implementations§

§

impl Forget for Tone

§

impl Freeze for Tone

§

impl Move for Tone

§

impl RefUnwindSafe for Tone

§

impl Send for Tone

§

impl Sync for Tone

§

impl Unpin for Tone

§

impl UnsafeUnpin for Tone

§

impl UnwindSafe for Tone

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§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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,

Source§

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>,

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.