[][src]Struct spectrusty_core::bus::DynamicSerdeBus

#[repr(transparent)]pub struct DynamicSerdeBus<S, D: BusDevice>(_, _);

A wrapper for DynamicBus that is able to serialize and deserialize together with currently attached dynamic devices.

Use this type instead of DynamicBus when specifying crate::chip::ControlUnit::BusDevice or BusDevice::NextDevice.

A type that implements SerializeDynDevice and DeserializeDynDevice must be declared as generic parameter S.

Methods from Deref<Target = DynamicBus<D>>

pub fn len(&self) -> usize[src]

Returns the number of attached devices.

pub fn is_empty(&self) -> bool[src]

Returns true if there are no devices in the dynamic chain. Otherwise returns false.

pub fn append_device<B>(&mut self, device: B) -> usize where
    B: Into<BoxNamedDynDevice<D::Timestamp>>, 
[src]

Appends an instance of a device at the end of the daisy-chain. Returns its index position in the dynamic device chain.

pub fn remove_device(&mut self) -> Option<BoxNamedDynDevice<D::Timestamp>>[src]

Removes the last device from the dynamic daisy-chain and returns an instance of the boxed dynamic object.

pub fn swap_remove_device(
    &mut self,
    index: usize
) -> BoxNamedDynDevice<D::Timestamp>
[src]

Replaces a device at the given index position and returns it.

The removed device is replaced by the last device of the chain.

Panics

Panics if a device doesn't exist at index.

pub fn replace_device<B>(
    &mut self,
    index: usize,
    device: B
) -> BoxNamedDynDevice<D::Timestamp> where
    B: Into<BoxNamedDynDevice<D::Timestamp>>, 
[src]

Replaces a device at the given index position. Returns the previous device occupying the replaced spot.

Panics

Panics if a device doesn't exist at index.

pub fn clear(&mut self)[src]

Removes all dynamic devices from the dynamic daisy-chain.

pub fn get_device_ref(
    &self,
    index: usize
) -> Option<&NamedDynDevice<D::Timestamp>>
[src]

Returns a reference to a dynamic device at index position in the dynamic daisy-chain.

pub fn get_device_mut(
    &mut self,
    index: usize
) -> Option<&mut NamedDynDevice<D::Timestamp>>
[src]

Returns a mutable reference to a dynamic device at index position in the dynamic daisy-chain.

pub fn remove_as_device<B>(&mut self) -> Option<Box<B>> where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Removes the last device from the dynamic daisy-chain.

Panics

Panics if a device is not of a type given as parameter B.

pub fn swap_remove_as_device<B>(&mut self, index: usize) -> Box<B> where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Replaces a device at the given index and returns it.

The removed device is replaced by the last device of the chain.

Panics

Panics if a device doesn't exist at index or if a device is not of a type given as parameter B.

pub fn as_device_ref<B>(&self, index: usize) -> &B where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Returns a reference to a device of a type B at index in the dynamic daisy-chain.

Panics

Panics if a device doesn't exist at index or if a device is not of a type given as parameter B.

pub fn as_device_mut<B>(&mut self, index: usize) -> &mut B where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Returns a mutable reference to a device of a type B at index in the dynamic daisy-chain.

Panics

Panics if a device doesn't exist at index or if a device is not of a type given as parameter B.

pub fn is_device<B>(&self, index: usize) -> bool where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Returns true if a device at index is of a type given as parameter B.

pub fn position_device<B>(&self) -> Option<usize> where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Searches for a first device of a type given as parameter B, returning its index.

pub fn find_device_ref<B>(&self) -> Option<&B> where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Searches for a first device of a type given as parameter B, returning a reference to a device.

pub fn find_device_mut<B>(&mut self) -> Option<&mut B> where
    B: NamedBusDevice<D::Timestamp> + 'static, 
[src]

Searches for a first device of a type given as parameter B, returning a mutable reference to a device.

Trait Implementations

impl<S, D: BusDevice> BusDevice for DynamicSerdeBus<S, D> where
    D: BusDevice,
    D::Timestamp: Copy + Debug
[src]

type Timestamp = D::Timestamp

A type used as a time-stamp.

type NextDevice = D

A type of the next device in a daisy chain.

impl<S, D> Debug for DynamicSerdeBus<S, D> where
    D: BusDevice + Debug,
    D::Timestamp: Debug
[src]

impl<S, D> Default for DynamicSerdeBus<S, D> where
    D: BusDevice + Default,
    D::Timestamp: Default
[src]

impl<S, D: BusDevice> Deref for DynamicSerdeBus<S, D>[src]

type Target = DynamicBus<D>

The resulting type after dereferencing.

impl<S, D: BusDevice> DerefMut for DynamicSerdeBus<S, D>[src]

impl<'de, DDD, B> Deserialize<'de> for DynamicSerdeBus<DDD, B> where
    DDD: DeserializeDynDevice<'de> + 'de,
    B: BusDevice + Deserialize<'de> + Default,
    B::Timestamp: Default + TimestampOps + Deserialize<'de> + 'static, 
[src]

impl<S, D: BusDevice> From<DynamicBus<D>> for DynamicSerdeBus<S, D>[src]

impl<S, D: BusDevice> From<DynamicSerdeBus<S, D>> for DynamicBus<D>[src]

impl<SDD, B> Serialize for DynamicSerdeBus<SDD, B> where
    SDD: SerializeDynDevice,
    B: BusDevice + Serialize,
    B::Timestamp: TimestampOps + Serialize + 'static, 
[src]

Auto Trait Implementations

impl<S, D> !RefUnwindSafe for DynamicSerdeBus<S, D>[src]

impl<S, D> !Send for DynamicSerdeBus<S, D>[src]

impl<S, D> !Sync for DynamicSerdeBus<S, D>[src]

impl<S, D> Unpin for DynamicSerdeBus<S, D> where
    D: Unpin,
    S: Unpin
[src]

impl<S, D> !UnwindSafe for DynamicSerdeBus<S, D>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.