pub struct DocumentScope { /* private fields */ }Expand description
The tenant and project a document belongs to.
Every storage call takes one, so a caller reaches only the documents of the
project it names: no DocumentName can spell out another project’s
document, and a read needs no check of its own. Backends keep the scope
apart from the name: columns in Postgres, the leading directories on a
filesystem, the leading segments of an object name in a bucket.
Implementations§
Source§impl DocumentScope
impl DocumentScope
Sourcepub fn new(tenant: &TenantId, project: &ProjectId) -> Self
pub fn new(tenant: &TenantId, project: &ProjectId) -> Self
Both ids match [haste_jwt::HOSTNAME_ID_PATTERN] by construction
(lowercase letters, digits and single hyphens), so a backend can use
them as path segments as they are.
Sourcepub fn from_backend(
tenant: String,
project: String,
) -> Result<Self, StorageError>
pub fn from_backend( tenant: String, project: String, ) -> Result<Self, StorageError>
Wraps ids read back from a backend. Only backends call this.
§Errors
Returns StorageError::InvalidScope when either is not a valid id,
which means something other than this crate wrote to the store.
pub fn tenant(&self) -> &TenantId
pub fn project(&self) -> &ProjectId
Trait Implementations§
Source§impl Clone for DocumentScope
impl Clone for DocumentScope
Source§impl Debug for DocumentScope
impl Debug for DocumentScope
Source§impl Display for DocumentScope
impl Display for DocumentScope
impl Eq for DocumentScope
Source§impl Hash for DocumentScope
impl Hash for DocumentScope
Source§impl PartialEq for DocumentScope
impl PartialEq for DocumentScope
impl StructuralPartialEq for DocumentScope
Auto Trait Implementations§
impl Freeze for DocumentScope
impl RefUnwindSafe for DocumentScope
impl Send for DocumentScope
impl Sync for DocumentScope
impl Unpin for DocumentScope
impl UnsafeUnpin for DocumentScope
impl UnwindSafe for DocumentScope
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
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§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> ⓘ
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