From 1024b765332c0a4876be07eebfc98dbb7a544f13 Mon Sep 17 00:00:00 2001 From: cksac Date: Tue, 24 Oct 2023 17:38:49 +0800 Subject: [PATCH] update readme --- Cargo.toml | 2 +- README.md | 15 +++++++-------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 43c5f11..42e2662 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "dataloader" -version = "0.16.0" +version = "0.17.0" edition = "2018" authors = ["cksac "] description = "Rust implementation of Facebook's DataLoader using async-await." diff --git a/README.md b/README.md index db9eee3..fdf6c98 100644 --- a/README.md +++ b/README.md @@ -14,37 +14,36 @@ Rust implementation of [Facebook's DataLoader](https://github.com/facebook/datal ## Usage ### Switching runtime, by using cargo features - `runtime-async-std` (default), to use the [async-std](https://async.rs) runtime - - dataloader = "0.16" + - dataloader = "0.17" - `runtime-tokio` to use the [Tokio](https://tokio.rs) runtime - - dataloader = { version = "0.16", default-features = false, features = ["runtime-tokio"]} + - dataloader = { version = "0.17", default-features = false, features = ["runtime-tokio"]} ### Add to your `Cargo.toml`: ```toml [dependencies] -dataloader = "0.16" +dataloader = "0.17" futures = "0.3" -async-trait = "0.1" ``` ### Example: ```rust -use async_trait::async_trait; use dataloader::cached::Loader; use dataloader::BatchFn; use futures::executor::block_on; +use futures::future::ready; use std::collections::HashMap; use std::thread; struct MyLoadFn; -#[async_trait] impl BatchFn for MyLoadFn { async fn load(&mut self, keys: &[usize]) -> HashMap { println!("BatchFn load keys {:?}", keys); - keys.iter() + let ret = keys.iter() .map(|v| (v.clone(), v.clone())) - .collect::>() + .collect::>(); + ready(ret).await } }