infrastructure tier

infrastructure-storage

File storage abstraction with pluggable backends (S3, local, GCS)

File storage abstraction with pluggable backends (S3, local, GCS)

Tierinfrastructure
Roleunclassified (baselined)
Pathcrates/infrastructure/storage
Edition2021
Targetsinfrastructure_storage
Public items29 across 2 modules
Tests47

What it is for

File storage abstraction with pluggable backends.

Supports local filesystem, S3, and other storage backends.

Capabilities

local (other)

Local filesystem storage backend.

Item
pub const DEFAULT_MAX_FILE_SIZE: usize

LocalStorage:LocalStorage

Local filesystem storage backend.

Item
pub struct LocalStorage

LocalStorage:delete

Local filesystem storage backend.

Item
LocalStorage :: async fn delete(& self, path : & str) -> Result <(), StorageError>

LocalStorage:download

Local filesystem storage backend.

Item
LocalStorage :: async fn download(& self, path : & str) -> Result <Vec <u8>, StorageError>

LocalStorage:exists

Local filesystem storage backend.

Item
LocalStorage :: async fn exists(& self, path : & str) -> Result <bool, StorageError>

LocalStorage:fs

Local filesystem storage backend.

Item
LocalStorage :: fn fs_path(& self, path : & str) -> PathBuf

LocalStorage:get

Local filesystem storage backend.

Item
LocalStorage :: async fn get_by_sha256(& self, sha256_hex : & str, scope : & StoreScope,) -> Result <Option <StoredFile>, StorageError>

LocalStorage:new

Local filesystem storage backend.

Item
LocalStorage :: fn new(root : impl AsRef <Path>) -> Self

LocalStorage:private

Local filesystem storage backend.

Item
LocalStorage :: fn private_root(& self) -> & Path

LocalStorage:public

Local filesystem storage backend.

Item
LocalStorage :: fn public_root(& self) -> & Path

LocalStorage:put

Local filesystem storage backend.

Item
LocalStorage :: async fn put_bytes(& self, content : & u8, filename : & str, content_type : & str, scope : & StoreScope,) -> Result <StoredFile, StorageError>

LocalStorage:upload

Local filesystem storage backend.

Item
LocalStorage :: async fn upload(& self, content : & u8, filename : & str, content_type : & str,) -> Result <StoredFile, StorageError>

LocalStorage:url

Local filesystem storage backend.

Item
LocalStorage :: async fn url(& self, path : & str) -> Result <String, StorageError>

LocalStorage:with

Local filesystem storage backend.

Item
LocalStorage :: fn with_private_root(root : impl AsRef <Path>, private_root : impl AsRef <Path>) -> Self
LocalStorage :: fn with_max_size(root : impl AsRef <Path>, max_file_size : usize) -> Self

S3Config

S3 / Cloudflare-R2 storage backend (Media Centralization, Group C).

Item
pub struct S3Config
S3Config :: fn from_env() -> Result <Self, StorageError>

S3Storage

S3 / Cloudflare-R2 storage backend (Media Centralization, Group C).

Item
pub struct S3Storage
S3Storage :: fn new(config : S3Config) -> Self
S3Storage :: fn with_max_size(config : S3Config, max_file_size : usize) -> Self
S3Storage :: fn from_env() -> Result <Self, StorageError>
S3Storage :: fn bucket(& self) -> & str
S3Storage :: async fn upload(& self, content : & u8, filename : & str, content_type : & str,) -> Result <StoredFile, StorageError>
S3Storage :: async fn download(& self, path : & str) -> Result <Vec <u8>, StorageError>
S3Storage :: async fn delete(& self, path : & str) -> Result <(), StorageError>
S3Storage :: async fn exists(& self, path : & str) -> Result <bool, StorageError>
S3Storage :: async fn url(& self, path : & str) -> Result <String, StorageError>
S3Storage :: async fn put_bytes(& self, content : & u8, filename : & str, content_type : & str, scope : & StoreScope,) -> Result <StoredFile, StorageError>
S3Storage :: async fn get_by_sha256(& self, sha256_hex : & str, scope : & StoreScope,) -> Result <Option <StoredFile>, StorageError>

How to use it

No examples/ target and no doctest in this crate's rustdoc. The tests listed under Verification are the closest executable usage.

