opendal/types/operator/info.rs
1// Licensed to the Apache Software Foundation (ASF) under one
2// or more contributor license agreements. See the NOTICE file
3// distributed with this work for additional information
4// regarding copyright ownership. The ASF licenses this file
5// to you under the Apache License, Version 2.0 (the
6// "License"); you may not use this file except in compliance
7// with the License. You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing,
12// software distributed under the License is distributed on an
13// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14// KIND, either express or implied. See the License for the
15// specific language governing permissions and limitations
16// under the License.
17
18use std::sync::Arc;
19
20use crate::raw::*;
21use crate::*;
22
23/// Metadata for operator, users can use this metadata to get information of operator.
24#[derive(Clone, Debug, Default)]
25pub struct OperatorInfo(Arc<AccessorInfo>);
26
27impl OperatorInfo {
28 pub(super) fn new(acc: Arc<AccessorInfo>) -> Self {
29 OperatorInfo(acc)
30 }
31
32 /// [`Scheme`] of operator.
33 pub fn scheme(&self) -> Scheme {
34 self.0.scheme()
35 }
36
37 /// Root of operator, will be in format like `/path/to/dir/`
38 pub fn root(&self) -> String {
39 self.0.root().to_string()
40 }
41
42 /// Name of backend, could be empty if underlying backend doesn't have namespace concept.
43 ///
44 /// For example:
45 ///
46 /// - name for `s3` => bucket name
47 /// - name for `azblob` => container name
48 pub fn name(&self) -> String {
49 self.0.name().to_string()
50 }
51
52 /// Get [`Full Capability`] of operator.
53 pub fn full_capability(&self) -> Capability {
54 self.0.full_capability()
55 }
56
57 /// Get [`Native Capability`] of operator.
58 pub fn native_capability(&self) -> Capability {
59 self.0.native_capability()
60 }
61}