crates.io ↗

iet-storage

core contracts official

Defines stream-based object contracts; authorization and tenant scoping remain caller policy.

CoreFeaturesIntegrationsStacksTooling
Used bynothing in the repository
iet-storagecontractsObject storage contracts
Depends oniet-corecontract

How to use it

iet-storage defines stream-based object contracts: ObjectStore (put/get/head/delete), the validated ObjectKey, ObjectMetadata/ObjectDownload, and ObjectPresigner for signed URLs. Authorization, tenant scoping, and streaming size limits are caller policies; no object-store adapter ships in this repository yet, so the closest real usage is the key contract itself.

rust
// crates/core/iet-storage/src/lib.rs (inline #[cfg(test)] module)
use iet_storage::ObjectKey;

for key in ["", "/absolute", "a/../b", "a//b", "a\\b", "a\nb"] {
    assert!(ObjectKey::new(key.into()).is_err());
}
let key = ObjectKey::new("tenant-a/documents/1".into()).unwrap();
assert_eq!(key.as_str(), "tenant-a/documents/1");
  • ObjectKey::new rejects empty keys, >4096 bytes, leading /, backslashes, control characters, and ./../empty path segments.
  • get returns an ObjectDownload carrying metadata plus a pinned Stream<Item = AppResult<Bytes>>; signed URLs from ObjectPresigner are bearer capabilities, so authorize before issuing and never log them.

How it works

An ObjectKey addresses objects in an ObjectStore, whose put, get, head, and delete methods operate on them; get yields an ObjectDownload, and ObjectPresigner mints time-limited URLs instead of streaming through the store.

flowchart LR
  A["ObjectKey::new"] --> B["ObjectStore"]
  B --> C["put"]
  B --> D["get"]
  B --> E["head"]
  B --> F["delete"]
  D --> G["ObjectDownload metadata and stream"]
  H["ObjectPresigner"] --> I["presign_get or presign_put"]

Core contract

This page is the crate reference. For the framework-wide runtime and trait model, read Architecture.

What it implements

  • Defines the traits other crates implement: ObjectStore, ObjectPresigner.

What's inside

Modules

  • src/lib.rs

Public API

(root)

  • type ObjectStream — Pinned concrete stream; boxing does not erase S or introduce a vtable.
  • struct ObjectKey
  • pub fn new(value: String) -> AppResult<Self>
  • pub fn as_str(&self) -> &str
  • struct ObjectMetadata
  • struct ObjectDownload
  • trait ObjectStore
rust
pub trait ObjectStore: Send + Sync {
    fn put<S: Stream<Item = AppResult<Bytes>> + Send>(
        &self,
        key: &ObjectKey,
        content_type: String,
        stream: S,
    ) -> impl Future<Output = AppResult<ObjectMetadata>> + Send;
    fn get(
        &self,
        key: &ObjectKey,
    ) -> impl Future<
        Output = AppResult<ObjectDownload<impl Stream<Item = AppResult<Bytes>> + Send + 'static>>,
    > + Send;
    fn head(&self, key: &ObjectKey) -> impl Future<Output = AppResult<ObjectMetadata>> + Send;
    fn delete(&self, key: &ObjectKey) -> impl Future<Output = AppResult<()>> + Send;
}
  • trait ObjectPresigner — Signed URLs are bearer capabilities; authorize before issuing and never log them.
rust
pub trait ObjectPresigner: Send + Sync {
    fn presign_get(
        &self,
        key: &ObjectKey,
        expiry: std::time::Duration,
    ) -> impl Future<Output = AppResult<String>> + Send;
    /// This URL does not enforce the server-side streaming upload size limit.
    fn presign_put(
        &self,
        key: &ObjectKey,
        expiry: std::time::Duration,
    ) -> impl Future<Output = AppResult<String>> + Send;
}

Depends on

External crates: bytes, futures-core

Used by

  • No other framework crate depends on it directly.

In this repository

  • Not used by a checked-in example yet.

Source: crates/core/iet-storage