pub struct RowPacker<'a> {
    row: &'a mut Row,
}
Expand description

Packs datums into a Row.

Creating a RowPacker via Row::packer starts a packing operation on the row. A packing operation always starts from scratch: the existing contents of the underlying row are cleared.

To complete a packing operation, drop the RowPacker.

Fields

row: &'a mut Row

Implementations

Constructs a row packer that will pack additional datums into the provided row.

This function is intentionally somewhat inconvenient to call. You usually want to call Row::packer instead to start packing from scratch.

Extend an existing Row with a Datum.

Extend an existing Row with additional Datums.

Extend an existing Row with additional Datums.

In the case the iterator produces an error, the pushing of datums in terminated and the error returned. The Row will be incomplete, but it will be safe to read datums from it.

Appends the datums of an entire Row.

Pushes a DatumList that is built from a closure.

The supplied closure will be invoked once with a Row that can be used to populate the list. It is valid to call any method on the RowPacker except for RowPacker::clear, RowPacker::truncate, or RowPacker::truncate_datums.

Returns the value returned by the closure, if any.

let mut row = Row::default();
row.packer().push_list_with(|row| {
    row.push(Datum::String("age"));
    row.push(Datum::Int64(42));
});
assert_eq!(
    row.unpack_first().unwrap_list().iter().collect::<Vec<_>>(),
    vec![Datum::String("age"), Datum::Int64(42)],
);

Pushes a DatumMap that is built from a closure.

The supplied closure will be invoked once with a Row that can be used to populate the dict.

The closure must alternate pushing string keys and arbitrary values, otherwise reading the dict will cause a panic.

The closure must push keys in ascending order, otherwise equality checks on the resulting Row may be wrong and reading the dict IN DEBUG MODE will cause a panic.

The closure must not call RowPacker::clear, RowPacker::truncate, or RowPacker::truncate_datums.

Example
let mut row = Row::default();
row.packer().push_dict_with(|row| {

    // key
    row.push(Datum::String("age"));
    // value
    row.push(Datum::Int64(42));

    // key
    row.push(Datum::String("name"));
    // value
    row.push(Datum::String("bob"));
});
assert_eq!(
    row.unpack_first().unwrap_map().iter().collect::<Vec<_>>(),
    vec![("age", Datum::Int64(42)), ("name", Datum::String("bob"))]
);

Convenience function to construct an array from an iter of Datums.

Returns an error if the number of elements in iter does not match the cardinality of the array as described by dims, or if the number of dimensions exceeds MAX_ARRAY_DIMENSIONS. If an error occurs, the packer’s state will be unchanged.

Convenience function to push a DatumList from an iter of Datums

See RowPacker::push_dict_with if you need to be able to handle errors

Convenience function to push a DatumMap from an iter of (&str, Datum) pairs

Clears the contents of the packer without de-allocating its backing memory.

Truncates the underlying storage to the specified byte position.

Safety

pos MUST specify a byte offset that lies on a datum boundary. If pos specifies a byte offset that is within a datum, the row packer will produce an invalid row, the unpacking of which may trigger undefined behavior!

To find the byte offset of a datum boundary, inspect the the packer’s byte length by calling packer.data().len() after pushing the desired number of datums onto the packer.

Truncates the underlying row to contain at most the first n datums.

Trait Implementations

Formats the value using the given formatter. Read more

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.

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Attaches the current Context to this type, returning a WithContext wrapper. Read more
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.

Wrap the input message T in a tonic::Request
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