CameraConfig
pub struct CameraConfig
A camera's whole configuration, taken off it and held in memory.
The in-memory half of the pair Camera::save_config and
Camera::load_config_checked make through a file. It is
what an application wants when it means to put a camera back the
way it found it at the end of a run, or try something and undo it,
and has no business writing to a disk to do that.
Why this is opaque rather than a struct of fields
A configuration carries the measuring regions, the alarm rules and the canvas placement as well as the scalar settings, none of which fit in a fixed struct. A struct that could only carry the scalars would silently delete a caller's regions every time it was applied, which is the worst possible shape for a "restore what was there" type.
The opacity is also what makes a record complete, which saving setting by setting can never be: a setting added in a later SDK rides along inside the record, so code that round-trips one is never quietly missing the new one and never has to be revisited.
A record is a snapshot. Nothing about it tracks the camera afterwards, so one taken before a change is exactly what puts the camera back after it.
Examples
# fn main() -> optris_sdk::Result<()> {
use optris_sdk::Camera;
let mut camera = Camera::open()?;
let before = camera.get_config()?;
// ... change whatever the experiment needs ...
camera.apply_config(&before, false).map_err(|(e, _report)| e)?;
# Ok(())
# }
CameraConfig — methods
pub fn serial(&self) -> Result<String>
The serial of the camera this record was read from, or an empty string if it carries none.
This is what require_matching_serial is compared against in
Camera::apply_config, and it is exposed so an application
can show the operator which camera a record came from before
it commits to applying it.
Errors
Returns Status::InvalidHandle if the record is not valid.
Status::InvalidHandle: crate::Status::InvalidHandle
pub fn canvas(&self) -> Result<crate::Canvas>
The canvas this record carries.
The canvas is part of a saved configuration alongside the regions, deliberately: restoring the measuring areas of a turned, zoomed view without restoring the view would put every one of them in the wrong place.
A record written before the canvas existed loads an empty canvas (a pass-through) rather than failing, so reading this from an older file is safe and answers "nothing was placed".