pub trait FieldSection<'a>: Sized {
const NAMES: FieldNames;
// Provided methods
fn interpret<I>(fields: I) -> Result<Self, FieldError>
where I: IntoIterator,
I::Item: IntoField<'a, Self> { ... }
fn partition<I, R>(fields: I) -> Result<(Self, R), FieldError>
where I: IntoIterator,
I::Item: IntoField<'a, Self>,
R: Default + Extend<FieldRef<'a>> { ... }
}Expand description
A field section interpreted into a struct. It is implemented only by #[derive(FieldSection)].
A section takes the fields it declares, refuses those it forbids, and either ignores or rejects the rest. Self::interpret discards the fields it does not take; Self::partition returns them, borrowed and with their original positions, for another section to interpret.
The lifetime is that of the field values, which a section with a lifetime parameter can borrow; a section that owns its values implements FieldSection<'a> for every 'a.
Required Associated Constants§
Sourceconst NAMES: FieldNames
const NAMES: FieldNames
The names this section declares and forbids, including those of sections it flattens.
Provided Methods§
Sourcefn interpret<I>(fields: I) -> Result<Self, FieldError>
fn interpret<I>(fields: I) -> Result<Self, FieldError>
Interpret a section from its fields in wire order, taking those it declares and discarding the rest.
§Errors
The first FieldError: a duplicate singleton, an invalid value its field treats as an error, a forbidden field, an unknown field the section rejects, or a missing required field.
Sourcefn partition<I, R>(fields: I) -> Result<(Self, R), FieldError>
fn partition<I, R>(fields: I) -> Result<(Self, R), FieldError>
Interpret a section from its fields in wire order, taking those it declares and returning the rest, with their original positions, for another section to interpret.
The remainder can be any collection: a Vec<FieldRef> borrows the fields without copying them, and OwnedFields copies them. A field a static table classified as undeclared for this section is passed on by name, since the next section may declare it. A forbidden field is an error, never part of the remainder.
§Errors
As for Self::interpret.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".