aboutsummaryrefslogtreecommitdiff
path: root/embassy-usb/src/driver.rs
diff options
context:
space:
mode:
authoralexmoon <[email protected]>2022-04-05 22:04:11 -0400
committerDario Nieuwenhuis <[email protected]>2022-04-09 01:48:17 +0200
commite867364d42477ecf3dc48e6fd787dff96cb6fadf (patch)
tree9bd64f21d1343b60186ce437f576c6a0fbbfdda6 /embassy-usb/src/driver.rs
parentb2cdaa56c1dca5ce293dad3b1e450f97bcf85251 (diff)
Unify ReadError and WriteError into EndpointError
Diffstat (limited to 'embassy-usb/src/driver.rs')
-rw-r--r--embassy-usb/src/driver.rs30
1 files changed, 9 insertions, 21 deletions
diff --git a/embassy-usb/src/driver.rs b/embassy-usb/src/driver.rs
index 01eb3d577..875ceafcb 100644
--- a/embassy-usb/src/driver.rs
+++ b/embassy-usb/src/driver.rs
@@ -130,7 +130,7 @@ pub trait Endpoint {
130} 130}
131 131
132pub trait EndpointOut: Endpoint { 132pub trait EndpointOut: Endpoint {
133 type ReadFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a 133 type ReadFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
134 where 134 where
135 Self: 'a; 135 Self: 'a;
136 136
@@ -145,10 +145,10 @@ pub trait ControlPipe {
145 type SetupFuture<'a>: Future<Output = Request> + 'a 145 type SetupFuture<'a>: Future<Output = Request> + 'a
146 where 146 where
147 Self: 'a; 147 Self: 'a;
148 type DataOutFuture<'a>: Future<Output = Result<usize, ReadError>> + 'a 148 type DataOutFuture<'a>: Future<Output = Result<usize, EndpointError>> + 'a
149 where 149 where
150 Self: 'a; 150 Self: 'a;
151 type DataInFuture<'a>: Future<Output = Result<(), WriteError>> + 'a 151 type DataInFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a
152 where 152 where
153 Self: 'a; 153 Self: 'a;
154 154
@@ -181,7 +181,7 @@ pub trait ControlPipe {
181} 181}
182 182
183pub trait EndpointIn: Endpoint { 183pub trait EndpointIn: Endpoint {
184 type WriteFuture<'a>: Future<Output = Result<(), WriteError>> + 'a 184 type WriteFuture<'a>: Future<Output = Result<(), EndpointError>> + 'a
185 where 185 where
186 Self: 'a; 186 Self: 'a;
187 187
@@ -216,24 +216,12 @@ pub struct Unsupported;
216 216
217#[derive(Copy, Clone, Eq, PartialEq, Debug)] 217#[derive(Copy, Clone, Eq, PartialEq, Debug)]
218#[cfg_attr(feature = "defmt", derive(defmt::Format))] 218#[cfg_attr(feature = "defmt", derive(defmt::Format))]
219/// Errors returned by [`EndpointIn::write`] 219/// Errors returned by [`EndpointIn::write`] and [`EndpointOut::read`]
220pub enum WriteError { 220pub enum EndpointError {
221 /// The packet is too long to fit in the 221 /// Either the packet to be written is too long to fit in the transmission
222 /// transmission buffer. This is generally an error in the class implementation, because the 222 /// buffer or the received packet is too long to fit in `buf`.
223 /// class shouldn't provide more data than the `max_packet_size` it specified when allocating
224 /// the endpoint.
225 BufferOverflow, 223 BufferOverflow,
226 Disabled,
227}
228 224
229#[derive(Copy, Clone, Eq, PartialEq, Debug)] 225 /// The endpoint is disabled.
230#[cfg_attr(feature = "defmt", derive(defmt::Format))]
231/// Errors returned by [`EndpointOut::read`]
232pub enum ReadError {
233 /// The received packet is too long to
234 /// fit in `buf`. This is generally an error in the class implementation, because the class
235 /// should use a buffer that is large enough for the `max_packet_size` it specified when
236 /// allocating the endpoint.
237 BufferOverflow,
238 Disabled, 226 Disabled,
239} 227}