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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
//! # LibreLinkUp API Client
//!
//! Unofficial Rust client for the LibreLinkUp API — fetch CGM (Continuous Glucose Monitor)
//! data from FreeStyle Libre 2/3 devices through Abbott's sharing service.
//!
//! ## Main API
//!
//! - **[`LibreLinkUpClient`]** — main client; use [`simple`](LibreLinkUpClient::simple) or [`new`](LibreLinkUpClient::new) to construct.
//! - **[`LibreLinkUpClient::get_country_config`](LibreLinkUpClient::get_country_config)** — unauthenticated country/region config.
//! - **[`ClientConfig`]** — client configuration (username, password, region, etc.).
//! - **[`ConnectionIdentifier`]** — how to pick a patient when following multiple (e.g. by name).
//! - **[`LibreLinkUpError`]** — error type for all operations.
//! - **[`Result<T>`](Result)** — alias for `Result<T, LibreLinkUpError>`.
//!
//! ## Response and model types
//!
//! Re-exported at crate root: [`ReadResponse`], [`ReadRawResponse`], [`UserResponse`], [`AccountResponse`],
//! [`LogbookResponse`], [`NotificationSettingsResponse`], [`CountryConfigResponse`], [`LibreCgmData`],
//! [`TrendType`], [`GlucoseItem`], [`Connection`], [`Region`]. See the [models] module for the full set.
//!
//! ## Quick Start
//!
//! ```no_run
//! use libre_link_up_api_client::LibreLinkUpClient;
//!
//! #[tokio::main]
//! async fn main() -> Result<(), Box<dyn std::error::Error>> {
//! // Create a client with your credentials
//! let client = LibreLinkUpClient::simple(
//! "your_email@example.com".to_string(),
//! "your_password".to_string(),
//! None,
//! )?;
//!
//! // Read current glucose data
//! let data = client.read().await?;
//!
//! println!("Current glucose: {:.1} mg/dL", data.current.value);
//! println!("Trend: {:?}", data.current.trend);
//! println!("Historical readings: {}", data.history.len());
//!
//! Ok(())
//! }
//! ```
//!
//! ## Advanced Usage
//!
//! ### Regional Endpoints
//!
//! ```no_run
//! use libre_link_up_api_client::{LibreLinkUpClient, ClientConfig, Region};
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let config = ClientConfig {
//! username: "email@example.com".to_string(),
//! password: "password".to_string(),
//! api_version: None,
//! region: Some(Region::EU),
//! connection_identifier: None,
//! };
//!
//! let client = LibreLinkUpClient::new(config)?;
//! let data = client.read().await?;
//! # Ok(())
//! # }
//! ```
//!
//! ### Raw API Access
//!
//! ```no_run
//! use libre_link_up_api_client::LibreLinkUpClient;
//!
//! # async fn example() -> Result<(), Box<dyn std::error::Error>> {
//! let client = LibreLinkUpClient::simple(
//! "email@example.com".to_string(),
//! "password".to_string(),
//! None,
//! )?;
//!
//! // Get raw API responses
//! let raw = client.read_raw().await?;
//! println!("Connection: {:?}", raw.connection);
//! println!("Active sensors: {:?}", raw.active_sensors);
//! # Ok(())
//! # }
//! ```
//!
//! ## Error Handling
//!
//! All API operations return [`Result<T, LibreLinkUpError>`](LibreLinkUpError).
//!
//! ```no_run
//! use libre_link_up_api_client::{LibreLinkUpClient, LibreLinkUpError};
//!
//! # async fn example() {
//! let client = LibreLinkUpClient::simple(
//! "email@example.com".to_string(),
//! "password".to_string(),
//! None,
//! );
//!
//! match client {
//! Ok(client) => match client.read().await {
//! Ok(data) => println!("Success: {:.1} mg/dL", data.current.value),
//! Err(LibreLinkUpError::NoConnections) => {
//! eprintln!("No patients followed. Start following someone in the app.");
//! }
//! Err(e) => eprintln!("API error: {}", e),
//! },
//! Err(e) => eprintln!("Client error: {}", e),
//! }
//! # }
//! ```
pub use ;
pub use ;
pub use ;