Skip to main content

AmountType

Enum AmountType 

Source
pub enum AmountType {
    None,
    OneByteOne,
    Standard,
    Deferred,
    Other(u8),
}
Expand description

Classification of the amount-type byte in a line item.

Variants§

§

None

0x00 — placeholder. The four bytes are not a cents value.

§

OneByteOne

0x01[0x01][u24 LE cents] (provisional encoding).

§

Standard

0x02[0x02][u24 LE cents].

§

Deferred

0x03 — deferred. Encoding not yet known; only raw is populated.

§

Other(u8)

Any other byte — likely an anchor false-positive or unrecognised tag.

Implementations§

Source§

impl AmountType

Source

pub fn from_byte(b: u8) -> Self

Classify the leading amount-type byte.

Source

pub fn decode_cents(self, raw: &[u8; 4]) -> Option<u32>

Decode the 4 amount bytes into UNSIGNED integer cents (the raw u24 LE in raw[1..4]). Preserves the original Phase 5 transaction-volume baseline. Use AmountType::decode_cents_signed for the signed (high-bit-of-byte-1) interpretation discovered in C.48.

Source

pub fn decode_cents_signed(self, raw: &[u8; 4]) -> Option<i32>

Decode the 4 amount bytes into SIGNED integer cents under the high-bit-of-byte-1-is-sign convention (C.48 Track A). The magnitude is (raw[1] & 0x7F) | (raw[2] << 8) | (raw[3] << 16) and the sign is -1 if raw[1] & 0x80 != 0. Returns None for types other than 0x01 and 0x02 (type 0x03 is NOT a signed amount; its bytes store enumerated reference codes - see C.48).

Trait Implementations§

Source§

impl Clone for AmountType

Source§

fn clone(&self) -> AmountType

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 AmountType

Source§

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

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

impl Hash for AmountType

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for AmountType

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for AmountType

Source§

impl Eq for AmountType

Source§

impl StructuralPartialEq for AmountType

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> 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 = 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.