summavy/fastfield/
error.rs

1use std::result;
2
3use crate::schema::FieldEntry;
4
5/// `FastFieldNotAvailableError` is returned when the
6/// user requested for a fast field reader, and the field was not
7/// defined in the schema as a fast field.
8#[derive(Debug, Error)]
9#[error("Fast field not available: '{field_name:?}'")]
10pub struct FastFieldNotAvailableError {
11    field_name: String,
12}
13
14impl FastFieldNotAvailableError {
15    /// Creates a `FastFieldNotAvailable` error.
16    /// `field_entry` is the configuration of the field
17    /// for which fast fields are not available.
18    pub fn new(field_entry: &FieldEntry) -> FastFieldNotAvailableError {
19        FastFieldNotAvailableError {
20            field_name: field_entry.name().to_string(),
21        }
22    }
23}
24
25/// Result when trying to access a fast field reader.
26pub type Result<R> = result::Result<R, FastFieldNotAvailableError>;