Skip to main content

Fixed

Struct Fixed 

Source
pub struct Fixed<const P: u32, const S: u32> { /* private fields */ }
Expand description

IDL-fixed<P, S>-Decimal mit P Gesamt-Stellen und S Stellen nach dem Komma.

Storage als Packed-BCD-Bytes (XCDR2 §7.4.4.5). Pure-Rust ohne externe Crate-Dep. Bewusste Architektur-Wahl: dieser Type bietet Roundtrip + String-Konversion, keine Decimal-Arithmetik (Add/Mul). End-User die Decimal-Arithmetik brauchen, kombinieren das mit rust_decimal o.ae. via From-Impl.

Implementations§

Source§

impl<const P: u32, const S: u32> Fixed<P, S>

Source

pub fn from_bcd_bytes(bytes: Vec<u8>) -> Result<Self, DecodeError>

Konstruiert eine Fixed<P, S> aus einer Roh-BCD-Bytes-Sequenz.

§Errors

Invalid wenn die Bytes-Laenge nicht (P + 1) / 2 + 1 ist.

Source

pub fn as_bcd_bytes(&self) -> &[u8]

Roh-BCD-Bytes.

Source

pub fn from_str_repr(s: &str) -> Result<Self, DecodeError>

Erzeugt aus String (z.B. "123.45" oder "-1.5").

§Errors

Invalid bei nicht-numerischen Eingaben oder Overflow gegen P/S.

Source

pub fn to_string_repr(&self) -> String

Decimal-String-Repraesentation (z.B. "123.45").

Trait Implementations§

Source§

impl<const P: u32, const S: u32> CdrDecode for Fixed<P, S>

Source§

fn decode(r: &mut BufferReader<'_>) -> Result<Self, DecodeError>

Liest diesen Wert aus dem Reader (alignment-bewusst). Read more
Source§

impl<const P: u32, const S: u32> CdrEncode for Fixed<P, S>

Source§

fn encode(&self, w: &mut BufferWriter) -> Result<(), EncodeError>

Schreibt diesen Wert in den Writer (alignment-bewusst). Read more
Source§

impl<const P: u32, const S: u32> Clone for Fixed<P, S>

Source§

fn clone(&self) -> Fixed<P, S>

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<const P: u32, const S: u32> Debug for Fixed<P, S>

Source§

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

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

impl<const P: u32, const S: u32> Default for Fixed<P, S>

Source§

fn default() -> Self

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

impl<const P: u32, const S: u32> PartialEq for Fixed<P, S>

Source§

fn eq(&self, other: &Fixed<P, S>) -> 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<const P: u32, const S: u32> Eq for Fixed<P, S>

Source§

impl<const P: u32, const S: u32> StructuralPartialEq for Fixed<P, S>

Auto Trait Implementations§

§

impl<const P: u32, const S: u32> Freeze for Fixed<P, S>

§

impl<const P: u32, const S: u32> RefUnwindSafe for Fixed<P, S>

§

impl<const P: u32, const S: u32> Send for Fixed<P, S>

§

impl<const P: u32, const S: u32> Sync for Fixed<P, S>

§

impl<const P: u32, const S: u32> Unpin for Fixed<P, S>

§

impl<const P: u32, const S: u32> UnsafeUnpin for Fixed<P, S>

§

impl<const P: u32, const S: u32> UnwindSafe for Fixed<P, S>

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.