pub struct ChunkWriter<W> { /* private fields */ }Expand description
This struct is used to write out chunks to a file.
Implementations§
Source§impl<W: Write + Seek> ChunkWriter<W>
impl<W: Write + Seek> ChunkWriter<W>
Sourcepub fn offset(&self) -> u64
pub fn offset(&self) -> u64
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.
Sourcepub fn content_len(&self) -> u32
pub fn content_len(&self) -> u32
Returns the current length of the contents.
Sourcepub fn children_len(&self) -> u32
pub fn children_len(&self) -> u32
Returns the current length of the children data. This is the total number of bytes written for children chunks.
Sourcepub 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.
Sourcepub fn write_content(&mut self, data: &[u8]) -> Result<(), WriteError>
pub fn write_content(&mut self, data: &[u8]) -> Result<(), WriteError>
Writes the given slice to the chunk’s data.
Sourcepub 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(())
})Sourcepub 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> Freeze for ChunkWriter<W>where
W: Freeze,
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§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
impl<T, U> IntoColor<U> for Twhere
U: FromColor<T>,
Source§fn into_color(self) -> U
fn into_color(self) -> U
Source§impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
impl<T, U> IntoColorUnclamped<U> for Twhere
U: FromColorUnclamped<T>,
Source§fn into_color_unclamped(self) -> U
fn into_color_unclamped(self) -> U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.Source§impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
impl<T, U> TryIntoColor<U> for Twhere
U: TryFromColor<T>,
Source§fn try_into_color(self) -> Result<U, OutOfBounds<U>>
fn try_into_color(self) -> Result<U, OutOfBounds<U>>
OutOfBounds error is returned which contains
the unclamped color. Read more