silver-ymz commented on code in PR #3004:
URL:
https://github.com/apache/incubator-opendal/pull/3004#discussion_r1315524199
##########
bindings/cpp/include/opendal.hpp:
##########
@@ -176,4 +188,45 @@ class Operator {
std::optional<rust::Box<opendal::ffi::Operator>> operator_;
};
+/**
+ * @class Reader
+ * @brief Reader is designed to read data from the operator.
+ * @details It provides basic read and seek operations. If you want to use it
+ * like a stream, you can use `ReaderStream` instead.
+ * @code{.cpp}
+ * auto reader = operator.reader("path");
+ * opendal::ReaderStream stream(reader);
+ * @endcode
+ */
+class Reader
+ : public boost::iostreams::device<boost::iostreams::input_seekable> {
+public:
+ // Users should not use this type directly.
+ using InternalReader = rust::Box<opendal::ffi::Reader>;
+
+ Reader(InternalReader &&reader) : reader_(std::move(reader)) {}
+
+ std::streamsize read(void *s, std::streamsize n);
+ std::streampos seek(std::streamoff off, std::ios_base::seekdir way);
+
+private:
+ InternalReader reader_;
Review Comment:
> Is it an idiom to add "_" after variables to represent private items?
Yes. This is the code style recommend by google which used widely.
> Can we use more clear naming style like raw_reader or ffi_reader?
I think it's better to keep its name same with the type name. So, I prefer
to rename `reader_` to `internal_reader_`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]