Struct ion_rs::binary::int::DecodedInt

source ·
pub struct DecodedInt { /* private fields */ }
Expand description

Represents a fixed-length signed integer. See the UInt and Int Fields section of the binary Ion spec for more details.

Implementations§

source§

impl DecodedInt

source

pub fn read<R: IonDataSource>( data_source: &mut R, length: usize ) -> IonResult<DecodedInt>

Reads an Int with length bytes from the provided data source.

source

pub fn read_using_buffer<R: IonDataSource>( data_source: &mut R, length: usize, buffer: &mut [u8] ) -> IonResult<DecodedInt>

source

pub fn write_i64<W: Write>(sink: &mut W, value: i64) -> IonResult<usize>

Encodes the provided value as an Int and writes it to the provided sink. Returns the number of bytes written.

source

pub fn write_negative_zero<W: Write>(sink: &mut W) -> IonResult<usize>

Encodes a negative zero as an Int and writes it to the privided sink. Returns the number of bytes written.

This method is similar to Self::write_i64. However, because an i64 cannot represent a negative zero, a separate method is required.

source

pub fn is_negative_zero(&self) -> bool

Returns true if the Int is negative zero.

source

pub fn value(&self) -> &Int

Returns the value of the signed integer.

source

pub fn size_in_bytes(&self) -> usize

Returns the number of bytes that were read from the data source to construct this signed integer.

source

pub fn zero() -> Self

Constructs a DecodedInt that represents zero. This is useful when reading from a stream where a zero-length Int is found, meaning that it is implicitly positive zero.

Trait Implementations§

source§

impl Debug for DecodedInt

source§

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

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

impl From<DecodedInt> for Coefficient

source§

fn from(int: DecodedInt) -> Self

Converts to this type from the input type.
source§

impl From<DecodedInt> for Int

source§

fn from(uint: DecodedInt) -> Self

Note that if the DecodedInt represents -0, converting it to an Integer will result in a 0. If negative zero is significant to your use case, check it using DecodedInt::is_negative_zero before converting it to an Integer.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.