Struct garage_model::key_table::Key
source · pub struct Key {
pub key_id: String,
pub state: Deletable<KeyParams>,
}
Expand description
An api key
Fields§
§key_id: String
The id of the key (immutable), used as partition key
state: Deletable<KeyParams>
Internal state of the key
Implementations§
source§impl Key
impl Key
sourcepub fn new(name: &str) -> Self
pub fn new(name: &str) -> Self
Initialize a new Key, generating a random identifier and associated secret key
sourcepub fn import(
key_id: &str,
secret_key: &str,
name: &str
) -> Result<Self, &'static str>
pub fn import( key_id: &str, secret_key: &str, name: &str ) -> Result<Self, &'static str>
Import a key from it’s parts
sourcepub fn delete(key_id: String) -> Self
pub fn delete(key_id: String) -> Self
Create a new Key which can me merged to mark an existing key deleted
sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Returns true if this represents a deleted bucket
sourcepub fn params(&self) -> Option<&KeyParams>
pub fn params(&self) -> Option<&KeyParams>
Returns an option representing the params (None if in deleted state)
sourcepub fn params_mut(&mut self) -> Option<&mut KeyParams>
pub fn params_mut(&mut self) -> Option<&mut KeyParams>
Mutable version of .state()
sourcepub fn bucket_permissions(&self, bucket: &Uuid) -> BucketKeyPerm
pub fn bucket_permissions(&self, bucket: &Uuid) -> BucketKeyPerm
Get permissions for a bucket
sourcepub fn allow_read(&self, bucket: &Uuid) -> bool
pub fn allow_read(&self, bucket: &Uuid) -> bool
Check if Key
is allowed to read in bucket
sourcepub fn allow_write(&self, bucket: &Uuid) -> bool
pub fn allow_write(&self, bucket: &Uuid) -> bool
Check if Key
is allowed to write in bucket
sourcepub fn allow_owner(&self, bucket: &Uuid) -> bool
pub fn allow_owner(&self, bucket: &Uuid) -> bool
Check if Key
is owner of bucket
Trait Implementations§
source§impl<'de> Deserialize<'de> for Key
impl<'de> Deserialize<'de> for Key
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
source§impl InitialFormat for Key
impl InitialFormat for Key
source§const VERSION_MARKER: &'static [u8] = b""
const VERSION_MARKER: &'static [u8] = b""
A sequence of bytes to add at the beginning of the serialized
string, to identify that the data is of this version.
impl Eq for Key
impl StructuralPartialEq for Key
Auto Trait Implementations§
impl Freeze for Key
impl RefUnwindSafe for Key
impl Send for Key
impl Sync for Key
impl Unpin for Key
impl UnwindSafe for Key
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Migrate for Twhere
T: InitialFormat,
impl<T> Migrate for Twhere
T: InitialFormat,
source§const VERSION_MARKER: &'static [u8] = <T as InitialFormat>::VERSION_MARKER
const VERSION_MARKER: &'static [u8] = <T as InitialFormat>::VERSION_MARKER
A sequence of bytes to add at the beginning of the serialized
string, to identify that the data is of this version.
§type Previous = NoPrevious
type Previous = NoPrevious
The previous version of this data type, from which items of this version
can be migrated.
source§fn migrate(_previous: <T as Migrate>::Previous) -> T
fn migrate(_previous: <T as Migrate>::Previous) -> T
The migration function that transforms a value decoded in the old format
to an up-to-date value.