pub trait WriterBuilder<T: ?Sized>: Sized {
// Required method
fn order(self, order: Order) -> Self;
// Provided methods
fn default_dtype(self) -> WithDType<Self>
where T: AutoSerialize { ... }
fn dtype(self, dtype: DType) -> WithDType<Self> { ... }
fn shape(self, shape: &[u64]) -> WithShape<Self> { ... }
fn writer<W>(self, writer: W) -> WithWriter<W, Self>
where Self: MissingWriter { ... }
fn begin_nd(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
where T: Serialize,
Self: HasDType + HasWriter + HasShape,
<Self as HasWriter>::Writer: Write { ... }
fn begin_1d(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
where T: Serialize,
Self: HasDType + HasWriter,
<Self as HasWriter>::Writer: Write + Seek { ... }
fn begin_2d(
self,
record_len: u64,
) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
where T: Serialize,
Self: HasDType + HasWriter,
<Self as HasWriter>::Writer: Write + Seek { ... }
fn write_header_only(self) -> Result<<Self as HasWriter>::Writer>
where Self: HasDType + HasWriter + HasShape,
<Self as HasWriter>::Writer: Write { ... }
}Expand description
Trait that provides methods on WriteOptions.
To obtain an initial instance of this trait, call WriteOptions::new.
The majority of methods return a type that also implements WriterBuilder; they are meant
to be chained together to construct a full config.
Required Methods§
Provided Methods§
Sourcefn default_dtype(self) -> WithDType<Self>where
T: AutoSerialize,
fn default_dtype(self) -> WithDType<Self>where
T: AutoSerialize,
Calls Self::dtype with the default dtype for the type to be serialized.
Calling this method or Self::dtype is required.
Sourcefn dtype(self, dtype: DType) -> WithDType<Self>
fn dtype(self, dtype: DType) -> WithDType<Self>
Use the specified dtype.
Calling dtype (or Self::default_dtype) is required.
Sourcefn shape(self, shape: &[u64]) -> WithShape<Self>
fn shape(self, shape: &[u64]) -> WithShape<Self>
Set the shape for an n-d array.
This is required for any array of dimension != 1.
Sourcefn writer<W>(self, writer: W) -> WithWriter<W, Self>where
Self: MissingWriter,
fn writer<W>(self, writer: W) -> WithWriter<W, Self>where
Self: MissingWriter,
Sourcefn begin_nd(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
fn begin_nd(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
Begin writing an array of the previously supplied shape.
Sourcefn begin_1d(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
fn begin_1d(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
Begin writing a 1d array, of length to be inferred from the number of elements written.
Notice that, in contrast to Self::begin_nd, this method requires Seek. If you have
a Vec<u8>, you can wrap it in an io::Cursor to satisfy this requirement.
Note: At present, any shape you did happen to provide will be ignored and not
validated against the number of elements written. This may change in the future.
Sourcefn begin_2d(
self,
record_len: u64,
) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
fn begin_2d( self, record_len: u64, ) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
Begin writing a 2d array, of length to be inferred from the number of elements written.
record_len is the number of items in a row. Or technically, rather, it is the length
of the fast axis. (so for Order::Fortran` it is the length of a column instead)
Notice that, in contrast to Self::begin_nd, this method requires Seek. If you have
a Vec<u8>, you can wrap it in an io::Cursor to satisfy this requirement.
Note: At present, any shape you did happen to provide will be ignored and not
validated against either the record len or the number of elements written. This may change in the future.
Sourcefn write_header_only(self) -> Result<<Self as HasWriter>::Writer>
fn write_header_only(self) -> Result<<Self as HasWriter>::Writer>
Write the header, and recover the writer, which now points to where the data should be written.
If the original writer object was passed in by reference, it too is guaranteed to point to this location after calling this function… so you do not necessarily need to use the returned writer.
This is the only build method you can call if the WriteOptions were
created with WriteOptions::new_header_only.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".