summaryrefslogtreecommitdiff
path: root/embassy-usb
diff options
context:
space:
mode:
authoralexmoon <alex.r.moon@gmail.com>2022-04-05 22:04:11 -0400
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-04-09 01:48:17 +0200
commite867364d42477ecf3dc48e6fd787dff96cb6fadf (patch)
tree9bd64f21d1343b60186ce437f576c6a0fbbfdda6 /embassy-usb
parentb2cdaa56c1dca5ce293dad3b1e450f97bcf85251 (diff)
downloadembassy-e867364d42477ecf3dc48e6fd787dff96cb6fadf.zip
Unify ReadError and WriteError into EndpointError
Diffstat (limited to 'embassy-usb')
-rw-r--r--embassy-usb/src/control.rs4
-rw-r--r--embassy-usb/src/driver.rs30
2 files changed, 11 insertions, 23 deletions
diff --git a/embassy-usb/src/control.rs b/embassy-usb/src/control.rs
index 7c46812b..a613f114 100644
--- a/embassy-usb/src/control.rs
+++ b/embassy-usb/src/control.rs
@@ -1,7 +1,7 @@
use core::mem;
use crate::descriptor::DescriptorWriter;
-use crate::driver::{self, ReadError};
+use crate::driver::{self, EndpointError};
use crate::DEFAULT_ALTERNATE_SETTING;
use super::types::*;
@@ -253,7 +253,7 @@ impl<C: driver::ControlPipe> ControlPipe<C> {
&mut self,
buf: &'a mut [u8],
stage: DataOutStage,
- ) -> Result<(&'a [u8], StatusStage), ReadError> {
+ ) -> Result<(&'a [u8], StatusStage), EndpointError> {
if stage.length == 0 {
Ok((&[], StatusStage {}))
} else {
diff --git a/embassy-usb/src/driver.rs b/embassy-usb/src/driver.rs
index 01eb3d57..875ceafc 100644
--- a/embassy-usb/src/driver.rs
+++ b/embassy-usb/src/driver.rs
@@ -130,7 +130,7 @@ pub trait Endpoint {
}
pub trait EndpointOut: Endpoint {
- type ReadFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a
+ type ReadFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
where
Self: 'a;
@@ -145,10 +145,10 @@ pub trait ControlPipe {
type SetupFuture<'a>: Future<Output = Request> + 'a
where
Self: 'a;
- type DataOutFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a
+ type DataOutFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
where
Self: 'a;
- type DataInFuture<'a>: Future<Output = Result<(), WriteError>> + 'a
+ type DataInFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a
where
Self: 'a;
@@ -181,7 +181,7 @@ pub trait ControlPipe {
}
pub trait EndpointIn: Endpoint {
- type WriteFuture<'a>: Future<Output = Result<(), WriteError>> + 'a
+ type WriteFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a
where
Self: 'a;
@@ -216,24 +216,12 @@ pub struct Unsupported;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
-/// Errors returned by [`EndpointIn::write`]
-pub enum WriteError {
- /// The packet is too long to fit in the
- /// transmission buffer. This is generally an error in the class implementation, because the
- /// class shouldn't provide more data than the `max_packet_size` it specified when allocating
- /// the endpoint.
+/// Errors returned by [`EndpointIn::write`] and [`EndpointOut::read`]
+pub enum EndpointError {
+ /// Either the packet to be written is too long to fit in the transmission
+ /// buffer or the received packet is too long to fit in `buf`.
BufferOverflow,
- Disabled,
-}
-#[derive(Copy, Clone, Eq, PartialEq, Debug)]
-#[cfg_attr(feature = "defmt", derive(defmt::Format))]
-/// Errors returned by [`EndpointOut::read`]
-pub enum ReadError {
- /// The received packet is too long to
- /// fit in `buf`. This is generally an error in the class implementation, because the class
- /// should use a buffer that is large enough for the `max_packet_size` it specified when
- /// allocating the endpoint.
- BufferOverflow,
+ /// The endpoint is disabled.
Disabled,
}