Skip to main content

GetterStateDeviceWrapper

Struct GetterStateDeviceWrapper 

Source
pub struct GetterStateDeviceWrapper<'a, T: Getter<State, E>, E: Copy + Debug> { /* private fields */ }
Expand description

Connect a Getter<State, E> to a Terminal<E> for use as an encoder in the device system.

Implementations§

Source§

impl<'a, T: Getter<State, E>, E: Copy + Debug> GetterStateDeviceWrapper<'a, T, E>

Source

pub const fn new(inner: T) -> Self

Constructor for GetterStateDeviceWrapper.

Examples found in repository?
examples/devices.rs (line 77)
67fn main() {
68    println!("Commanding Motor to {:?}", COMMAND);
69    println!(
70        "K values are {:?}",
71        K_VALUES.get_k_values(PositionDerivative::from(COMMAND))
72    );
73    let motor = Motor::new();
74    let mut motor_wrapper =
75        devices::wrappers::PIDWrapper::new(motor, Time(0), STATE, COMMAND, K_VALUES);
76    let encoder = Encoder::default();
77    let mut encoder_wrapper = devices::wrappers::GetterStateDeviceWrapper::new(encoder);
78    connect(motor_wrapper.get_terminal(), encoder_wrapper.get_terminal());
79    for _ in 0..5 {
80        motor_wrapper.update().unwrap();
81        encoder_wrapper.update().unwrap();
82    }
83}
Source

pub fn get_terminal(&self) -> &'a RefCell<Terminal<'a, E>>

Get a reference to this wrapper’s terminal.

Examples found in repository?
examples/devices.rs (line 78)
67fn main() {
68    println!("Commanding Motor to {:?}", COMMAND);
69    println!(
70        "K values are {:?}",
71        K_VALUES.get_k_values(PositionDerivative::from(COMMAND))
72    );
73    let motor = Motor::new();
74    let mut motor_wrapper =
75        devices::wrappers::PIDWrapper::new(motor, Time(0), STATE, COMMAND, K_VALUES);
76    let encoder = Encoder::default();
77    let mut encoder_wrapper = devices::wrappers::GetterStateDeviceWrapper::new(encoder);
78    connect(motor_wrapper.get_terminal(), encoder_wrapper.get_terminal());
79    for _ in 0..5 {
80        motor_wrapper.update().unwrap();
81        encoder_wrapper.update().unwrap();
82    }
83}

Trait Implementations§

Source§

impl<T: Getter<State, E>, E: Copy + Debug> Device<E> for GetterStateDeviceWrapper<'_, T, E>

Source§

fn update_terminals(&mut self) -> NothingOrError<E>

Call only the update methods of owned terminals and do not update anything else with the device.
Source§

impl<T: Getter<State, E>, E: Copy + Debug> Updatable<E> for GetterStateDeviceWrapper<'_, T, E>

Source§

fn update(&mut self) -> NothingOrError<E>

As this trait is very generic, exactly what this does will be very dependent on the implementor.

Auto Trait Implementations§

§

impl<'a, T, E> !Freeze for GetterStateDeviceWrapper<'a, T, E>

§

impl<'a, T, E> !RefUnwindSafe for GetterStateDeviceWrapper<'a, T, E>

§

impl<'a, T, E> !Send for GetterStateDeviceWrapper<'a, T, E>

§

impl<'a, T, E> !Sync for GetterStateDeviceWrapper<'a, T, E>

§

impl<'a, T, E> Unpin for GetterStateDeviceWrapper<'a, T, E>
where T: Unpin,

§

impl<'a, T, E> UnsafeUnpin for GetterStateDeviceWrapper<'a, T, E>
where T: UnsafeUnpin,

§

impl<'a, T, E> !UnwindSafe for GetterStateDeviceWrapper<'a, T, E>

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.