pub struct Usecase { /* private fields */ }Expand description
An identifier for a workload in Objectstore, along with defaults to use for all operations within that Usecase.
Usecases need to be statically defined in Objectstore’s configuration server-side. Objectstore can make decisions based on the Usecase. For example, choosing the most suitable storage backend.
Names must be 3–64 ASCII characters from [A-Za-z0-9_-]. Any permitted
character may appear in any position. Names are case-sensitive and are never
normalized.
Implementations§
Source§impl Usecase
impl Usecase
Sourcepub fn new(name: &str) -> Result<Self, InvalidUsecaseName>
pub fn new(name: &str) -> Result<Self, InvalidUsecaseName>
Creates a Usecase, returning an error if the name is invalid.
Use Self::from_static for statically defined names.
§Errors
Returns InvalidUsecaseName if the name violates the naming rules on
Usecase.
Sourcepub const fn from_static(name: &'static str) -> Self
pub const fn from_static(name: &'static str) -> Self
Creates a Usecase for a statically defined name.
Use Self::new for dynamic names. The result can initialize a static:
use objectstore_client::Usecase;
static ATTACHMENTS: Usecase = Usecase::from_static("attachments");
assert_eq!(ATTACHMENTS.name(), "attachments");§Panics
Panics if the name violates the naming rules on Usecase. In a const
context, this panic is reported as a compile error.
Sourcepub fn compression(&self) -> Option<Compression>
pub fn compression(&self) -> Option<Compression>
Returns the compression algorithm to use for operations within this usecase.
Sourcepub fn with_compression(
self,
compression: impl Into<Option<Compression>>,
) -> Self
pub fn with_compression( self, compression: impl Into<Option<Compression>>, ) -> Self
Sets the compression algorithm to use for operations within this usecase.
It’s still possible to override this default on each operation’s builder.
By default, Compression::Zstd is used. Pass None to disable compression.
Sourcepub fn expiration_policy(&self) -> ExpirationPolicy
pub fn expiration_policy(&self) -> ExpirationPolicy
Returns the expiration policy to use by default for operations within this usecase.
Sourcepub fn with_expiration_policy(self, expiration_policy: ExpirationPolicy) -> Self
pub fn with_expiration_policy(self, expiration_policy: ExpirationPolicy) -> Self
Sets the expiration policy to use for operations within this usecase.
It’s still possible to override this default on each operation’s builder.
By default, ExpirationPolicy::Manual is used, meaning that objects won’t automatically
expire.
Sourcepub fn resumable_threshold_bytes(&self) -> Option<u64>
pub fn resumable_threshold_bytes(&self) -> Option<u64>
Returns the automatic resumable upload threshold, or None if disabled.
Sourcepub fn with_resumable_threshold_bytes(
self,
threshold: impl Into<Option<u64>>,
) -> Self
pub fn with_resumable_threshold_bytes( self, threshold: impl Into<Option<u64>>, ) -> Self
Sets the minimum remaining input size for automatic resumable uploads.
Defaults to 256 MiB, measured before client compression. Pass None to disable or
zero to include every supported payload. Individual uploads can override this using
crate::PutBuilder::resumable_threshold_bytes. See crate::PutBuilder for eligibility.
Sourcepub fn scope(&self) -> Scope
pub fn scope(&self) -> Scope
Creates a new custom Scope.
Add parts to it using Scope::push.
Generally, Usecase::for_organization and Usecase::for_project should fit most usecases,
so prefer using those methods rather than creating your own custom Scope.
Sourcepub fn for_organization(&self, organization: u64) -> Scope
pub fn for_organization(&self, organization: u64) -> Scope
Creates a new Scope tied to the given organization.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Usecase
impl RefUnwindSafe for Usecase
impl Send for Usecase
impl Sync for Usecase
impl Unpin for Usecase
impl UnsafeUnpin for Usecase
impl UnwindSafe for Usecase
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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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 more