Skip to main content

Value

Enum Value 

Source
pub enum Value {
Show 13 variants Bool(bool), Integer(i128), Float(f64), Octet(u8), Char(char), String(String), Bytes(Vec<u8>), Enum(Box<Enumerator>), Array(Vec<Value>), Record(Vec<(String, Value)>), Variant(Box<VariantValue>), Handle(Vec<u8>), Raw(Vec<u8>),
}
Expand description

A value of any FOM data type; see the module documentation for the mapping.

Variants§

§

Bool(bool)

HLAboolean.

§

Integer(i128)

A signed or unsigned integer of up to 64 bits. Numbers outside i64::MIN..=u64::MAX fit no data type and do not survive JSON.

§

Float(f64)

A 32-bit or 64-bit floating point number.

§

Octet(u8)

One uninterpreted octet (HLAoctet, HLAbyte).

§

Char(char)

One character (HLAASCIIchar, HLAunicodeChar).

§

String(String)

An array of characters (HLAASCIIstring, HLAunicodeString…).

§

Bytes(Vec<u8>)

An array of octets (HLAopaqueData, HLAlogicalTime…).

§

Enum(Box<Enumerator>)

An enumerator of an enumerated data type.

§

Array(Vec<Value>)

An array of any other element data type.

§

Record(Vec<(String, Value)>)

A fixed record: its fields by name, in the order of the data type.

§

Variant(Box<VariantValue>)

A variant record.

§

Handle(Vec<u8>)

The encoded form of a handle (HLAfederateHandle…), see 12.2.

§

Raw(Vec<u8>)

The octets of a value whose data type cannot be resolved.

Implementations§

Source§

impl Value

Source

pub fn integer(value: impl Into<i128>) -> Self

An integer.

Source

pub fn string(text: impl Into<String>) -> Self

A string.

Source

pub fn bytes(octets: impl Into<Vec<u8>>) -> Self

Opaque octets.

Source

pub fn handle(octets: impl Into<Vec<u8>>) -> Self

The encoded form of a handle.

Source

pub fn raw(octets: impl Into<Vec<u8>>) -> Self

Octets of an unresolved data type.

Source

pub fn enumerator(name: impl Into<String>) -> Self

An enumerator given by name.

Source

pub fn enumerator_value(value: impl Into<i128>) -> Self

An enumerator given by number.

Source

pub fn enumerator_with(name: impl Into<String>, value: impl Into<i128>) -> Self

An enumerator with name and number, the form decoding produces.

Source

pub fn array<T: Into<Value>>(items: impl IntoIterator<Item = T>) -> Self

An array of the given items.

Source

pub fn record<N: Into<String>, T: Into<Value>>( fields: impl IntoIterator<Item = (N, T)>, ) -> Self

A record of the given fields.

Source

pub fn variant( discriminant: impl Into<Enumerator>, value: Option<Value>, ) -> Self

A variant record whose alternative is not named; value is None for a discriminant without data.

Source

pub fn variant_named( discriminant: impl Into<Enumerator>, alternative: impl Into<String>, value: impl Into<Value>, ) -> Self

A variant record with a named alternative.

Source

pub fn kind(&self) -> &'static str

Name of the variant, for messages: integer, record…

Source

pub fn as_bool(&self) -> Option<bool>

The boolean of a Bool.

Source

pub fn as_integer(&self) -> Option<i128>

The number of an Integer, an Octet or an Enum that has one.

Source

pub fn as_i64(&self) -> Option<i64>

Value::as_integer when the number fits an i64.

Source

pub fn as_u64(&self) -> Option<u64>

Value::as_integer when the number fits a u64.

Source

pub fn as_f64(&self) -> Option<f64>

The number of a Float, or of an Integer converted to the nearest f64.

Source

pub fn as_char(&self) -> Option<char>

The character of a Char.

Source

pub fn as_str(&self) -> Option<&str>

The text of a String, or the name of an Enum that has one.

Source

