1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
//! This crate provides C ABI interface for [battery](https://crates.io/crate/battery) crate.
//!
//! # Bindings generation
//!
//! Among library creation this crate generates `battery_ffi.h` file, enabled by default by `cbindgen` feature,
//! which might be useful for automatic bindings generation or just with plain `C`/`C++` development.
//!
//! After build it will be located somewhere at `target/*/build/battery-ffi-*/out/`,
//! depending on build profile (`debug`/`release`) and build hash.
//!
//! Disabling `cbindgen` feature might speed up compilation a little bit,
//! especially if you don't need the header file.
//!
//! # Examples
//!
//! ```c
//! #include "battery_ffi.h"
//!
//! void main() {
//!    Manager *manager = battery_manager_new();
//!    // .. handle `manager == NULL` here ..
//!    Batteries *iterator = battery_manager_iter(manager);
//!    // .. handle `iterator == NULL` here ..
//!    while (true) {
//!        Battery *battery = battery_iterator_next(iterator);
//!        // .. handle possible error here ..
//!        if (battery == NULL) {
//!            break;
//!        }
//!
//!        // Use some `battery_get_*` functions here
//!
//!        battery_free(battery);
//!    }
//!
//!    battery_iterator_free(iterator);
//!    battery_manager_free(manager);
//! }
//! ```
//!
//! Also, check the `examples/` directory in the repository for examples with C and Python.

// cbindgen==0.8.0 fails to export typedefs for opaque pointers
// from the battery crate, if this line is missing
extern crate battery as battery_lib;

mod battery;
mod errors;
mod iterator;
mod manager;
mod state;
mod technology;

/// Opaque struct representing battery manager.
///
/// End users should consider it as a some memory somewhere in the heap,
/// and work with it only via library methods.
pub type Manager = battery_lib::Manager;

/// Opaque struct representing batteries iterator.
///
/// End users should consider it as a some memory somewhere in the heap,
/// and work with it only via library methods.
pub type Batteries = battery_lib::Batteries;

/// Opaque struct representing battery.
///
/// End users should consider it as a some memory somewhere in the heap,
/// and work with it only via library methods.
pub type Battery = battery_lib::Battery;

pub use self::battery::*;
pub use self::errors::{battery_last_error_length, battery_last_error_message};
pub use self::iterator::*;
pub use self::manager::*;
pub use self::state::*;
pub use self::technology::*;