Struct Unsigned

Source
pub struct Unsigned { /* private fields */ }
Expand description

A type modeling multiple bits.

The length number of bits represent an unsigned integer which is multiplied with the factor, and summed up with the offset. The endian controls the exact sequence of selected bits.

The following formula summarizes the relation between the bit sequence, factor, and offset:

result = bits_unsigned * factor + offset

Implementations§

Source§

impl Unsigned

Source

pub fn new( start: u16, length: u16, factor: f64, offset: f64, endian: Endian, ) -> Result<Unsigned, LengthError>

Constructs a new Unsigned signal.

§Example
use cantools::signals::Unsigned;
use cantools::utils::Endian;
let sig = Unsigned::new(0, 8, 42.0, 1337.0, Endian::Little).unwrap();

Trait Implementations§

Source§

impl Debug for Unsigned

Source§

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

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

impl Decode<f64> for Unsigned

Source§

fn decode<D: CANRead>(&self, data: &D) -> T

Decodes the data. Read more
Source§

impl Default for Unsigned

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl DefaultDecode<f64> for Unsigned

Source§

fn default_decode<D: CANRead>(&self, data: &D) -> T

Tries to decode a value. If the data is not decodable, a default value is returned. Otherwise, the decoded value is returned.
Source§

impl Encode<f64> for Unsigned

Source§

fn encode<D: CANWrite>(&self, data: &mut D, value: T)

Encodes value into the CAN-bus data data. Read more
Source§

impl Max for Unsigned

Source§

type Item = f64

The type of return value of a call to max.
Source§

fn max(&self) -> Self::Item

The maximal value producible by the implementor.
Source§

impl Min for Unsigned

Source§

type Item = f64

The type of return value of a call to min.
Source§

fn min(&self) -> Self::Item

The minimal value producible by the implementor.
Source§

impl PartialEq for Unsigned

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl TryDecode<f64> for Unsigned

Source§

type Error = DecodeError

A type modeling the different possible failures of the decoding.
Source§

fn try_decode<D: CANRead>(&self, data: &D) -> Result<f64, Self::Error>

Tries to decode a value.
Source§

impl TryEncode<f64> for Unsigned

Source§

type Error = EncodeError

A type modelling the different possible failures of the encoding.
Source§

fn try_encode<D: CANWrite>( &self, data: &mut D, value: f64, ) -> Result<(), Self::Error>

Tries to encode value into data.
Source§

impl StructuralPartialEq for Unsigned

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.