Skip to main content

Field

Trait Field 

Source
pub trait Field: Sized {
    // Required methods
    fn write(&self, w: &mut impl ColumnWriter);
    fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>;
}
Expand description

A KEY VALUE REPORTING ITSELF IN COLUMNS — engine-blind, written once, read by every engine.

The merged form of the two per-engine row traits, and the merge is what makes a row’s cost per-TYPE instead of per-(type × engine). A declaring crate writes impl Field for MyId once and its id crosses into every engine there is; an engine implements the column language once and takes every row anybody has written.

Sized because read returns Self by value.

§Not object-safe, and it has no reason to be

write takes impl ColumnWriter and read is generic over the reader, so a row is spent through a type parameter and never behind a dyn. A key’s members are known at compile time — the seam that spends them is generic anyway — and both column traits are dyn-incompatible themselves.

Required Methods§

Source

fn write(&self, w: &mut impl ColumnWriter)

Report this value’s columns to w, in the order read takes them back off.

Source

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Take this value’s columns off r, in the order write put them down.

§Errors

The engine’s own refusal if a column is missing, or if the one that is there is not the kind this value’s read asks for — and this value’s OWN, worded through ColumnError, when a well-formed column decodes to something the type does not admit.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl Field for IpAddr

Source§

fn write(&self, w: &mut impl ColumnWriter)

A VARIABLE-width column, and deliberately not a fixed one: the width is this row’s discriminant, so the read has to be able to ask for whatever is there. Writing through fixed would land the two arms in two different columns on any engine with a native fixed width, and the read asks for one.

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for Ipv4Addr

The network family, each as the OCTETS its own identity is — never the textual form, whose spellings are several per address.

The widths are what make the two ENUM members injective untagged: 4 against 16 for an IpAddr, 6 against 26 for a SocketAddr. A tag byte would buy nothing a width already buys.

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for Ipv6Addr

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroI8

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroI16

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroI32

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroI64

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroI128

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroU8

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroU16

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroU32

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroU64

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for NonZeroU128

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for ObjectId

Available on crate feature mongo only.
Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for SmolStr

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for SocketAddr

Source§

fn write(&self, w: &mut impl ColumnWriter)

The arms share the two PACKINGS and not the two rows, which is IpAddr’s argument one type over: this row reads its arms apart off a variable-width column, so it has to land one — where each arm’s own row lands a fixed-width column an engine is free to make native. Same bytes, different kind, and the kind is what the read has to agree with.

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for SocketAddrV4

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for SocketAddrV6

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for String

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for Uuid

uuid::Uuid: a column of its own kind, which is the sixteen bytes and never a spelling of them.

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for Uuid

Available on crate feature mongo only.

The BSON pair, under the feature that supplies the types: each as its own raw bytes at its own width, which is what both of them already are.

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for i8

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for i16

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for i32

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for i64

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for i128

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for u8

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for u16

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for u32

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for u64

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl Field for u128

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl<T: Field> Field for Arc<T>

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl<T: Field> Field for Box<T>

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl<T: Field> Field for Rc<T>

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Source§

impl<const N: usize> Field for [u8; N]

A fixed-width byte member: the bytes themselves, at the width the TYPE states.

N is the admission — see Id — so the width the read demands is the type’s own and a column of another width is not this value.

Source§

fn write(&self, w: &mut impl ColumnWriter)

Source§

fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>

Implementors§

Source§

impl Field for Utf8Bytes

Source§

impl<I: Field, E> Field for TypedId<I, E>

A TypedId: the STORED id’s columns, and nothing for the entity marker.

E reaches no column anywhere else in this crate and reaches none here — storage and wire see only I is the type’s own stated law, and a column is storage.