DynamicSerdeBus

Struct DynamicSerdeBus 

Source
pub struct DynamicSerdeBus<S, D: BusDevice>(/* private fields */);
Expand description

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>>§

Source

pub fn len(&self) -> usize

Returns the number of attached devices.

Source

pub fn is_empty(&self) -> bool

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

Source

pub fn append_device<B>(&mut self, device: B) -> usize

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

Source

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

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

Source

pub fn swap_remove_device( &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.

Source

pub fn replace_device<B>( &mut self, index: usize, device: B, ) -> 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.

Source

pub fn clear(&mut self)

Removes all dynamic devices from the dynamic daisy-chain.

Source

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

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

Source

pub fn get_device_mut( &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.

Source

pub fn remove_as_device<B>(&mut self) -> Option<Box<B>>
where 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.

Source

pub fn swap_remove_as_device<B>(&mut self, index: usize) -> Box<B>
where 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.

Source

pub fn as_device_ref<B>(&self, index: usize) -> &B
where 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.

Source

pub fn as_device_mut<B>(&mut self, index: usize) -> &mut B
where 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.

Source

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

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

Source

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

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

Source

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

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

Source

pub fn find_device_mut<B>(&mut self) -> Option<&mut B>
where 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§

Source§

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

Source§

type Timestamp = <D as BusDevice>::Timestamp

A type used as a time-stamp.
Source§

type NextDevice = D

A type of the next device in a daisy chain.
Source§

fn next_device_mut(&mut self) -> &mut Self::NextDevice

Returns a mutable reference to the next device.
Source§

fn next_device_ref(&self) -> &Self::NextDevice

Returns a reference to the next device.
Source§

fn into_next_device(self) -> Self::NextDevice

Destructs self and returns the instance of the next bus device.
Source§

fn reset(&mut self, timestamp: Self::Timestamp)

Resets the device and all devices in this chain. Read more
Source§

fn update_timestamp(&mut self, timestamp: Self::Timestamp)

This method should be called near the end of each frame. Read more
Source§

fn next_frame(&mut self, timestamp: Self::Timestamp)

This method should be called just before the T-state counter of the control unit is wrapped when preparing for the next frame. Read more
Source§

fn read_io( &mut self, port: u16, timestamp: Self::Timestamp, ) -> Option<(u8, Option<NonZeroU16>)>

This method is called by the control unit during an I/O read cycle. Read more
Source§

fn write_io( &mut self, port: u16, data: u8, timestamp: Self::Timestamp, ) -> Option<u16>

This method is called by the control unit during an I/O write cycle. Read more
Source§

fn type_id(&self) -> TypeId
where Self: 'static,

Gets the TypeId of self. Read more
Source§

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

Source§

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

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

impl<S, D> Default for DynamicSerdeBus<S, D>

Source§

fn default() -> Self

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

impl<S, D: BusDevice> Deref for DynamicSerdeBus<S, D>

Source§

type Target = DynamicBus<D>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<S, D: BusDevice> DerefMut for DynamicSerdeBus<S, D>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

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,

Source§

fn deserialize<D: Deserializer<'de>>(deserializer: D) -> Result<Self, D::Error>

Deserialize this value from the given Serde deserializer. Read more
Source§

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

Source§

fn from(dynamic_bus: DynamicBus<D>) -> Self

Converts to this type from the input type.
Source§

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

Source§

fn from(dynamic_bus: DynamicSerdeBus<S, D>) -> Self

Converts to this type from the input type.
Source§

impl<SDD, B> Serialize for DynamicSerdeBus<SDD, B>

Source§

fn serialize<S: Serializer>(&self, serializer: S) -> Result<S::Ok, S::Error>

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<S, D> Freeze for DynamicSerdeBus<S, D>
where D: Freeze,

§

impl<S, D> !RefUnwindSafe for DynamicSerdeBus<S, D>

§

impl<S, D> !Send for DynamicSerdeBus<S, D>

§

impl<S, D> !Sync for DynamicSerdeBus<S, D>

§

impl<S, D> Unpin for DynamicSerdeBus<S, D>
where D: Unpin, S: Unpin,

§

impl<S, D> !UnwindSafe for DynamicSerdeBus<S, D>

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<S, T> IntoSample<S> for T
where S: FromSample<T>,

Source§

fn into_sample(self) -> S

Convert to S a sample type from self.
Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.
Source§

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