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 { 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 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) } }