Struct noodles::bgzf::VirtualPosition [−][src]
pub struct VirtualPosition(_);
Expand description
A BGZF virtual position.
A virtual position is a 64-bit unsigned integer representing both the position in the compressed stream and position in the uncompressed block data. The compressed position is typically at the start of a block.
The compressed position is the first six most significant bytes; and the uncompressed position, the last two least significant bytes. For example, for the virtual position 10253313912875616487:
compressed position
| |
10253313912875616487 = 8e 4b 16 ad eb 85 88 e7
| |
uncompressed position
The compressed position is at 156453154188165 (8e 4b 16 ad eb 85
), and the uncompressed
position, 35047 (88 e7
).
This is also called a virtual file offset; or, simply, a virtual offset.
Implementations
Creates the largest value that can be represented as a virtual position.
Examples
use noodles_bgzf as bgzf;
let virtual_position = bgzf::VirtualPosition::max();
assert_eq!(u64::from(virtual_position), u64::MAX);
The position in the compressed BGZF stream.
This is typically at the start of a block.
The maximum value of a compressed position is 281474976710655 (2^48 - 1).
Examples
use noodles_bgzf as bgzf;
let virtual_position = bgzf::VirtualPosition::from(3741638);
assert_eq!(virtual_position.compressed(), 57);
The position in the uncompressed block data.
The maximum value of an uncompressed position is 65535 (2^16 - 1).
Examples
use noodles_bgzf as bgzf;
let virtual_position = bgzf::VirtualPosition::from(3741638);
assert_eq!(virtual_position.uncompressed(), 6086);
Trait Implementations
Returns the “default value” for a type. Read more
Performs the conversion.
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
This method tests for !=
.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
Converts a (compressed position, uncompressed position)
tuple to a virtual position.
Examples
use std::convert::TryFrom;
use noodles_bgzf as bgzf;
let virtual_position = bgzf::VirtualPosition::try_from((57, 6086));
assert_eq!(virtual_position, Ok(bgzf::VirtualPosition::from(3741638)));
type Error = TryFromU64U16TupleError
type Error = TryFromU64U16TupleError
The type returned in the event of a conversion error.
Auto Trait Implementations
impl RefUnwindSafe for VirtualPosition
impl Send for VirtualPosition
impl Sync for VirtualPosition
impl Unpin for VirtualPosition
impl UnwindSafe for VirtualPosition
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.