pub struct Scalar(/* private fields */);Expand description
One plain value in an entry: a boolean, a number, a short text or an enum variant. Nested values are never stored.
Implementations§
Source§impl Scalar
impl Scalar
Sourcepub fn from_json(value: &Value) -> Option<Self>
pub fn from_json(value: &Value) -> Option<Self>
A plain JSON value, text cut to MAX_SCALAR_CHARS. None for
arrays and objects, and for null.
Sourcepub fn argument(value: &Value) -> Option<Self>
pub fn argument(value: &Value) -> Option<Self>
A verb’s argument as passed: a plain JSON value, text kept whole
(Self::whole_text). None for arrays and objects, and for null.
Sourcepub fn text(text: &str) -> Self
pub fn text(text: &str) -> Self
Text cut to MAX_SCALAR_CHARS, without control characters.
Sourcepub fn whole_text(text: &str) -> Self
pub fn whole_text(text: &str) -> Self
A text an edit wrote whole (a formula, a title), kept whole without
control characters: the change carries the text anyway, and a reader
elides it where it draws it. Other text is cut (Self::text).
Sourcepub fn of<T: Serialize + ?Sized>(value: &T) -> Option<Self>
pub fn of<T: Serialize + ?Sized>(value: &T) -> Option<Self>
Any serializable plain value (a bool, a number, a unit enum, a
string). None when it serializes to anything else.
pub fn as_json(&self) -> &Value
pub fn as_bool(&self) -> Option<bool>
pub fn as_str(&self) -> Option<&str>
pub fn as_f64(&self) -> Option<f64>
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Scalar
impl<'de> Deserialize<'de> for Scalar
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
impl Eq for Scalar
impl StructuralPartialEq for Scalar
Auto Trait Implementations§
impl Forget for Scalar
impl Freeze for Scalar
impl Move for Scalar
impl RefUnwindSafe for Scalar
impl Send for Scalar
impl Sync for Scalar
impl Unpin for Scalar
impl UnsafeUnpin for Scalar
impl UnwindSafe for Scalar
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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> ⓘ
Converts
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> ⓘ
Converts
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