vapix
Client for AXIS Communications devices' VAPIX API. Bullet points:
- Async
#![forbid(unsafe_code)]
Features:
axis::Device
monitors and controls devices running AXIS firmware >= 5.00axis::Transport
decouples the library fromhttp
Optional features:
hyper
: HTTP viaaxis::HyperTransport
(enabled by default)
Basic use
// Instantiate a Device using `hyper` to communicate
let uri = from_static;
let device = new;
// Probe for VAPIX APIs supported by this device
let services = device.services.await?;
// If it supports the basic device info service...
if let Some = services.basic_device_info.as_ref else
Development
Use cargo test
, cargo check
, cargo clippy
, rustfmt
as usual. Open issues with issues, open PRs with changesets.
Many API tests use crate::mock_device()
, bound to a testing Transport
which goes to a block instead of to
the network. If you want to ensure that a function sends the right request or does the right thing with a certain
response, mock up a test which covers exactly that.
async
Tests covering safe-to-call APIs use create::test_with_devices()
to test against recordings of actual devices.
test_with_devices()
takes an async block which gets called repeatedly with various TestDevice
s, containing metadata
and a Device
. Tests are free to fail with Error::UnsupportedFeature
, but assertion failures or other errors will
cause the containing test to fail.
Recordings are produced using the test suite itself. When RECORD_DEVICE_URI
is set, each test_with_devices()
block
is additionally run against the live device, and a fixture is produced.
$ RECORD_DEVICE_URI=http://user:pass@1.2.3.4 cargo test
…
$ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
fixtures/recordings/ACCC8EF7DE6B v9.80.2.2.json
$
It is desirable to collect recordings from devices in the field, so test_with_devices()
blocks must avoid modifying
the device state.