Struct vox_format::chunk::ChunkWriter [−][src]
pub struct ChunkWriter<W> { /* fields omitted */ }
Expand description
This struct is used to write out chunks to a file.
Implementations
Returns the offset at which this chunk is written in the underlying
writer. Similar to Chunk::offset
, this is is usually 0 for child
chunks, since the use a ContentWriter
, which only sees the children
data.
Returns the current length of the contents.
Returns the current length of the children data. This is the total number of bytes written for children chunks.
pub fn content_writer<'w, F: FnMut(&mut ContentWriter<&'w mut W>) -> Result<(), WriteError>>(
&'w mut self,
f: F
) -> Result<(), WriteError>
pub fn content_writer<'w, F: FnMut(&mut ContentWriter<&'w mut W>) -> Result<(), WriteError>>(
&'w mut self,
f: F
) -> Result<(), WriteError>
Writes data to the chunks content.
Note, that this must be called before any calls to child_writer
.
Example
use std::io::Write; chunk_writer.content_writer(|writer| { // `writer` implements `std::io::Write + std::io::Seek`. writer.write_all(b"Hello World")?; Ok(()) })
Panics
Panics, if children have been written already.
Writes the given slice to the chunk’s data.
pub fn child_writer<'w, F: FnMut(&mut ChildWriter<'w, W>) -> Result<(), WriteError>>(
&'w mut self,
chunk_id: ChunkId,
f: F
) -> Result<(), WriteError>
pub fn child_writer<'w, F: FnMut(&mut ChildWriter<'w, W>) -> Result<(), WriteError>>(
&'w mut self,
chunk_id: ChunkId,
f: F
) -> Result<(), WriteError>
Writes children chunks to this chunk. Note, that after a child has been written to a chunk, you can’t write any more data to its contents.
Example
chunk_writer.child_writer(ChunkId::Main, |child_writer| { // `child_writer` is just another `ChunkWriter`. child_writer.write_content(b"Hello World")?; Ok(()) })
pub fn child_content_writer<'w, F: FnMut(&mut ContentWriter<&mut ContentWriter<&'w mut W>>) -> Result<(), WriteError>>(
&'w mut self,
chunk_id: ChunkId,
f: F
) -> Result<(), WriteError>
pub fn child_content_writer<'w, F: FnMut(&mut ContentWriter<&mut ContentWriter<&'w mut W>>) -> Result<(), WriteError>>(
&'w mut self,
chunk_id: ChunkId,
f: F
) -> Result<(), WriteError>
Short-hand to opening and child-writer and then a content-writer to that child. Useful, if you want to write a child with only content data.
Trait Implementations
Auto Trait Implementations
impl<W> RefUnwindSafe for ChunkWriter<W> where
W: RefUnwindSafe,
impl<W> Send for ChunkWriter<W> where
W: Send,
impl<W> Sync for ChunkWriter<W> where
W: Sync,
impl<W> Unpin for ChunkWriter<W> where
W: Unpin,
impl<W> UnwindSafe for ChunkWriter<W> where
W: UnwindSafe,
Blanket Implementations
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S where
T: FloatComponent,
D: AdaptFrom<S, Swp, Dwp, T>,
Swp: WhitePoint,
Dwp: WhitePoint,
Mutably borrows from an owned value. Read more
Convert into T with values clamped to the color defined bounds Read more
Convert into T. The resulting color might be invalid in its color space Read more
type Output = T
type Output = T
Should always be Self
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
pub fn is_in_subset(&self) -> bool
pub fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
pub fn to_subset_unchecked(&self) -> SS
pub fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
pub fn from_subset(element: &SS) -> SP
pub fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
Convert into T, returning ok if the color is inside of its defined
range, otherwise an OutOfBounds
error is returned which contains
the unclamped color. Read more