pub enum AttrValue {
Show 26 variants Boolean(bool), UChar(u8), Short(i16), UShort(u16), Long(i32), ULong(u32), Long64(i64), ULong64(u64), Float(f32), Double(f64), String(Vec<u8>), State(TangoDevState), Encoded(DevEncoded), BooleanArray(Vec<bool>), UCharArray(Vec<u8>), ShortArray(Vec<i16>), UShortArray(Vec<u16>), LongArray(Vec<i32>), ULongArray(Vec<u32>), Long64Array(Vec<i64>), ULong64Array(Vec<u64>), FloatArray(Vec<f32>), DoubleArray(Vec<f64>), StringArray(Vec<Vec<u8>>), StateArray(Vec<TangoDevState>), EncodedArray(Vec<DevEncoded>),
}
Expand description

Represents the value of an attribute.

The normal way to construct this is to use the desired variant directly.

Variants§

§

Boolean(bool)

§

UChar(u8)

§

Short(i16)

§

UShort(u16)

§

Long(i32)

§

ULong(u32)

§

Long64(i64)

§

ULong64(u64)

§

Float(f32)

§

Double(f64)

§

String(Vec<u8>)

§

State(TangoDevState)

§

Encoded(DevEncoded)

§

BooleanArray(Vec<bool>)

§

UCharArray(Vec<u8>)

§

ShortArray(Vec<i16>)

§

UShortArray(Vec<u16>)

§

LongArray(Vec<i32>)

§

ULongArray(Vec<u32>)

§

Long64Array(Vec<i64>)

§

ULong64Array(Vec<u64>)

§

FloatArray(Vec<f32>)

§

DoubleArray(Vec<f64>)

§

StringArray(Vec<Vec<u8>>)

§

StateArray(Vec<TangoDevState>)

§

EncodedArray(Vec<DevEncoded>)

Implementations§

source§

impl AttrValue

source

pub fn len(&self) -> usize

Return the number of items in this value.

1 for simple values, the length for arrays.

source

pub fn convert(self, to: TangoDataType) -> Result<Self, Self>

Try to convert this data into a different type.

If the conversion fails or is impossible, Self is returned unchanged in the Err variant.

source

pub fn into_bool(self) -> Result<bool, Self>

Return the value if it’s a bool or integral 0 or 1. Otherwise return Err(self).

source

pub fn into_i32(self) -> Result<i32, Self>

Return the value as i32 if it’s an integral type and inside i32 limits. Otherwise return Err(self).

source

pub fn into_i64(self) -> Result<i64, Self>

Return the value as i64 if it’s a an integral type and inside i64 limits. Otherwise return Err(self).

source

pub fn into_u32(self) -> Result<u32, Self>

Return the value as u32 if it’s an integral type and inside u32 limits. Otherwise return Err(self).

source

pub fn into_u64(self) -> Result<u64, Self>

Return the value as u64 if it’s an integral type and inside u64 limits. Otherwise return Err(self).

source

pub fn into_f32(self) -> Result<f32, Self>

Return the value as f32 if it’s a numeric type. Otherwise return Err(self).

source

pub fn into_f64(self) -> Result<f64, Self>

Return the value as f64 if it’s a numeric type. Otherwise return Err(self).

source

pub fn into_bytes(self) -> Result<Vec<u8>, Self>

Return the value as a byte array if it’s a string, DevEncoded or UCharArray. Otherwise return Err(self).

source

pub fn into_string(self) -> Result<String, Self>

Return the value as a byte array if it’s a string, DevEncoded or UCharArray, and decodable as UTF-8. Otherwise return Err(self).

Trait Implementations§

source§

impl Clone for AttrValue

source§

fn clone(&self) -> AttrValue

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 Debug for AttrValue

source§

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

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

impl<'de> Deserialize<'de> for AttrValue

source§

fn deserialize<D: Deserializer<'de>>(deser: D) -> Result<AttrValue, D::Error>

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

impl Display for AttrValue

source§

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

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

impl LowerExp for AttrValue

source§

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

Formats the value using the given formatter.
source§

impl LowerHex for AttrValue

source§

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

Formats the value using the given formatter.
source§

impl PartialEq<AttrValue> for AttrValue

source§

fn eq(&self, other: &AttrValue) -> 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 Serialize for AttrValue

source§

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

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

impl UpperExp for AttrValue

source§

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

Formats the value using the given formatter.
source§

impl UpperHex for AttrValue

source§

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

Formats the value using the given formatter.
source§

impl StructuralPartialEq for AttrValue

Auto Trait Implementations§

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,

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. 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.
const: unstable · 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.
const: unstable · source§

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

Performs the conversion.
source§

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