Struct inspect_format::Block
source · 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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)