feat: early steps of storage and configuration
This commit is contained in:
39
src/storage.rs
Normal file
39
src/storage.rs
Normal file
@@ -0,0 +1,39 @@
|
||||
use std::{fmt::Debug, str::FromStr};
|
||||
|
||||
use opendal::{IntoOperatorUri, Operator, OperatorUri};
|
||||
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Storage {
|
||||
uri: OperatorUri,
|
||||
operator: Operator,
|
||||
}
|
||||
|
||||
impl FromStr for Storage {
|
||||
type Err = opendal::Error;
|
||||
|
||||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
let uri = s.into_operator_uri()?;
|
||||
let operator = Operator::from_uri(&uri)?;
|
||||
|
||||
Ok(Self { uri, operator })
|
||||
}
|
||||
}
|
||||
|
||||
impl Storage {
|
||||
pub fn into_inner(self) -> Operator {
|
||||
self.operator
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Storage> for Operator {
|
||||
fn from(wrapper: Storage) -> Self {
|
||||
wrapper.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Storage {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
Debug::fmt(&self.uri, f)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user