daumdic 0.9.0

Daum Dictionary API wrapper
Documentation

daumdic-rs docs.rs

Daum Dictionary API wrapper written in Rust, inspired by daumdic-ruby.

use daumdic::search;

#[tokio::main]
async fn main() {
    let res = search("ironic").await.unwrap();
    // Prints a one-liner in the style of daumdic-ruby
    println!("{}", res);
    // => "[airάnik]  아이러니한, 역설적인, 모순적인, 반어적인"

    // Or use the structured result
    for word in &res.words {
        println!("{:?}: {}", word.lang, word.meaning.join(", "));
    }
}

Ruby compatibility

Search implements Ruby-style one-line formatting, not exact compatibility with Daumdic.one_liner. Use search(...).await?.to_string() for this output; formatting an individual Word always includes its word.

  • Hanja readings are included, even where the Ruby library omits them.
  • No search results produce an empty Search and an empty display string, rather than Ruby's nil.
  • Empty or whitespace-only input returns Err(DaumdicError::EmptyWord), rather than nil. Rust's Unicode whitespace trimming also differs from Ruby's strip.
  • HTTP error status codes are not checked before parsing the response; Ruby's open-uri raises for these errors.

The parsers also differ for missing elements and repeated headword elements, so identical output is not guaranteed for every response.

Testing

cargo test runs deterministic tests against saved HTML fixtures and compiles network examples without executing them. No dictionary access is needed.

Run the live integration test separately (requires network access):

cargo test --test live -- --ignored

Live results depend on Daum's availability, rate limits, and current content.

 


daumdic-rs is primarily distributed under the terms of both the Apache License (Version 2.0) and the MIT license. See COPYRIGHT for details.