Struct spectrusty::peripherals::serial::Rs232Io
source · pub struct Rs232Io<T, R, W> {
pub reader: R,
pub writer: W,
/* private fields */
}
Expand description
The RS-232 serial port remote device.
Both ZX Spectrum’s Interface 1 and 128k for communication via RS-232 use DTR
and CTS
lines to signal
readiness and transmit or receive data using one START
bit, 8 data bits, and 2 STOP
bits without parity.
Spectrum’s 128k ROM routines can send and transmit data with the following baud rates: 50, 110, 300, 600, 1200, 2400, 4800, 9600 (default). The ZX Interface 1 allows additionally for 19200.
This type implements SerialPortDevice that transforms Spectrum’s RS-232 signals to byte streams and vice-versa.
Rs232Io
actually doesn’t emulate any particular device, but rather writes transmitted bytes to a
generic writer and reads bytes from a generic reader.
Both reader
and writer
need to be implemented by the user and its types should be provided as
generics R
and W
accordingly.
An implementation of TimestampOps is required to be provided as T
for timestamp calculations.
The baud rate is not needed to be set up, as it is being auto-detected.
You may read the currently transmitted data baud rate for reading and writing using Rs232Io::baud_rate.
Panics
The Read and Write implementation methods must not return any error other than ErrorKind::Interrupted. If any other error is returned the SerialPortDevice implementation will panic.
Fields§
§reader: R
A reader providing data received by Spectrum.
writer: W
A writer receiving data from Spectrum.
Implementations§
Trait Implementations§
source§impl<'de, T, R, W> Deserialize<'de> for Rs232Io<T, R, W>where
T: Deserialize<'de>,
R: Deserialize<'de> + Default,
W: Deserialize<'de> + Default,
impl<'de, T, R, W> Deserialize<'de> for Rs232Io<T, R, W>where
T: Deserialize<'de>,
R: Deserialize<'de> + Default,
W: Deserialize<'de> + Default,
source§fn deserialize<__D>(
__deserializer: __D
) -> Result<Rs232Io<T, R, W>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D
) -> Result<Rs232Io<T, R, W>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
source§impl<T, R, W> SerialPortDevice for Rs232Io<T, R, W>where
T: TimestampOps,
R: Read,
W: Write,
impl<T, R, W> SerialPortDevice for Rs232Io<T, R, W>where
T: TimestampOps,
R: Read,
W: Write,
type Timestamp = T
source§fn write_data(
&mut self,
rxd: DataState,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> ControlState
fn write_data(
&mut self,
rxd: DataState,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> ControlState
source§fn poll_ready(
&mut self,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> ControlState
fn poll_ready(
&mut self,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> ControlState
DTR
line state.source§fn update_cts(
&mut self,
cts: ControlState,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
)
fn update_cts(
&mut self,
cts: ControlState,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
)
CTS
line state. Read moresource§fn read_data(
&mut self,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> DataState
fn read_data(
&mut self,
timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
) -> DataState
TxD
line state. Read moresource§fn next_frame(
&mut self,
end_timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
)
fn next_frame(
&mut self,
end_timestamp: <Rs232Io<T, R, W> as SerialPortDevice>::Timestamp
)
Auto Trait Implementations§
impl<T, R, W> RefUnwindSafe for Rs232Io<T, R, W>where
R: RefUnwindSafe,
T: RefUnwindSafe,
W: RefUnwindSafe,
impl<T, R, W> Send for Rs232Io<T, R, W>where
R: Send,
T: Send,
W: Send,
impl<T, R, W> Sync for Rs232Io<T, R, W>where
R: Sync,
T: Sync,
W: Sync,
impl<T, R, W> Unpin for Rs232Io<T, R, W>where
R: Unpin,
T: Unpin,
W: Unpin,
impl<T, R, W> UnwindSafe for Rs232Io<T, R, W>where
R: UnwindSafe,
T: UnwindSafe,
W: UnwindSafe,
Blanket Implementations§
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
source§impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
impl<S, T> IntoSample<S> for Twhere
S: FromSample<T>,
source§fn into_sample(self) -> S
fn into_sample(self) -> S
S
a sample type from self
.§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> Rwhere
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> Rwhere
Self: BorrowMut<B>,
B: 'a + ?Sized,
R: 'a,
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> Rwhere
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> Rwhere
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Selfwhere
Self: Deref<Target = T>,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Selfwhere
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Selfwhere
Self: Borrow<B>,
B: ?Sized,
.tap_borrow()
only in debug builds, and is erased in release
builds. Read more§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Selfwhere
Self: BorrowMut<B>,
B: ?Sized,
.tap_borrow_mut()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Selfwhere
Self: AsRef<R>,
R: ?Sized,
.tap_ref()
only in debug builds, and is erased in release
builds. Read more§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Selfwhere
Self: AsMut<R>,
R: ?Sized,
.tap_ref_mut()
only in debug builds, and is erased in release
builds. Read more