Skip to content

Commit 0ab50cd

Browse files
bors[bot]Dirbaio
andauthored
Merge #280
280: [RFC] blocking/serial: make method naming consistent r=therealprof a=Dirbaio `blocking::serial::Write`'s methods are named `bwrite_all` and `bflush`. - the `b` prefix indicates blocking (I guess?). However no other blocking trait method has this prefix. - the `_all` suffix indicates it writes a slice instead of a single word (I guess?). However, no other trait method that writes a slice has this suffix. To make them consistent, this PR renames them to `write` and `flush`. Co-authored-by: Dario Nieuwenhuis <[email protected]>
2 parents 4ff73e7 + 5ff8d54 commit 0ab50cd

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1717
- Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking).
1818
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
1919
importing the `nb` crate directly in dependendent crates.
20+
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.
2021

2122
## [v1.0.0-alpha.4] - 2020-11-11
2223

src/blocking/serial.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ pub trait Write<Word> {
1010
/// An implementation can choose to buffer the write, returning `Ok(())`
1111
/// after the complete slice has been written to a buffer, but before all
1212
/// words have been sent via the serial interface. To make sure that
13-
/// everything has been sent, call [`bflush`] after this function returns.
13+
/// everything has been sent, call [`flush`] after this function returns.
1414
///
15-
/// [`bflush`]: #tymethod.bflush
16-
fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;
15+
/// [`flush`]: #tymethod.flush
16+
fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;
1717

1818
/// Block until the serial interface has sent all buffered words
19-
fn bflush(&mut self) -> Result<(), Self::Error>;
19+
fn flush(&mut self) -> Result<(), Self::Error>;
2020
}
2121

2222
/// Blocking serial write
@@ -38,15 +38,15 @@ pub mod write {
3838
{
3939
type Error = S::Error;
4040

41-
fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error> {
41+
fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error> {
4242
for word in buffer {
4343
nb::block!(self.write(word.clone()))?;
4444
}
4545

4646
Ok(())
4747
}
4848

49-
fn bflush(&mut self) -> Result<(), Self::Error> {
49+
fn flush(&mut self) -> Result<(), Self::Error> {
5050
nb::block!(self.flush())?;
5151
Ok(())
5252
}

0 commit comments

Comments
 (0)