Enum Value
pub enum Value<'a> {
Object(ObjType),
Scalar(Cow<'a, ScalarValue>),
}Expand description
The type of values in an automerge document
Variants§
Object(ObjType)
A composite object of type ObjType
Scalar(Cow<'a, ScalarValue>)
A non composite value
Implementations§
§impl<'a> Value<'a>
impl<'a> Value<'a>
pub fn map() -> Value<'a>
pub fn list() -> Value<'a>
pub fn text() -> Value<'a>
pub fn table() -> Value<'a>
pub fn str(s: &str) -> Value<'a>
pub fn int(n: i64) -> Value<'a>
pub fn uint(n: u64) -> Value<'a>
pub fn counter(n: i64) -> Value<'a>
pub fn timestamp(n: i64) -> Value<'a>
pub fn f64(n: f64) -> Value<'a>
pub fn bytes(b: Vec<u8>) -> Value<'a>
pub fn is_object(&self) -> bool
pub fn is_scalar(&self) -> bool
pub fn is_bytes(&self) -> bool
pub fn is_str(&self) -> bool
pub fn is_int(&self) -> bool
pub fn is_uint(&self) -> bool
pub fn is_f64(&self) -> bool
pub fn is_counter(&self) -> bool
pub fn is_timestamp(&self) -> bool
pub fn is_boolean(&self) -> bool
pub fn is_null(&self) -> bool
pub fn into_scalar(self) -> Result<ScalarValue, Value<'a>>
pub fn into_scalar(self) -> Result<ScalarValue, Value<'a>>
If the Value is a scalar, return the ScalarValue.
Returns the original value otherwise.
pub fn to_scalar(&self) -> Option<&ScalarValue>
👎Deprecated: Use as_scalar instead
pub fn to_scalar(&self) -> Option<&ScalarValue>
Use as_scalar instead
See Value::as_scalar.
pub fn as_scalar(&self) -> Option<&ScalarValue>
pub fn as_scalar(&self) -> Option<&ScalarValue>
If the Value is a scalar, return the ScalarValue.
Returns None otherwise.
pub fn to_objtype(&self) -> Option<ObjType>
pub fn as_objtype(&self) -> Option<ObjType>
pub fn as_objtype(&self) -> Option<ObjType>
pub fn into_owned(self) -> Value<'static>
pub fn to_owned(&self) -> Value<'static>
pub fn into_bytes(self) -> Result<Vec<u8>, Value<'a>>
pub fn into_bytes(self) -> Result<Vec<u8>, Value<'a>>
pub fn to_bytes(&self) -> Option<&[u8]>
👎Deprecated: Use as_bytes instead
pub fn to_bytes(&self) -> Option<&[u8]>
Use as_bytes instead
See Value::as_bytes.
pub fn into_string(self) -> Result<String, Value<'a>>
pub fn into_string(self) -> Result<String, Value<'a>>
pub fn to_str(&self) -> Option<&str>
👎Deprecated: Use as_str instead
pub fn to_str(&self) -> Option<&str>
Use as_str instead
See Value::as_str.
pub fn to_i64(&self) -> Option<i64>
👎Deprecated: Use as_i64 instead
pub fn to_i64(&self) -> Option<i64>
Use as_i64 instead
See Value::as_i64.
pub fn to_u64(&self) -> Option<u64>
👎Deprecated: Use as_u64 instead
pub fn to_u64(&self) -> Option<u64>
Use as_u64 instead
See Value::as_u64.
pub fn to_f64(&self) -> Option<f64>
👎Deprecated: Use as_f64 instead
pub fn to_f64(&self) -> Option<f64>
Use as_f64 instead
See Value::as_f64.
pub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
If this ScalarValue is a numeric value, and can be coerced to an
f64, return the f64 value.
pub fn to_bool(&self) -> Option<bool>
👎Deprecated: Use as_bool instead
pub fn to_bool(&self) -> Option<bool>
Use as_bool instead
See Value::as_bool.
pub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
If this ScalarValue is a boolean, return the bool value.
Trait Implementations§
§impl<'a> From<&'a ScalarValue> for Value<'a>
impl<'a> From<&'a ScalarValue> for Value<'a>
§fn from(v: &'a ScalarValue) -> Value<'a>
fn from(v: &'a ScalarValue) -> Value<'a>
Converts to this type from the input type.
§impl<'a> From<&'a ScalarValue<'_>> for Value<'static>
impl<'a> From<&'a ScalarValue<'_>> for Value<'static>
§fn from(v: &'a ScalarValue<'_>) -> Value<'static>
fn from(v: &'a ScalarValue<'_>) -> Value<'static>
Converts to this type from the input type.
§impl From<ScalarValue> for Value<'_>
impl From<ScalarValue> for Value<'_>
§fn from(v: ScalarValue) -> Value<'_>
fn from(v: ScalarValue) -> Value<'_>
Converts to this type from the input type.
impl<'a> StructuralPartialEq for Value<'a>
Auto Trait Implementations§
impl<'a> Freeze for Value<'a>
impl<'a> RefUnwindSafe for Value<'a>
impl<'a> Send for Value<'a>
impl<'a> Sync for Value<'a>
impl<'a> Unpin for Value<'a>
impl<'a> UnsafeUnpin for Value<'a>
impl<'a> UnwindSafe for Value<'a>
Blanket Implementations§
§impl<T> AnyEq for T
impl<T> AnyEq for T
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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