Crate shindan_maker

Source
Expand description

GitHubcrates-iodocs-rs


A Rust library for interacting with ShindanMaker.

This library provides functionality to interact with various ShindanMaker domains, submit shindans, and parse results.

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

§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);
    }
}

Structs§

Segment
A segment of a shindan result.
Segments
A collection of segments.
ShindanClient
A client for interacting with ShindanMaker.

Enums§

ShindanDomain
A domain of ShindanMaker.