Trait npyz::WriterBuilder

source ·
pub trait WriterBuilder<T: Serialize + ?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 Self: HasDType + HasWriter + HasShape,
             <Self as HasWriter>::Writer: Write { ... }
    fn begin_1d(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
       where Self: HasDType + HasWriter,
             <Self as HasWriter>::Writer: Write + Seek { ... }
}
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§

source

fn order(self, order: Order) -> Self

Set the data order for arrays with more than one dimension.

If this is not called, Order::C is assumed.

Provided Methods§

source

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.

source

fn dtype(self, dtype: DType) -> WithDType<Self>

Use the specified dtype.

Calling dtype (or Self::default_dtype) is required.

source

fn shape(self, shape: &[u64]) -> WithShape<Self>

Set the shape for an n-d array.

This is required for any array of dimension != 1.

source

fn writer<W>(self, writer: W) -> WithWriter<W, Self>
where Self: MissingWriter,

Set the ouput Write object.

Calling this method is required. In some cases (e.g. the builder obtained from an NpzWriter), it will already have been called for you.

source

fn begin_nd(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
where Self: HasDType + HasWriter + HasShape, <Self as HasWriter>::Writer: Write,

Begin writing an array of the previously supplied shape.

source

fn begin_1d(self) -> Result<NpyWriter<T, <Self as HasWriter>::Writer>>
where Self: HasDType + HasWriter, <Self as HasWriter>::Writer: Write + Seek,

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.

Object Safety§

This trait is not object safe.

Implementors§