#[repr(transparent)]pub struct PulseCode(pub u32);Expand description
Convenience newtype to work with pulse codes.
A PulseCode is represented as u32, with fields laid out as follows:
| Bit 31 | Bits 30-16 | Bit 15 | Bits 14-0 | 
|---|---|---|---|
| level2 | length2 | level1 | length1 | 
Here, level1 / length1 correspond to the signal that is send/received first,
and the signal with level2 / length2 is send/received afterwards.
If length1 or length2 are zero, this implies an end marker and transmission will
stop with the corresponding signal.
Tuple Fields§
§0: u32Implementations§
Source§impl PulseCode
 
impl PulseCode
Sourcepub const fn new(
    level1: Level,
    length1: u16,
    level2: Level,
    length2: u16,
) -> Self
 
pub const fn new( level1: Level, length1: u16, level2: Level, length2: u16, ) -> Self
Create a new instance.
Panics if length1 or length2 exceed the maximum representable range.
Sourcepub const fn new_clamped(
    level1: Level,
    length1: u16,
    level2: Level,
    length2: u16,
) -> Self
 
pub const fn new_clamped( level1: Level, length1: u16, level2: Level, length2: u16, ) -> Self
Create a new instance.
If length1 or length2 exceed the maximum representable range, they
will be clamped to Self::MAX_LEN.
Sourcepub fn try_new(
    level1: Level,
    length1: impl TryInto<u16>,
    level2: Level,
    length2: impl TryInto<u16>,
) -> Option<Self>
 
pub fn try_new( level1: Level, length1: impl TryInto<u16>, level2: Level, length2: impl TryInto<u16>, ) -> Option<Self>
Create a new instance, attempting to convert lengths to u16 first.
This is slightly more convenient when passing in longer integers (e.g. u32) resulting from
a preceding calculation.
If length1 or length2 fail to convert to u16 or exceed the maximum representable
range, this will return None.
Sourcepub const unsafe fn new_unchecked(
    level1: Level,
    length1: u16,
    level2: Level,
    length2: u16,
) -> Self
 
pub const unsafe fn new_unchecked( level1: Level, length1: u16, level2: Level, length2: u16, ) -> Self
Create a new instance without checking that code lengths are in range.
§Safety
length1 and length2 must be 15-bit wide, i.e. their MSB must be cleared.
Sourcepub const fn end_marker() -> Self
 
pub const fn end_marker() -> Self
Create a new instance that is an end marker with Level::Low.
This corresponds to the all-zero PulseCode, i.e. with both level and
length fields set to zero, equivalent to (but more semantic than)
PulseCode::from(0u32) and PulseCode::default().
Sourcepub fn reset(&mut self)
 
pub fn reset(&mut self)
Set all levels and lengths to 0.
In other words, assigns the value of PulseCode::end_marker() to self.
Sourcepub const fn with_level1(self, level: Level) -> Self
 
pub const fn with_level1(self, level: Level) -> Self
Set level1 and return the modified PulseCode.
Sourcepub const fn with_level2(self, level: Level) -> Self
 
pub const fn with_level2(self, level: Level) -> Self
Set level2 and return the modified PulseCode.
Sourcepub const fn with_length1(self, length: u16) -> Option<Self>
 
pub const fn with_length1(self, length: u16) -> Option<Self>
Set length1 and return the modified PulseCode.
Returns None if length exceeds the representable range.
Sourcepub const fn with_length2(self, length: u16) -> Option<Self>
 
pub const fn with_length2(self, length: u16) -> Option<Self>
Set length2 and return the modified PulseCode.
Returns None if length exceeds the representable range.
Sourcepub const fn is_end_marker(self) -> bool
 
pub const fn is_end_marker(self) -> bool
Return whether this pulse code contains an end marker.
Equivalent to self.length1() == 0 || self.length2() == 0.
Trait Implementations§
impl Copy for PulseCode
unstable only.impl Eq for PulseCode
unstable only.impl StructuralPartialEq for PulseCode
unstable only.Auto Trait Implementations§
impl Freeze for PulseCode
impl RefUnwindSafe for PulseCode
impl Send for PulseCode
impl Sync for PulseCode
impl Unpin for PulseCode
impl UnwindSafe for PulseCode
Blanket Implementations§
§impl<T> Any for Twhere
    T: 'static + ?Sized,
 
impl<T> Any for Twhere
    T: 'static + ?Sized,
§impl<T> Borrow<T> for Twhere
    T: ?Sized,
 
impl<T> Borrow<T> for Twhere
    T: ?Sized,
§impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
 
impl<T> BorrowMut<T> for Twhere
    T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
 
fn borrow_mut(&mut self) -> &mut T
§impl<T> CloneToUninit for Twhere
    T: Clone,
 
impl<T> CloneToUninit for Twhere
    T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
 
unsafe fn clone_to_uninit(&self, dest: *mut u8)
clone_to_uninit)