pub struct Block<T> { /* 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> Block<T>
impl<T: Deref<Target = Q>, Q> Block<T>
Sourcepub fn new(container: T, index: BlockIndex) -> Self
pub fn new(container: T, index: BlockIndex) -> Self
Creates a new block.
Source§impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T>
impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T>
Sourcepub fn index(&self) -> BlockIndex
pub fn index(&self) -> BlockIndex
Returns index of the block in the vmo.
Sourcepub fn header_magic(&self) -> Result<u32, Error>
pub fn header_magic(&self) -> Result<u32, Error>
Returns the magic number in a HEADER block.
Sourcepub fn header_version(&self) -> Result<u32, Error>
pub fn header_version(&self) -> Result<u32, Error>
Returns the version of a HEADER block.
Sourcepub fn header_generation_count(&self) -> Result<u64, Error>
pub fn header_generation_count(&self) -> Result<u64, Error>
Returns the generation count of a HEADER block.
Sourcepub fn header_vmo_size(&self) -> Result<Option<u32>, Error>
pub fn header_vmo_size(&self) -> Result<Option<u32>, Error>
Returns the size of the part of the VMO that is currently allocated. The size is saved in a field in the HEADER block.
Sourcepub fn header_is_locked(&self) -> Result<bool, Error>
pub fn header_is_locked(&self) -> Result<bool, Error>
True if the header is locked, false otherwise.
Sourcepub fn double_value(&self) -> Result<f64, Error>
pub fn double_value(&self) -> Result<f64, Error>
Gets the double value of a DOUBLE_VALUE block.
Sourcepub fn uint_value(&self) -> Result<u64, Error>
pub fn uint_value(&self) -> Result<u64, Error>
Gets the unsigned value of a UINT_VALUE block.
Sourcepub fn bool_value(&self) -> Result<bool, Error>
pub fn bool_value(&self) -> Result<bool, Error>
Gets the bool values of a BOOL_VALUE block.
Sourcepub fn property_extent_index(&self) -> Result<BlockIndex, Error>
pub fn property_extent_index(&self) -> Result<BlockIndex, Error>
Gets the index of the EXTENT of the PROPERTY block.
Sourcepub fn total_length(&self) -> Result<usize, Error>
pub fn total_length(&self) -> Result<usize, Error>
Gets the total length of a PROPERTY or STRING_REFERERENCE block.
Sourcepub fn property_format(&self) -> Result<PropertyFormat, Error>
pub fn property_format(&self) -> Result<PropertyFormat, Error>
Gets the flags of a PROPERTY block.
Sourcepub fn next_extent(&self) -> Result<BlockIndex, Error>
pub fn next_extent(&self) -> Result<BlockIndex, Error>
Returns the next EXTENT in an EXTENT chain.
Sourcepub fn extent_contents(&'a self) -> Result<&'a [u8], Error>
pub fn extent_contents(&'a self) -> Result<&'a [u8], Error>
Returns the payload bytes value of an EXTENT block.
Sourcepub fn name_index(&self) -> Result<BlockIndex, Error>
pub fn name_index(&self) -> Result<BlockIndex, Error>
Gets the NAME block index of a *_VALUE block.
Sourcepub fn array_format(&self) -> Result<ArrayFormat, Error>
pub fn array_format(&self) -> Result<ArrayFormat, Error>
Gets the format of an ARRAY_VALUE block.
Sourcepub fn array_slots(&self) -> Result<usize, Error>
pub fn array_slots(&self) -> Result<usize, Error>
Gets the number of slots in an ARRAY_VALUE block.
Sourcepub fn array_entry_type(&self) -> Result<BlockType, Error>
pub fn array_entry_type(&self) -> Result<BlockType, Error>
Gets the type of each slot in an ARRAY_VALUE block.
pub fn array_get_string_index_slot( &self, slot_index: usize, ) -> Result<BlockIndex, Error>
Sourcepub fn array_get_int_slot(&self, slot_index: usize) -> Result<i64, Error>
pub fn array_get_int_slot(&self, slot_index: usize) -> Result<i64, Error>
Gets the value of an int ARRAY_VALUE slot.
Sourcepub fn array_get_double_slot(&self, slot_index: usize) -> Result<f64, Error>
pub fn array_get_double_slot(&self, slot_index: usize) -> Result<f64, Error>
Gets the value of a double ARRAY_VALUE slot.
Sourcepub fn array_get_uint_slot(&self, slot_index: usize) -> Result<u64, Error>
pub fn array_get_uint_slot(&self, slot_index: usize) -> Result<u64, Error>
Gets the value of a uint ARRAY_VALUE slot.
Sourcepub fn link_content_index(&self) -> Result<BlockIndex, Error>
pub fn link_content_index(&self) -> Result<BlockIndex, Error>
Gets the index of the content of this LINK_VALUE block.
Sourcepub fn link_node_disposition(&self) -> Result<LinkNodeDisposition, Error>
pub fn link_node_disposition(&self) -> Result<LinkNodeDisposition, Error>
Gets the node disposition of a LINK_VALUE block.
Sourcepub fn parent_index(&self) -> Result<BlockIndex, Error>
pub fn parent_index(&self) -> Result<BlockIndex, Error>
Get the parent block index of a *_VALUE block.
Sourcepub fn child_count(&self) -> Result<u64, Error>
pub fn child_count(&self) -> Result<u64, Error>
Get the child count of a NODE_VALUE block.
Sourcepub fn free_next_index(&self) -> Result<BlockIndex, Error>
pub fn free_next_index(&self) -> Result<BlockIndex, Error>
Get next free block
Sourcepub fn name_length(&self) -> Result<usize, Error>
pub fn name_length(&self) -> Result<usize, Error>
Get the length of the name of a NAME block
Sourcepub fn name_contents(&'a self) -> Result<&'a str, Error>
pub fn name_contents(&'a self) -> Result<&'a str, Error>
Returns the contents of a NAME block.
Sourcepub fn string_reference_count(&self) -> Result<u32, Error>
pub fn string_reference_count(&self) -> Result<u32, Error>
Returns the current reference count of a string reference.
Sourcepub fn inline_string_reference(&'a self) -> Result<&'a [u8], Error>
pub fn inline_string_reference(&'a self) -> Result<&'a [u8], Error>
Read the inline portion of a STRING_REFERENCE
Sourcepub fn block_type(&self) -> BlockType
pub fn block_type(&self) -> BlockType
Returns the type of a block. Panics on an invalid value.
Sourcepub fn block_type_or(&self) -> Result<BlockType, Error>
pub fn block_type_or(&self) -> Result<BlockType, Error>
Returns the type of a block or an error if invalid.
Source§impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T>
impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T>
Sourcepub fn new_free(
container: T,
index: BlockIndex,
order: u8,
next_free: BlockIndex,
) -> Result<Block<T>, Error>
pub fn new_free( container: T, index: BlockIndex, order: u8, next_free: BlockIndex, ) -> Result<Block<T>, Error>
Initializes an empty free block.
Sourcepub fn set_header_magic(&mut self, value: u32) -> Result<(), Error>
pub fn set_header_magic(&mut self, value: u32) -> Result<(), Error>
Allows to set the magic value of the header. NOTE: this should only be used for testing.
Sourcepub fn set_header_vmo_size(&mut self, size: u32) -> Result<(), Error>
pub fn set_header_vmo_size(&mut self, size: u32) -> Result<(), Error>
Set the size of the part of the VMO that is currently allocated. The size is saved in a field in the HEADER block.
Sourcepub fn freeze_header(&mut self) -> Result<u64, Error>
pub fn freeze_header(&mut self) -> Result<u64, Error>
Freeze the HEADER, indicating a VMO is frozen.
Sourcepub fn thaw_header(&mut self, gen: u64) -> Result<(), Error>
pub fn thaw_header(&mut self, gen: u64) -> Result<(), Error>
Thaw the HEADER, indicating a VMO is Live again.
Sourcepub fn lock_header(&mut self) -> Result<(), Error>
pub fn lock_header(&mut self) -> Result<(), Error>
Lock a HEADER block
Sourcepub fn unlock_header(&mut self) -> Result<(), Error>
pub fn unlock_header(&mut self) -> Result<(), Error>
Unlock a HEADER block
Sourcepub fn become_tombstone(&mut self) -> Result<(), Error>
pub fn become_tombstone(&mut self) -> Result<(), Error>
Initializes a TOMBSTONE block.
Sourcepub fn become_reserved(&mut self) -> Result<(), Error>
pub fn become_reserved(&mut self) -> Result<(), Error>
Converts a FREE block to a RESERVED block
Sourcepub fn become_free(&mut self, next: BlockIndex)
pub fn become_free(&mut self, next: BlockIndex)
Converts a block to a FREE block
Sourcepub fn become_array_value(
&mut self,
slots: usize,
format: ArrayFormat,
entry_type: BlockType,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_array_value( &mut self, slots: usize, format: ArrayFormat, entry_type: BlockType, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Converts a block to an *_ARRAY_VALUE block
Sourcepub fn array_clear(&mut self, start_slot_index: usize) -> Result<(), Error>
pub fn array_clear(&mut self, start_slot_index: usize) -> Result<(), Error>
Sets all values of the array to zero starting on start_slot_index
(inclusive).
Sourcepub fn array_set_string_slot(
&mut self,
slot_index: usize,
string_index: BlockIndex,
) -> Result<(), Error>
pub fn array_set_string_slot( &mut self, slot_index: usize, string_index: BlockIndex, ) -> Result<(), Error>
Sets the value of a string ARRAY_VALUE block.
Sourcepub fn array_set_int_slot(
&mut self,
slot_index: usize,
value: i64,
) -> Result<(), Error>
pub fn array_set_int_slot( &mut self, slot_index: usize, value: i64, ) -> Result<(), Error>
Sets the value of an int ARRAY_VALUE block.
Sourcepub fn array_set_double_slot(
&mut self,
slot_index: usize,
value: f64,
) -> Result<(), Error>
pub fn array_set_double_slot( &mut self, slot_index: usize, value: f64, ) -> Result<(), Error>
Sets the value of a double ARRAY_VALUE block.
Sourcepub fn array_set_uint_slot(
&mut self,
slot_index: usize,
value: u64,
) -> Result<(), Error>
pub fn array_set_uint_slot( &mut self, slot_index: usize, value: u64, ) -> Result<(), Error>
Sets the value of a uint ARRAY_VALUE block.
Sourcepub fn become_extent(
&mut self,
next_extent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_extent( &mut self, next_extent_index: BlockIndex, ) -> Result<(), Error>
Converts a block to an EXTENT block.
Sourcepub fn set_extent_next_index(
&mut self,
next_extent_index: BlockIndex,
) -> Result<(), Error>
pub fn set_extent_next_index( &mut self, next_extent_index: BlockIndex, ) -> Result<(), Error>
Sets the index of the next EXTENT in the chain.
Sourcepub fn extent_set_contents(&mut self, value: &[u8]) -> Result<usize, Error>
pub fn extent_set_contents(&mut self, value: &[u8]) -> Result<usize, Error>
Set the payload of an EXTENT block. The number of bytes written will be returned.
Sourcepub fn become_double_value(
&mut self,
value: f64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_double_value( &mut self, value: f64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Converts a RESERVED block into a DOUBLE_VALUE block.
Sourcepub fn set_double_value(&mut self, value: f64) -> Result<(), Error>
pub fn set_double_value(&mut self, value: f64) -> Result<(), Error>
Sets the value of a DOUBLE_VALUE block.
Sourcepub fn become_int_value(
&mut self,
value: i64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_int_value( &mut self, value: i64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Converts a RESERVED block into a INT_VALUE block.
Sourcepub fn set_int_value(&mut self, value: i64) -> Result<(), Error>
pub fn set_int_value(&mut self, value: i64) -> Result<(), Error>
Sets the value of an INT_VALUE block.
Sourcepub fn become_uint_value(
&mut self,
value: u64,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_uint_value( &mut self, value: u64, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Converts a block into a UINT_VALUE block.
Sourcepub fn set_uint_value(&mut self, value: u64) -> Result<(), Error>
pub fn set_uint_value(&mut self, value: u64) -> Result<(), Error>
Sets the value of a UINT_VALUE block.
Sourcepub fn become_bool_value(
&mut self,
value: bool,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_bool_value( &mut self, value: bool, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Converts a block into a BOOL_VALUE block.
Sourcepub fn set_bool_value(&mut self, value: bool) -> Result<(), Error>
pub fn set_bool_value(&mut self, value: bool) -> Result<(), Error>
Sets the value of a BOOL_VALUE block.
Sourcepub fn become_node(
&mut self,
name_index: BlockIndex,
parent_index: BlockIndex,
) -> Result<(), Error>
pub fn become_node( &mut self, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>
Initializes a NODE_VALUE block.
Sourcepub fn become_property(
&mut self,
name_index: BlockIndex,
parent_index: BlockIndex,
format: PropertyFormat,
) -> Result<(), Error>
pub fn become_property( &mut self, name_index: BlockIndex, parent_index: BlockIndex, format: PropertyFormat, ) -> Result<(), Error>
Converts a *_VALUE block into a BUFFER_VALUE block.
Sourcepub fn become_string_reference(&mut self) -> Result<(), Error>
pub fn become_string_reference(&mut self) -> Result<(), Error>
Initializes a STRING_REFERENCE block. Everything is set except for the payload string and total length.
Sourcepub fn set_total_length(&mut self, length: u32) -> Result<(), Error>
pub fn set_total_length(&mut self, length: u32) -> Result<(), Error>
Sets the total length of a BUFFER_VALUE or STRING_REFERENCE block.
Sourcepub fn set_property_extent_index(
&mut self,
index: BlockIndex,
) -> Result<(), Error>
pub fn set_property_extent_index( &mut self, index: BlockIndex, ) -> Result<(), Error>
Sets the index of the EXTENT of a BUFFER_VALUE block.
Sourcepub fn set_child_count(&mut self, count: u64) -> Result<(), Error>
pub fn set_child_count(&mut self, count: u64) -> Result<(), Error>
Set the child count of a NODE_VALUE block.
Sourcepub fn increment_string_reference_count(&mut self) -> Result<(), Error>
pub fn increment_string_reference_count(&mut self) -> Result<(), Error>
Increment the reference count by 1.
Sourcepub fn decrement_string_reference_count(&mut self) -> Result<(), Error>
pub fn decrement_string_reference_count(&mut self) -> Result<(), Error>
Decrement the reference count by 1.
Sourcepub fn write_string_reference_inline(
&mut self,
value: &[u8],
) -> Result<usize, Error>
pub fn write_string_reference_inline( &mut self, value: &[u8], ) -> Result<usize, Error>
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.
Sourcepub fn set_free_next_index(
&mut self,
next_free: BlockIndex,
) -> Result<(), Error>
pub fn set_free_next_index( &mut self, next_free: BlockIndex, ) -> Result<(), Error>
Set the next free block.
Sourcepub fn become_link(
&mut self,
name_index: BlockIndex,
parent_index: BlockIndex,
content_index: BlockIndex,
disposition_flags: LinkNodeDisposition,
) -> Result<(), Error>
pub fn become_link( &mut self, name_index: BlockIndex, parent_index: BlockIndex, content_index: BlockIndex, disposition_flags: LinkNodeDisposition, ) -> Result<(), Error>
Creates a LINK block.
pub fn set_parent(&mut self, new_parent_index: BlockIndex) -> Result<(), Error>
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Block<T>where
T: Freeze,
impl<T> RefUnwindSafe for Block<T>where
T: RefUnwindSafe,
impl<T> Send for Block<T>where
T: Send,
impl<T> Sync for Block<T>where
T: Sync,
impl<T> Unpin for Block<T>where
T: Unpin,
impl<T> UnwindSafe for Block<T>where
T: 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,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)