You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by su...@apache.org on 2023/11/22 15:31:48 UTC
(incubator-opendal) 01/02: save work
This is an automated email from the ASF dual-hosted git repository.
suyanhanx pushed a commit to branch binding-nodejs-capability
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git
commit 807327325285f7ad75d09fbd188868b5aca86cdf
Author: suyanhanx <su...@gmail.com>
AuthorDate: Wed Nov 22 22:38:09 2023 +0800
save work
Signed-off-by: suyanhanx <su...@gmail.com>
---
bindings/nodejs/src/capability.rs | 44 +++++++++++++++++++++++++++++++++++++++
bindings/nodejs/src/lib.rs | 2 ++
2 files changed, 46 insertions(+)
diff --git a/bindings/nodejs/src/capability.rs b/bindings/nodejs/src/capability.rs
new file mode 100644
index 000000000..2eaee90a1
--- /dev/null
+++ b/bindings/nodejs/src/capability.rs
@@ -0,0 +1,44 @@
+
+#[napi]
+pub struct Capability(opendal::Capability);
+
+impl Capability {
+ pub fn new(op: opendal::Operator) -> Self {
+ Self(op.info().full_capability())
+ }
+}
+
+#[napi]
+impl Capability {
+ #[napi(getter)]
+ pub fn stat(&self) -> bool {
+ self.0.stat
+ }
+
+ // stat_with_if_match
+ #[napi(getter)]
+ pub fn stat_with_if_none_match(&self) -> bool {
+ self.0.stat_with_if_none_match
+ }
+
+ // stat_with_if_none_match
+ #[napi(getter)]
+ pub fn stat_with_if_match(&self) -> bool {
+ self.0.stat_with_if_match
+ }
+
+ #[napi(getter)]
+ pub fn read(&self) -> bool {
+ self.0.read
+ }
+
+ #[napi(getter)]
+ pub fn write(&self) -> bool {
+ self.0.write
+ }
+
+ #[napi(getter)]
+ pub fn delete(&self) -> bool {
+ self.0.delete
+ }
+}
diff --git a/bindings/nodejs/src/lib.rs b/bindings/nodejs/src/lib.rs
index 20e46d7e2..ec964e594 100644
--- a/bindings/nodejs/src/lib.rs
+++ b/bindings/nodejs/src/lib.rs
@@ -18,6 +18,8 @@
#[macro_use]
extern crate napi_derive;
+mod capability;
+
use std::collections::HashMap;
use std::str::FromStr;
use std::time::Duration;