Crates.io | ntfy-api |
lib.rs | ntfy-api |
version | 0.1.1 |
source | src |
created_at | 2022-09-17 14:43:48.633 |
updated_at | 2022-09-18 10:13:47.523513 |
description | Rust bindings for ntfy API |
homepage | |
repository | https://github.com/tomaThomas/ntfy-api |
max_upload_size | |
id | 668199 |
size | 30,944 |
This library contains async rust bindings for the ntfy API. It uses reqwest as HTTP client.
Features implemented:
Cargo.toml
:
[dependencies]
tokio = { version = "1", features = ["full"] }
ntfy-api = "^0.1.1"
use ntfy_api::{NtfyApi, NtfyMsg};
#[tokio::main]
async fn main() {
let api = NtfyApi::default();
let ntfy_msg = NtfyMsg {
topic: String::from("alerts"),
message: Some(String::from("Message body")),
title: Some(String::from("New Message")),
tags: None,
priority: None,
attach: None,
filename: None,
click: None,
action: None,
};
match api.post(&ntfy_msg).await {
Ok(_) => println!("Message sent"),
Err(_) => println!("Error sending message"),
}
}
let api = NtfyApi::new(NtfySettings {
host: String::from("https://ntfysh/"),
authorization: Some(NtfyAuthorization {
username: String::from("username"),
password: String::from("password"),
}),
});