writefreely_client

Crates.iowritefreely_client
lib.rswritefreely_client
version0.2.0
created_at2023-11-14 22:25:01.897622+00
updated_at2024-02-04 11:52:10.912236+00
descriptionWriteFreely API client library
homepagehttps://git.madhouse-project.org/algernon/writefreely-client.rs
repositoryhttps://git.madhouse-project.org/algernon/writefreely-client.rs
max_upload_size
id1035514
size152,949
Gergely Nagy (algernon)

documentation

README

writefreely-client.rs

Build status Tested with: writefreely 0.15.0 Documentation Crates.io release

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.

Example

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.

Commit count: 0

cargo fmt