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§
Structs§
- Document
- A document to store: its bytes and what the backend keeps with them.
- Document
Body - 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. - Document
Key - A validated object key such as
tenant/project/Binary/123. - Document
Metadata - What a backend knows about a stored document without reading its body.
- List
Page - One page of a listing, in key order.
- List
Request - Selects one page of a listing.
- Stored
Document - A stored document: its metadata and body.
Enums§
- Document
Storage Kind - The backend to connect to, with its configuration.
- Storage
Error - Failure of a
DocumentStoragecall.
Traits§
- Document
Storage - Object storage for document bodies, keyed by
DocumentKey.
Functions§
- connect
- Builds the configured backend and verifies that it can authenticate.
Type Aliases§
- Storage
Future - Boxed future returned by
DocumentStoragemethods, so the trait stays object safe.