Skip to content

Commit

Permalink
Refactor Lister
Browse files Browse the repository at this point in the history
Signed-off-by: Jack Drogon <[email protected]>
  • Loading branch information
JackDrogon committed Nov 18, 2023
1 parent b94d3b6 commit cf59ad8
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
3 changes: 1 addition & 2 deletions bindings/cpp/include/lister.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ namespace opendal {
*/
class Lister {
public:
Lister(rust::Box<opendal::ffi::Lister> &&lister)
: raw_lister_(std::move(lister)) {}
Lister(rust::Box<opendal::ffi::Lister> &&lister) noexcept;

/**
* @class ListerIterator
Expand Down
1 change: 0 additions & 1 deletion bindings/cpp/include/operator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <vector>

#include "entry.hpp"
#include "lib.rs.h"
#include "lister.hpp"
#include "metadata.hpp"
#include "reader.hpp"
Expand Down
1 change: 1 addition & 0 deletions bindings/cpp/include/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class Reader
std::streampos seek(std::streamoff off, std::ios_base::seekdir way);

private:
struct Rep;
rust::Box<opendal::ffi::Reader> raw_reader_;
};

Expand Down
9 changes: 5 additions & 4 deletions bindings/cpp/src/lister.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,14 @@

namespace opendal {

Lister::Lister(rust::Box<opendal::ffi::Lister> &&lister) noexcept
: raw_lister_(std::move(lister)) {}

std::optional<Entry> Lister::next() {
auto entry = raw_lister_->next();
if (entry.has_value) {
if (auto entry = raw_lister_->next(); entry.has_value) {
return std::move(entry.value);
} else {
return std::nullopt;
}
return std::nullopt;
}

} // namespace opendal

0 comments on commit cf59ad8

Please sign in to comment.