Skip to content

Commit

Permalink
Added overflow error variant
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed May 24, 2021
1 parent 900531e commit 4498462
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/device_handle/async_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ pub enum AsyncError {
Errno(&'static str, i32),
#[error("Transfer was cancelled")]
Cancelled,
#[error("Transfer could not fit into provided buffer with size of {0}")]
Overflow(usize),
}

struct AsyncTransfer<C: UsbContext> {
Expand Down Expand Up @@ -260,9 +262,7 @@ impl<C: UsbContext> AsyncPool<C> {
}
LIBUSB_TRANSFER_STALL => Err(E::Stall),
LIBUSB_TRANSFER_NO_DEVICE => Err(E::Disconnected),
LIBUSB_TRANSFER_OVERFLOW => {
panic!("Device sent more data than expected. Is this even possible when reading?")
}
LIBUSB_TRANSFER_OVERFLOW => Err(E::Overflow(transfer.buffer.len())),
_ => panic!("Found an unexpected error value for transfer status"),
};
match result {
Expand Down

0 comments on commit 4498462

Please sign in to comment.