pub struct Azblob { /* private fields */ }
services-azblob
only.Expand description
§Capabilities
This service can be used to:
- stat
- read
- write
- append
- create_dir
- delete
- copy
- rename
- list
- presign
- blocking
§Configuration
root
: Set the work dir for backend.container
: Set the container name for backend.endpoint
: Set the endpoint for backend.account_name
: Set the account_name for backend.account_key
: Set the account_key for backend.
Refer to public API docs for more information.
§Examples
This example works on Azurite for local developments.
§Start local blob service
docker run -p 10000:10000 mcr.microsoft.com/azure-storage/azurite
az storage container create --name test --connection-string "DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;"
§Init OpenDAL Operator
§Via Builder
use std::sync::Arc;
use anyhow::Result;
use opendal::services::Azblob;
use opendal::Operator;
#[tokio::main]
async fn main() -> Result<()> {
// Create azblob backend builder.
let mut builder = Azblob::default()
// Set the root for azblob, all operations will happen under this root.
//
// NOTE: the root must be absolute path.
.root("/path/to/dir")
// Set the container name, this is required.
.container("test")
// Set the endpoint, this is required.
//
// For examples:
// - "http://127.0.0.1:10000/devstoreaccount1"
// - "https://accountname.blob.core.windows.net"
.endpoint("http://127.0.0.1:10000/devstoreaccount1")
// Set the account_name and account_key.
//
// OpenDAL will try load credential from the env.
// If credential not set and no valid credential in env, OpenDAL will
// send request without signing like anonymous user.
.account_name("devstoreaccount1")
.account_key("Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==");
// `Accessor` provides the low level APIs, we will use `Operator` normally.
let op: Operator = Operator::new(builder)?.finish();
Ok(())
}
Implementations§
source§impl AzblobBuilder
impl AzblobBuilder
sourcepub fn root(self, root: &str) -> Self
pub fn root(self, root: &str) -> Self
Set root of this backend.
All operations will happen under this root.
sourcepub fn endpoint(self, endpoint: &str) -> Self
pub fn endpoint(self, endpoint: &str) -> Self
Set endpoint of this backend
Endpoint must be full uri, e.g.
- Azblob:
https://accountname.blob.core.windows.net
- Azurite:
http://127.0.0.1:10000/devstoreaccount1
sourcepub fn account_name(self, account_name: &str) -> Self
pub fn account_name(self, account_name: &str) -> Self
Set account_name of this backend.
- If account_name is set, we will take user’s input first.
- If not, we will try to load it from environment.
sourcepub fn account_key(self, account_key: &str) -> Self
pub fn account_key(self, account_key: &str) -> Self
Set account_key of this backend.
- If account_key is set, we will take user’s input first.
- If not, we will try to load it from environment.
sourcepub fn encryption_key(self, v: &str) -> Self
pub fn encryption_key(self, v: &str) -> Self
Set encryption_key of this backend.
§Args
v
: Base64-encoded key that matches algorithm specified in encryption_algorithm
.
§Note
This function is the low-level setting for SSE related features.
SSE related options should be set carefully to make them works.
Please use server_side_encryption_with_*
helpers if even possible.
sourcepub fn encryption_key_sha256(self, v: &str) -> Self
pub fn encryption_key_sha256(self, v: &str) -> Self
Set encryption_key_sha256 of this backend.
§Args
v
: Base64-encoded SHA256 digest of the key specified in encryption_key.
§Note
This function is the low-level setting for SSE related features.
SSE related options should be set carefully to make them works.
Please use server_side_encryption_with_*
helpers if even possible.
sourcepub fn encryption_algorithm(self, v: &str) -> Self
pub fn encryption_algorithm(self, v: &str) -> Self
Set encryption_algorithm of this backend.
§Args
v
: server-side encryption algorithm. (Available values: AES256
)
§Note
This function is the low-level setting for SSE related features.
SSE related options should be set carefully to make them works.
Please use server_side_encryption_with_*
helpers if even possible.
sourcepub fn server_side_encryption_with_customer_key(self, key: &[u8]) -> Self
pub fn server_side_encryption_with_customer_key(self, key: &[u8]) -> Self
Enable server side encryption with customer key.
As known as: CPK
§Args
key
: Base64-encoded SHA256 digest of the key specified in encryption_key.
§Note
Function that helps the user to set the server-side customer-provided encryption key, the key’s SHA256, and the algorithm. See Server-side encryption with customer-provided keys (CPK) for more info.
sourcepub fn sas_token(self, sas_token: &str) -> Self
pub fn sas_token(self, sas_token: &str) -> Self
Set sas_token of this backend.
- If sas_token is set, we will take user’s input first.
- If not, we will try to load it from environment.
See Grant limited access to Azure Storage resources using shared access signatures (SAS) for more info.
sourcepub fn http_client(self, client: HttpClient) -> Self
pub fn http_client(self, client: HttpClient) -> Self
Specify the http client that used by this service.
§Notes
This API is part of OpenDAL’s Raw API. HttpClient
could be changed
during minor updates.
sourcepub fn batch_max_operations(self, batch_max_operations: usize) -> Self
pub fn batch_max_operations(self, batch_max_operations: usize) -> Self
Set maximum batch operations of this backend.
sourcepub fn from_connection_string(conn: &str) -> Result<Self>
pub fn from_connection_string(conn: &str) -> Result<Self>
from_connection_string will make a builder from connection string
connection string looks like:
DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;
AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;
BlobEndpoint=http://127.0.0.1:10000/devstoreaccount1;
QueueEndpoint=http://127.0.0.1:10001/devstoreaccount1;
TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;
Or
DefaultEndpointsProtocol=https;
AccountName=storagesample;
AccountKey=<account-key>;
EndpointSuffix=core.chinacloudapi.cn;
For reference: Configure Azure Storage connection strings
§Note
connection string only configures the endpoint, account name and account key. User still needs to configure bucket names.
Trait Implementations§
source§impl Builder for AzblobBuilder
impl Builder for AzblobBuilder
source§impl Clone for AzblobBuilder
impl Clone for AzblobBuilder
source§fn clone(&self) -> AzblobBuilder
fn clone(&self) -> AzblobBuilder
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for AzblobBuilder
impl Debug for AzblobBuilder
source§impl Default for AzblobBuilder
impl Default for AzblobBuilder
source§fn default() -> AzblobBuilder
fn default() -> AzblobBuilder
Auto Trait Implementations§
impl Freeze for AzblobBuilder
impl !RefUnwindSafe for AzblobBuilder
impl Send for AzblobBuilder
impl Sync for AzblobBuilder
impl Unpin for AzblobBuilder
impl !UnwindSafe for AzblobBuilder
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
§impl<T> CompatExt for T
impl<T> CompatExt for T
§impl<T> Conv for T
impl<T> Conv for T
§impl<T> FmtForward for T
impl<T> FmtForward for T
§fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
fn fmt_binary(self) -> FmtBinary<Self>where
Self: Binary,
self
to use its Binary
implementation when Debug
-formatted.§fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
fn fmt_display(self) -> FmtDisplay<Self>where
Self: Display,
self
to use its Display
implementation when
Debug
-formatted.§fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
fn fmt_lower_exp(self) -> FmtLowerExp<Self>where
Self: LowerExp,
self
to use its LowerExp
implementation when
Debug
-formatted.§fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
fn fmt_lower_hex(self) -> FmtLowerHex<Self>where
Self: LowerHex,
self
to use its LowerHex
implementation when
Debug
-formatted.§fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
fn fmt_octal(self) -> FmtOctal<Self>where
Self: Octal,
self
to use its Octal
implementation when Debug
-formatted.§fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
fn fmt_pointer(self) -> FmtPointer<Self>where
Self: Pointer,
self
to use its Pointer
implementation when
Debug
-formatted.§fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
fn fmt_upper_exp(self) -> FmtUpperExp<Self>where
Self: UpperExp,
self
to use its UpperExp
implementation when
Debug
-formatted.§fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
fn fmt_upper_hex(self) -> FmtUpperHex<Self>where
Self: UpperHex,
self
to use its UpperHex
implementation when
Debug
-formatted.§fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
fn fmt_list(self) -> FmtList<Self>where
&'a Self: for<'a> IntoIterator,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§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>
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>
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 moresource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request
§impl<T> Pipe for Twhere
T: ?Sized,
impl<T> Pipe for Twhere
T: ?Sized,
§fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> Rwhere
Self: Sized,
§fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> Rwhere
R: 'a,
self
and passes that borrow into the pipe function. Read more§fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R
§fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R,
) -> R
fn pipe_borrow_mut<'a, B, R>( &'a mut self, func: impl FnOnce(&'a mut B) -> R, ) -> R
§fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R
self
, then passes self.as_ref()
into the pipe function.§fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R
self
, then passes self.as_mut()
into the pipe
function.§fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R
self
, then passes self.deref()
into the pipe function.§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> Tap for T
impl<T> Tap for T
§fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self
Borrow<B>
of a value. Read more§fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self
BorrowMut<B>
of a value. Read more§fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self
AsRef<R>
view of a value. Read more§fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self
AsMut<R>
view of a value. Read more§fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self
Deref::Target
of a value. Read more§fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self
Deref::Target
of a value. Read more§fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
.tap()
only in debug builds, and is erased in release builds.§fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
.tap_mut()
only in debug builds, and is erased in release
builds.§fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self
.tap_borrow()
only in debug builds, and is erased in release
builds.§fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self
.tap_borrow_mut()
only in debug builds, and is erased in release
builds.§fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self
.tap_ref()
only in debug builds, and is erased in release
builds.§fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self
.tap_ref_mut()
only in debug builds, and is erased in release
builds.§fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self
.tap_deref()
only in debug builds, and is erased in release
builds.