Struct webc::v2::write::Writer

source ·
pub struct Writer<S> { /* private fields */ }
Expand description

A serializer for the WEBC format.

Implementations§

source§

impl Writer<WritingManifest>

source

pub fn new(checksum_algorithm: ChecksumAlgorithm) -> Self

Create a new Writer in its initial state.

source§

impl Writer<WritingManifest>

source

pub fn write_manifest( self, manifest: &Manifest ) -> Result<Writer<WritingAtoms>, WriteError>

Write a Manifest to the manifest section, transitioning from the WritingManifest state to WritingAtoms.

source

pub fn write_cbor_manifest( self, manifest: &impl Serialize ) -> Result<Writer<WritingAtoms>, WriteError>

Serialize an arbitrary object to CBOR and write it to the manifest section.

Most users should prefer to use Writer::write_manifest(), although this method might be useful in niche circumstances where you have your own, specialized Manifest type.

source

pub fn write_raw_manifest( self, manifest: impl Into<Bytes> ) -> Writer<WritingAtoms>

Write some bytes to the manifest section.

This assumes the provided bytes encode a valid CBOR object roughly following the Manifest structure.

source§

impl Writer<WritingAtoms>

source

pub fn write_atoms( self, atoms: BTreeMap<PathSegment, FileEntry<'_>> ) -> Result<Writer<WritingVolumes>, WriteError>

Write some atoms to the atoms section of the file, transitioning from the WritingAtoms state to WritingVolumes.

source§

impl Writer<WritingVolumes>

source

pub fn write_volume( &mut self, name: &str, volume: Directory<'_> ) -> Result<(), WriteError>

Write a volume to the file.

source

pub fn with_volume( self, name: &str, volume: Directory<'_> ) -> Result<Self, WriteError>

Add a volume to the file.

source

pub fn finish( self, signature_algorithm: SignatureAlgorithm ) -> Result<Bytes, WriteError>

Finish writing volumes and get the final WEBC file.

Trait Implementations§

source§

impl<S: Debug> Debug for Writer<S>

source§

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

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

impl Default for Writer<WritingManifest>

source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> RefUnwindSafe for Writer<S>where S: RefUnwindSafe,

§

impl<S> Send for Writer<S>where S: Send,

§

impl<S> Sync for Writer<S>where S: Sync,

§

impl<S> Unpin for Writer<S>where S: Unpin,

§

impl<S> UnwindSafe for Writer<S>where S: UnwindSafe,

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