pub struct Mapping { /* private fields */ }Expand description
An ordered set of field mappings with name-to-ID lookup.
Fields are assigned sequential FieldIds starting at 0. The schema is
immutable after construction — new fields are added by building a new
schema that extends the previous one (see schema evolution in
[[architecture-api-surface#Schema Evolution]]).
See [[architecture-api-surface#Schema Definition]].
Implementations§
Source§impl Mapping
impl Mapping
Sourcepub fn builder() -> MappingBuilder
pub fn builder() -> MappingBuilder
Start building a schema.
Sourcepub fn ensure_id_field(&mut self)
pub fn ensure_id_field(&mut self)
Ensure the _id field exists, appending it if needed.
Called by Index at creation time. See [[feature-document-crud]].
Sourcepub fn field(&self, id: FieldId) -> &FieldMapping
pub fn field(&self, id: FieldId) -> &FieldMapping
Sourcepub fn fields(&self) -> &[FieldMapping]
pub fn fields(&self) -> &[FieldMapping]
All field mappings in insertion order.
Sourcepub fn dynamic_mode(&self) -> DynamicMode
pub fn dynamic_mode(&self) -> DynamicMode
How unknown fields are handled.
Sourcepub fn validate(&self) -> Result<()>
pub fn validate(&self) -> Result<()>
Validate cross-field references (currently: copy_to targets).
Returns an error if any field’s copy_to references a target name
that does not exist in the schema. Without this check the writer
would silently skip the copy at index time, leaving the user with
no signal that their configuration is a no-op — see
[[code-must-not-lie]].
Called automatically by Mapping::from_json; programmatic
builder users should call it (or rely on Index::create_with_mapping
to call it on their behalf).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mapping
impl RefUnwindSafe for Mapping
impl Send for Mapping
impl Sync for Mapping
impl Unpin for Mapping
impl UnsafeUnpin for Mapping
impl UnwindSafe for Mapping
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more