[−][src]Enum nvim_rs::rpc::Value
Represents any valid MessagePack value.
Variants
Nil represents nil.
Boolean(bool)
Boolean represents true or false.
Integer(Integer)
Integer represents an integer.
A value of an Integer
object is limited from -(2^63)
upto (2^64)-1
.
Examples
use rmpv::Value; assert_eq!(42, Value::from(42).as_i64().unwrap());
F32(f32)
A 32-bit floating point number.
F64(f64)
A 64-bit floating point number.
String(Utf8String)
String extending Raw type represents a UTF-8 string.
Note
String objects may contain invalid byte sequence and the behavior of a deserializer depends on the actual implementation when it received invalid byte sequence. Deserializers should provide functionality to get the original byte array so that applications can decide how to handle the object
Binary extending Raw type represents a byte array.
Array represents a sequence of objects.
Map represents key-value pairs of objects.
Extended implements Extension interface: represents a tuple of type information and a byte array where type information is an integer whose meaning is defined by applications.
Methods
impl Value
[src]
pub fn as_ref(&self) -> ValueRef
[src]
Converts the current owned Value to a ValueRef.
Panics
Panics in unable to allocate memory to keep all internal structures and buffers.
Examples
use rmpv::{Value, ValueRef}; let val = Value::Array(vec![ Value::Nil, Value::from(42), Value::Array(vec![ Value::String("le message".into()) ]) ]); let expected = ValueRef::Array(vec![ ValueRef::Nil, ValueRef::from(42), ValueRef::Array(vec![ ValueRef::from("le message"), ]) ]); assert_eq!(expected, val.as_ref());
pub fn is_nil(&self) -> bool
[src]
Returns true if the Value
is a Null. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::Nil.is_nil());
pub fn is_bool(&self) -> bool
[src]
Returns true if the Value
is a Boolean. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::Boolean(true).is_bool()); assert!(!Value::Nil.is_bool());
pub fn is_i64(&self) -> bool
[src]
Returns true if the Value
is convertible to an i64. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::from(42).is_i64()); assert!(!Value::from(42.0).is_i64());
pub fn is_u64(&self) -> bool
[src]
Returns true if the Value
is convertible to an u64. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::from(42).is_u64()); assert!(!Value::F32(42.0).is_u64()); assert!(!Value::F64(42.0).is_u64());
pub fn is_f32(&self) -> bool
[src]
Returns true if (and only if) the Value
is a f32. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::F32(42.0).is_f32()); assert!(!Value::from(42).is_f32()); assert!(!Value::F64(42.0).is_f32());
pub fn is_f64(&self) -> bool
[src]
Returns true if (and only if) the Value
is a f64. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::F64(42.0).is_f64()); assert!(!Value::from(42).is_f64()); assert!(!Value::F32(42.0).is_f64());
pub fn is_number(&self) -> bool
[src]
Returns true if the Value
is a Number. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::from(42).is_number()); assert!(Value::F32(42.0).is_number()); assert!(Value::F64(42.0).is_number()); assert!(!Value::Nil.is_number());
pub fn is_str(&self) -> bool
[src]
Returns true if the Value
is a String. Returns false otherwise.
Examples
use rmpv::Value; assert!(Value::String("value".into()).is_str()); assert!(!Value::Nil.is_str());
pub fn is_bin(&self) -> bool
[src]
Returns true if the Value
is a Binary. Returns false otherwise.
pub fn is_array(&self) -> bool
[src]
Returns true if the Value
is an Array. Returns false otherwise.
pub fn is_map(&self) -> bool
[src]
Returns true if the Value
is a Map. Returns false otherwise.
pub fn is_ext(&self) -> bool
[src]
Returns true if the Value
is an Ext. Returns false otherwise.
pub fn as_bool(&self) -> Option<bool>
[src]
If the Value
is a Boolean, returns the associated bool.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some(true), Value::Boolean(true).as_bool()); assert_eq!(None, Value::Nil.as_bool());
pub fn as_i64(&self) -> Option<i64>
[src]
If the Value
is an integer, return or cast it to a i64.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some(42i64), Value::from(42).as_i64()); assert_eq!(None, Value::F64(42.0).as_i64());
pub fn as_u64(&self) -> Option<u64>
[src]
If the Value
is an integer, return or cast it to a u64.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some(42u64), Value::from(42).as_u64()); assert_eq!(None, Value::from(-42).as_u64()); assert_eq!(None, Value::F64(42.0).as_u64());
pub fn as_f64(&self) -> Option<f64>
[src]
If the Value
is a number, return or cast it to a f64.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some(42.0), Value::from(42).as_f64()); assert_eq!(Some(42.0), Value::F32(42.0f32).as_f64()); assert_eq!(Some(42.0), Value::F64(42.0f64).as_f64()); assert_eq!(Some(2147483647.0), Value::from(i32::max_value() as i64).as_f64()); assert_eq!(None, Value::Nil.as_f64());
pub fn as_str(&self) -> Option<&str>
[src]
If the Value
is a String, returns the associated str.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some("le message"), Value::String("le message".into()).as_str()); assert_eq!(None, Value::Boolean(true).as_str());
pub fn as_slice(&self) -> Option<&[u8]>
[src]
If the Value
is a Binary or a String, returns the associated slice.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some(&[1, 2, 3, 4, 5][..]), Value::Binary(vec![1, 2, 3, 4, 5]).as_slice()); assert_eq!(None, Value::Boolean(true).as_slice());
pub fn as_array(&self) -> Option<&Vec<Value>>
[src]
If the Value
is an Array, returns the associated vector.
Returns None otherwise.
Examples
use rmpv::Value; let val = Value::Array(vec![Value::Nil, Value::Boolean(true)]); assert_eq!(Some(&vec![Value::Nil, Value::Boolean(true)]), val.as_array()); assert_eq!(None, Value::Nil.as_array());
pub fn as_map(&self) -> Option<&Vec<(Value, Value)>>
[src]
If the Value
is a Map, returns the associated vector of key-value tuples.
Returns None otherwise.
Note
MessagePack represents map as a vector of key-value tuples.
Examples
use rmpv::Value; let val = Value::Map(vec![(Value::Nil, Value::Boolean(true))]); assert_eq!(Some(&vec![(Value::Nil, Value::Boolean(true))]), val.as_map()); assert_eq!(None, Value::Nil.as_map());
pub fn as_ext(&self) -> Option<(i8, &[u8])>
[src]
If the Value
is an Ext, returns the associated tuple with a ty and slice.
Returns None otherwise.
Examples
use rmpv::Value; assert_eq!(Some((42, &[1, 2, 3, 4, 5][..])), Value::Ext(42, vec![1, 2, 3, 4, 5]).as_ext()); assert_eq!(None, Value::Boolean(true).as_ext());
Trait Implementations
impl Clone for Value
[src]
impl Debug for Value
[src]
impl Display for Value
[src]
impl<'a> From<&'a [u8]> for Value
[src]
impl<'a> From<&'a str> for Value
[src]
impl<'a> From<Cow<'a, [u8]>> for Value
[src]
impl<'a> From<Cow<'a, str>> for Value
[src]
impl From<String> for Value
[src]
impl From<Value> for Box<CallError>
[src]
impl From<Vec<(Value, Value)>> for Value
[src]
impl From<Vec<Value>> for Value
[src]
impl From<Vec<u8>> for Value
[src]
impl From<bool> for Value
[src]
impl From<f32> for Value
[src]
impl From<f64> for Value
[src]
impl From<i16> for Value
[src]
impl From<i32> for Value
[src]
impl From<i64> for Value
[src]
impl From<i8> for Value
[src]
impl From<isize> for Value
[src]
impl From<u16> for Value
[src]
impl From<u32> for Value
[src]
impl From<u64> for Value
[src]
impl From<u8> for Value
[src]
impl From<usize> for Value
[src]
impl<V> FromIterator<V> for Value where
V: Into<Value>,
[src]
V: Into<Value>,
fn from_iter<I>(iter: I) -> Value where
I: IntoIterator<Item = V>,
[src]
I: IntoIterator<Item = V>,
impl FromVal<Value> for ()
[src]
impl FromVal<Value> for Value
[src]
impl FromVal<Value> for Vec<(Value, Value)>
[src]
impl<T: FromVal<Value>> FromVal<Value> for Vec<T>
[src]
impl FromVal<Value> for (i64, i64)
[src]
impl FromVal<Value> for bool
[src]
impl FromVal<Value> for String
[src]
impl FromVal<Value> for i64
[src]
impl<'_> Index<&'_ str> for Value
[src]
impl Index<usize> for Value
[src]
impl<'a> IntoVal<Value> for &'a str
[src]
impl IntoVal<Value> for Vec<String>
[src]
impl<'_, W> IntoVal<Value> for &'_ Tabpage<W> where
W: AsyncWrite + Send + Sync + Unpin + 'static,
[src]
W: AsyncWrite + Send + Sync + Unpin + 'static,
impl<'_, W> IntoVal<Value> for &'_ Window<W> where
W: AsyncWrite + Send + Sync + Unpin + 'static,
[src]
W: AsyncWrite + Send + Sync + Unpin + 'static,
impl IntoVal<Value> for Vec<Value>
[src]
impl IntoVal<Value> for (i64, i64)
[src]
impl IntoVal<Value> for bool
[src]
impl IntoVal<Value> for i64
[src]
impl IntoVal<Value> for String
[src]
impl IntoVal<Value> for Value
[src]
impl IntoVal<Value> for Vec<(Value, Value)>
[src]
impl<'_, W> IntoVal<Value> for &'_ Buffer<W> where
W: AsyncWrite + Send + Sync + Unpin + 'static,
[src]
W: AsyncWrite + Send + Sync + Unpin + 'static,
impl PartialEq<Value> for Value
[src]
impl StructuralPartialEq for Value
[src]
Auto Trait Implementations
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,