pub struct StorageService { /* private fields */ }Expand description
Authenticated Storage Service handle.
Wraps a PushService plus the short-lived basic-auth credentials and
the account StorageServiceKey, so callers get decrypted protobufs
straight out and never touch the wire crypto themselves.
Implementations§
Source§impl StorageService
impl StorageService
Sourcepub async fn new(
service: PushService,
storage_key: StorageServiceKey,
) -> Result<Self, ServiceError>
pub async fn new( service: PushService, storage_key: StorageServiceKey, ) -> Result<Self, ServiceError>
Authenticate against the storage service.
Fetches a fresh basic-auth token (GET /v1/storage/auth); the token
is good for ~24h server-side but cheap enough to re-fetch per sync.
Sourcepub async fn manifest(&self) -> Result<ManifestRecord, StorageServiceError>
pub async fn manifest(&self) -> Result<ManifestRecord, StorageServiceError>
Fetch and decrypt the latest manifest.
Sourcepub async fn manifest_if_changed(
&self,
version: u64,
) -> Result<Option<ManifestRecord>, StorageServiceError>
pub async fn manifest_if_changed( &self, version: u64, ) -> Result<Option<ManifestRecord>, StorageServiceError>
Fetch and decrypt the manifest only if the server’s version differs
from version. Ok(None) means the server matched (HTTP 204).
Sourcepub async fn read_items(
&self,
keys: Vec<Vec<u8>>,
record_ikm: Option<&[u8]>,
) -> Result<Vec<StorageRecord>, StorageServiceError>
pub async fn read_items( &self, keys: Vec<Vec<u8>>, record_ikm: Option<&[u8]>, ) -> Result<Vec<StorageRecord>, StorageServiceError>
Fetch and decrypt storage items by key.
keys are Identifier.raw blobs from ManifestRecord::identifiers;
record_ikm is ManifestRecord::record_ikm (empty on legacy
accounts, in which case the per-item key is derived from the storage
key directly). Items the server doesn’t return are simply absent from
the result.
Sourcepub fn decrypt_manifest(
storage_key: &StorageServiceKey,
manifest: &StorageManifest,
) -> Result<ManifestRecord, StorageServiceError>
pub fn decrypt_manifest( storage_key: &StorageServiceKey, manifest: &StorageManifest, ) -> Result<ManifestRecord, StorageServiceError>
Decrypt a StorageManifest into a ManifestRecord.
Sourcepub fn encrypt_manifest(
storage_key: &StorageServiceKey,
record: &ManifestRecord,
) -> StorageManifest
pub fn encrypt_manifest( storage_key: &StorageServiceKey, record: &ManifestRecord, ) -> StorageManifest
Encrypt a ManifestRecord into a StorageManifest ready to PUT.
Sourcepub fn decrypt_item(
storage_key: &StorageServiceKey,
item: &StorageItem,
record_ikm: Option<&[u8]>,
) -> Result<StorageRecord, StorageServiceError>
pub fn decrypt_item( storage_key: &StorageServiceKey, item: &StorageItem, record_ikm: Option<&[u8]>, ) -> Result<StorageRecord, StorageServiceError>
Decrypt a StorageItem into a StorageRecord.
Sourcepub fn encrypt_item(
storage_key: &StorageServiceKey,
raw_id: Vec<u8>,
record: &StorageRecord,
record_ikm: Option<&[u8]>,
) -> StorageItem
pub fn encrypt_item( storage_key: &StorageServiceKey, raw_id: Vec<u8>, record: &StorageRecord, record_ikm: Option<&[u8]>, ) -> StorageItem
Encrypt a StorageRecord into a StorageItem ready to PUT.
raw_id is the item’s identifier; record_ikm should match what’s
in the manifest this item will be referenced from.
Auto Trait Implementations§
impl Freeze for StorageService
impl !RefUnwindSafe for StorageService
impl Send for StorageService
impl Sync for StorageService
impl Unpin for StorageService
impl UnsafeUnpin for StorageService
impl !UnwindSafe for StorageService
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> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§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> 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> 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§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].