Module structure

infrastructure_storage

flowchart TD
  n_infrastructure_storage["infrastructure_storage"]
  n_infrastructure_storage --> n_local["local"]
  n_infrastructure_storage --> n_s3["s3"]

Public surface

`local`

ItemWhat it is
pub const DEFAULT_MAX_FILE_SIZE: usizeDefault maximum file size: 10 MB.
pub struct LocalStorageLocal filesystem storage backend
LocalStorage :: fn new(root : impl AsRef <Path>) -> SelfCreates a new local storage backend with the given public root directory
LocalStorage :: fn with_private_root(root : impl AsRef <Path>, private_root : impl AsRef <Path>) -> SelfCreates a new local storage backend with an explicit public + private root
LocalStorage :: fn with_max_size(root : impl AsRef <Path>, max_file_size : usize) -> SelfCreates a new local storage backend with a maximum file size limit.
LocalStorage :: fn public_root(& self) -> & PathThe public root (where a ServeDir may be mounted)
LocalStorage :: fn private_root(& self) -> & PathThe private root (never served)
LocalStorage :: fn fs_path(& self, path : & str) -> PathBufResolve a stored logical path to its absolute on-disk location, routing private-scope paths (the __private prefix) to the non-served private root
LocalStorage :: async fn upload(& self, content : & u8, filename : & str, content_type : & str,) -> Result <StoredFile, StorageError>
LocalStorage :: async fn download(& self, path : & str) -> Result <Vec <u8>, StorageError>
LocalStorage :: async fn delete(& self, path : & str) -> Result <(), StorageError>
LocalStorage :: async fn exists(& self, path : & str) -> Result <bool, StorageError>
LocalStorage :: async fn url(& self, path : & str) -> Result <String, StorageError>
LocalStorage :: async fn put_bytes(& self, content : & u8, filename : & str, content_type : & str, scope : & StoreScope,) -> Result <StoredFile, StorageError>
LocalStorage :: async fn get_by_sha256(& self, sha256_hex : & str, scope : & StoreScope,) -> Result <Option <StoredFile>, StorageError>

`s3`

ItemWhat it is
pub struct S3ConfigConfiguration for S3Storage
S3Config :: fn from_env() -> Result <Self, StorageError>Builds a config from environment variables (see module docs for the full table)
pub struct S3StorageS3 / R2 storage backend
S3Storage :: fn new(config : S3Config) -> SelfBuilds an S3Storage from an explicit S3Config
S3Storage :: fn with_max_size(config : S3Config, max_file_size : usize) -> SelfBuilds an S3Storage with a maximum file size limit (bytes).
S3Storage :: fn from_env() -> Result <Self, StorageError>Convenience constructor reading S3Config::from_env
S3Storage :: fn bucket(& self) -> & strReturns the bucket name (test/inspection helper).
S3Storage :: async fn upload(& self, content : & u8, filename : & str, content_type : & str,) -> Result <StoredFile, StorageError>
S3Storage :: async fn download(& self, path : & str) -> Result <Vec <u8>, StorageError>
S3Storage :: async fn delete(& self, path : & str) -> Result <(), StorageError>
S3Storage :: async fn exists(& self, path : & str) -> Result <bool, StorageError>
S3Storage :: async fn url(& self, path : & str) -> Result <String, StorageError>
S3Storage :: async fn put_bytes(& self, content : & u8, filename : & str, content_type : & str, scope : & StoreScope,) -> Result <StoredFile, StorageError>
S3Storage :: async fn get_by_sha256(& self, sha256_hex : & str, scope : & StoreScope,) -> Result <Option <StoredFile>, StorageError>

Re-exports. Exported here, defined elsewhere.

ExportDefined in
StorageBackendbackend::StorageBackend
StorageErrorerror::StorageError
StoredFilestored_file::StoredFile
{LocalStorage,DEFAULT_MAX_FILE_SIZE}local::{LocalStorage,DEFAULT_MAX_FILE_SIZE}
{S3Config,S3Storage}s3::{S3Config,S3Storage}
{path_is_private,StoreScope,PRIVATE_PREFIX}scope::{path_is_private,StoreScope,PRIVATE_PREFIX}

Boundary

Reaches into foundation.

