Enum liquid::model::ValueCow

source ·
pub enum ValueCow<'s> {
    Owned(Value),
    Borrowed(&'s (dyn ValueView + 's)),
}
Expand description

Abstract the lifetime of a Value.

Variants§

§

Owned(Value)

A boxed Value

§

Borrowed(&'s (dyn ValueView + 's))

A borrowed Value

Implementations§

source§

impl<'s> ValueCow<'s>

source

pub fn into_owned(self) -> Value

Extracts the owned data.

Clones the data if it is not already owned.

source

pub fn as_view(&self) -> &dyn ValueView

Performs the conversion.

Trait Implementations§

source§

impl<'s> Clone for ValueCow<'s>

source§

fn clone(&self) -> ValueCow<'s>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<'s> Debug for ValueCow<'s>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl<'v> Default for ValueCow<'v>

source§

fn default() -> ValueCow<'v>

Returns the “default value” for a type. Read more
source§

impl<'s> From<&'s Value> for ValueCow<'s>

source§

fn from(other: &'s Value) -> ValueCow<'s>

Converts to this type from the input type.
source§

impl From<Object> for ValueCow<'static>

source§

fn from(other: Object) -> ValueCow<'static>

Converts to this type from the input type.
source§

impl From<ScalarCow<'static>> for ValueCow<'static>

source§

fn from(other: ScalarCow<'static>) -> ValueCow<'static>

Converts to this type from the input type.
source§

impl From<State> for ValueCow<'static>

source§

fn from(other: State) -> ValueCow<'static>

Converts to this type from the input type.
source§

impl From<Value> for ValueCow<'static>

source§

fn from(other: Value) -> ValueCow<'static>

Converts to this type from the input type.
source§

impl From<Vec<Value, Global>> for ValueCow<'static>

source§

fn from(other: Vec<Value, Global>) -> ValueCow<'static>

Converts to this type from the input type.
source§

impl<'v> PartialEq<&'v str> for ValueCow<'v>

source§

fn eq(&self, other: &&str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<Date> for ValueCow<'v>

source§

fn eq(&self, other: &Date) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<DateTime> for ValueCow<'v>

source§

fn eq(&self, other: &DateTime) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<KStringBase<Box<str, Global>>> for ValueCow<'v>

source§

fn eq(&self, other: &KStringBase<Box<str, Global>>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<KStringCowBase<'v, Box<str, Global>>> for ValueCow<'v>

source§

fn eq(&self, other: &KStringCowBase<'v, Box<str, Global>>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<KStringRef<'v>> for ValueCow<'v>

source§

fn eq(&self, other: &KStringRef<'v>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<String> for ValueCow<'v>

source§

fn eq(&self, other: &String) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<Value> for ValueCow<'v>

source§

fn eq(&self, other: &Value) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<ValueCow<'v>> for ValueCow<'v>

source§

fn eq(&self, other: &ValueCow<'v>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<ValueViewCmp<'v>> for ValueCow<'v>

source§

fn eq(&self, other: &ValueViewCmp<'v>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<bool> for ValueCow<'v>

source§

fn eq(&self, other: &bool) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<f64> for ValueCow<'v>

source§

fn eq(&self, other: &f64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<i64> for ValueCow<'v>

source§

fn eq(&self, other: &i64) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'v> PartialEq<str> for ValueCow<'v>

source§

fn eq(&self, other: &str) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'s> ValueView for ValueCow<'s>

source§

fn as_debug(&self) -> &dyn Debug

Get a Debug representation
source§

fn render(&self) -> DisplayCow<'_>

A Display for a BoxedValue rendered for the user.
source§

fn source(&self) -> DisplayCow<'_>

A Display for a Value as source code.
source§

fn type_name(&self) -> &'static str

Report the data type (generally for error reporting).
source§

fn query_state(&self, state: State) -> bool

Query the value’s state
source§

fn to_kstr(&self) -> KStringCowBase<'_, Box<str, Global>>

Interpret as a string.
source§

fn to_value(&self) -> Value

Convert to an owned type.
source§

fn as_scalar(&self) -> Option<ScalarCow<'_>>

Extracts the scalar value if it is a scalar.
source§

fn as_array(&self) -> Option<&dyn ArrayView>

Extracts the array value if it is an array.
source§

fn as_object(&self) -> Option<&dyn ObjectView>

Extracts the object value if it is a object.
source§

fn as_state(&self) -> Option<State>

Extracts the state if it is one
source§

fn is_nil(&self) -> bool

Tests whether this value is nil Read more
source§

fn is_scalar(&self) -> bool

Tests whether this value is a scalar
source§

fn is_array(&self) -> bool

Tests whether this value is an array
source§

fn is_object(&self) -> bool

Tests whether this value is an object
source§

fn is_state(&self) -> bool

Tests whether this value is state

Auto Trait Implementations§

§

impl<'s> !RefUnwindSafe for ValueCow<'s>

§

impl<'s> !Send for ValueCow<'s>

§

impl<'s> !Sync for ValueCow<'s>

§

impl<'s> Unpin for ValueCow<'s>

§

impl<'s> !UnwindSafe for ValueCow<'s>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> Any for Twhere T: Any,

§

impl<T> CloneAny for Twhere T: Any + Clone,