Skip to content

Commit 99cd786

Browse files
committed
feat(http): expose download methods on OpenDictionary
1 parent 58e447b commit 99cd786

File tree

2 files changed

+22
-4
lines changed

2 files changed

+22
-4
lines changed

Cargo.lock

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/src/download/download.rs

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use crate::{
1111
options::{DownloadOptions, ProgressCallback},
1212
utils::parse_remote_dictionary_name,
1313
},
14-
Error,
14+
Error, OpenDictionary,
1515
};
1616

1717
use futures_util::StreamExt;
@@ -238,6 +238,24 @@ impl<'a> DictionaryDownloader<'a> {
238238
}
239239
}
240240
}
241+
242+
impl OpenDictionary {
243+
pub async fn download(dictionary_name: &str) -> Result<PathBuf, Error> {
244+
DictionaryDownloader::default()
245+
.download(dictionary_name)
246+
.await
247+
}
248+
249+
pub async fn download_with_options<'a, Options: AsRef<DownloadOptions<'a>>>(
250+
dictionary_name: &str,
251+
options: Options,
252+
) -> Result<PathBuf, Error> {
253+
DictionaryDownloader::default()
254+
.download_with_options(dictionary_name, options)
255+
.await
256+
}
257+
}
258+
241259
#[cfg(test)]
242260
mod tests {
243261
use std::fs;

0 commit comments

Comments
 (0)