pub struct OpendalStore { /* private fields */ }Expand description
OpendalStore implements ObjectStore trait by using opendal.
This allows users to use opendal as an object store without extra cost.
Visit [opendal::services] for more information about supported services.
use std::sync::Arc;
use bytes::Bytes;
use object_store::path::Path;
use object_store::ObjectStore;
use object_store::ObjectStoreExt;
use object_store_opendal::OpendalStore;
use opendal::services::S3;
use opendal::{Builder, Operator};
#[tokio::main]
async fn main() {
let builder = S3::default()
.access_key_id("my_access_key")
.secret_access_key("my_secret_key")
.endpoint("my_endpoint")
.region("my_region");
// Create a new operator
let operator = Operator::new(builder).unwrap().finish();
// Create a new object store
let object_store = Arc::new(OpendalStore::new(operator));
let path = Path::from("data/nested/test.txt");
let bytes = Bytes::from_static(b"hello, world! I am nested.");
object_store.put(&path, bytes.clone().into()).await.unwrap();
let content = object_store
.get(&path)
.await
.unwrap()
.bytes()
.await
.unwrap();
assert_eq!(content, bytes);
}Implementations§
Source§impl OpendalStore
impl OpendalStore
Source§impl OpendalStore
impl OpendalStore
Sourcepub fn new_amazon_s3(builder: AmazonS3Builder) -> Result<OpendalStore>
pub fn new_amazon_s3(builder: AmazonS3Builder) -> Result<OpendalStore>
Create OpendalStore from object_store Amazon S3 builder.
Trait Implementations§
Source§impl Clone for OpendalStore
impl Clone for OpendalStore
Source§fn clone(&self) -> OpendalStore
fn clone(&self) -> OpendalStore
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for OpendalStore
impl Debug for OpendalStore
Source§impl Display for OpendalStore
impl Display for OpendalStore
Source§impl From<Operator> for OpendalStore
impl From<Operator> for OpendalStore
Source§impl ObjectStore for OpendalStore
impl ObjectStore for OpendalStore
Source§fn put_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
bytes: PutPayload,
opts: PutOptions,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
bytes: PutPayload,
opts: PutOptions,
) -> Pin<Box<dyn Future<Output = Result<PutResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Source§fn put_multipart_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
opts: PutMultipartOptions,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn put_multipart_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
opts: PutMultipartOptions,
) -> Pin<Box<dyn Future<Output = Result<Box<dyn MultipartUpload>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Perform a multipart upload with options Read more
Source§fn get_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
options: GetOptions,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn get_opts<'life0, 'life1, 'async_trait>(
&'life0 self,
location: &'life1 Path,
options: GetOptions,
) -> Pin<Box<dyn Future<Output = Result<GetResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Perform a get request with options Read more
Source§fn get_ranges<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
location: &'life1 Path,
ranges: &'life2 [Range<u64>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn get_ranges<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
location: &'life1 Path,
ranges: &'life2 [Range<u64>],
) -> Pin<Box<dyn Future<Output = Result<Vec<Bytes>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Return the bytes that are stored at the specified location
in the given byte ranges
Source§fn delete_stream(
&self,
locations: BoxStream<'static, Result<Path>>,
) -> BoxStream<'static, Result<Path>>
fn delete_stream( &self, locations: BoxStream<'static, Result<Path>>, ) -> BoxStream<'static, Result<Path>>
Delete all the objects at the specified locations Read more
Source§fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, Result<ObjectMeta>>
fn list(&self, prefix: Option<&Path>) -> BoxStream<'static, Result<ObjectMeta>>
List all the objects with the given prefix. Read more
Source§fn list_with_offset(
&self,
prefix: Option<&Path>,
offset: &Path,
) -> BoxStream<'static, Result<ObjectMeta>>
fn list_with_offset( &self, prefix: Option<&Path>, offset: &Path, ) -> BoxStream<'static, Result<ObjectMeta>>
List all the objects with the given prefix and a location greater than
offset Read moreSource§fn list_with_delimiter<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 Path>,
) -> Pin<Box<dyn Future<Output = Result<ListResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn list_with_delimiter<'life0, 'life1, 'async_trait>(
&'life0 self,
prefix: Option<&'life1 Path>,
) -> Pin<Box<dyn Future<Output = Result<ListResult>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
List objects with the given prefix and an implementation specific
delimiter. Returns common prefixes (directories) in addition to object
metadata. Read more
Source§fn copy_opts<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
options: ObjectStoreCopyOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn copy_opts<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
options: ObjectStoreCopyOptions,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Copy an object from one path to another in the same object store.
§fn rename_opts<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
options: RenameOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
fn rename_opts<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
from: &'life1 Path,
to: &'life2 Path,
options: RenameOptions,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
Move an object from one path to another in the same object store. Read more
Auto Trait Implementations§
impl Freeze for OpendalStore
impl !RefUnwindSafe for OpendalStore
impl Send for OpendalStore
impl Sync for OpendalStore
impl Unpin for OpendalStore
impl !UnwindSafe for OpendalStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> ObjectStoreExt for Twhere
T: ObjectStore + ?Sized,
impl<T> ObjectStoreExt for Twhere
T: ObjectStore + ?Sized,
§async fn put(
&self,
location: &Path,
payload: PutPayload,
) -> Result<PutResult, Error>
async fn put( &self, location: &Path, payload: PutPayload, ) -> Result<PutResult, Error>
Save the provided bytes to the specified location Read more
§async fn put_multipart(
&self,
location: &Path,
) -> Result<Box<dyn MultipartUpload>, Error>
async fn put_multipart( &self, location: &Path, ) -> Result<Box<dyn MultipartUpload>, Error>
Perform a multipart upload Read more
§async fn get(&self, location: &Path) -> Result<GetResult, Error>
async fn get(&self, location: &Path) -> Result<GetResult, Error>
Return the bytes that are stored at the specified location. Read more
§async fn get_range(
&self,
location: &Path,
range: Range<u64>,
) -> Result<Bytes, Error>
async fn get_range( &self, location: &Path, range: Range<u64>, ) -> Result<Bytes, Error>
Return the bytes that are stored at the specified location
in the given byte range. Read more
§async fn head(&self, location: &Path) -> Result<ObjectMeta, Error>
async fn head(&self, location: &Path) -> Result<ObjectMeta, Error>
Return the metadata for the specified location
§async fn delete(&self, location: &Path) -> Result<(), Error>
async fn delete(&self, location: &Path) -> Result<(), Error>
Delete the object at the specified location.
§async fn copy(&self, from: &Path, to: &Path) -> Result<(), Error>
async fn copy(&self, from: &Path, to: &Path) -> Result<(), Error>
Copy an object from one path to another in the same object store. Read more
§async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<(), Error>
async fn copy_if_not_exists(&self, from: &Path, to: &Path) -> Result<(), Error>
Copy an object from one path to another, only if destination is empty. Read more
§async fn rename(&self, from: &Path, to: &Path) -> Result<(), Error>
async fn rename(&self, from: &Path, to: &Path) -> Result<(), Error>
Move an object from one path to another in the same object store. Read more
§async fn rename_if_not_exists(
&self,
from: &Path,
to: &Path,
) -> Result<(), Error>
async fn rename_if_not_exists( &self, from: &Path, to: &Path, ) -> Result<(), Error>
Move an object from one path to another in the same object store. Read more
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> ToStringFallible for Twhere
T: Display,
impl<T> ToStringFallible for Twhere
T: Display,
§fn try_to_string(&self) -> Result<String, TryReserveError>
fn try_to_string(&self) -> Result<String, TryReserveError>
ToString::to_string, but without panic on OOM.