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§
Sourcefn write(&self, w: &mut impl ColumnWriter)
fn write(&self, w: &mut impl ColumnWriter)
Report this value’s columns to w, in the order read takes them back off.
Sourcefn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>
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
impl Field for IpAddr
Source§fn write(&self, w: &mut impl ColumnWriter)
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.
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.
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§impl Field for NonZeroI16
impl Field for NonZeroI16
Source§impl Field for NonZeroI32
impl Field for NonZeroI32
Source§impl Field for NonZeroI64
impl Field for NonZeroI64
Source§impl Field for NonZeroI128
impl Field for NonZeroI128
Source§impl Field for NonZeroU16
impl Field for NonZeroU16
Source§impl Field for NonZeroU32
impl Field for NonZeroU32
Source§impl Field for NonZeroU64
impl Field for NonZeroU64
Source§impl Field for NonZeroU128
impl Field for NonZeroU128
Source§impl Field for SocketAddr
impl Field for SocketAddr
Source§fn write(&self, w: &mut impl ColumnWriter)
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.
fn read<R: ColumnReader>(r: &mut R) -> Result<Self, R::Error>
Source§impl Field for SocketAddrV4
impl Field for SocketAddrV4
Source§impl Field for SocketAddrV6
impl Field for SocketAddrV6
Source§impl Field for Uuid
uuid::Uuid: a column of its own kind, which is the sixteen bytes and never a spelling of them.
impl Field for Uuid
uuid::Uuid: a column of its own kind, which is the sixteen bytes and never a spelling of them.
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.
impl Field for Uuid
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§impl<const N: usize> Field for [u8; N]
A fixed-width byte member: the bytes themselves, at the width the TYPE states.
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.