inspect_format

Struct 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>

Source

pub fn new(container: T, index: BlockIndex) -> Self

Creates a new block.

Source§

impl<'a, T: Deref<Target = Q>, Q: ReadBytes + 'a> Block<T>

Source

pub fn index(&self) -> BlockIndex

Returns index of the block in the vmo.

Source

pub fn order(&self) -> u8

Returns the order of the block.

Source

pub fn header_magic(&self) -> Result<u32, Error>

Returns the magic number in a HEADER block.

Source

pub fn header_version(&self) -> Result<u32, Error>

Returns the version of a HEADER block.

Source

pub fn header_generation_count(&self) -> Result<u64, Error>

Returns the generation count of a HEADER block.

Source

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.

Source

pub fn header_is_locked(&self) -> Result<bool, Error>

True if the header is locked, false otherwise.

Source

pub fn double_value(&self) -> Result<f64, Error>

Gets the double value of a DOUBLE_VALUE block.

Source

pub fn int_value(&self) -> Result<i64, Error>

Gets the value of an INT_VALUE block.

Source

pub fn uint_value(&self) -> Result<u64, Error>

Gets the unsigned value of a UINT_VALUE block.

Source

pub fn bool_value(&self) -> Result<bool, Error>

Gets the bool values of a BOOL_VALUE block.

Source

pub fn property_extent_index(&self) -> Result<BlockIndex, Error>

Gets the index of the EXTENT of the PROPERTY block.

Source

pub fn total_length(&self) -> Result<usize, Error>

Gets the total length of a PROPERTY or STRING_REFERERENCE block.

Source

pub fn property_format(&self) -> Result<PropertyFormat, Error>

Gets the flags of a PROPERTY block.

Source

pub fn next_extent(&self) -> Result<BlockIndex, Error>

Returns the next EXTENT in an EXTENT chain.

Source

