[][src]Struct spectrusty_core::bus::DynamicBus

pub struct DynamicBus<D: BusDevice> { /* fields omitted */ }

A pseudo bus device that allows for adding and removing devices of different types at run time.

The penalty is that the access to the devices must be done using a virtual call dispatch. Also the device of this type can't be cloned (nor the ControlUnit with this device attached).

DynamicBus<D> implements BusDevice itself, so obviously it's possible to declare a statically dispatched downstream BusDevice as its parameter D.

Currently only types implementing BusDevice that are directly terminated with NullDevice can be attached as dynamically dispatched objects.

Implementations

impl<D> DynamicBus<D> where
    D: BusDevice
[src]

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.

impl<D> DynamicBus<D> where
    D: BusDevice,
    D::Timestamp: 'static, 
[src]

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<D: BusDevice> AsMut<[Box<dyn NamedBusDevice<<D as BusDevice>::Timestamp, NextDevice = NullDevice<<D as BusDevice>::Timestamp>, Timestamp = <D as BusDevice>::Timestamp> + 'static, Global>]> for DynamicBus<D>[src]

impl<D: BusDevice> AsRef<[Box<dyn NamedBusDevice<<D as BusDevice>::Timestamp, NextDevice = NullDevice<<D as BusDevice>::Timestamp>, Timestamp = <D as BusDevice>::Timestamp> + 'static, Global>]> for DynamicBus<D>[src]

impl<D> BusDevice for DynamicBus<D> where
    D: BusDevice,
    D::Timestamp: Debug + Copy
[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<D: Debug + BusDevice> Debug for DynamicBus<D> where
    D::Timestamp: Debug
[src]

impl<D: Default + BusDevice> Default for DynamicBus<D> where
    D::Timestamp: Default
[src]

impl<'de, D: BusDevice> Deserialize<'de> for DynamicBus<D> where
    D: Deserialize<'de>,
    D: Default
[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<D: BusDevice> Index<usize> for DynamicBus<D>[src]

type Output = NamedDynDevice<D::Timestamp>

The returned type after indexing.

impl<D: BusDevice> IndexMut<usize> for DynamicBus<D>[src]

impl<'a, D: BusDevice> IntoIterator for &'a DynamicBus<D>[src]

type Item = &'a BoxNamedDynDevice<D::Timestamp>

The type of the elements being iterated over.

type IntoIter = Iter<'a, BoxNamedDynDevice<D::Timestamp>>

Which kind of iterator are we turning this into?

impl<'a, D: BusDevice> IntoIterator for &'a mut DynamicBus<D>[src]

type Item = &'a mut BoxNamedDynDevice<D::Timestamp>

The type of the elements being iterated over.

type IntoIter = IterMut<'a, BoxNamedDynDevice<D::Timestamp>>

Which kind of iterator are we turning this into?

impl<D: BusDevice> IntoIterator for DynamicBus<D>[src]

type Item = BoxNamedDynDevice<D::Timestamp>

The type of the elements being iterated over.

type IntoIter = IntoIter<BoxNamedDynDevice<D::Timestamp>>

Which kind of iterator are we turning this into?

impl<D: BusDevice> Serialize for DynamicBus<D> where
    D: Serialize
[src]

Auto Trait Implementations

impl<D> !RefUnwindSafe for DynamicBus<D>[src]

impl<D> !Send for DynamicBus<D>[src]

impl<D> !Sync for DynamicBus<D>[src]

impl<D> Unpin for DynamicBus<D> where
    D: Unpin
[src]

impl<D> !UnwindSafe for DynamicBus<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.