Xuanwo commented on code in PR #5758: URL: https://github.com/apache/opendal/pull/5758#discussion_r1998317965
########## core/src/services/opfs/backend.rs: ########## @@ -0,0 +1,85 @@ +// 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 crate::raw::{Access, AccessorInfo}; +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 = (); + + type Writer = (); + + type Lister = (); + + type Deleter = (); + + type BlockingReader = (); + + type BlockingWriter = (); + + type BlockingLister = (); + + type BlockingDeleter = (); + + fn info(&self) -> Arc<AccessorInfo> { + todo!() Review Comment: Let's provide a default `AccessorInfo` instead. ########## core/src/services/opfs/backend.rs: ########## @@ -0,0 +1,85 @@ +// 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 crate::raw::{Access, AccessorInfo}; +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!() Review Comment: We can `derive` it instead of `panic`. ########## core/src/services/opfs/error.rs: ########## @@ -0,0 +1,30 @@ +// 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 wasm_bindgen::JsValue; + +use crate::Error; +use crate::ErrorKind; + +impl From<JsValue> for Error { Review Comment: Hi, please implement `parse_js_error` instead to avoid leak this public API to users. ########## core/src/services/opfs/backend.rs: ########## @@ -0,0 +1,85 @@ +// 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 crate::raw::{Access, AccessorInfo}; +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 { Review Comment: The same. ########## core/src/services/mod.rs: ########## @@ -148,6 +148,9 @@ pub use obs::*; mod onedrive; pub use onedrive::*; +mod opfs; Review Comment: Maybe we need to gate this under `cfg(wasm32)`? -- 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]
