Enum dsdl_parser::CastMode [] [src]

pub enum CastMode {
    Saturated,
    Truncated,
}

Cast mode defines the rules of conversion from the native value of a certain programming language to the serialized field value.

Cast mode may be left undefined, in which case the default will be used.

Variants

This is the default cast mode, which will be used if the attribute definition does not specify the cast mode explicitly.

For integers, it prevents an integer overflow - for example, attempting to write 0x44 to a 4-bit field will result in a bitfield value of 0x0F. For floating point values, it prevents overflow when casting to a lower precision floating point representation - for example, 65536.0 will be converted to a float16 as 65504.0; infinity will be preserved.

For integers, it discards the excess most significant bits - for example, attempting to write 0x44 to a 4-bit field will produce 0x04. For floating point values, overflow during downcasting will produce an infinity.

Trait Implementations

impl Display for CastMode
[src]

[src]

Formats the value using the given formatter. Read more

impl Clone for CastMode
[src]

[src]

Returns a copy of the value. Read more

1.0.0
[src]

Performs copy-assignment from source. Read more

impl Copy for CastMode
[src]

impl Debug for CastMode
[src]

[src]

Formats the value using the given formatter.

impl PartialEq for CastMode
[src]

[src]

This method tests for self and other values to be equal, and is used by ==. Read more

1.0.0
[src]

This method tests for !=.

impl Eq for CastMode
[src]

impl FromStr for CastMode
[src]

The associated error which can be returned from parsing.

[src]

Parses a string s to return a value of this type. Read more