pub struct Writer<S> { /* private fields */ }
Expand description
A serializer for the WEBC format.
Implementations§
source§impl Writer<WritingManifest>
impl Writer<WritingManifest>
sourcepub fn new(checksum_algorithm: ChecksumAlgorithm) -> Self
pub fn new(checksum_algorithm: ChecksumAlgorithm) -> Self
Create a new Writer
in its initial state.
source§impl Writer<WritingManifest>
impl Writer<WritingManifest>
sourcepub fn write_manifest(
self,
manifest: &Manifest
) -> Result<Writer<WritingAtoms>, WriteError>
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
.
sourcepub fn write_cbor_manifest(
self,
manifest: &impl Serialize
) -> Result<Writer<WritingAtoms>, WriteError>
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.
sourcepub fn write_raw_manifest(
self,
manifest: impl Into<Bytes>
) -> Writer<WritingAtoms>
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>
impl Writer<WritingAtoms>
sourcepub fn write_atoms(
self,
atoms: BTreeMap<PathSegment, FileEntry<'_>>
) -> Result<Writer<WritingVolumes>, WriteError>
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>
impl Writer<WritingVolumes>
sourcepub fn write_volume(
&mut self,
name: &str,
volume: Directory<'_>
) -> Result<(), WriteError>
pub fn write_volume( &mut self, name: &str, volume: Directory<'_> ) -> Result<(), WriteError>
Write a volume to the file.
sourcepub fn with_volume(
self,
name: &str,
volume: Directory<'_>
) -> Result<Self, WriteError>
pub fn with_volume( self, name: &str, volume: Directory<'_> ) -> Result<Self, WriteError>
Add a volume to the file.
sourcepub fn finish(
self,
signature_algorithm: SignatureAlgorithm
) -> Result<Bytes, WriteError>
pub fn finish( self, signature_algorithm: SignatureAlgorithm ) -> Result<Bytes, WriteError>
Finish writing volumes and get the final WEBC file.