Skip to content

Commit 4ff73e7

Browse files
bors[bot]Dirbaio
andauthored
Merge #281
281: [RFC] Rename `send` to `write`. r=therealprof a=Dirbaio `send` and `write` are essentially synonymous. All the traits use `write`, except `nb::spi::FullDuplex`, which uses `send`. This PR renames it to `write`. Instances of `send` in the docs are also replaced, for consistency. Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents b60c39a + aef6ef6 commit 4ff73e7

File tree

4 files changed

+15
-15
lines changed

4 files changed

+15
-15
lines changed

src/blocking/i2c.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ pub trait Write<A: AddressMode = SevenBitAddress> {
143143
/// Error type
144144
type Error;
145145

146-
/// Sends bytes to slave with address `address`
146+
/// Writes bytes to slave with address `address`
147147
///
148148
/// # I2C Events (contract)
149149
///
@@ -167,7 +167,7 @@ pub trait WriteIter<A: AddressMode = SevenBitAddress> {
167167
/// Error type
168168
type Error;
169169

170-
/// Sends bytes to slave with address `address`
170+
/// Writes bytes to slave with address `address`
171171
///
172172
/// # I2C Events (contract)
173173
///
@@ -182,7 +182,7 @@ pub trait WriteRead<A: AddressMode = SevenBitAddress> {
182182
/// Error type
183183
type Error;
184184

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

220-
/// Sends bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
220+
/// Writes bytes to slave with address `address` and then reads enough bytes to fill `buffer` *in a
221221
/// single transaction*
222222
///
223223
/// # I2C Events (contract)

src/blocking/spi.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ pub trait Transfer<W> {
55
/// Error type
66
type Error;
77

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

@@ -14,7 +14,7 @@ pub trait Write<W> {
1414
/// Error type
1515
type Error;
1616

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

@@ -23,7 +23,7 @@ pub trait WriteIter<W> {
2323
/// Error type
2424
type Error;
2525

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

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

@@ -68,7 +68,7 @@ pub mod write {
6868

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

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

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@
193193
//!
194194
//! ### Blocking mode
195195
//!
196-
//! An example of sending a string over the serial interface in a blocking
196+
//! An example of writing a string over the serial interface in a blocking
197197
//! fashion:
198198
//!
199199
//! ```

src/nb/spi.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
///
77
/// - It's the task of the user of this interface to manage the slave select lines
88
///
9-
/// - Due to how full duplex SPI works each `read` call must be preceded by a `send` call.
9+
/// - Due to how full duplex SPI works each `read` call must be preceded by a `write` call.
1010
///
11-
/// - `read` calls only return the data received with the last `send` call.
11+
/// - `read` calls only return the data received with the last `write` call.
1212
/// Previously received data is discarded
1313
///
1414
/// - Data is only guaranteed to be clocked out when the `read` call succeeds.
@@ -26,8 +26,8 @@ pub trait FullDuplex<Word> {
2626
/// method.
2727
fn read(&mut self) -> nb::Result<Word, Self::Error>;
2828

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

3333
/// Clock polarity

0 commit comments

Comments
 (0)