Updated examples to work, properly imported get_device() to root

This commit is contained in:
G2-Games 2024-02-02 00:16:50 -06:00
parent 6ac7479879
commit 2d732695e8
4 changed files with 7 additions and 88 deletions

View file

@ -1,11 +0,0 @@
install:
- appveyor-retry appveyor DownloadFile https://win.rustup.rs/ -FileName rustup-init.exe
- if not defined RUSTFLAGS rustup-init.exe -y --default-host x86_64-pc-windows-msvc --default-toolchain nightly
- set PATH=%PATH%;C:\Users\appveyor\.cargo\bin
- rustc -V
- cargo -V
build: false
test_script:
- cargo test --locked

3
.gitignore vendored
View file

@ -6,3 +6,6 @@ pkg/
wasm-pack.log wasm-pack.log
www www
.travis
.appveyor

View file

@ -1,69 +0,0 @@
language: rust
sudo: false
cache: cargo
matrix:
include:
# Builds with wasm-pack.
- rust: beta
env: RUST_BACKTRACE=1
addons:
firefox: latest
chrome: stable
before_script:
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update)
- (test -x $HOME/.cargo/bin/cargo-generate || cargo install --vers "^0.2" cargo-generate)
- cargo install-update -a
- curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh -s -- -f
script:
- cargo generate --git . --name testing
# Having a broken Cargo.toml (in that it has curlies in fields) anywhere
# in any of our parent dirs is problematic.
- mv Cargo.toml Cargo.toml.tmpl
- cd testing
- wasm-pack build
- wasm-pack test --chrome --firefox --headless
# Builds on nightly.
- rust: nightly
env: RUST_BACKTRACE=1
before_script:
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update)
- (test -x $HOME/.cargo/bin/cargo-generate || cargo install --vers "^0.2" cargo-generate)
- cargo install-update -a
- rustup target add wasm32-unknown-unknown
script:
- cargo generate --git . --name testing
- mv Cargo.toml Cargo.toml.tmpl
- cd testing
- cargo check
- cargo check --target wasm32-unknown-unknown
- cargo check --no-default-features
- cargo check --target wasm32-unknown-unknown --no-default-features
- cargo check --no-default-features --features console_error_panic_hook
- cargo check --target wasm32-unknown-unknown --no-default-features --features console_error_panic_hook
- cargo check --no-default-features --features "console_error_panic_hook wee_alloc"
- cargo check --target wasm32-unknown-unknown --no-default-features --features "console_error_panic_hook wee_alloc"
# Builds on beta.
- rust: beta
env: RUST_BACKTRACE=1
before_script:
- (test -x $HOME/.cargo/bin/cargo-install-update || cargo install cargo-update)
- (test -x $HOME/.cargo/bin/cargo-generate || cargo install --vers "^0.2" cargo-generate)
- cargo install-update -a
- rustup target add wasm32-unknown-unknown
script:
- cargo generate --git . --name testing
- mv Cargo.toml Cargo.toml.tmpl
- cd testing
- cargo check
- cargo check --target wasm32-unknown-unknown
- cargo check --no-default-features
- cargo check --target wasm32-unknown-unknown --no-default-features
- cargo check --no-default-features --features console_error_panic_hook
- cargo check --target wasm32-unknown-unknown --no-default-features --features console_error_panic_hook
# Note: no enabling the `wee_alloc` feature here because it requires
# nightly for now.

View file

@ -20,7 +20,7 @@
//! device_filter!{vendor_id: 0x054c, product_id: 0x00c9} //! device_filter!{vendor_id: 0x054c, product_id: 0x00c9}
//! ]; //! ];
//! //!
//! let device = cross_usb::get_device_filter(filter).await.expect("Failed to get device"); //! let device = cross_usb::get_device(filter).await.expect("Failed to get device");
//! //!
//! // Obtain an interface of the device //! // Obtain an interface of the device
//! let interface = device.open_interface(0).await.expect("Failed to open interface"); //! let interface = device.open_interface(0).await.expect("Failed to open interface");
@ -64,16 +64,12 @@ pub use crate::context::UsbInterface;
#[doc(inline)] #[doc(inline)]
pub use crate::context::DeviceFilter; pub use crate::context::DeviceFilter;
/// Gets a single device from the VendorID and ProductID
#[doc(inline)]
pub use crate::context::get_device;
/// Gets a single device from a list of VendorID and ProductIDs /// Gets a single device from a list of VendorID and ProductIDs
/// ///
/// ## Example /// ## Example
/// ```no_run /// ```no_run
/// # tokio_test::block_on(async { /// # tokio_test::block_on(async {
/// use cross_usb::{get_device_filter, DeviceFilter, device_filter}; /// use cross_usb::{get_device, DeviceFilter, device_filter};
/// ///
/// ///
/// let filter = vec![ /// let filter = vec![
@ -81,11 +77,11 @@ pub use crate::context::get_device;
/// device_filter!{vendor_id: 0x054c}, /// device_filter!{vendor_id: 0x054c},
/// ]; /// ];
/// ///
/// let device = get_device_filter(filter).await.expect("Could not find device in list"); /// let device = get_device(filter).await.expect("Could not find device in list");
/// # }) /// # })
/// ``` /// ```
#[doc(inline)] #[doc(inline)]
pub use crate::context::get_device_filter; pub use crate::context::get_device;
/// Macro to create a device filter easily from data. /// Macro to create a device filter easily from data.
/// ///