| Crates.io | writefreely_client |
| lib.rs | writefreely_client |
| version | 0.2.0 |
| created_at | 2023-11-14 22:25:01.897622+00 |
| updated_at | 2024-02-04 11:52:10.912236+00 |
| description | WriteFreely API client library |
| homepage | https://git.madhouse-project.org/algernon/writefreely-client.rs |
| repository | https://git.madhouse-project.org/algernon/writefreely-client.rs |
| max_upload_size | |
| id | 1035514 |
| size | 152,949 |
An opinionated WriteFreely API client library in Rust. It implements most of the documented API, with workarounds where necessary. It is not a strict implementation, but rather one that tries to be practical.
use writefreely_client::{error::Error, post::PostCreateRequest, Client};
const MARK: &str = "🐾";
#[tokio::main]
async fn main() -> Result<(), Error> {
let client = Client::new("http://localhost:8080")?
.login("username", "password")
.await?;
let posts = client.posts().list().await?;
let paw_prints = posts.iter().any(|post| post.body.contains(MARK));
if !paw_prints {
client
.posts()
.create(
PostCreateRequest::new()
.title("Footprints in the snow")
.body(MARK),
)
.await?;
println!("{} Woof.", MARK);
} else {
println!("{} Been there, done that. Woof, nevertheless.", MARK);
}
Ok(())
}
For more information, see the examples, or the documentation.