pub struct Block<T, Kind> { /* private fields */ }
Expand description
Points to an index in the VMO and reads it according to the bytes in it.
Implementations§
Source§impl<T: Deref<Target = Q>, Q: ReadBytes, K: BlockKind> Block<T, K>
impl<T: Deref<Target = Q>, Q: ReadBytes, K: BlockKind> Block<T, K>
Sourcepub fn index(&self) -> BlockIndex
pub fn index(&self) -> BlockIndex
Returns index of the block in the vmo.
Sourcepub fn block_type(&self) -> Option<BlockType>
pub fn block_type(&self) -> Option<BlockType>
Returns the type of a block.
Sourcepub fn block_type_raw(&self) -> u8
pub fn block_type_raw(&self) -> u8
Returns the type of a block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Unknown>>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<Unknown>>
pub fn cast_array<K: ArraySlotKind>(self) -> Option<Block<T, Array<K>>>
pub fn cast_array_unchecked<K: BlockKind>(self) -> Block<T, Array<K>>
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Header>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Header>
Sourcepub fn magic_number(&self) -> u32
pub fn magic_number(&self) -> u32
Returns the magic number in a HEADER block.
Sourcepub fn generation_count(&self) -> u64
pub fn generation_count(&self) -> u64
Returns the generation count of a HEADER block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Buffer>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Buffer>
Sourcepub fn extent_index(&self) -> BlockIndex
pub fn extent_index(&self) -> BlockIndex
Gets the index of the EXTENT of the PROPERTY block.
Sourcepub fn total_length(&self) -> usize
pub fn total_length(&self) -> usize
Gets the total length of a PROPERTY or STRING_REFERERENCE block.
Sourcepub fn format(&self) -> Option<PropertyFormat>
pub fn format(&self) -> Option<PropertyFormat>
Gets the flags of a PROPERTY block.
Sourcepub fn format_raw(&self) -> u8
pub fn format_raw(&self) -> u8
Gets the flags of a PROPERTY block.
Source§impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, StringRef>
impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, StringRef>
Sourcepub fn total_length(&self) -> usize
pub fn total_length(&self) -> usize
Gets the total length of a PROPERTY or STRING_REFERERENCE block.
Sourcepub fn next_extent(&self) -> BlockIndex
pub fn next_extent(&self) -> BlockIndex
Returns the next EXTENT in an EXTENT chain.
Sourcepub fn reference_count(&self) -> u32
pub fn reference_count(&self) -> u32
Returns the current reference count of a string reference.
Sourcepub fn inline_data(&'a self) -> Result<&'a [u8], Error>
pub fn inline_data(&'a self) -> Result<&'a [u8], Error>
Read the inline portion of a STRING_REFERENCE
Source§impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, Extent>
impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T, Extent>
Sourcepub fn next_extent(&self) -> BlockIndex
pub fn next_extent(&self) -> BlockIndex
Returns the next EXTENT in an EXTENT chain.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes, S: ArraySlotKind> Block<T, Array<S>>
impl<T: Deref<Target = Q>, Q: ReadBytes, S: ArraySlotKind> Block<T, Array<S>>
Sourcepub fn format(&self) -> Option<ArrayFormat>
pub fn format(&self) -> Option<ArrayFormat>
Gets the format of an ARRAY_VALUE block.
Sourcepub fn entry_type(&self) -> Option<BlockType>
pub fn entry_type(&self) -> Option<BlockType>
Gets the type of each slot in an ARRAY_VALUE block.
Sourcepub fn entry_type_raw(&self) -> u8
pub fn entry_type_raw(&self) -> u8
Gets the type of each slot in an ARRAY_VALUE block.
pub fn entry_type_size(&self) -> Option<usize>
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<StringRef>>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Array<StringRef>>
pub fn get_string_index_at(&self, slot_index: usize) -> Option<BlockIndex>
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Link>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Link>
Sourcepub fn content_index(&self) -> BlockIndex
pub fn content_index(&self) -> BlockIndex
Gets the index of the content of this LINK_VALUE block.
Sourcepub fn link_node_disposition(&self) -> Option<LinkNodeDisposition>
pub fn link_node_disposition(&self) -> Option<LinkNodeDisposition>
Gets the node disposition of a LINK_VALUE block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes, K: ValueBlockKind> Block<T, K>
impl<T: Deref<Target = Q>, Q: ReadBytes, K: ValueBlockKind> Block<T, K>
Sourcepub fn name_index(&self) -> BlockIndex
pub fn name_index(&self) -> BlockIndex
Gets the NAME block index of a *_VALUE block.
Sourcepub fn parent_index(&self) -> BlockIndex
pub fn parent_index(&self) -> BlockIndex
Get the parent block index of a *_VALUE block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Node>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Node>
Sourcepub fn child_count(&self) -> u64
pub fn child_count(&self) -> u64
Get the child count of a NODE_VALUE block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Tombstone>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Tombstone>
Sourcepub fn child_count(&self) -> u64
pub fn child_count(&self) -> u64
Get the child count of a TOMBSTONE block.
Source§impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Free>
impl<T: Deref<Target = Q>, Q: ReadBytes> Block<T, Free>
Sourcepub fn free_next_index(&self) -> BlockIndex
pub fn free_next_index(&self) -> BlockIndex
Get next free block
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>
Sourcepub fn become_free(self, next: BlockIndex) -> Block<T, Free>
pub fn become_free(self, next: BlockIndex) -> Block<T, Free>
Converts a block to a FREE block
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: BlockKind> Block<T, K>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Free>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Free>
Sourcepub fn free(
container: T,
index: BlockIndex,
order: u8,
next_free: BlockIndex,
) -> Result<Block<T, Free>, Error>
pub fn free( container: T, index: BlockIndex, order: u8, next_free: BlockIndex, ) -> Result<Block<T, Free>, Error>
Initializes an empty free block.
Sourcepub fn become_reserved(self) -> Block<T, Reserved>
pub fn become_reserved(self) -> Block<T, Reserved>
Converts a FREE block to a RESERVED block
Sourcepub fn set_free_next_index(&mut self, next_free: BlockIndex)
pub fn set_free_next_index(&mut self, next_free: BlockIndex)
Set the next free block.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Reserved>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Reserved>
Sourcepub fn become_header(self, size: usize) -> Result<Block<T, Header>, Error>
pub fn become_header(self, size: usize) -> Result<Block<T, Header>, Error>
Initializes a HEADER block.
Sourcepub fn become_extent(self, next_extent_index: BlockIndex) -> Block<T, Extent>
pub fn become_extent(self, next_extent_index: BlockIndex) -> Block<T, Extent>
Converts a block to an EXTENT block.
Sourcepub fn become_double_value(
self,
value: f64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Block<T, Double>
pub fn become_double_value( self, value: f64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Double>
Converts a RESERVED block into a DOUBLE_VALUE block.
Sourcepub fn become_int_value(
self,
value: i64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Block<T, Int>
pub fn become_int_value( self, value: i64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Int>
Converts a RESERVED block into an INT_VALUE block.
Sourcepub fn become_uint_value(
self,
value: u64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Block<T, Uint>
pub fn become_uint_value( self, value: u64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Uint>
Converts a RESERVED block into a UINT_VALUE block.
Sourcepub fn become_bool_value(
self,
value: bool,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Block<T, Bool>
pub fn become_bool_value( self, value: bool, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Bool>
Converts a RESERVED block into a BOOL_VALUE block.
Sourcepub fn become_node(
self,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Block<T, Node>
pub fn become_node( self, name_index: BlockIndex, parent_index: BlockIndex, ) -> Block<T, Node>
Initializes a NODE_VALUE block.
Sourcepub fn become_property(
self,
name_index: BlockIndex,
parent_index: BlockIndex,
format: PropertyFormat,
) -> Block<T, Buffer>
pub fn become_property( self, name_index: BlockIndex, parent_index: BlockIndex, format: PropertyFormat, ) -> Block<T, Buffer>
Converts a *_VALUE block into a BUFFER_VALUE block.
Sourcepub fn become_string_reference(self) -> Block<T, StringRef>
pub fn become_string_reference(self) -> Block<T, StringRef>
Initializes a STRING_REFERENCE block. Everything is set except for the payload string and total length.
Sourcepub fn become_name(self, name: &str) -> Block<T, Name>
pub fn become_name(self, name: &str) -> Block<T, Name>
Creates a NAME block.
Sourcepub fn become_link(
self,
name_index: BlockIndex,
parent_index: BlockIndex,
content_index: BlockIndex,
disposition_flags: LinkNodeDisposition,
) -> Block<T, Link>
pub fn become_link( self, name_index: BlockIndex, parent_index: BlockIndex, content_index: BlockIndex, disposition_flags: LinkNodeDisposition, ) -> Block<T, Link>
Creates a LINK block.
Sourcepub fn become_array_value<S: ArraySlotKind>(
self,
slots: usize,
format: ArrayFormat,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<Block<T, Array<S>>, Error>
pub fn become_array_value<S: ArraySlotKind>( self, slots: usize, format: ArrayFormat, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<Block<T, Array<S>>, Error>
Converts a block to an *_ARRAY_VALUE block
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Header>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Header>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Node>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Node>
Sourcepub fn become_tombstone(self) -> Block<T, Tombstone>
pub fn become_tombstone(self) -> Block<T, Tombstone>
Initializes a TOMBSTONE block.
Sourcepub fn set_child_count(&mut self, count: u64)
pub fn set_child_count(&mut self, count: u64)
Set the child count of a NODE_VALUE block.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, S: ArraySlotKind> Block<T, Array<S>>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, S: ArraySlotKind> Block<T, Array<S>>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<StringRef>>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<StringRef>>
Sourcepub fn set_string_slot(&mut self, slot_index: usize, string_index: BlockIndex)
pub fn set_string_slot(&mut self, slot_index: usize, string_index: BlockIndex)
Sets the value of a string ARRAY_VALUE block.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Int>>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Int>>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Double>>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Double>>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Uint>>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Array<Uint>>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Extent>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Extent>
Sourcepub fn set_next_index(&mut self, next_extent_index: BlockIndex)
pub fn set_next_index(&mut self, next_extent_index: BlockIndex)
Sets the index of the next EXTENT in the chain.
Sourcepub fn set_contents(&mut self, value: &[u8]) -> usize
pub fn set_contents(&mut self, value: &[u8]) -> usize
Set the payload of an EXTENT block. The number of bytes written will be returned.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, StringRef>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, StringRef>
Sourcepub fn set_next_index(&mut self, next_extent_index: BlockIndex)
pub fn set_next_index(&mut self, next_extent_index: BlockIndex)
Sets the index of the next EXTENT in the chain.
Sourcepub fn set_total_length(&mut self, length: u32)
pub fn set_total_length(&mut self, length: u32)
Sets the total length of a BUFFER_VALUE or STRING_REFERENCE block.
Sourcepub fn increment_ref_count(&mut self) -> Result<(), Error>
pub fn increment_ref_count(&mut self) -> Result<(), Error>
Increment the reference count by 1.
Sourcepub fn decrement_ref_count(&mut self) -> Result<(), Error>
pub fn decrement_ref_count(&mut self) -> Result<(), Error>
Decrement the reference count by 1.
Sourcepub fn write_inline(&mut self, value: &[u8]) -> usize
pub fn write_inline(&mut self, value: &[u8]) -> usize
Write the portion of the string that fits into the STRING_REFERENCE block, as well as write the total length of value to the block. Returns the number of bytes written.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Double>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Double>
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Buffer>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Buffer>
Sourcepub fn set_total_length(&mut self, length: u32)
pub fn set_total_length(&mut self, length: u32)
Sets the total length of a BUFFER_VALUE block.
Sourcepub fn set_extent_index(&mut self, index: BlockIndex)
pub fn set_extent_index(&mut self, index: BlockIndex)
Sets the index of the EXTENT of a BUFFER_VALUE block.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Tombstone>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T, Tombstone>
Sourcepub fn set_child_count(&mut self, count: u64)
pub fn set_child_count(&mut self, count: u64)
Set the child count of a NODE_VALUE block.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: ValueBlockKind> Block<T, K>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes, K: ValueBlockKind> Block<T, K>
pub fn set_parent(&mut self, new_parent_index: BlockIndex)
Trait Implementations§
Auto Trait Implementations§
impl<T, Kind> Freeze for Block<T, Kind>where
T: Freeze,
impl<T, Kind> RefUnwindSafe for Block<T, Kind>where
T: RefUnwindSafe,
Kind: RefUnwindSafe,
impl<T, Kind> Send for Block<T, Kind>
impl<T, Kind> Sync for Block<T, Kind>
impl<T, Kind> Unpin for Block<T, Kind>
impl<T, Kind> UnwindSafe for Block<T, Kind>where
T: UnwindSafe,
Kind: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more