Enum webc::v2::Tag

source ·
#[repr(u8)]
#[non_exhaustive]
pub enum Tag {
    Manifest,
    Index,
    Atoms,
    Volume,
    ChecksumNone,
    ChecksumSha256,
    SignatureNone,
    Directory,
    File,
}
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

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

§

Index

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

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

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

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

§

ChecksumSha256

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

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

§

Directory

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

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

impl PartialEq<Tag> for Tag

source§

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

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

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

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

impl PartialEq<Tag> for u8

source§

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

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

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

This method 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

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

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

This method 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.
source§

impl Copy for Tag

source§

impl Eq for Tag

source§

impl StructuralEq for Tag

source§

impl StructuralPartialEq for Tag

Auto Trait Implementations§

§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<Q, K> Equivalent<K> for Qwhere 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 Qwhere 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 Qwhere 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

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

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 Twhere 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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