[−][src]Struct bigbit::linkedbytes::LinkedByte
An element in a series of Linked Bytes.
Implementations
impl LinkedByte
[src]
pub const LINK_MASK: u8
[src]
The link bit mask.
Use is_linked
to easily check for this.
pub const VALUE_MASK: u8
[src]
The value bit mask.
Use value
to easily check for this.
pub const ZERO_END: Self
[src]
The zero value as an endpoint (no follow-up bytes expected).
pub const ZERO_LINK: Self
[src]
The zero value as a linked byte (one or more follow-up bytes expected).
pub const MIN: u8
[src]
The smallest value representable, as a u8
.
Alias for ZERO_END
.
pub const MAX: u8
[src]
The largest value representable, as a u8
.
The value is 127
, since the individual Linked Bytes are 7-bit, plus the link/end flag.
pub const fn is_linked(self) -> bool
[src]
Returns true
if the byte is linked to a following byte, false
otherwise.
The opposite of is_end
.
pub const fn is_end(self) -> bool
[src]
Returns true
if the byte is not linked to a following byte (i.e. is an endpoint), false
otherwise.
The opposite of is_linked
.
pub const fn value(self) -> u8
[src]
Returns the value of the linked byte, in the range from 0 to 127, inclusively.
The main use for this is performing arithmetic with linked bytes.
#[must_use = "this is not an in-place operation"]pub const fn into_linked(self) -> Self
[src]
Sets the link bit to true
(linked state).
pub fn make_linked(&mut self)
[src]
Converts self
into the linked state in place.
#[must_use = "this is not an in-place operation"]pub const fn into_end(self) -> Self
[src]
Sets the link bit to false
(endpoint state).
pub fn make_end(&mut self)
[src]
Converts self
into the linked state in place.
#[must_use = "this is not an in-place operation"]pub fn checked_add(self, rhs: Self) -> Option<Self>
[src]
Performs checked addition. None
is returned if the result overflows the limit of 127.
#[must_use = "this is not an in-place operation"]pub fn add_with_carry(self, rhs: Self) -> (Self, bool)
[src]
Performs checked wrapping addition. Unlike checked_add
, this method returns a tuple, in which the first value is the result, which wraps over if the result overflows the limit of 127, and the second value is whether the overflow actually occurred.
#[must_use = "this is not an in-place operation"]pub fn checked_sub(self, rhs: Self) -> Option<Self>
[src]
Performs checked subtraction. None
is returned if the result underflows the limit of 0.
#[must_use = "this is not an in-place operation"]pub fn sub_with_borrow(self, rhs: Self) -> (Self, bool)
[src]
Performs checked wrapping subtraction. Unlike checked_sub
, this method returns a tuple, in which the first value is the result, which wraps over if the result underflows the limit of 0, and the second value is whether the overflow actually occurred.
pub const fn into_inner(self) -> u8
[src]
Consumes the value and unwraps it into its inner u8
, retaining the link bit if it's set.
Use into_int7
if you need only the value without the link bit, which is usually the case.
pub const fn into_int7(self) -> u8
[src]
Consumes the value and unwraps it into its inner 7-bit integer, i.e. dropping the link bit if it's set.
Use into_inner
if you need the unmodified value with the link bit unmodified.
Trait Implementations
impl Clone for LinkedByte
[src]
fn clone(&self) -> LinkedByte
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl Copy for LinkedByte
[src]
impl Debug for LinkedByte
[src]
impl Eq for LinkedByte
[src]
impl From<(u8, bool)> for LinkedByte
[src]
fn from(op: (u8, bool)) -> Self
[src]
Constructs either a linked or an endpoint byte depending on the second argument.
The most significant bit is silently dropped.
impl From<LinkedByte> for u8
[src]
fn from(op: LinkedByte) -> Self
[src]
Consumes the byte and unwraps it into its inner u8
, retaining the link bit if it's set.
impl From<u8> for LinkedByte
[src]
fn from(op: u8) -> Self
[src]
Constructs an endpoint byte from a u8
.
The most significant bit is silently dropped. Use into_linked
to convert the result into a linked byte if you actually want to initialize it like that.
impl FromIterator<LinkedByte> for LBNum
[src]
fn from_iter<T: IntoIterator<Item = LinkedByte>>(op: T) -> Self
[src]
Converts an iterator over linked bytes into an LBNum. Little-endian byte order is assumed, regardless of platform.
If any of the bytes except for the last one are endpoints (most significant bit cleared), they are converted into linked (most significant bit set), and if the last byte is linked, it's converted into and endpoint.
If possible, use TryFrom
or from_sequence
instead.
impl FromIterator<LinkedByte> for LBSequence
[src]
#[must_use]fn from_iter<T: IntoIterator<Item = LinkedByte>>(op: T) -> Self
[src]
Converts an iterator over linked bytes into an LBSequence
. Little-endian byte order is assumed, regardless of platform.
impl Ord for LinkedByte
[src]
fn cmp(&self, other: &Self) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl PartialEq<LinkedByte> for LinkedByte
[src]
fn eq(&self, other: &LinkedByte) -> bool
[src]
fn ne(&self, other: &LinkedByte) -> bool
[src]
impl PartialOrd<LinkedByte> for LinkedByte
[src]
fn partial_cmp(&self, other: &Self) -> Option<Ordering>
[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn gt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn ge(&self, other: &Rhs) -> bool
1.0.0[src]
impl StructuralEq for LinkedByte
[src]
impl StructuralPartialEq for LinkedByte
[src]
Auto Trait Implementations
impl RefUnwindSafe for LinkedByte
impl Send for LinkedByte
impl Sync for LinkedByte
impl Unpin for LinkedByte
impl UnwindSafe for LinkedByte
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,