pub trait Table: Sized {
type InternalEntry: TableEntry;
type Entry: Copy;
const NAME: &'static str;
const MAX_ENTRIES: usize;
Show 17 methods
// Required methods
fn from_data(data: Box<[Self::InternalEntry]>, header: &Header) -> Self;
fn entries(&self) -> usize;
fn get_ref(&self, index: usize) -> Option<&Self::InternalEntry>;
fn get(&self, index: usize) -> Self::Entry;
fn get_cluster(&self) -> Option<HostCluster>;
fn get_offset(&self) -> Option<HostOffset>;
fn set_cluster(&mut self, cluster: HostCluster);
fn unset_cluster(&mut self);
fn cluster_bits(&self) -> u32;
fn is_modified(&self) -> bool;
fn clear_modified(&self);
fn set_modified(&self);
// Provided methods
fn byte_size(&self) -> usize { ... }
fn cluster_count(&self) -> ClusterCount { ... }
async fn load<S: Storage>(
image: &S,
header: &Header,
cluster: HostCluster,
entries: usize,
) -> Result<Self> { ... }
async fn write<S: Storage>(&self, image: &S) -> Result<()> { ... }
async fn write_entry<S: Storage>(
&self,
image: &S,
index: usize,
) -> Result<()> { ... }
}
Expand description
Generic trait for qcow2 metadata tables (L1, L2, refcount table).
Required Associated Constants§
Sourceconst MAX_ENTRIES: usize
const MAX_ENTRIES: usize
Maximum allowable number of entries.
Required Associated Types§
Sourcetype InternalEntry: TableEntry
type InternalEntry: TableEntry
Internal type for each table entry.
Required Methods§
Sourcefn from_data(data: Box<[Self::InternalEntry]>, header: &Header) -> Self
fn from_data(data: Box<[Self::InternalEntry]>, header: &Header) -> Self
Create a new table with the given contents
Sourcefn get_ref(&self, index: usize) -> Option<&Self::InternalEntry>
fn get_ref(&self, index: usize) -> Option<&Self::InternalEntry>
Get the given entry (as reference).
Sourcefn get_cluster(&self) -> Option<HostCluster>
fn get_cluster(&self) -> Option<HostCluster>
Get this table’s (first) cluster in the image file.
Sourcefn get_offset(&self) -> Option<HostOffset>
fn get_offset(&self) -> Option<HostOffset>
Get this table’s offset in the image file.
Sourcefn set_cluster(&mut self, cluster: HostCluster)
fn set_cluster(&mut self, cluster: HostCluster)
Set this table’s (first) cluster in the image file (for writing).
Sourcefn unset_cluster(&mut self)
fn unset_cluster(&mut self)
Remove the table’s association with any cluster in the image file.
Sourcefn cluster_bits(&self) -> u32
fn cluster_bits(&self) -> u32
Return log2 of the cluster size.
All tables store this anyway.
Sourcefn is_modified(&self) -> bool
fn is_modified(&self) -> bool
Check whether this table has been modified since it was last written.
Sourcefn clear_modified(&self)
fn clear_modified(&self)
Clear the modified flag.
Sourcefn set_modified(&self)
fn set_modified(&self)
Set the modified flag.
Provided Methods§
Sourcefn cluster_count(&self) -> ClusterCount
fn cluster_count(&self) -> ClusterCount
Number of clusters used by this table.
Sourceasync fn load<S: Storage>(
image: &S,
header: &Header,
cluster: HostCluster,
entries: usize,
) -> Result<Self>
async fn load<S: Storage>( image: &S, header: &Header, cluster: HostCluster, entries: usize, ) -> Result<Self>
Load a table from the image file.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.