#shindan #diagnosis #fortune-tellings

shindan-maker

A Rust library for interacting with ShindanMaker, the popular personality quiz service

24 releases

0.1.23 Nov 3, 2024
0.1.22 Nov 3, 2024
0.1.18 Oct 31, 2024

#91 in HTTP client

Download history 81/week @ 2024-10-06 474/week @ 2024-10-13 256/week @ 2024-10-20 1288/week @ 2024-10-27 328/week @ 2024-11-03 15/week @ 2024-11-10 13/week @ 2024-11-17 2/week @ 2024-11-24

560 downloads per month
Used in 2 crates

MIT/Apache

38KB
634 lines

ShindanMaker

github crates.io docs.rs

A Rust library for interacting with ShindanMaker, the popular personality quiz service.

  • Asynchronous API (Tokio)
  • Multi-domain support (JP, EN, CN, KR, TH)
  • Easy shindan submission and result parsing

Usage

[dependencies]
# default feature: ["segments"]
# optional features: ["html"], ["full"](segments + html)
shindan-maker = { version = "0.1", features = ["segments"] }

Example

Get title

use anyhow::Result;
use shindan_maker::{ShindanClient, ShindanDomain};

#[tokio::main]
async fn main() -> Result<()> {
    let client = ShindanClient::new(ShindanDomain::En)?; // Enum variant
    // let client = ShindanClient::new("Jp".parse()?)?; // String slice
    // let client = ShindanClient::new("EN".parse()?)?; // Case-insensitive
    // let client = ShindanClient::new(String::from("cn").parse()?)?; // String
    
    let title = client
        .get_title("1222992")
        .await?;
    
    assert_eq!("Fantasy Stats", title);
    Ok(())
}

Get segments (need "segments" feature)

use shindan_maker::{ShindanClient, ShindanDomain};

#[tokio::main]
async fn main() {
    let client = ShindanClient::new(ShindanDomain::En).unwrap();
    
    let (segments, title) = client
        .get_segments_with_title("1222992", "test_user")
        .await
        .unwrap();
    
    assert_eq!("Fantasy Stats", title);

    println!("Result title: {}", title);
    println!("Result text: {}", segments);
    
    println!("Result segments: {:#?}", segments);
}

Get HTML string (need "html" feature)

#[tokio::main]
async fn main() {
    #[cfg(feature = "html")]
    {
        use shindan_maker::{ShindanClient, ShindanDomain};
        let client = ShindanClient::new(ShindanDomain::En).unwrap();

        let (_html_str, title) = client
            .get_html_str_with_title("1222992", "test_user")
            .await
            .unwrap();

        assert_eq!("Fantasy Stats", title);
    }
}

License

Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this crate by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~9–22MB
~289K SLoC