pub struct VarInt { /* private fields */ }
Implementations§
source§impl VarInt
impl VarInt
Represents a variable-length signed integer. See the VarUInt and VarInt Fields section of the binary Ion spec for more details.
sourcepub fn read<R: IonDataSource>(data_source: &mut R) -> IonResult<VarInt>
pub fn read<R: IonDataSource>(data_source: &mut R) -> IonResult<VarInt>
Reads a VarInt from the provided data source.
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>
Writes an i64
to sink
, returning 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 VarInt
and writes it to the provided sink
.
Returns the number of bytes written.
This method is similar to 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 VarInt is negative zero.
sourcepub fn value(&self) -> i64
pub fn value(&self) -> i64
Returns the value of the signed integer. If the VarInt is negative zero, this method
will return 0
. Use the is_negative_zero method to check for
negative zero explicitly.
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