[−][src]Struct spectrusty_core::bus::DynamicBus
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]
D: BusDevice,
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]
B: Into<BoxNamedDynDevice<D::Timestamp>>,
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]
&mut self,
index: usize
) -> BoxNamedDynDevice<D::Timestamp>
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]
&mut self,
index: usize,
device: B
) -> BoxNamedDynDevice<D::Timestamp> where
B: Into<BoxNamedDynDevice<D::Timestamp>>,
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]
&self,
index: usize
) -> Option<&NamedDynDevice<D::Timestamp>>
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]
&mut self,
index: usize
) -> Option<&mut NamedDynDevice<D::Timestamp>>
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]
D: BusDevice,
D::Timestamp: 'static,
pub fn remove_as_device<B>(&mut self) -> Option<Box<B>> where
B: NamedBusDevice<D::Timestamp> + 'static, [src]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
B: NamedBusDevice<D::Timestamp> + 'static,
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]
D: BusDevice,
D::Timestamp: Debug + Copy,
type Timestamp = D::Timestamp
A type used as a time-stamp.
type NextDevice = D
A type of the next device in a daisy chain.
pub fn next_device_mut(&mut self) -> &mut Self::NextDevice[src]
pub fn next_device_ref(&self) -> &Self::NextDevice[src]
pub fn into_next_device(self) -> Self::NextDevice[src]
pub fn reset(&mut self, timestamp: Self::Timestamp)[src]
pub fn update_timestamp(&mut self, timestamp: Self::Timestamp)[src]
pub fn next_frame(&mut self, timestamp: Self::Timestamp)[src]
pub fn read_io(
&mut self,
port: u16,
timestamp: Self::Timestamp
) -> Option<(u8, Option<NonZeroU16>)>[src]
&mut self,
port: u16,
timestamp: Self::Timestamp
) -> Option<(u8, Option<NonZeroU16>)>
pub fn write_io(
&mut self,
port: u16,
data: u8,
timestamp: Self::Timestamp
) -> Option<u16>[src]
&mut self,
port: u16,
data: u8,
timestamp: Self::Timestamp
) -> Option<u16>
pub fn type_id(&self) -> TypeId where
Self: 'static, [src]
Self: 'static,
impl<D: Debug + BusDevice> Debug for DynamicBus<D> where
D::Timestamp: Debug, [src]
D::Timestamp: Debug,
impl<D: Default + BusDevice> Default for DynamicBus<D> where
D::Timestamp: Default, [src]
D::Timestamp: Default,
pub fn default() -> DynamicBus<D>[src]
impl<'de, D: BusDevice> Deserialize<'de> for DynamicBus<D> where
D: Deserialize<'de>,
D: Default, [src]
D: Deserialize<'de>,
D: Default,
pub fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>, [src]
__D: Deserializer<'de>,
impl<S, D: BusDevice> From<DynamicBus<D>> for DynamicSerdeBus<S, D>[src]
pub fn from(dynamic_bus: DynamicBus<D>) -> Self[src]
impl<S, D: BusDevice> From<DynamicSerdeBus<S, D>> for DynamicBus<D>[src]
pub fn from(dynamic_bus: DynamicSerdeBus<S, D>) -> Self[src]
impl<D: BusDevice> Index<usize> for DynamicBus<D>[src]
type Output = NamedDynDevice<D::Timestamp>
The returned type after indexing.
pub fn index(&self, index: usize) -> &Self::Output[src]
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?
pub fn into_iter(self) -> Self::IntoIter[src]
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?
pub fn into_iter(self) -> Self::IntoIter[src]
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?
pub fn into_iter(self) -> Self::IntoIter[src]
impl<D: BusDevice> Serialize for DynamicBus<D> where
D: Serialize, [src]
D: Serialize,
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]
D: Unpin,
impl<D> !UnwindSafe for DynamicBus<D>[src]
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>, [src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,