pub fn as_bytes(&self) -> Option<&[u8]>

The octets of Bytes, Handle or Raw.

Source

pub fn as_enumerator(&self) -> Option<&Enumerator>

The enumerator of an Enum.

Source

pub fn as_variant(&self) -> Option<&VariantValue>

The content of a Variant.

Source

pub fn items(&self) -> Option<&[Value]>

The items of an Array.

Source

pub fn get(&self, index: usize) -> Option<&Value>

The item of an Array at index.

Source

pub fn fields(&self) -> Option<&[(String, Value)]>

The fields of a Record, in order.

Source

pub fn field(&self, name: &str) -> Option<&Value>

The field of a Record called name, or the value of a Variant whose alternative has that name.

Trait Implementations§

Source§

impl Clone for Value

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Value

Source§

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

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

impl<'de> Deserialize<'de> for Value

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for Value

A compact single-line form: {Name: "Joe", Rate: 1.5, Tags: [1, 2], State: Serving(2)}.

Strings and characters are quoted and escaped, octets are hexadecimal (0x0a0b, handle(0x..), raw(0x..)), enumerators are Name(number), variant records are Discriminant(number){Alternative: value}.

Source§

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

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

impl From<&[u8]> for Value

Opaque octets (Value::Bytes).

Source§

fn from(octets: &[u8]) -> Self

Converts to this type from the input type.
Source§

impl From<&str> for Value

Source§

fn from(text: &str) -> Self

Converts to this type from the input type.
Source§

impl From<Enumerator> for Value

Source§

fn from(enumerator: Enumerator) -> Self

Converts to this type from the input type.
Source§

impl From<String> for Value

Source§

fn from(text: String) -> Self

Converts to this type from the input type.
Source§

impl From<VariantValue> for Value

Source§

fn from(variant: VariantValue) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<Value>> for Value

Source§

fn from(items: Vec<Value>) -> Self

Converts to this type from the input type.
Source§

impl From<Vec<u8>> for Value

Opaque octets (Value::Bytes).

Source§

fn from(octets: Vec<u8>) -> Self

Converts to this type from the input type.
Source§

impl From<bool> for Value

Source§

fn from(value: bool) -> Self

Converts to this type from the input type.
Source§

impl From<char> for Value

Source§

fn from(value: char) -> Self

Converts to this type from the input type.
Source§

impl From<f32> for Value

Source§

fn from(value: f32) -> Self

Converts to this type from the input type.
Source§

impl From<f64> for Value

Source§

fn from(value: f64) -> Self

Converts to this type from the input type.
Source§

impl From<i8> for Value

Source§

fn from(value: i8) -> Self

Converts to this type from the input type.
Source§

impl From<i16> for Value

Source§

fn from(value: i16) -> Self

Converts to this type from the input type.
Source§

impl From<i32> for Value

Source§

fn from(value: i32) -> Self

Converts to this type from the input type.
Source§

impl From<i64> for Value

Source§

fn from(value: i64) -> Self

Converts to this type from the input type.
Source§

impl From<i128> for Value

Source§

fn from(value: i128) -> Self

Converts to this type from the input type.
Source§

impl From<u8> for Value

Source§

fn from(value: u8) -> Self

Converts to this type from the input type.
Source§

impl From<u16> for Value

Source§

fn from(value: u16) -> Self

Converts to this type from the input type.
Source§

impl From<u32> for Value

Source§

fn from(value: u32) -> Self

Converts to this type from the input type.
Source§

impl From<u64> for Value

Source§

fn from(value: u64) -> Self

Converts to this type from the input type.
Source§

impl FromIterator<Value> for Value

Source§

fn from_iter<I: IntoIterator<Item = Value>>(items: I) -> Self

Creates a value from an iterator. Read more
Source§

impl PartialEq for Value

Source§

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

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

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

Inequality operator !=. Read more
Source§

impl Serialize for Value

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Value

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where 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 T
where T: Clone,

Source§

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

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

Source§

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.