Struct noodles_bgzf::virtual_position::VirtualPosition
source · [−]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
sourceimpl VirtualPosition
impl VirtualPosition
sourcepub fn max() -> Self
pub fn max() -> Self
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);
sourcepub fn compressed(self) -> u64
pub fn compressed(self) -> u64
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);
sourcepub fn uncompressed(self) -> u16
pub fn uncompressed(self) -> u16
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
sourceimpl Clone for VirtualPosition
impl Clone for VirtualPosition
sourcefn clone(&self) -> VirtualPosition
fn clone(&self) -> VirtualPosition
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for VirtualPosition
impl Debug for VirtualPosition
sourceimpl Default for VirtualPosition
impl Default for VirtualPosition
sourcefn default() -> VirtualPosition
fn default() -> VirtualPosition
Returns the “default value” for a type. Read more
sourceimpl From<VirtualPosition> for u64
impl From<VirtualPosition> for u64
sourcefn from(pos: VirtualPosition) -> Self
fn from(pos: VirtualPosition) -> Self
Converts to this type from the input type.
sourceimpl From<VirtualPosition> for (u64, u16)
impl From<VirtualPosition> for (u64, u16)
sourcefn from(pos: VirtualPosition) -> Self
fn from(pos: VirtualPosition) -> Self
Converts to this type from the input type.
sourceimpl From<u64> for VirtualPosition
impl From<u64> for VirtualPosition
sourceimpl Ord for VirtualPosition
impl Ord for VirtualPosition
sourceimpl PartialEq<VirtualPosition> for VirtualPosition
impl PartialEq<VirtualPosition> for VirtualPosition
sourcefn eq(&self, other: &VirtualPosition) -> bool
fn eq(&self, other: &VirtualPosition) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &VirtualPosition) -> bool
fn ne(&self, other: &VirtualPosition) -> bool
This method tests for !=
.
sourceimpl PartialOrd<VirtualPosition> for VirtualPosition
impl PartialOrd<VirtualPosition> for VirtualPosition
sourcefn partial_cmp(&self, other: &VirtualPosition) -> Option<Ordering>
fn partial_cmp(&self, other: &VirtualPosition) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl TryFrom<(u64, u16)> for VirtualPosition
impl TryFrom<(u64, u16)> for VirtualPosition
sourcefn try_from(pos: (u64, u16)) -> Result<Self, Self::Error>
fn try_from(pos: (u64, u16)) -> Result<Self, Self::Error>
Converts a (compressed position, uncompressed position)
tuple to a virtual position.
Examples
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.
impl Copy for VirtualPosition
impl Eq for VirtualPosition
impl StructuralEq for VirtualPosition
impl StructuralPartialEq for VirtualPosition
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more