Crates.io | bloodbath |
lib.rs | bloodbath |
version | 0.1.4 |
source | src |
created_at | 2023-04-27 08:42:27.715527 |
updated_at | 2024-05-26 16:32:16.014628 |
description | This is a Rust implementation of the Bloodbath event scheduling library. |
homepage | |
repository | |
max_upload_size | |
id | 850161 |
size | 10,644 |
This is a Rust implementation of the Bloodbath event scheduling library. This library is to be moved here.
To use this library in your Rust project, add the following to your Cargo.toml
file:
[dependencies]
bloodbath = "0.1.3"
tokio = { version = "1", features = ["full"] }
Or run the following command to add the dependency to your project's Cargo.toml
file:
cargo add bloodbath
Here's a basic example of how to use the bloodbath-rust library:
//[your_project_name]/src/main.rs
use bloodbath::{Bloodbath, Event, BloodbathEvent};
use std::sync::Arc;
#[tokio::main]
async fn main() {
// Create a Bloodbath instance with your API key
let bloodbath = Arc::new(Bloodbath::new("your_api_key"));
// Schedule an event
let timestamp_str = "2023-04-27T12:00:00Z";
let timestamp = chrono::DateTime::parse_from_rfc3339(timestamp_str)
.unwrap()
.timestamp();
let event = BloodbathEvent {
scheduled_for: timestamp,
headers: Default::default(),
method: "POST".to_owned(), // or simply Default::default(),
body: "some body content".to_owned(), // or simply Default::default(),
endpoint: "https://api.acme.com/path".to_owned(),
};
let result = Event::schedule(&bloodbath, &event).await;
match result {
Ok(event) => {
println!("Event scheduled successfully:");
println!("ID: {}", event.id);
println!("Name: {}", event.name);
println!("Timestamp: {}", event.timestamp);
},
Err(e) => eprintln!("Error scheduling event: {:?}", e),
}
}
Replace "your_api_key" with your Bloodbath API key.
IMPORTANT: To use latest unpublished version direct from source, add to your Cargo.toml
file:
[dependencies]
bloodbath = { git = "https://github.com/avosa/bloodbath-rust.git" }
tokio = { version = "1", features = ["full"] }
Testing:
cargo test --lib
Bloodbath is a powerful library that simplifies event scheduling and management. For more information, see the official documentation.