Skip to content

[RFC] Rename send to write. #281

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/blocking/i2c.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ pub trait Write<A: AddressMode = SevenBitAddress> {
/// Error type
type Error;

/// Sends bytes to slave with address `address`
/// Writes bytes to slave with address `address`
///
/// # I2C Events (contract)
///
Expand All @@ -167,7 +167,7 @@ pub trait WriteIter<A: AddressMode = SevenBitAddress> {
/// Error type
type Error;

/// Sends bytes to slave with address `address`
/// Writes bytes to slave with address `address`
///
/// # I2C Events (contract)
///
Expand All @@ -182,7 +182,7 @@ pub trait WriteRead<A: AddressMode = SevenBitAddress> {
/// Error type
type Error;

/// Sends bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
/// single transaction*
///
/// # I2C Events (contract)
Expand Down Expand Up @@ -217,7 +217,7 @@ pub trait WriteIterRead<A: AddressMode = SevenBitAddress> {
/// Error type
type Error;

/// Sends bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
/// single transaction*
///
/// # I2C Events (contract)
Expand Down
12 changes: 6 additions & 6 deletions src/blocking/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pub trait Transfer<W> {
/// Error type
type Error;

/// Sends `words` to the slave. Returns the `words` received from the slave
/// Writes `words` to the slave. Returns the `words` received from the slave
fn transfer<'w>(&mut self, words: &'w mut [W]) -> Result<&'w [W], Self::Error>;
}

Expand All @@ -14,7 +14,7 @@ pub trait Write<W> {
/// Error type
type Error;

/// Sends `words` to the slave, ignoring all the incoming words
/// Writes `words` to the slave, ignoring all the incoming words
fn write(&mut self, words: &[W]) -> Result<(), Self::Error>;
}

Expand All @@ -23,7 +23,7 @@ pub trait WriteIter<W> {
/// Error type
type Error;

/// Sends `words` to the slave, ignoring all the incoming words
/// Writes `words` to the slave, ignoring all the incoming words
fn write_iter<WI>(&mut self, words: WI) -> Result<(), Self::Error>
where
WI: IntoIterator<Item = W>;
Expand All @@ -44,7 +44,7 @@ pub mod transfer {

fn transfer<'w>(&mut self, words: &'w mut [W]) -> Result<&'w [W], S::Error> {
for word in words.iter_mut() {
nb::block!(self.send(word.clone()))?;
nb::block!(self.write(word.clone()))?;
*word = nb::block!(self.read())?;
}

Expand All @@ -68,7 +68,7 @@ pub mod write {

fn write(&mut self, words: &[W]) -> Result<(), S::Error> {
for word in words {
nb::block!(self.send(word.clone()))?;
nb::block!(self.write(word.clone()))?;
nb::block!(self.read())?;
}

Expand All @@ -95,7 +95,7 @@ pub mod write_iter {
WI: IntoIterator<Item = W>,
{
for word in words.into_iter() {
nb::block!(self.send(word.clone()))?;
nb::block!(self.write(word.clone()))?;
nb::block!(self.read())?;
}

Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@
//!
//! ### Blocking mode
//!
//! An example of sending a string over the serial interface in a blocking
//! An example of writing a string over the serial interface in a blocking
//! fashion:
//!
//! ```
Expand Down
8 changes: 4 additions & 4 deletions src/nb/spi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
///
/// - It's the task of the user of this interface to manage the slave select lines
///
/// - Due to how full duplex SPI works each `read` call must be preceded by a `send` call.
/// - Due to how full duplex SPI works each `read` call must be preceded by a `write` call.
///
/// - `read` calls only return the data received with the last `send` call.
/// - `read` calls only return the data received with the last `write` call.
/// Previously received data is discarded
///
/// - Data is only guaranteed to be clocked out when the `read` call succeeds.
Expand All @@ -26,8 +26,8 @@ pub trait FullDuplex<Word> {
/// method.
fn read(&mut self) -> nb::Result<Word, Self::Error>;

/// Sends a word to the slave
fn send(&mut self, word: Word) -> nb::Result<(), Self::Error>;
/// Writes a word to the slave
fn write(&mut self, word: Word) -> nb::Result<(), Self::Error>;
}

/// Clock polarity
Expand Down