Skip to main content

viva_u3v/
lib.rs

1//! USB3 Vision transport layer.
2//!
3//! Provides device discovery, GenCP-over-USB control, bootstrap register
4//! parsing, and bulk-endpoint streaming for USB3 Vision cameras.
5//!
6//! The `usb` feature flag enables actual USB hardware access via `rusb`.
7//! Without it, only protocol types, encoding, and mock-based testing compile.
8
9pub mod bootstrap;
10pub mod control;
11pub mod descriptor;
12pub mod device;
13pub mod discovery;
14pub mod stream;
15pub mod usb;
16
17use viva_gencp::StatusCode;
18
19/// Errors produced by the USB3 Vision transport layer.
20#[derive(Debug, thiserror::Error)]
21#[non_exhaustive]
22pub enum U3vError {
23    /// Low-level USB I/O error.
24    #[error("usb: {0}")]
25    Usb(String),
26
27    /// Wire-format or protocol violation.
28    #[error("protocol: {0}")]
29    Protocol(String),
30
31    /// A bulk transfer or control transaction timed out.
32    #[error("timeout")]
33    Timeout,
34
35    /// GenCP-level decode error.
36    #[error("gencp: {0}")]
37    GenCp(#[from] viva_gencp::GenCpError),
38
39    /// Device returned a non-success status code.
40    #[error("device status: {status:?}")]
41    Status { status: StatusCode },
42
43    /// USB descriptor parsing failed.
44    #[error("descriptor: {0}")]
45    Descriptor(String),
46}