pub struct ShindanClient { /* private fields */ }Expand description
Client for interacting with Shindan Maker.
Implementations§
source§impl ShindanClient
impl ShindanClient
sourcepub fn new(domain: ShindanDomain) -> Result<Self, Error>
pub fn new(domain: ShindanDomain) -> Result<Self, Error>
Creates a new ShindanClient with the specified domain.
§Examples
use shindan_maker::{ShindanClient, ShindanDomain};
let client = ShindanClient::new(ShindanDomain::En).expect("Failed to create client");sourcepub fn set_domain(&mut self, domain: ShindanDomain)
pub fn set_domain(&mut self, domain: ShindanDomain)
Sets the domain for the ShindanClient.
sourcepub async fn get_title(&self, id: &str) -> Result<String, ShindanError>
pub async fn get_title(&self, id: &str) -> Result<String, ShindanError>
Gets the title of a Shindan by its ID.
§Examples
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ShindanClient::new(ShindanDomain::En)?;
let title = client.get_title("1218842").await?;
println!("Shindan title: {}", title);
Ok(())
}sourcepub async fn submit_shindan(
&self,
id: &str,
name: &str,
) -> Result<ShindanResult, ShindanError>
pub async fn submit_shindan( &self, id: &str, name: &str, ) -> Result<ShindanResult, ShindanError>
Submits a Shindan and returns the result.
§Examples
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = ShindanClient::new(ShindanDomain::En)?;
let result = client.submit_shindan("1218842", "test_user").await?;
if let ShindanResult::Text { title, content } = result {
println!("Title: {}", title);
for segment in content {
if let Some(text) = segment.get_text() {
println!("Text: {}", text);
}
}
}
Ok(())
}Trait Implementations§
Auto Trait Implementations§
impl Freeze for ShindanClient
impl !RefUnwindSafe for ShindanClient
impl Send for ShindanClient
impl Sync for ShindanClient
impl Unpin for ShindanClient
impl !UnwindSafe for ShindanClient
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more