pub fn extent_contents(&'a self) -> Result<&'a [u8], Error>

Returns the payload bytes value of an EXTENT block.

Source

pub fn name_index(&self) -> Result<BlockIndex, Error>

Gets the NAME block index of a *_VALUE block.

Source

pub fn array_format(&self) -> Result<ArrayFormat, Error>

Gets the format of an ARRAY_VALUE block.

Source

pub fn array_slots(&self) -> Result<usize, Error>

Gets the number of slots in an ARRAY_VALUE block.

Source

pub fn array_entry_type(&self) -> Result<BlockType, Error>

Gets the type of each slot in an ARRAY_VALUE block.

Source

pub fn array_get_string_index_slot( &self, slot_index: usize, ) -> Result<BlockIndex, Error>

Source

pub fn array_get_int_slot(&self, slot_index: usize) -> Result<i64, Error>

Gets the value of an int ARRAY_VALUE slot.

Source

pub fn array_get_double_slot(&self, slot_index: usize) -> Result<f64, Error>

Gets the value of a double ARRAY_VALUE slot.

Source

pub fn array_get_uint_slot(&self, slot_index: usize) -> Result<u64, Error>

Gets the value of a uint ARRAY_VALUE slot.

Gets the index of the content of this LINK_VALUE block.

Gets the node disposition of a LINK_VALUE block.

Source

pub fn parent_index(&self) -> Result<BlockIndex, Error>

Get the parent block index of a *_VALUE block.

Source

pub fn child_count(&self) -> Result<u64, Error>

Get the child count of a NODE_VALUE block.

Source

pub fn free_next_index(&self) -> Result<BlockIndex, Error>

Get next free block

Source

pub fn name_length(&self) -> Result<usize, Error>

Get the length of the name of a NAME block

Source

pub fn name_contents(&'a self) -> Result<&'a str, Error>

Returns the contents of a NAME block.

Source

pub fn string_reference_count(&self) -> Result<u32, Error>

Returns the current reference count of a string reference.

Source

pub fn inline_string_reference(&'a self) -> Result<&'a [u8], Error>

Read the inline portion of a STRING_REFERENCE

Source

pub fn block_type(&self) -> BlockType

Returns the type of a block. Panics on an invalid value.

Source

pub fn block_type_or(&self) -> Result<BlockType, Error>

Returns the type of a block or an error if invalid.

Source

pub fn check_locked(&self, value: bool) -> Result<(), Error>

Check if the HEADER block is locked (when generation count is odd). NOTE: this should only be used for testing.

Source§

impl<T: Deref<Target = Q> + DerefMut<Target = Q>, Q: WriteBytes + ReadBytes> Block<T>

Source

pub fn new_free( container: T, index: BlockIndex, order: u8, next_free: BlockIndex, ) -> Result<Block<T>, Error>

Initializes an empty free block.

Source

pub fn set_order(&mut self, order: u8) -> Result<(), Error>

Set the order of the block.

Source

pub fn become_header(&mut self, size: usize) -> Result<(), Error>

Initializes a HEADER block.

Source

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.

Source

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.

Source

pub fn freeze_header(&mut self) -> Result<u64, Error>

Freeze the HEADER, indicating a VMO is frozen.

Source

pub fn thaw_header(&mut self, gen: u64) -> Result<(), Error>

Thaw the HEADER, indicating a VMO is Live again.

Source

pub fn lock_header(&mut self) -> Result<(), Error>

Lock a HEADER block

Source

pub fn unlock_header(&mut self) -> Result<(), Error>

Unlock a HEADER block

Source

pub fn become_tombstone(&mut self) -> Result<(), Error>

Initializes a TOMBSTONE block.

Source

pub fn become_reserved(&mut self) -> Result<(), Error>

Converts a FREE block to a RESERVED block

Source

pub fn become_free(&mut self, next: BlockIndex)

Converts a block to a FREE block

Source

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

Source

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).

Source

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.

Source

pub fn array_set_int_slot( &mut self, slot_index: usize, value: i64, ) -> Result<(), Error>

Sets the value of an int ARRAY_VALUE block.

Source

pub fn array_set_double_slot( &mut self, slot_index: usize, value: f64, ) -> Result<(), Error>

Sets the value of a double ARRAY_VALUE block.

Source

pub fn array_set_uint_slot( &mut self, slot_index: usize, value: u64, ) -> Result<(), Error>

Sets the value of a uint ARRAY_VALUE block.

Source

pub fn become_extent( &mut self, next_extent_index: BlockIndex, ) -> Result<(), Error>

Converts a block to an EXTENT block.

Source

pub fn set_extent_next_index( &mut self, next_extent_index: BlockIndex, ) -> Result<(), Error>

Sets the index of the next EXTENT in the chain.

Source

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.

Source

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.

Source

pub fn set_double_value(&mut self, value: f64) -> Result<(), Error>

Sets the value of a DOUBLE_VALUE block.

Source

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.

Source

pub fn set_int_value(&mut self, value: i64) -> Result<(), Error>

Sets the value of an INT_VALUE block.

Source

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.

Source

pub fn set_uint_value(&mut self, value: u64) -> Result<(), Error>

Sets the value of a UINT_VALUE block.

Source

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.

Source

pub fn set_bool_value(&mut self, value: bool) -> Result<(), Error>

Sets the value of a BOOL_VALUE block.

Source

pub fn become_node( &mut self, name_index: BlockIndex, parent_index: BlockIndex, ) -> Result<(), Error>

Initializes a NODE_VALUE block.

Source

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.

Source

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.

Source

pub fn set_total_length(&mut self, length: u32) -> Result<(), Error>

Sets the total length of a BUFFER_VALUE or STRING_REFERENCE block.

Source

pub fn set_property_extent_index( &mut self, index: BlockIndex, ) -> Result<(), Error>

Sets the index of the EXTENT of a BUFFER_VALUE block.

Source

pub fn set_child_count(&mut self, count: u64) -> Result<(), Error>

Set the child count of a NODE_VALUE block.

Source

pub fn increment_string_reference_count(&mut self) -> Result<(), Error>

Increment the reference count by 1.

Source

pub fn decrement_string_reference_count(&mut self) -> Result<(), Error>

Decrement the reference count by 1.

Source

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.

Source

pub fn become_name(&mut self, name: &str) -> Result<(), Error>

Creates a NAME block.

Source

pub fn set_free_next_index( &mut self, next_free: BlockIndex, ) -> Result<(), Error>

Set the next free block.

Creates a LINK block.

Source

pub fn set_parent(&mut self, new_parent_index: BlockIndex) -> Result<(), Error>

Trait Implementations§

Source§

impl<T: Clone> Clone for Block<T>

Source§

fn clone(&self) -> Block<T>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for Block<T>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<T, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more