| Crates.io | nrfcloudlib |
| lib.rs | nrfcloudlib |
| version | 0.1.3 |
| created_at | 2025-05-22 11:15:37.210557+00 |
| updated_at | 2025-05-22 14:30:54.753913+00 |
| description | Library to interact with nrf cloud |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1685026 |
| size | 51,000 |
A Rust library for interacting with the NRF Cloud API.
Add this to your Cargo.toml:
[dependencies]
nrfcloudlib = "0.1.0"
use nrfcloudlib::NRFCloudClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = "your_api_token_here";
let client = NRFCloudClient::new(token);
// Simple GET request
let response = client.get("/devices").await?;
println!("Response: {}", response);
Ok(())
}
use nrfcloudlib::NRFCloudClient;
use serde::Serialize;
#[derive(Serialize)]
struct QueryParams {
limit: u32,
offset: u32,
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = "your_api_token_here";
let client = NRFCloudClient::new(token);
let params = QueryParams {
limit: 10,
offset: 0,
};
let response = client.get_with_params("/devices", ¶ms).await?;
println!("Response: {}", response);
Ok(())
}
use nrfcloudlib::NRFCloudClient;
use serde::Deserialize;
#[derive(Deserialize, Debug)]
struct Device {
id: String,
name: String,
// Add other fields as needed
}
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let token = "your_api_token_here";
let client = NRFCloudClient::new(token);
// GET request with JSON deserialization
let device: Device = client.get_json("/devices/device-id").await?;
println!("Device: {:?}", device);
Ok(())
}
This project is licensed under the MIT License - see the LICENSE file for details.