nvapi_sys/
lib.rs

1#![allow(non_camel_case_types, non_snake_case)]
2#![doc(html_root_url = "http://arcnmx.github.io/nvapi-rs/")]
3
4#[cfg(windows)]
5extern crate winapi;
6#[macro_use]
7extern crate bitflags;
8
9#[cfg(feature = "serde_derive")]
10#[macro_use]
11extern crate serde_derive;
12
13#[macro_use]
14mod macros;
15
16#[macro_use]
17mod debug_array;
18pub use debug_array::Array;
19
20pub mod nvid;
21pub mod nvapi;
22pub mod status;
23pub mod types;
24
25/// NVAPI Handles - These handles are retrieved from various calls and passed in
26/// to others in NvAPI These are meant to be opaque types. Do not assume they
27/// correspond to indices, HDCs, display indexes or anything else.
28///
29/// Most handles remain valid until a display re-configuration (display mode set)
30/// or GPU reconfiguration (going into or out of SLI modes) occurs. If
31/// NVAPI_HANDLE_INVALIDATED is received by an app, it should discard all
32/// handles, and re-enumerate them.
33pub mod handles;
34
35/// The display driver APIs are used to retrieve information about the display driver.
36pub mod driverapi;
37
38/// The GPU APIs retrieve and control various attributes of the GPU, such as outputs, VBIOS revision, APG rate, frame buffer size, and thermal settings.
39pub mod gpu;
40
41/// I2C API - Provides ability to read or write data using I2C protocol.
42/// These APIs allow I2C access only to DDC monitors
43pub mod i2c;
44
45#[cfg(windows)]
46pub mod dx;
47
48pub mod dispcontrol;
49
50pub use nvid::Api;
51pub use nvapi::nvapi_QueryInterface;
52pub use types::*;
53pub use status::{NvAPI_Status, Status};
54
55use std::result;
56
57/// The result of a fallible NVAPI call.
58pub type Result<T> = result::Result<T, Status>;
59
60/// Treat `NVAPI_OK` as `Ok(())` and all else as an `Err(..)`.
61pub fn status_result(status: NvAPI_Status) -> Result<()> {
62    match status {
63        status::NVAPI_OK => Ok(()),
64        status => Err(Status::from_raw(status).unwrap_or(Status::Error)),
65    }
66}
67
68/// Error type indicating a raw value is out of the range of known enum values.
69#[derive(Debug, Copy, Clone, Default)]
70pub struct ArgumentRangeError;
71
72impl From<ArgumentRangeError> for Status {
73    fn from(_: ArgumentRangeError) -> Self {
74        Status::ArgumentExceedMaxSize
75    }
76}
77
78// TODO: NvAPI_SYS_GetChipSetInfo