Skip to content
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

[RFC] blocking/serial: make method naming consistent #280

Merged
merged 2 commits into from
Jun 29, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- Moved all traits into two modules depending on the execution model: `blocking` and `nb` (non-blocking).
- Re-export `nb::{block!, Error, Result}` to avoid version mismatches. These should be used instead of
importing the `nb` crate directly in dependendent crates.
- `blocking::Serial`: renamed `bwrite_all` to `write`, `bflush` to `flush.

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

Expand Down
12 changes: 6 additions & 6 deletions src/blocking/serial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ pub trait Write<Word> {
/// An implementation can choose to buffer the write, returning `Ok(())`
/// after the complete slice has been written to a buffer, but before all
/// words have been sent via the serial interface. To make sure that
/// everything has been sent, call [`bflush`] after this function returns.
/// everything has been sent, call [`flush`] after this function returns.
///
/// [`bflush`]: #tymethod.bflush
fn bwrite_all(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;
/// [`flush`]: #tymethod.flush
fn write(&mut self, buffer: &[Word]) -> Result<(), Self::Error>;

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

/// Blocking serial write
Expand All @@ -38,15 +38,15 @@ pub mod write {
{
type Error = S::Error;

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

Ok(())
}

fn bflush(&mut self) -> Result<(), Self::Error> {
fn flush(&mut self) -> Result<(), Self::Error> {
nb::block!(self.flush())?;
Ok(())
}
Expand Down