Shares tier infrastructure with 82 other crates: infrastructure-acquire, infrastructure-adapters-google-calendar, infrastructure-adapters-google-gmail, infrastructure-adapters-google-places, infrastructure-adapters-google-trends, infrastructure-adapters-shodan, infrastructure-adapters-yelp, infrastructure-agent, … (82 total).

_What this crate deliberately does NOT own is a judgment. No committed registry records one for it, so none is stated here._

Where it sits

Tier (ontology)infrastructure
Architectural role (taxonomy)unclassified (baselined)
Locationcrates/infrastructure/storage
Vocabulary in force (lexicon)current

Tier flow. Which tiers this crate's own edges cross.

flowchart LR
  n_infrastructure["infrastructure"] --> n_foundation["foundation"]

Dependencies

Runtime, in this workspace.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
async-trait^0.1noalways
aws-config^1yesalways
aws-sdk-s3^1yesalways
chrono^0.4serdenoalways
hex^0.4noalways
mime_guess^2noalways
serde^1derivenoalways
serde_json^1noalways
sha2^0.10noalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1full, fsnoalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tempfile^3noalways
tokio-test^0.4noalways

Build. None.

Depended on by. 11 workspace crates.

Signal flow — what reaches this crate, and what it reaches.

flowchart LR
  n_application_cms["application-cms"] -->|uses| SELF
  n_application_wiki["application-wiki"] -->|uses| SELF
  n_content_assets["content-assets"] -->|uses| SELF
  n_domain_legal_documents["domain-legal-documents"] -->|uses| SELF
  n_domain_legal_evidence["domain-legal-evidence"] -->|uses| SELF
  n_domain_legal_procedure["domain-legal-procedure"] -->|uses| SELF
  n_infrastructure_acquire["infrastructure-acquire"] -->|uses| SELF
  n_infrastructure_fetcher["infrastructure-fetcher"] -->|uses| SELF
  n_infrastructure_web_ingest["infrastructure-web-ingest"] -->|uses| SELF
  n_platform_api["platform-api"] -->|uses| SELF
  n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF
  SELF["infrastructure-storage"]
  SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
aws-configdep:aws-configno
aws-sdk-s3dep:aws-sdk-s3no
defaultyes
s3aws-sdk-s3, aws-configno
flowchart LR
  n_aws_config["aws-config"] --> n_dep_aws_config["dep:aws-config"]
  n_aws_sdk_s3["aws-sdk-s3"] --> n_dep_aws_sdk_s3["dep:aws-sdk-s3"]
  n_default["default"]
  n_s3["s3"] --> n_aws_sdk_s3["aws-sdk-s3"]
  n_s3["s3"] --> n_aws_config["aws-config"]

Targets

KindNameSource
libinfrastructure_storage`src/lib.rs`

Error model

No public error type was detected: no public item declares a type named *Error, and no public signature returns one.

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.

Configuration

No environment variable is read with a literal name anywhere in this crate. A variable whose key is computed at run time cannot be listed here, and is not claimed to be absent.

11 workspace crates depend on this one: application-cms, application-wiki, content-assets, domain-legal-documents, domain-legal-evidence, domain-legal-procedure, infrastructure-acquire, infrastructure-fetcher, infrastructure-web-ingest, platform-api, platform-privacy-scan-api.

Verification

KindCount
Unit tests47
Integration tests0
Examples0
Doctests0

Evidence by module. How often each public module is named by something executable.

ModuleTestsExamplesConsumers
local207
s3200

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc1529
Public modules with a //! block22
pie showData
    title Public items with rustdoc
    "Documented" : 15
    "No rustdoc detected" : 14

Metrics

MetricValue
Rust source files7
Source lines1831
Code lines1258
Public API items29
Public modules2
Tests47
Examples0
Cargo features4
Direct runtime dependencies14
Workspace reverse dependencies11
pie showData
    title Public API by kind
    "constant" : 1
    "method" : 25
    "struct" : 3
pie showData
    title Rust source composition
    "Code" : 1258
    "Blank or comment" : 573

Generation

Rendered by tools-corpus corpus readme from repository evidence alone, renderer schema 2, lexicon current. No model, network service or database was consulted. Regenerate with tools-corpus corpus readme --write; verify with --check.

All infrastructure · Manual