Skip to main content

Crate haste_document_storage

Crate haste_document_storage 

Source
Expand description

Storage for document bodies (Binary content, attachments, exports) that is independent of the hosting cloud.

Callers only use the DocumentStorage trait; each backend lives under providers behind a cargo feature and is built with connect.

use haste_document_storage::{
    Document, DocumentKey, DocumentStorageKind, StorageError,
    providers::gcs::{GcsConfig, GcsCredentials},
};

let storage = haste_document_storage::connect(DocumentStorageKind::Gcs(GcsConfig {
    bucket: "my-bucket".into(),
    prefix: Some("documents".into()),
    credentials: GcsCredentials::ApplicationDefault,
    endpoint: None,
}))
.await?;

let key = DocumentKey::new("tenant/project/Binary/123")?;
storage
    .put(&key, Document::new(b"...".as_slice()).with_content_type("application/pdf"))
    .await?;
let document = storage.get(&key).await?;
let bytes = document.body.collect().await?;

Modules§

providers
Storage backends, each behind a cargo feature.
retry
Retry policy shared by backends.

Structs§

Document
A document to store: its bytes and what the backend keeps with them.
DocumentBody
A document body as a stream of chunks. Forward it chunk by chunk (for example into an HTTP response) or gather it with DocumentBody::collect.
DocumentKey
A validated object key such as tenant/project/Binary/123.
DocumentMetadata
What a backend knows about a stored document without reading its body.
ListPage
One page of a listing, in key order.
ListRequest
Selects one page of a listing.
StoredDocument
A stored document: its metadata and body.

Enums§

DocumentStorageKind
The backend to connect to, with its configuration.
StorageError
Failure of a DocumentStorage call.

Traits§

DocumentStorage
Object storage for document bodies, keyed by DocumentKey.

Functions§

connect
Builds the configured backend and verifies that it can authenticate.

Type Aliases§

StorageFuture
Boxed future returned by DocumentStorage methods, so the trait stays object safe.