#[non_exhaustive]pub enum FrontMatterValue {
DateTime(FrontMatterDateTimeValue),
DateTimeList(FrontMatterDateTimeList),
User(FrontMatterUserValue),
UserList(FrontMatterUserList),
String(FrontMatterStringValue),
StringList(FrontMatterStringList),
Number(FrontMatterNumberValue),
NumberList(FrontMatterNumberList),
}Expand description
Known variants of front-matter values for runtime validation.
Front matter values can hold extra type information to allow the API and the operational transform operations to validate values before storing them.
The usual pattern to use these values is to use the validate_value method
of FrontMatterSchemaEntry to check if the value has the expected type:
// An existing schema to check values against
let schema = FrontMatterSchemaEntry::builder()
.key("foo")
.schema(FrontMatterNumberSchema::builder()
.display_name("A number field that accepts single numbers")
.build())
.build();
// A value that came from an API boundary
let good_value_from_api = json!(42);
assert!(schema.validate_value(good_value_from_api.clone()).is_ok());
// Another value (that has the wrong type)
let bad_value_from_api = json!("2022-10-08T13:29:00.78Z");
assert!(schema.validate_value(bad_value_from_api).is_err());This can be used to validate the obtained value format.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
DateTime(FrontMatterDateTimeValue)
A timestamp front matter value
DateTimeList(FrontMatterDateTimeList)
A list-of-timestamps front matter value
User(FrontMatterUserValue)
A user front matter value
UserList(FrontMatterUserList)
A list-of-users front matter value
String(FrontMatterStringValue)
A string front matter value
StringList(FrontMatterStringList)
A list-of-strings front matter value
Number(FrontMatterNumberValue)
A number front matter value
NumberList(FrontMatterNumberList)
A list-of-numbers front matter value
Implementations§
Trait Implementations§
source§impl Clone for FrontMatterValue
impl Clone for FrontMatterValue
source§fn clone(&self) -> FrontMatterValue
fn clone(&self) -> FrontMatterValue
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moresource§impl Debug for FrontMatterValue
impl Debug for FrontMatterValue
source§impl<'de> Deserialize<'de> for FrontMatterValue
impl<'de> Deserialize<'de> for FrontMatterValue
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl Display for FrontMatterValue
impl Display for FrontMatterValue
source§impl From<FrontMatterDateTimeList> for FrontMatterValue
impl From<FrontMatterDateTimeList> for FrontMatterValue
source§fn from(v: FrontMatterDateTimeList) -> Self
fn from(v: FrontMatterDateTimeList) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterDateTimeValue> for FrontMatterValue
impl From<FrontMatterDateTimeValue> for FrontMatterValue
source§fn from(v: FrontMatterDateTimeValue) -> Self
fn from(v: FrontMatterDateTimeValue) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterNumberList> for FrontMatterValue
impl From<FrontMatterNumberList> for FrontMatterValue
source§fn from(v: FrontMatterNumberList) -> Self
fn from(v: FrontMatterNumberList) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterNumberValue> for FrontMatterValue
impl From<FrontMatterNumberValue> for FrontMatterValue
source§fn from(v: FrontMatterNumberValue) -> Self
fn from(v: FrontMatterNumberValue) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterStringList> for FrontMatterValue
impl From<FrontMatterStringList> for FrontMatterValue
source§fn from(v: FrontMatterStringList) -> Self
fn from(v: FrontMatterStringList) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterStringValue> for FrontMatterValue
impl From<FrontMatterStringValue> for FrontMatterValue
source§fn from(v: FrontMatterStringValue) -> Self
fn from(v: FrontMatterStringValue) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterUserList> for FrontMatterValue
impl From<FrontMatterUserList> for FrontMatterValue
source§fn from(v: FrontMatterUserList) -> Self
fn from(v: FrontMatterUserList) -> Self
Converts to this type from the input type.
source§impl From<FrontMatterUserValue> for FrontMatterValue
impl From<FrontMatterUserValue> for FrontMatterValue
source§fn from(v: FrontMatterUserValue) -> Self
fn from(v: FrontMatterUserValue) -> Self
Converts to this type from the input type.
source§impl From<Value> for FrontMatterValue
impl From<Value> for FrontMatterValue
source§impl PartialEq for FrontMatterValue
impl PartialEq for FrontMatterValue
source§fn eq(&self, other: &FrontMatterValue) -> bool
fn eq(&self, other: &FrontMatterValue) -> bool
This method tests for
self and other values to be equal, and is used
by ==.source§impl Serialize for FrontMatterValue
impl Serialize for FrontMatterValue
source§impl TryFrom<&str> for FrontMatterValue
impl TryFrom<&str> for FrontMatterValue
impl Eq for FrontMatterValue
impl StructuralPartialEq for FrontMatterValue
Auto Trait Implementations§
impl Freeze for FrontMatterValue
impl RefUnwindSafe for FrontMatterValue
impl Send for FrontMatterValue
impl Sync for FrontMatterValue
impl Unpin for FrontMatterValue
impl UnwindSafe for FrontMatterValue
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
Mutably borrows from an owned value. Read more