pub struct Files { /* private fields */ }Expand description
Files of up to 16 MiB (the kernel’s --max-data-bytes) under keys of 1 to 512 bytes, per tenant and domain; see
crate::Kernable::data. Files are not part of the signed event log, and erasing a vault
subject does not delete them, so keep personal data in vault fields instead. A refused or
invalid request is Error::Status; a middleware that refuses it (checking PutData,
GetData, DeleteData or ListData of the domain) makes it PERMISSION_DENIED with
"<code>: <message>". Example:
kernable.data().put("shop", "invoices/c1.pdf", pdf, "application/pdf").await?, then
kernable.data().get("shop", "invoices/c1.pdf").await? returns Some(Data { .. }).
Implementations§
Source§impl Files
impl Files
Sourcepub fn tenant(self, tenant: impl Into<String>) -> Files
pub fn tenant(self, tenant: impl Into<String>) -> Files
The tenant to keep files under. Default: the connection’s (crate::Options::tenant).
Sourcepub fn context(self, context: RequestContext) -> Files
pub fn context(self, context: RequestContext) -> Files
Replaces the client’s default context for the requests of this handle (signed with
each; middlewares decide on it); inside a listener, pass ctx.follow(). Example:
kernable.data().context(alice).get("shop", "k").await?.
Sourcepub async fn put(
&self,
domain: &str,
key: &str,
data: impl Into<Vec<u8>>,
content_type: &str,
) -> Result<String, Error>
pub async fn put( &self, domain: &str, key: &str, data: impl Into<Vec<u8>>, content_type: &str, ) -> Result<String, Error>
Stores data as key of domain (granted data_write), replacing any file there.
Returns the SHA-256 of data (hex) as the kernel computed it: for an event to name.
Sourcepub async fn get(&self, domain: &str, key: &str) -> Result<Option<Data>, Error>
pub async fn get(&self, domain: &str, key: &str) -> Result<Option<Data>, Error>
The file key of domain (granted data_read); None if there is none.
Sourcepub async fn list(
&self,
domain: &str,
prefix: &str,
after: &str,
) -> Result<Listing, Error>
pub async fn list( &self, domain: &str, prefix: &str, after: &str, ) -> Result<Listing, Error>
The files of domain whose keys start with prefix (granted data_read), in the order
of their keys’ bytes, up to 1,000 after the key after ("" for the first page). To
find files no event names, or what a tenant stores. Example: let mut after = String::new(); loop { let page = files.list("shop", "invoices/", &after).await?; …; match page.next { Some(n) => after = n, None => break } }.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Files
impl !RefUnwindSafe for Files
impl !UnwindSafe for Files
impl Forget for Files
impl Move for Files
impl Send for Files
impl Sync for Files
impl Unpin for Files
impl UnsafeUnpin for Files
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> 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