Struct mz_avro::writer::Writer

source ·
pub struct Writer<W> {
    schema: Schema,
    writer: W,
    buffer: Vec<u8>,
    num_values: usize,
    codec: Option<Codec>,
    marker: [u8; 16],
    has_header: bool,
}
Expand description

Main interface for writing Avro Object Container Files.

Fields§

§schema: Schema§writer: W§buffer: Vec<u8>§num_values: usize§codec: Option<Codec>§marker: [u8; 16]§has_header: bool

Implementations§

Creates a Writer for the Schema and something implementing the std::io::Write trait to write to.

This uses the no-compression Codec::Null when appending records.

Creates a Writer given a Schema and a specific compression Codec

Create a Writer with the given parameters.

All parameters have the same meaning as with_codec, but if codec is None then no compression will be used and the avro.codec field in the header will be omitted.

Creates a Writer that appends to an existing OCF file.

Get a reference to the Schema associated to a Writer.

Append a compatible value (implementing the ToAvro trait) to a Writer, also performing schema validation.

Return the number of bytes written (it might be 0, see below).

NOTE This function is not guaranteed to perform any actual write, since it relies on internal buffering for performance reasons. If you want to be sure the value has been written, then call flush.

Append a compatible value to a Writer, also performing schema validation.

Return the number of bytes written (it might be 0, see below).

NOTE This function is not guaranteed to perform any actual write, since it relies on internal buffering for performance reasons. If you want to be sure the value has been written, then call flush.

Extend a Writer with an Iterator of compatible values (implementing the ToAvro trait), also performing schema validation.

Return the number of bytes written.

NOTE This function forces the written data to be flushed (an implicit call to flush is performed).

Extend a Writer by appending each Value from a slice, while also performing schema validation on each value appended.

Return the number of bytes written.

NOTE This function forces the written data to be flushed (an implicit call to flush is performed).

Flush the content appended to a Writer. Call this function to make sure all the content has been written before releasing the Writer.

Return the number of bytes written.

Return what the Writer is writing to, consuming the Writer itself.

NOTE This function doesn’t guarantee that everything gets written before consuming the buffer. Please call flush before.

Generate and append synchronization marker to the payload.

Append a raw Avro Value to the payload avoiding to encode it again.

Append pure bytes to the payload.

Create an Avro header based on schema, codec and sync marker.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more