OptrisOptrisDocumentation

Documentation/OTC SDK/optris_sdk — Rust API referencev12.0

faults — functions and constants

Breaking a camera on purpose, so your error handling can be tested.

Nothing here is a feature of a camera and nothing here does anything to one. Every call refuses a real device outright and works only on a simulated camera, so a call that reached a production build stops being silent the first time it runs against hardware.

That is also why these are free functions in a module of their own rather than methods on crate::Camera, mirroring the ABI's own naming: these entry points carry a testing prefix and deliberately not the imager one every camera call has, because they are not things a camera does; they are things a test does to a camera.

What this does not do. It does not make a camera come back. A simulated camera has no device to re-open, so the SDK's attempts against it fail and the schedule runs to crate::ReconnectPhase::GaveUp. That is the right shape for testing what an application shows during an outage and when recovery is abandoned, and the wrong tool for testing what it does when a camera returns; that needs a simulated camera which genuinely re-opens, and does not exist yet.

pub fn fake_connection_event(

Publish a connection state the camera is not in.

Drives whatever Camera::on_connection_status and Camera::on_reconnect are subscribed to, exactly as a real event would, so an application can exercise the branch it has never seen.

Errors

Returns crate::Status::NotSupported for a real camera, a recording or a still, and crate::Status::InvalidArgument for ConnectionStatus::Connecting or ConnectionStatus::Connected. Those two are refused: they are the SDK's own answers about work it did, and a handler told the camera is back when nothing opened is being misled in the direction that hides a fault rather than inventing one.

pub fn fake_connection_failed(camera: &mut Camera, message: &str) -> Result<()>

Pretend an open failed.

Errors

As fake_connection_event.

pub fn fake_connection_lost(camera: &mut Camera, message: &str) -> Result<()>

Pretend the link was lost.

Errors

As fake_connection_event.

pub fn fake_connection_stalled(camera: &mut Camera, message: &str) -> Result<()>

Pretend frames stopped arriving while the link stayed up.

Errors

As fake_connection_event.

pub fn fake_disconnect(camera: &mut Camera, message: &str) -> Result<()>

Pretend the camera was disconnected deliberately.

ConnectionStatus::Disconnected is where a cancelled attempt rests and ConnectionStatus::Failed is where a failed one rests: the distinction Connect relies on, so both are worth being able to produce in a test.

Errors

As fake_connection_event.