webc::v2

Enum Tag

source
#[non_exhaustive]
#[repr(u8)]
pub enum Tag { Manifest = 1, Index = 2, Atoms = 3, Volume = 4, ChecksumNone = 20, ChecksumSha256 = 21, SignatureNone = 22, Directory = 30, File = 31, }
Available on crate feature v2 only.
Expand description

Unique identifiers used to indicate various components of a WEBC file.

§Top-Level Sections

In general, all top-level sections are Type-Length-Value encoded.

  • Tag (u8)
  • Length (u64 LE)
  • Value (Length bytes)

§Versioning

Besides acting as an identifier for various elements in a WEBC file, the Tag plays an important part in versioning. An item’s layout is tied to its Tag, so any time the layout is changed, a new unique Tag should be created.

For example, if the format for a volume needs to be changed, a new Tag::VolumeV2 variant would be added instead of modifying the spec for existing volumes. Future reader implementations then need to handle Tag::Volume and Tag::VolumeV2 gracefully.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Manifest = 1

The manifest section, containing a CBOR-serialized crate::metadata::Manifest.

§

Index = 2

The index section, containing a CBOR-serialized crate::v2::Index.

The index section is laid out as follows:

  • Tag::Index
  • overall section length (u64 LE)
  • CBOR data
  • padding

§Note to Implementors

This section may contain trailing padding bytes that should be ignored when deserializing the index.

Depending on the writer implementation, padding bytes may be necessary because the crate::v2::Index needs to be at the start of a WEBC file, yet it can only be calculated after everything has been serialized.

§

Atoms = 3

The atoms section.

An atoms section is laid out similar to Tag::Volume.

  • Tag::Atoms
  • overall section length (u64 LE)
  • volume header length (u64 LE)
  • volume header
  • volume data length (u64 LE)
  • volume data
§

Volume = 4

The volume section.

A volume section is laid out similar to Tag::Atoms.

  • Tag::Volume
  • overall section length
  • volume name length (u64 LE)
  • volume name (u64 LE)
  • volume header length (u64 LE)
  • volume header
  • volume data length (u64 LE)
  • volume data
§

ChecksumNone = 20

A tag for the empty checksum (i.e. crate::v2::Checksum::none()).

§

ChecksumSha256 = 21

A tag indicating that the crate::v2::Checksum is calculated using the SHA-256 hash of a section’s contents.

See also, crate::v2::Checksum::sha256().

§

SignatureNone = 22

A tag for the empty signature (i.e. crate::v2::Signature::none()).

§

Directory = 30

Metadata for a directory in the Tag::Volume header.

Each directory follows the type-length-value format.

  • Tag::Directory
  • overall directory length (u64 LE)
  • zero or more entries

Where each entry is

  • offset of the entry relative to the start of the header (u64 LE)
  • name length (u64 LE)
  • name (arbitrary number of bytes)
§

File = 31

Metadata for a file in the Tag::Volume header.

File metadata follows the following format:

  • Tag::File
  • start offset in data section (u64 LE)
  • end offset in data section (u64 LE)
  • SHA256 checksum (32 bytes)

Implementations§

source§

impl Tag

source

pub const ALL: [Tag; 9] = _

Get an iterator over all the tag variants.

source

pub const fn from_u8(tag: u8) -> Option<Self>

Try to load a Tag from its u8 representation.

source

pub const fn as_u8(self) -> u8

Get the Tag’s u8 representation.

source

pub const fn name(self) -> &'static str

Get the Tag’s human-friendly name.

source

pub fn display(maybe_tag: u8) -> impl Display

Gets a displayable implementation for something that may or may not be a known tag.

Unknown tags are printed in their hexadecimal representation.

Trait Implementations§

source§

impl Clone for Tag

source§

fn clone(&self) -> Tag

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 Debug for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl<'de> Deserialize<'de> for Tag

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl Hash for Tag

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl LowerHex for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl PartialEq<Tag> for u8

source§

fn eq(&self, other: &Tag) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq<u8> for Tag

source§

fn eq(&self, other: &u8) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialEq for Tag

source§

fn eq(&self, other: &Tag) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Serialize for Tag

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl UpperHex for Tag

source§

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

Formats the value using the given formatter. Read more
source§

impl Copy for Tag

source§

impl Eq for Tag

source§

impl StructuralPartialEq for Tag

Auto Trait Implementations§

§

impl Freeze for Tag

§

impl RefUnwindSafe for Tag

§

impl Send for Tag

§

impl Sync for Tag

§

impl Unpin for Tag

§

impl UnwindSafe for Tag

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
source§

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

source§

fn __clone_box(&self, _: Private) -> *mut ()

source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

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.

source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
source§

type Init = T

The type for initializers.
source§

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

Initializes a with the given initializer. Read more
source§

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

Dereferences the given pointer. Read more
source§

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

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

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

impl<T> Same for T

source§

type Output = T

Should always be Self
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> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,