2 unstable releases

0.2.0 Feb 4, 2024
0.1.0 Nov 14, 2023

#726 in Web programming

Download history 10/week @ 2024-02-18 30/week @ 2024-02-25 1/week @ 2024-03-03 20/week @ 2024-03-17 3/week @ 2024-03-24 39/week @ 2024-03-31

62 downloads per month
Used in gemfreely

EUPL-1.2

53KB
787 lines

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.

Dependencies

~7–21MB
~302K SLoC