Struct co2mon::OpenOptions[][src]

pub struct OpenOptions { /* fields omitted */ }
Expand description

Sensor open options.

Opens the first available device with the USB Vendor ID 0x04d9 and Product ID 0xa052, a 0 encryption key and a 5 seconds timeout.

Normally there’s no need to change the encryption key.

Example

let sensor = OpenOptions::new()
    .timeout(Some(Duration::from_secs(10)))
    .open()?;

Implementations

Creates a new set of options to be configured.

The defaults are opening the first connected sensor and a timeout of 5 seconds.

Example

let sensor = OpenOptions::new()
    .timeout(Some(Duration::from_secs(10)))
    .open()?;

Sets the serial number of the sensor device to open.

The serial number appears to be the firmware version.

Example

let sensor = OpenOptions::new()
    .with_serial_number("1.40")
    .open()?;

Sets the path to the sensor device to open.

Example

let sensor = OpenOptions::new()
    .with_path(CString::new("/dev/bus/usb/001/004")?)
    .open()?;

Sets the encryption key.

The key is used to encrypt the communication with the sensor, but changing it is probably not very useful.

Example

let sensor = OpenOptions::new()
    .with_key([0x62, 0xea, 0x1d, 0x4f, 0x14, 0xfa, 0xe5, 0x6c])
    .open()?;

Sets the read timeout.

Example

let sensor = OpenOptions::new()
    .timeout(Some(Duration::from_secs(10)))
    .open()?;

Opens the sensor.

Example

let sensor = OpenOptions::new()
    .timeout(Some(Duration::from_secs(10)))
    .open()?;

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.