Skip to main content

MorsePattern

Struct MorsePattern 

Source
pub struct MorsePattern(/* private fields */);
Expand description

MorsePattern is a sequence of maximum 15 taps or holds that can be encoded into an u16: 0x1 when empty, then 0 for tap or 1 for hold shifted from the right

Implementations§

Source§

impl MorsePattern

Source

pub fn max_taps() -> usize

Source

pub fn from_u16(value: u16) -> Self

Creates a MorsePattern from a raw u16.

§Panics (debug only)

Panics if value is 0, which is not a valid encoding (the empty pattern is 0b1).

Source

pub fn to_u16(&self) -> u16

Source

pub fn is_empty(&self) -> bool

Source

pub fn is_full(&self) -> bool

Source

pub fn pattern_length(&self) -> usize

Source

pub fn starts_with(&self, pattern_start: MorsePattern) -> bool

Checks if this pattern starts with the given one

Source

pub fn last_is_hold(&self) -> bool

Returns true if the last step in the pattern is a hold. Returns false for empty patterns.

Source

pub fn followed_by_tap(&self) -> Self

Source

pub fn followed_by_hold(&self) -> Self

Source

pub fn is_all_taps(&self) -> bool

true when the pattern consists only of tap steps (no holds). Returns false for the empty pattern (encoding 0b1).

Trait Implementations§

Source§

impl Clone for MorsePattern

Source§

fn clone(&self) -> MorsePattern

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 Copy for MorsePattern

Source§

impl Debug for MorsePattern

Source§

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

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

impl Default for MorsePattern

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for MorsePattern

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 Eq for MorsePattern

Source§

impl MaxSize for MorsePattern

Source§

const POSTCARD_MAX_SIZE: usize

The maximum possible size that the serialization of this type can have, in bytes.
Source§

impl PartialEq for MorsePattern

Source§

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

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

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

Inequality operator !=. Read more
Source§

impl Serialize for MorsePattern

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
Source§

impl StructuralPartialEq for MorsePattern

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§

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.