Shindan Maker
A Rust library for interacting with Shindan Maker, the popular personality quiz service.
Features
- Multi-domain support (JP, EN, CN, KR, TH)
- Asynchronous API
- Easy shindan submission and result parsing
Installation
[dependencies]
shindan-maker = "0.1.0"
Example
Here's a comprehensive example demonstrating how to use the Shindan Maker library:
use shindan_maker::{ShindanClient, ShindanDomain, ShindanResult, Segment};
use std::error::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn Error>> {
let client = ShindanClient::new(ShindanDomain::En)?;
let shindan_id = "1221154";
let title = client.get_title(shindan_id).await?;
println!("Shindan title: {}", title);
let result = client.submit_shindan(shindan_id, "Rust Developer").await?;
if let ShindanResult::Text { title, content } = result {
println!("Result title: {}", title);
for segment in content.iter().filter_map(|s| s.get_text()) {
println!("Text: {}", segment);
}
for segment in content.iter().filter_map(|s| s.get_image_url()) {
println!("Image URL: {}", segment);
}
let text_segments: Vec<&Segment> = shindan_maker::filter_segments_by_type(&content, "text");
println!("Number of text segments: {}", text_segments.len());
}
Ok(())
}
This example shows how to:
- Create a
ShindanClient
- Fetch a shindan title
- Submit a shindan and get results
- Process different types of result segments (text and images)
- Use the
filter_segments_by_type utility function
Documentation
For more details, check the API documentation.
License
MIT OR Apache-2.0.