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
impl DecodedInt
sourcepub fn read<R: IonDataSource>(
data_source: &mut R,
length: usize
) -> IonResult<DecodedInt>
pub fn read<R: IonDataSource>( data_source: &mut R, length: usize ) -> IonResult<DecodedInt>
Reads an Int with length
bytes from the provided data source.
pub fn read_using_buffer<R: IonDataSource>( data_source: &mut R, length: usize, buffer: &mut [u8] ) -> IonResult<DecodedInt>
sourcepub fn write_i64<W: Write>(sink: &mut W, value: i64) -> IonResult<usize>
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.
sourcepub fn write_negative_zero<W: Write>(sink: &mut W) -> IonResult<usize>
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.
sourcepub fn is_negative_zero(&self) -> bool
pub fn is_negative_zero(&self) -> bool
Returns true
if the Int is negative zero.
sourcepub fn size_in_bytes(&self) -> usize
pub fn size_in_bytes(&self) -> usize
Returns the number of bytes that were read from the data source to construct this signed integer.
Trait Implementations§
source§impl Debug for DecodedInt
impl Debug for DecodedInt
source§impl From<DecodedInt> for Coefficient
impl From<DecodedInt> for Coefficient
source§fn from(int: DecodedInt) -> Self
fn from(int: DecodedInt) -> Self
source§impl From<DecodedInt> for Int
impl From<DecodedInt> for Int
source§fn from(uint: DecodedInt) -> Self
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.