This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch polish-lister
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git

commit 3d4a62bb244fc7684a9919e7887082152f1f050d
Author: Xuanwo <[email protected]>
AuthorDate: Wed Nov 15 23:45:39 2023 +0800

    Polish naming
    
    Signed-off-by: Xuanwo <[email protected]>
---
 core/src/layers/complete.rs                        |  6 ++--
 .../{into_hierarchy_pager.rs => hierarchy_list.rs} | 32 +++++++++++-----------
 core/src/raw/oio/list/mod.rs                       |  5 ++--
 3 files changed, 21 insertions(+), 22 deletions(-)

diff --git a/core/src/layers/complete.rs b/core/src/layers/complete.rs
index 68af92d2d..4732be231 100644
--- a/core/src/layers/complete.rs
+++ b/core/src/layers/complete.rs
@@ -30,9 +30,9 @@ use bytes::Bytes;
 use crate::raw::oio::FileReader;
 use crate::raw::oio::FlatLister;
 use crate::raw::oio::HierarchyLister;
+use crate::raw::oio::LazyReader;
 use crate::raw::oio::RangeReader;
 use crate::raw::oio::StreamableReader;
-use crate::raw::oio::{into_hierarchy_page, LazyReader};
 use crate::raw::*;
 use crate::*;
 
@@ -255,7 +255,7 @@ impl<A: Accessor> CompleteAccessor<A> {
             // If recursive is false but service can't list_without_recursive
             (false, true, false) => {
                 let (_, p) = self.inner.list(path, 
args.with_recursive(true)).await?;
-                let p = into_hierarchy_page(p, path);
+                let p = HierarchyLister::new(p, path);
                 Ok((RpList::default(), CompleteLister::NeedHierarchy(p)))
             }
         }
@@ -298,7 +298,7 @@ impl<A: Accessor> CompleteAccessor<A> {
             (false, true, false) => {
                 let (_, p) = self.inner.blocking_list(path, 
args.with_recursive(true))?;
                 let p: HierarchyLister<<A as Accessor>::BlockingLister> =
-                    into_hierarchy_page(p, path);
+                    HierarchyLister::new(p, path);
                 Ok((RpList::default(), CompleteLister::NeedHierarchy(p)))
             }
         }
diff --git a/core/src/raw/oio/list/into_hierarchy_pager.rs 
b/core/src/raw/oio/list/hierarchy_list.rs
similarity index 93%
rename from core/src/raw/oio/list/into_hierarchy_pager.rs
rename to core/src/raw/oio/list/hierarchy_list.rs
index bc972ff56..79d26b3ac 100644
--- a/core/src/raw/oio/list/into_hierarchy_pager.rs
+++ b/core/src/raw/oio/list/hierarchy_list.rs
@@ -23,21 +23,6 @@ use async_trait::async_trait;
 use crate::raw::*;
 use crate::*;
 
-/// to_hierarchy_lister is used to make a hierarchy lister flat.
-pub fn into_hierarchy_page<P>(lister: P, path: &str) -> HierarchyLister<P> {
-    let path = if path == "/" {
-        "".to_string()
-    } else {
-        path.to_string()
-    };
-
-    HierarchyLister {
-        lister,
-        path,
-        visited: HashSet::default(),
-    }
-}
-
 /// ToHierarchyLister will convert a flat page to hierarchy by filter
 /// not needed entries.
 ///
@@ -55,6 +40,21 @@ pub struct HierarchyLister<P> {
 }
 
 impl<P> HierarchyLister<P> {
+    /// Create a new hierarchy lister
+    pub fn new(lister: P, path: &str) -> HierarchyLister<P> {
+        let path = if path == "/" {
+            "".to_string()
+        } else {
+            path.to_string()
+        };
+
+        HierarchyLister {
+            lister,
+            path,
+            visited: HashSet::default(),
+        }
+    }
+
     /// ## NOTES
     ///
     /// We take `&mut Entry` here because we need to perform modification on 
entry in the case like
@@ -192,7 +192,7 @@ mod tests {
         let lister = MockLister::new(vec![
             "x/x/", "x/y/", "y/", "x/x/x", "y/y", "xy/", "z", "y/a",
         ]);
-        let mut lister = into_hierarchy_page(lister, "");
+        let mut lister = HierarchyLister::new(lister, "");
 
         let mut entries = Vec::default();
 
diff --git a/core/src/raw/oio/list/mod.rs b/core/src/raw/oio/list/mod.rs
index 30c117333..1969d3a8f 100644
--- a/core/src/raw/oio/list/mod.rs
+++ b/core/src/raw/oio/list/mod.rs
@@ -30,6 +30,5 @@ pub use page_list::PageLister;
 mod flat_list;
 pub use flat_list::FlatLister;
 
-mod into_hierarchy_pager;
-pub use into_hierarchy_pager::into_hierarchy_page;
-pub use into_hierarchy_pager::HierarchyLister;
+mod hierarchy_list;
+pub use hierarchy_list::HierarchyLister;

Reply via email to