Enum crazyflie_lib::Value[][src]

pub enum Value {
    U8(u8),
    U16(u16),
    U32(u32),
    U64(u64),
    I8(i8),
    I16(i16),
    I32(i32),
    I64(i64),
    F16(f16),
    F32(f32),
    F64(f64),
}
Expand description

Typed data value

This enum supports all the data types that can be exchanged with the Crazyflie using the log and param subsystems.

A function allows to convert a [u8] to a Value and the Into<Vec> trait is implemented to convert a Value into a vector of bytes.

The TryFrom trait is implemented for all matching rust primitive type. There is only direct conversion implemented. For example the following is OK:

let v:u32 = Value::U32(42).try_into().unwrap();

However the following will panic:

let v:u32 = Value::U8(42).try_into().unwrap();

Variants

U8(u8)

u8 value

Tuple Fields of U8

0: u8
U16(u16)

u16 value

Tuple Fields of U16

0: u16
U32(u32)

u32 value

Tuple Fields of U32

0: u32
U64(u64)

u64 value

Tuple Fields of U64

0: u64
I8(i8)

i8 value

Tuple Fields of I8

0: i8
I16(i16)

i16 value

Tuple Fields of I16

0: i16
I32(i32)

i32 value

Tuple Fields of I32

0: i32
I64(i64)

i64 value

Tuple Fields of I64

0: i64
F16(f16)

f16 value

Tuple Fields of F16

0: f16
F32(f32)

f32 value

Tuple Fields of F32

0: f32
F64(f64)

f64 value

Tuple Fields of F64

0: f64

Implementations

Convert a &[u8] slice to a Value. The length of the slice must match the length of the value type, otherwise an error will be returned.

Convert a Value to a f64.

This conversion is lossless in most case but can be lossy if the value is a u64: a f64 cannot accurately store large values of a u64.

Make a Value from a f64 and a ValueType

This function allows to construct any type of value from a f64.

The conversion has possibility to be lossy in a couple of cases:

  • When making an integer, the value is truncated to the number of bit of the parameter
    • Example: Setting 257 to a u8 variable will set it to the value 1
  • Similarly floating point precision will be truncated to the parameter precision. Rounding is undefined.
  • Making a floating point outside the range of the parameter is undefined.
  • It is not possible to represent accurately a u64 parameter in a f64.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.