pub enum MsgValue {
}Expand description
Represents an arbitrary ROS message or value in it.
Variants§
Bool(bool)
Represents bool.
I8(i8)
Represents int8 or byte.
I16(i16)
Represents int16.
I32(i32)
Represents int32.
I64(i64)
Represents int64.
U8(u8)
Represents uint8 or char.
U16(u16)
Represents uint16.
U32(u32)
Represents uint32.
U64(u64)
Represents uint64.
F32(f32)
Represents float32.
F64(f64)
Represents float64.
String(String)
Represents string.
Time(Time)
Represents time.
Duration(Duration)
Represents duration.
Array(Vec<Value>)
Represents some_type[] or some_type[length].
For example: float32[64], geometry_msgs/Point[].
Message(HashMap<String, Value>)
Represents an embedded message.
Implementations§
Source§impl Value
impl Value
Sourcepub fn as_bool(&self) -> Option<bool>
pub fn as_bool(&self) -> Option<bool>
Returns the content if Value is a bool.
§Examples
assert_eq!(Value::Bool(true).as_bool(), Some(true));
assert_eq!(Value::Bool(false).as_bool(), Some(false));
assert!(Value::U32(12).as_bool().is_none());Sourcepub fn as_i8(&self) -> Option<i8>
pub fn as_i8(&self) -> Option<i8>
Returns the content if Value is an i8.
§Examples
assert_eq!(Value::I8(12).as_i8(), Some(12));
assert!(Value::U32(12).as_i8().is_none());Sourcepub fn as_i16(&self) -> Option<i16>
pub fn as_i16(&self) -> Option<i16>
Returns the content if Value is an i16.
§Examples
assert_eq!(Value::I16(12).as_i16(), Some(12));
assert!(Value::U32(12).as_i16().is_none());Sourcepub fn as_i32(&self) -> Option<i32>
pub fn as_i32(&self) -> Option<i32>
Returns the content if Value is an i32.
§Examples
assert_eq!(Value::I32(12).as_i32(), Some(12));
assert!(Value::U32(12).as_i32().is_none());Sourcepub fn as_i64(&self) -> Option<i64>
pub fn as_i64(&self) -> Option<i64>
Returns the content if Value is an i64.
§Examples
assert_eq!(Value::I64(12).as_i64(), Some(12));
assert!(Value::U32(12).as_i64().is_none());Sourcepub fn as_u8(&self) -> Option<u8>
pub fn as_u8(&self) -> Option<u8>
Returns the content if Value is a u8.
§Examples
assert_eq!(Value::U8(12).as_u8(), Some(12));
assert!(Value::U32(12).as_u8().is_none());Sourcepub fn as_u16(&self) -> Option<u16>
pub fn as_u16(&self) -> Option<u16>
Returns the content if Value is a u16.
§Examples
assert_eq!(Value::U16(12).as_u16(), Some(12));
assert!(Value::U32(12).as_u16().is_none());Sourcepub fn as_u32(&self) -> Option<u32>
pub fn as_u32(&self) -> Option<u32>
Returns the content if Value is a u32.
§Examples
assert_eq!(Value::U32(12).as_u32(), Some(12));
assert!(Value::U16(12).as_u32().is_none());Sourcepub fn as_u64(&self) -> Option<u64>
pub fn as_u64(&self) -> Option<u64>
Returns the content if Value is a u64.
§Examples
assert_eq!(Value::U64(12).as_u64(), Some(12));
assert!(Value::U32(12).as_u64().is_none());Sourcepub fn as_f32(&self) -> Option<f32>
pub fn as_f32(&self) -> Option<f32>
Returns the content if Value is an f32.
§Examples
assert_eq!(Value::F32(12.0).as_f32(), Some(12.0));
assert!(Value::U32(12).as_f32().is_none());Sourcepub fn as_f64(&self) -> Option<f64>
pub fn as_f64(&self) -> Option<f64>
Returns the content if Value is an f64.
§Examples
assert_eq!(Value::F64(12.0).as_f64(), Some(12.0));
assert!(Value::U32(12).as_f64().is_none());Sourcepub fn as_str(&self) -> Option<&str>
pub fn as_str(&self) -> Option<&str>
Returns a &str if Value is a String.
§Examples
assert_eq!(Value::String("foo".into()).as_str(), Some("foo"));
assert!(Value::U32(12).as_str().is_none());Sourcepub fn try_into_string(self) -> Option<String>
pub fn try_into_string(self) -> Option<String>
Returns the content if Value is a String.
§Examples
assert_eq!(Value::String("foo".into()).try_into_string(), Some("foo".into()));
assert!(Value::U32(12).try_into_string().is_none());Sourcepub fn as_time(&self) -> Option<Time>
pub fn as_time(&self) -> Option<Time>
Returns the content if Value is a Time struct.
§Examples
assert_eq!(
Value::Time(Time::from_nanos(120)).as_time(),
Some(Time::from_nanos(120)),
);
assert!(Value::U32(12).as_time().is_none());Sourcepub fn as_duration(&self) -> Option<Duration>
pub fn as_duration(&self) -> Option<Duration>
Returns the content if Value is a Duration struct.
§Examples
assert_eq!(
Value::Duration(Duration::from_nanos(120)).as_duration(),
Some(Duration::from_nanos(120)),
);
assert!(Value::U32(12).as_duration().is_none());Sourcepub fn as_slice(&self) -> Option<&[Value]>
pub fn as_slice(&self) -> Option<&[Value]>
Returns a reference to the content if Value is an array.
§Examples
assert_eq!(
Value::Array(vec![1u32.into(), 2u32.into(), 3u32.into()]).as_slice(),
Some(&[Value::U32(1), Value::U32(2), Value::U32(3)][..]),
);
assert!(Value::U32(12).as_slice().is_none());Sourcepub fn try_into_vec(self) -> Option<Vec<Value>>
pub fn try_into_vec(self) -> Option<Vec<Value>>
Returns the content if Value is an array.
§Examples
assert_eq!(
Value::Array(vec![1u32.into(), 2u32.into(), 3u32.into()]).try_into_vec(),
Some(vec![Value::U32(1), Value::U32(2), Value::U32(3)]),
);
assert!(Value::U32(12).try_into_vec().is_none());Sourcepub fn as_map(&self) -> Option<&HashMap<String, Value>>
pub fn as_map(&self) -> Option<&HashMap<String, Value>>
Returns a reference to the content if Value is a message.
§Examples
let mut data = HashMap::<String, Value>::new();
data.insert("foo".into(), true.into());
data.insert("bar".into(), false.into());
assert_eq!(Value::Message(data.clone()).as_map(), Some(&data));
assert!(Value::U32(12).as_map().is_none());Sourcepub fn try_into_map(self) -> Option<HashMap<String, Value>>
pub fn try_into_map(self) -> Option<HashMap<String, Value>>
Returns the content if Value is a message.
§Examples
let mut data = HashMap::<String, Value>::new();
data.insert("foo".into(), true.into());
data.insert("bar".into(), false.into());
assert_eq!(Value::Message(data.clone()).try_into_map(), Some(data));
assert!(Value::U32(12).try_into_map().is_none());Trait Implementations§
Source§impl<'de> Deserialize<'de> for Value
impl<'de> Deserialize<'de> for Value
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Value, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl<K, T> FromIterator<(K, T)> for Value
impl<K, T> FromIterator<(K, T)> for Value
Source§impl<T> FromIterator<T> for Value
impl<T> FromIterator<T> for Value
Source§impl Serialize for Value
impl Serialize for Value
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for Value
Auto Trait Implementations§
impl Freeze for Value
impl RefUnwindSafe for Value
impl Send for Value
impl Sync for Value
impl Unpin for Value
impl UnwindSafe for Value
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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