pub fn write_i64(&mut self, value: i64) -> IonResult<()> {
        self.write_scalar(|enc_buffer| {
            let is_positive: bool = value >= 0;
            let magnitude: u64 = value.abs() as u64;

            // We can divide the number of leading zero bits by 8
            // to to get the number of leading zero bytes.
            let empty_leading_bytes: u32 = magnitude.leading_zeros() >> 3;
            let first_occupied_byte = empty_leading_bytes as usize;

            let magnitude_bytes: [u8; mem::size_of::<u64>()] = magnitude.to_be_bytes();
            let bytes_to_write: &[u8] = &magnitude_bytes[first_occupied_byte..];

            let encoded_length = bytes_to_write.len();

            // The encoded length will never be larger than 8 bytes, so it will always fit in
            // the Int's type descriptor byte.

            let type_descriptor: u8 = if is_positive {
                0x20 | (encoded_length as u8)
            } else {
                0x30 | (encoded_length as u8)
            };
            enc_buffer.push(type_descriptor);
            enc_buffer.extend_from_slice(bytes_to_write);
            Ok(())
        })
    }
/// Writes an Ion integer with the specified value.
Writes an Ion integer with the specified value.
Writes an Ion integer with the specified value .
pub fn write_i64(&mut self, value: i64) -> IonResult<()> {
        self.write_scalar(|enc_buffer| {
            let is_positive: bool = value >= 0;
            let magnitude: u64 = value.abs() as u64;
            // We can divide the number of leading zero bits by 8
            // to to get the number of leading zero bytes.
            let empty_leading_bytes: u32 = magnitude.leading_zeros() >> 3;
            let first_occupied_byte = empty_leading_bytes as usize;
            let magnitude_bytes: [u8; mem::size_of::<u64>()] = magnitude.to_be_bytes();
            let bytes_to_write: &[u8] = &magnitude_bytes[first_occupied_byte..];
            let encoded_length = bytes_to_write.len();
            // The encoded length will never be larger than 8 bytes, so it will always fit in
            // the Int's type descriptor byte.
            let type_descriptor: u8 = if is_positive {
                0x20 | (encoded_length as u8)
            } else {
                0x30 | (encoded_length as u8)
            };
            enc_buffer.push(type_descriptor);
            enc_buffer.extend_from_slice(bytes_to_write);
            Ok(())
        })
    }
pub fn write_i64 ( & mut self , value : i64 ) -> IonResult < ( ) > { self . write_scalar ( | enc_buffer | { let is_positive : bool = value >= 0 ; let magnitude : u64 = value . abs ( ) as u64 ; // We can divide the number of leading zero bits by 8 // to to get the number of leading zero bytes. let empty_leading_bytes : u32 = magnitude . leading_zeros ( ) >> 3 ; let first_occupied_byte = empty_leading_bytes as usize ; let magnitude_bytes : [ u8 ; mem :: size_of :: < u64 > ( ) ] = magnitude . to_be_bytes ( ) ; let bytes_to_write : & [ u8 ] = & magnitude_bytes [ first_occupied_byte .. ] ; let encoded_length = bytes_to_write . len ( ) ; // The encoded length will never be larger than 8 bytes, so it will always fit in // the Int's type descriptor byte. let type_descriptor : u8 = if is_positive { 0x20 | ( encoded_length as u8 ) } else { 0x30 | ( encoded_length as u8 ) } ; enc_buffer . push ( type_descriptor ) ; enc_buffer . extend_from_slice ( bytes_to_write ) ; Ok ( ( ) ) } ) }
Writes an Ion integer with the specified value.
Writes an Ion integer with the specified value .
&mut self
value
i64
&mut self
value
i64