Xuanwo commented on code in PR #5758:
URL: https://github.com/apache/opendal/pull/5758#discussion_r1992842532


##########
core/src/services/opfs/reader.rs:
##########


Review Comment:
   Remove this. Let's implement in other PRs.



##########
core/src/services/opfs/helper.rs:
##########


Review Comment:
   Remove empty files.



##########
core/src/services/opfs/lister.rs:
##########


Review Comment:
   Remove this. We can implement in other PRs.



##########
core/src/types/scheme.rs:
##########
@@ -373,6 +375,7 @@ impl FromStr for Scheme {
             "monoiofs" => Ok(Scheme::Monoiofs),
             "obs" => Ok(Scheme::Obs),
             "onedrive" => Ok(Scheme::Onedrive),
+            "opfs" => Ok(Scheme::Opfs),

Review Comment:
   Don't expose here until we are ready.



##########
core/src/services/opfs/backend.rs:
##########
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use serde::Deserialize;
+use std::sync::Arc;
+
+use super::{lister::OpfsLister, reader::OpfsReader, writer::OpfsWriter};
+use crate::{
+    raw::{Access, AccessorInfo, OpRead, OpWrite, RpRead, RpWrite},
+    Builder, Capability, Error, Result, Scheme,
+};
+use std::fmt::Debug;
+
+/// Origin private file system (OPFS) configuration
+#[derive(Default, Deserialize)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct OpfsConfig {}
+
+impl Debug for OpfsConfig {
+    fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        panic!()
+    }
+}
+
+/// Origin private file system (OPFS) support
+#[doc = include_str!("docs.md")]
+#[derive(Default)]
+pub struct OpfsBuilder {
+    config: OpfsConfig,
+}
+
+impl OpfsBuilder {}
+
+impl Debug for OpfsBuilder {
+    fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        panic!()
+    }
+}
+
+impl Builder for OpfsBuilder {
+    const SCHEME: Scheme = Scheme::Opfs;
+
+    type Config = ();
+
+    fn build(self) -> Result<impl Access> {
+        Ok(OpfsBackend {})
+    }
+}
+
+/// OPFS Service backend
+#[derive(Debug, Clone)]
+pub struct OpfsBackend {}
+
+impl Access for OpfsBackend {
+    type Reader = OpfsReader;

Review Comment:
   We can use `()` here don't need to implement anything others.



##########
core/src/services/opfs/backend.rs:
##########
@@ -0,0 +1,152 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use serde::Deserialize;
+use std::sync::Arc;
+
+use super::{lister::OpfsLister, reader::OpfsReader, writer::OpfsWriter};
+use crate::{
+    raw::{Access, AccessorInfo, OpRead, OpWrite, RpRead, RpWrite},
+    Builder, Capability, Error, Result, Scheme,
+};
+use std::fmt::Debug;
+
+/// Origin private file system (OPFS) configuration
+#[derive(Default, Deserialize)]
+#[serde(default)]
+#[non_exhaustive]
+pub struct OpfsConfig {}
+
+impl Debug for OpfsConfig {
+    fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        panic!()
+    }
+}
+
+/// Origin private file system (OPFS) support
+#[doc = include_str!("docs.md")]
+#[derive(Default)]
+pub struct OpfsBuilder {
+    config: OpfsConfig,
+}
+
+impl OpfsBuilder {}
+
+impl Debug for OpfsBuilder {
+    fn fmt(&self, _f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+        panic!()
+    }
+}
+
+impl Builder for OpfsBuilder {
+    const SCHEME: Scheme = Scheme::Opfs;
+
+    type Config = ();
+
+    fn build(self) -> Result<impl Access> {
+        Ok(OpfsBackend {})
+    }
+}
+
+/// OPFS Service backend
+#[derive(Debug, Clone)]
+pub struct OpfsBackend {}
+
+impl Access for OpfsBackend {
+    type Reader = OpfsReader;
+
+    type Writer = OpfsWriter;
+
+    type Lister = OpfsLister;
+
+    type Deleter = ();
+
+    type BlockingReader = ();
+
+    type BlockingWriter = ();
+
+    type BlockingLister = OpfsLister;
+
+    type BlockingDeleter = ();
+
+    fn info(&self) -> Arc<AccessorInfo> {
+        let access_info = AccessorInfo::default();
+        access_info
+            .set_scheme(Scheme::Opfs)
+            .set_native_capability(Capability {

Review Comment:
   We can use `Capability::default()` to get started.



##########
core/src/services/opfs/writer.rs:
##########


Review Comment:
   Remove this, let's implement in other PRs.



##########
core/src/services/opfs/core.rs:
##########
@@ -0,0 +1,134 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//   http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied.  See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+use crate::Error;
+use crate::Result;
+use std::fmt::Debug;
+use std::future::Future;
+use tokio::sync::oneshot;
+
+use web_sys::{
+    window, File, FileSystemDirectoryHandle, FileSystemFileHandle, 
FileSystemGetFileOptions,
+    FileSystemWritableFileStream,
+};
+
+use wasm_bindgen::{JsCast, JsValue};
+use wasm_bindgen_futures::JsFuture;
+
+async fn spawn_local<F, T>(fut: F) -> T

Review Comment:
   I have questions about most functions like this, but I think it's better to 
move on to other PRs. In this PR, we're just preparing the basics.



-- 
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]

Reply via email to