Skip to content

Commit

Permalink
Removed some out of date documentation, cleaned things up
Browse files Browse the repository at this point in the history
  • Loading branch information
TheButlah committed May 18, 2021
1 parent b165387 commit 7c03321
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/device_handle/async_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,8 @@ impl<C: UsbContext> AsyncTransfer<C> {
result
}

// We need to invoke our closure using a c-style function, so we store the closure
// inside the custom user data field of the transfer struct, and then call the
// user provided closure from there.
// Step 4 of async API
// Part of step 4 of async API the transfer is finished being handled when
// `poll()` is called.
extern "system" fn transfer_cb(transfer: *mut ffi::libusb_transfer) {
// Safety: libusb should never make this null, so this is fine
let transfer = unsafe { &mut *transfer };
Expand All @@ -112,11 +110,17 @@ impl<C: UsbContext> AsyncTransfer<C> {
.push_back(transfer.pool_id);
}

// Step 3 of async API
fn submit(self: &mut Transfer<C>) -> Result<(), AsyncError> {
todo!()
}
}
// TODO: Figure out how to destroy transfers
impl<C: UsbContext> Drop for AsyncTransfer<C> {
fn drop(&mut self) {
// TODO: Figure out how to destroy transfers, which is step 5 of async API.
todo!()
}
}

/// Represents a pool of asynchronous transfers, that can be polled to completion
pub struct AsyncPool<C: UsbContext> {
Expand Down Expand Up @@ -158,7 +162,7 @@ impl<C: UsbContext> AsyncPool<C> {
}

/// Once a transfer is completed, check the c struct for errors, otherwise swap
/// buffers
/// buffers. Step 4 of async API.
fn handle_completed_transfer(
transfer: &mut Transfer<C>,
new_buf: Vec<u8>,
Expand Down

0 comments on commit 7c03321

Please sign in to comment.