Media assets, file attachments, and variant generation with integrity verification
| Tier | content |
| Role | unclassified (baselined) |
| Path | crates/content/assets |
| Edition | 2021 |
| Targets | content_assets, asset_text_state_machine, migration_013_media_access, migration_016_asset_audience_grants, migration_017_audience_migration, pg_set_visibility |
| Public items | 410 across 29 modules |
| Tests | 357 |
What it is for
# content-assets
Media assets, file attachments, and variant generation with integrity verification.
Core Concepts
- Assets are immutable: Once uploaded, file content never changes.
To "update" a file, create a new asset and re-attach.
- SHA-256 integrity: Every asset has a content hash for verification and deduplication.
- Generic attachments: One attachment table links assets to any model.
- Visibility tiers: Public, Internal, or Private access control.
- Soft delete: Assets can be restored; files preserved on disk.
Example
use content_assets::{Asset, Attachment, Variant, Visibility, mime_types, variant_kinds};
use uuid::Uuid;
// Create an asset
let asset = Asset::builder()
.file_path("assets/2024/01/photo.jpg")
.original_filename("vacation_photo.jpg")
.content_type(mime_types::JPEG)
.size_bytes(1_048_576) // 1 MB
.sha256("abc123def456...")
.dimensions(1920, 1080)
.title("Beach Sunset")
.alt_text("A beautiful sunset over the ocean")
.visibility(Visibility::Public)
.build();
// Attach to a target object
let attachment = Attachment::builder()
.asset(asset.id)
.target("posts.Post", "post-123")
.field_name("featured_image")
.build();
// Create a thumbnail variant
let thumb = Variant::builder()
.asset(asset.id)
.thumb()
.file_path("variants/abc123/thumb.jpg")
.dimensions(256, 144)
.jpeg()
.build();
Capabilities
access (other)
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
fn in_ceiling(page : & Audience, attachment : Option <& Audience>, viewer : & Viewer) -> bool |
fn variant_satisfied(variant : & VariantTier, viewer : & Viewer) -> bool |
fn resolve(in_ceiling : bool, variants : & VariantTier, viewer : & Viewer, on_deny : OnDeny, floor : Option <Uuid>,) -> AccessDecision |
AccessDecision
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub enum AccessDecision |
Audience
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub struct Audience |
Audience :: fn of(subjects : impl IntoIterator <Item = Subject>) -> Self |
Audience :: fn deny_all() -> Self |
fn audience_admits(audience : & Audience, viewer : & Viewer) -> bool |
OnDeny
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub enum OnDeny |
Subject
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub enum Subject |
Tier
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub enum Tier |
TierRef
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub enum TierRef |
VariantTier
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub struct VariantTier |
Viewer
Media access resolution (Sprint 0.59) — the decidable core of the Media RBAC
| Item |
|---|
pub struct Viewer |
access_map (other)
DB-scalar → access-type codecs (Sprint 0.60, T-0.60.1).
| Item |
|---|
fn parse_tier(min_tier : & str) -> Result <Tier, AssetError> |
fn variant_tier_from_row(variant_id : Uuid, quality_rank : i16, min_tier : & str, tier_ref_group : Option <Uuid>, tier_ref_entitlement : Option <String>,) -> Result <VariantTier, AssetError> |
fn subject_from_row(subject_kind : & str, subject_id : Option <Uuid>,) -> Result <Subject, AssetError> |
fn parse_on_deny(on_deny : & str) -> Result <OnDeny, AssetError> |
fn audience_mode_narrows(audience_mode : & str) -> Result <bool, AssetError> |
fn build_viewer(authenticated : bool, user_id : Option <Uuid>, roles : impl IntoIterator <Item = Uuid>, direct_groups : impl IntoIterator <Item = Uuid>, role_bound_groups : impl IntoIterator <Item = Uuid>, entitlements : impl IntoIterator <Item = String>,) -> Viewer |
Asset:Asset
Asset model for media/file storage.
| Item |
|---|
pub struct Asset |
Asset:builder
Asset model for media/file storage.
| Item |
|---|
Asset :: fn builder() -> AssetBuilder |
Asset:can
Asset model for media/file storage.
| Item |
|---|
Asset :: fn can_access(& self, party_id : Option <PartyId>, is_staff : bool) -> bool |
Asset:created
Asset model for media/file storage.
| Item |
|---|
Asset :: fn created_at(& self) -> DateTime <Utc> |
Asset:deleted
Asset model for media/file storage.
| Item |
|---|
Asset :: fn deleted_at(& self) -> Option <DateTime <Utc>> |
Asset:dimensions
Asset model for media/file storage.
| Item |
|---|
Asset :: fn dimensions(& self) -> Option <(i32, i32)> |
Asset:display
Asset model for media/file storage.
| Item |
|---|
Asset :: fn display_source_url(& self) -> & str |
Asset:extension
Asset model for media/file storage.
| Item |
|---|
Asset :: fn extension(& self) -> Option <& str> |
Asset:human
Asset model for media/file storage.
| Item |
|---|
Asset :: fn human_size(& self) -> String |
Asset:id
Asset model for media/file storage.
| Item |
|---|
Asset :: fn id(& self) -> Uuid |
Asset:is
Asset model for media/file storage.
| Item |
|---|
Asset :: fn is_image(& self) -> bool |
Asset:license
Asset model for media/file storage.
| Item |
|---|
Asset :: fn license(& self) -> License |
Asset:restore
Asset model for media/file storage.
| Item |
|---|
Asset :: fn restore(& mut self) |
Asset:soft
Asset model for media/file storage.
| Item |
|---|
Asset :: fn soft_delete(& mut self) |
Asset:updated
Asset model for media/file storage.
| Item |
|---|
Asset :: fn updated_at(& self) -> DateTime <Utc> |
AssetBuilder:AssetBuilder
Asset model for media/file storage.
| Item |
|---|
pub struct AssetBuilder |
AssetBuilder:alt
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn alt_text(mut self, alt_text : impl Into <String>) -> Self |
AssetBuilder:attribution
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn attribution_title(mut self, title : impl Into <String>) -> Self |
AssetBuilder :: fn attribution_author(mut self, author : impl Into <String>) -> Self |
AssetBuilder :: fn attribution_author_url(mut self, url : impl Into <String>) -> Self |
AssetBuilder :: fn attribution_required(mut self, required : bool) -> Self |
AssetBuilder :: fn attribution_modified_note(mut self, note : impl Into <String>) -> Self |
AssetBuilder:build
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn build(self) -> Asset |
AssetBuilder:caption
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn caption(mut self, caption : impl Into <String>) -> Self |
AssetBuilder:content
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn content_type(mut self, content_type : impl Into <String>) -> Self |
AssetBuilder:dimensions
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn dimensions(mut self, width : i32, height : i32) -> Self |
AssetBuilder:file
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn file_path(mut self, path : impl Into <String>) -> Self |
AssetBuilder:focal
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn focal(mut self, x : f64, y : f64) -> Self |
AssetBuilder:is
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn is_image(mut self, is_image : bool) -> Self |
AssetBuilder:license
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn license(mut self, license : & License) -> Self |
AssetBuilder :: fn license_short_name(mut self, name : impl Into <String>) -> Self |
AssetBuilder :: fn license_url(mut self, url : impl Into <String>) -> Self |
AssetBuilder:metadata
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn metadata(mut self, metadata : JsonValue) -> Self |
AssetBuilder:new
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn new() -> Self |
AssetBuilder:notes
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn notes(mut self, notes : impl Into <String>) -> Self |
AssetBuilder:original
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn original_filename(mut self, name : impl Into <String>) -> Self |
AssetBuilder :: fn original_source_url(mut self, url : impl Into <String>) -> Self |
AssetBuilder:owner
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn owner(mut self, owner_id : PartyId) -> Self |
AssetBuilder:raw
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn raw_import_metadata(mut self, value : JsonValue) -> Self |
AssetBuilder:sha256
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn sha256(mut self, hash : impl Into <String>) -> Self |
AssetBuilder:size
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn size_bytes(mut self, size : i64) -> Self |
AssetBuilder:source
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn source_url(mut self, url : impl Into <String>) -> Self |
AssetBuilder:tag
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn tag(mut self, tag : impl Into <String>) -> Self |
AssetBuilder:tags
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn tags(mut self, tags : Vec <String>) -> Self |
AssetBuilder:title
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn title(mut self, title : impl Into <String>) -> Self |
AssetBuilder:visibility
Asset model for media/file storage.
| Item |
|---|
AssetBuilder :: fn visibility(mut self, visibility : Visibility) -> Self |
asset_text (other)
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
fn text_for(rows : & AssetText, viewer_locale : & str, kind : TextKind) -> String |
async fn get(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind,) -> Result <Option <AssetText>, AssetError> |
async fn apply_translation(pool : & PgPool, asset_id : Uuid, target_locale : & str, kind : TextKind, translated_text : & str, source_locale : & str, derived_from_hash : & str, model : Option <& str>,) -> Result <TranslationOutcome, AssetError> |
AssetText
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub struct AssetText |
AssetText :: fn ready_to_translate(& self) -> bool |
AssetText :: fn is_human_confirmed(& self) -> bool |
fn translation_may_replace(existing : Option <& AssetText>) -> bool |
AssetText :: fn try_from(r : AssetTextRow) -> Result <Self, Self::Error> |
async fn list_for_asset(pool : & PgPool, asset_id : Uuid) -> Result <Vec <AssetText>, AssetError> |
SuggestedDraft
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub struct SuggestedDraft |
async fn record_suggested(pool : & PgPool, draft : & SuggestedDraft) -> Result <(), AssetError> |
TextKind
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub enum TextKind |
TextKind :: fn as_str(self) -> & 'static str |
TextKind :: fn parse(s : & str) -> Option <Self> |
async fn confirm_human(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind, text : & str, confirmed_by : Option <Uuid>,) -> Result <(), AssetError> |
async fn mark_stale(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind, reason : & str,) -> Result <(), AssetError> |
TextSource
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub enum TextSource |
TextSource :: fn as_str(self) -> & 'static str |
TextSource :: fn parse(s : & str) -> Option <Self> |
TextStatus
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub enum TextStatus |
TextStatus :: fn as_str(self) -> & 'static str |
TextStatus :: fn parse(s : & str) -> Option <Self> |
fn ready_to_translate(status : TextStatus) -> bool |
TranslationOutcome
Bilingual asset text (Sprint 0.83) — per-(asset, locale, kind) description
| Item |
|---|
pub enum TranslationOutcome |
Attachment
Attachment model for linking assets to any target object.
| Item |
|---|
pub struct Attachment |
Attachment :: fn builder() -> AttachmentBuilder |
Attachment :: fn is_for(& self, target_type : & str, target_id : & str) -> bool |
Attachment :: fn is_in_field(& self, field_name : & str) -> bool |
Attachment :: fn matches(& self, target_type : & str, target_id : & str, field_name : & str) -> bool |
Attachment :: fn id(& self) -> Uuid |
Attachment :: fn created_at(& self) -> DateTime <Utc> |
Attachment :: fn updated_at(& self) -> DateTime <Utc> |
Attachment :: fn deleted_at(& self) -> Option <DateTime <Utc>> |
Attachment :: fn soft_delete(& mut self) |
Attachment :: fn restore(& mut self) |
AttachmentBuilder
Attachment model for linking assets to any target object.
| Item |
|---|
pub struct AttachmentBuilder |
AttachmentBuilder :: fn new() -> Self |
AttachmentBuilder :: fn asset(mut self, asset_id : Uuid) -> Self |
AttachmentBuilder :: fn target(mut self, target_type : impl Into <String>, target_id : impl Into <String>) -> Self |
AttachmentBuilder :: fn field_name(mut self, field_name : impl Into <String>) -> Self |
AttachmentBuilder :: fn sort_order(mut self, order : i32) -> Self |
AttachmentBuilder :: fn note(mut self, note : impl Into <String>) -> Self |
AttachmentBuilder :: fn created_by(mut self, user_id : Uuid) -> Self |
AttachmentBuilder :: fn build(self) -> Attachment |
audience (other)
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
fn evaluate(asset : AssetState, actor : & ActorSubjects, surface : Surface, requested_action : Action, grants : & ActiveGrant,) -> Decision |
Action
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub enum Action |
fn required_capability(requested : Action, is_display_kind : bool) -> Action |
ActiveGrant
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub struct ActiveGrant |
ActorSubjects
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub struct ActorSubjects |
ActorSubjects :: fn anonymous() -> Self |
AssetState
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub struct AssetState |
AssetState :: fn tier_servable(self) -> bool |
AudienceKind
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub enum AudienceKind |
Decision
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub enum Decision |
EntityRefSubject
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub struct EntityRefSubject |
EntityRefTarget
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub struct EntityRefTarget |
Surface
Per-asset scoped-audience evaluator (Sprint 0.77) — the decidable core of
| Item |
|---|
pub enum Surface |
Surface :: fn as_str(self) -> & 'static str |
fn kind_valid_on_surface(kind : AudienceKind, surface : Surface) -> bool |
commons_import (other)
Wikimedia Commons import — fetch CC-licensed media + structured
| Item |
|---|
async fn fetch_metadata(client : & reqwest::Client, file_title : & str,) -> Result <CommonsImport, CommonsImportError> |
CommonsImport
Wikimedia Commons import — fetch CC-licensed media + structured
| Item |
|---|
pub struct CommonsImport |
CommonsImport :: fn from_api_response(json : & serde_json::Value, file_title : & str,) -> Result <Self, CommonsImportError> |
CommonsImportError
Wikimedia Commons import — fetch CC-licensed media + structured
| Item |
|---|
pub enum CommonsImportError |
fn parse_url(url : & str) -> Result <String, CommonsImportError> |
async fn fetch_image_bytes(image_url : & str, max_bytes : Option <usize>,) -> Result <Vec <u8>, CommonsImportError> |
composite (other)
Image compositing: stitch multiple images into a single composite.
| Item |
|---|
fn stitch_images(images : & & [u8], options : & CompositeOptions,) -> Result <Vec <u8>, CompositeError> |
fn stitch_image_files(paths : & & str, options : & CompositeOptions,) -> Result <Vec <u8>, CompositeError> |
CompositeError
Image compositing: stitch multiple images into a single composite.
| Item |
|---|
pub enum CompositeError |
CompositeLayout
Image compositing: stitch multiple images into a single composite.
| Item |
|---|
pub enum CompositeLayout |
CompositeOptions
Image compositing: stitch multiple images into a single composite.
| Item |
|---|
pub struct CompositeOptions |
CompositeOptions :: fn default() -> Self |
OutputFormat
Image compositing: stitch multiple images into a single composite.
| Item |
|---|
pub enum OutputFormat |
OutputFormat :: fn default() -> Self |
content_types (other)
Content type validation utilities.
| Item |
|---|
pub const IMAGE_TYPES: & & str |
ContentTypeValidator
Content type validation utilities.
| Item |
|---|
pub struct ContentTypeValidator |
ContentTypeValidator :: fn images_only() -> Self |
ContentTypeValidator :: fn new(allowed : impl IntoIterator <Item = impl Into <String>>) -> Self |
ContentTypeValidator :: fn is_allowed(& self, content_type : & str) -> bool |
ContentTypeValidator :: fn extension_for(content_type : & str) -> & 'static str |
ContentTypeValidator :: fn allowed_types(& self) -> & String |
ContentTypeValidator :: fn default() -> Self |
AssetError:AssetError
Error types for the assets crate.
| Item |
|---|
pub enum AssetError |
AssetError:access
Error types for the assets crate.
| Item |
|---|
AssetError :: fn access_denied(id : Uuid) -> Self |
AssetError:asset
Error types for the assets crate.
| Item |
|---|
AssetError :: fn asset_not_found(id : Uuid) -> Self |
AssetError :: fn asset_deleted(id : Uuid) -> Self |
AssetError:attachment
Error types for the assets crate.
| Item |
|---|
AssetError :: fn attachment_not_found(id : Uuid) -> Self |
AssetError:duplicate
Error types for the assets crate.
| Item |
|---|
AssetError :: fn duplicate_asset(sha256 : impl Into <String>, existing_id : Uuid) -> Self |
AssetError:file
Error types for the assets crate.
| Item |
|---|
AssetError :: fn file_too_large(size_bytes : i64, max_bytes : i64) -> Self |
AssetError:forbidden
Error types for the assets crate.
| Item |
|---|
AssetError :: fn forbidden(message : impl Into <String>) -> Self |
AssetError:hash
Error types for the assets crate.
| Item |
|---|
AssetError :: fn hash_mismatch(expected : impl Into <String>, actual : impl Into <String>) -> Self |
AssetError:invalid
Error types for the assets crate.
| Item |
|---|
AssetError :: fn invalid_file_type(content_type : impl Into <String>) -> Self |
AssetError :: fn invalid_reorder(message : impl Into <String>) -> Self |
AssetError :: fn invalid_access_data(message : impl Into <String>) -> Self |
AssetError:storage
Error types for the assets crate.
| Item |
|---|
AssetError :: fn storage_error(message : impl Into <String>) -> Self |
AssetError:unsupported
Error types for the assets crate.
| Item |
|---|
AssetError :: fn unsupported_content_type(content_type : impl Into <String>) -> Self |
AssetError:variant
Error types for the assets crate.
| Item |
|---|
AssetError :: fn variant_not_found(asset_id : Uuid, kind : impl Into <String>) -> Self |
ExifData
EXIF extraction library crate (Sprint 0.27).
| Item |
|---|
pub struct ExifData |
fn extract_exif(bytes : & u8) -> Option <ExifData> |
async fn get_exif(pool : & PgPool, asset_id : Uuid) -> Result <Option <ExifData>, AssetError> |
fetch (other)
Remote-URL fetch ingestion (Sprint 0.30).
| Item |
|---|
pub const FETCH_TIMEOUT: Duration |
FetchErrorKind
Remote-URL fetch ingestion (Sprint 0.30).
| Item |
|---|
pub enum FetchErrorKind |
FetchErrorKind :: fn as_str(self) -> & 'static str |
fn classify_ingest_error(err : & AssetError) -> FetchErrorKind |
SourceKind
Remote-URL fetch ingestion (Sprint 0.30).
| Item |
|---|
pub struct SourceKind |
SourceKind :: fn new(s : impl Into <String>) -> Self |
SourceKind :: fn as_str(& self) -> & str |
async fn fetch_and_ingest(pool : & PgPool, storage : & dyn StorageBackend, url : & str, source_kind : & SourceKind, filename : & str, fetch_run_id : Option <Uuid>,) -> Result <UploadResult, AssetError> |
handlers (other)
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub const BLOB_MAX_SIZE_BYTES: usize |
pub const BLOB_ALLOWED_MIMES: & & str |
pub const INLINE_ELIGIBLE_BLOB_MIMES: & & str |
fn requires_sanitizer(content_type : & str) -> bool |
fn blob_inline_servable_allowed(content_type : & str, sanitized : bool) -> bool |
fn validate_pdf(bytes : & u8) -> Result <(), IngestError> |
BlobHandler
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub struct BlobHandler |
BlobHandler :: fn can_handle(& self, mime : & str) -> bool |
BlobHandler :: fn supported_mimes(& self) -> & 'static & 'static str |
BlobHandler :: fn name(& self) -> & 'static str |
BlobHandler :: fn process(& self, input : ProcessInput <'_>) -> Result <Processed, AssetError> |
ContentHandler
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub trait ContentHandler |
HandlerRegistry
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub struct HandlerRegistry |
HandlerRegistry :: fn new() -> Self |
HandlerRegistry :: fn register(& mut self, handler : Box <dyn ContentHandler>) -> & mut Self |
HandlerRegistry :: fn resolve(& self, mime : & str) -> Option <& dyn ContentHandler> |
HandlerRegistry :: fn require(& self, mime : & str) -> Result <& dyn ContentHandler, AssetError> |
HandlerRegistry :: fn default() -> Self |
ImageHandler
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub struct ImageHandler |
ImageHandler :: fn can_handle(& self, mime : & str) -> bool |
ImageHandler :: fn supported_mimes(& self) -> & 'static & 'static str |
ImageHandler :: fn name(& self) -> & 'static str |
ImageHandler :: fn process(& self, input : ProcessInput <'_>) -> Result <Processed, AssetError> |
PreparedBlob
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub struct PreparedBlob |
ProcessInput
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub struct ProcessInput<'a> |
Processed
Content-type handler dispatch (Sprint 0.57).
| Item |
|---|
pub enum Processed |
ImageError
Image processing utilities (requires imaging feature).
| Item |
|---|
pub enum ImageError |
ImageProcessor
Image processing utilities (requires imaging feature).
| Item |
|---|
pub struct ImageProcessor |
ImageProcessor :: fn extract_dimensions(content : & u8) -> Result <(u32, u32), ImageError> |
ImageProcessor :: fn create_thumbnail(content : & u8, max_dimension : u32,) -> Result <(Vec <u8>, u32, u32), ImageError> |
ImageProcessor :: fn create_variant(content : & u8, max_dimension : u32, format : ImageFormat,) -> Result <(Vec <u8>, u32, u32), ImageError> |
ImageProcessor :: fn is_valid_image(content : & u8) -> bool |
ImageProcessor :: fn detect_format(content : & u8) -> Option <ImageFormat> |
ImageProcessor :: fn perceptual_fingerprint(content : & u8) -> Result <u64, ImageError> |
ImageProcessor :: fn fingerprint_distance(a : u64, b : u64) -> u32 |
ImageProcessor :: fn mime_type_for(format : ImageFormat) -> & 'static str |
verb:apply
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn apply_orientation(img : DynamicImage, orientation : u32) -> DynamicImage |
verb:canonical
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn canonical_jpeg(bytes : & u8) -> Result <CanonicalImage, IngestError> |
verb:constants
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub const MAX_SIZE_BYTES: usize |
pub const MAX_DIMENSION: u32 |
pub const ALLOWED_MIMES: & & str |
pub const CANONICAL_JPEG_QUALITY: u8 |
pub const ALL_DISPLAY_KINDS: & & str |
pub const IMMEDIATE_ELIGIBLE_KINDS: & & str |
pub const FAST_FORMATS: & & str |
pub const ALL_FORMATS: & & str |
pub const WORKER_AVIF_SPEED: u8 |
verb:crop
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn crop_window(src_w : u32, src_h : u32, tw : u32, th : u32, fx : f64, fy : f64,) ->(u32, u32, u32, u32) |
fn crop_to_aspect(img : & DynamicImage, tw : u32, th : u32, fx : f64, fy : f64) -> DynamicImage |
verb:generate
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
async fn generate_missing_variants(pool : & PgPool, storage : & dyn StorageBackend, asset_id : Uuid,) -> Result <usize, AssetError> |
verb:ingest
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
async fn ingest(pool : & PgPool, storage : & dyn StorageBackend, bytes : & u8, declared_mime : & str, filename : & str, opts : IngestOptions <'_>,) -> Result <UploadResult, AssetError> |
async fn ingest_blob_validated(pool : & PgPool, storage : & dyn StorageBackend, blob : crate::handlers::PreparedBlob, sanitizer : Option <& dyn Sanitizer>, opts : & IngestOptions <'_>,) -> Result <UploadResult, AssetError> |
async fn ingest_blob(pool : & PgPool, storage : & dyn StorageBackend, bytes : & u8, declared_mime : & str, filename : & str, sanitizer : Option <& dyn Sanitizer>, opts : & IngestOptions <'_>,) -> Result <UploadResult, AssetError> |
verb:prepare
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn prepare_ingest(bytes : & u8, declared_mime : & str, focal : Option <(f64, f64)>, kinds : & & str, formats : & & str, avif_speed : u8,) -> Result <PreparedIngest, IngestError> |
verb:read
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn read_exif_orientation(bytes : & u8) -> u32 |
verb:regenerate
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
async fn regenerate_variants(pool : & PgPool, storage : & dyn StorageBackend, asset_id : Uuid,) -> Result <usize, AssetError> |
verb:resize
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn resize_max(img : & DynamicImage, max_px : u32) -> DynamicImage |
verb:sha256
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn sha256_hex(bytes : & u8) -> String |
verb:sniff
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
fn sniff_image_format(bytes : & u8) -> Option <& 'static str> |
CanonicalImage
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub struct CanonicalImage |
IngestError
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub enum IngestError |
fn validate_magic(declared : & str, bytes : & u8) -> Result <(), IngestError> |
fn check_dimensions(bytes : & u8) -> Result <(u32, u32), IngestError> |
fn encode_jpeg(img : & DynamicImage, quality : u8) -> Result <Vec <u8>, IngestError> |
fn encode_webp(img : & DynamicImage, quality : f32) -> Result <Vec <u8>, IngestError> |
fn encode_avif(_img : & DynamicImage, _quality : u8, _speed : u8) -> Result <Vec <u8>, IngestError> |
IngestOptions
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub struct IngestOptions<'a> |
IngestOptions<'_>
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
IngestOptions<'_> :: fn default() -> Self |
PreparedIngest
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub struct PreparedIngest |
PreparedVariant
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub struct PreparedVariant |
Sanitizer
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub trait Sanitizer |
UploadResult
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub struct UploadResult |
VariantSpec
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub type VariantSpec: (& 'static str, u32, u8, Option <(u32, u32)>) |
pub const SIZES: & VariantSpec |
License
Content license model — Creative Commons + ARR + free-text fallback.
| Item |
|---|
pub enum License |
License :: fn short_name(& self) -> & str |
License :: fn canonical_url(& self) -> & 'static str |
License :: fn attribution_required(& self) -> bool |
License :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result |
License :: fn from_str(s : & str) -> Result <Self, Self::Err> |
verb:constants
Validated image-ingest pipeline (Sprint 0.26).
| Item |
|---|
pub const JPEG: & str |
pub const PNG: & str |
pub const GIF: & str |
pub const WEBP: & str |
pub const SVG: & str |
pub const BMP: & str |
pub const TIFF: & str |
pub const ICO: & str |
pub const PDF: & str |
pub const DOC: & str |
pub const DOCX: & str |
pub const XLS: & str |
pub const XLSX: & str |
pub const PPT: & str |
pub const PPTX: & str |
pub const JSON: & str |
pub const XML: & str |
pub const CSV: & str |
pub const TEXT: & str |
pub const HTML: & str |
pub const MARKDOWN: & str |
pub const ZIP: & str |
pub const GZIP: & str |
pub const TAR: & str |
pub const MP3: & str |
pub const WAV: & str |
pub const OGG_AUDIO: & str |
pub const MP4: & str |
pub const WEBM: & str |
pub const OGG_VIDEO: & str |
pub const OCTET_STREAM: & str |
verb:extension
Common MIME type constants.
| Item |
|---|
fn extension_for(mime_type : & str) -> Option <& 'static str> |
verb:from
Common MIME type constants.
| Item |
|---|
fn from_extension(ext : & str) -> Option <& 'static str> |
verb:is
Common MIME type constants.
| Item |
|---|
fn is_image(mime_type : & str) -> bool |
fn is_document(mime_type : & str) -> bool |
fn is_audio(mime_type : & str) -> bool |
fn is_video(mime_type : & str) -> bool |
fn is_media(mime_type : & str) -> bool |
AttachInput
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct AttachInput |
AttachInput :: fn new(tenant_id : Uuid, asset_id : Uuid, entity_ref : EntityRef, field_name : impl Into <String>,) -> Self |
AttachInput :: fn uploaded_by(mut self, id : Uuid) -> Self |
AttachInput :: fn owner(mut self, id : Uuid) -> Self |
AttachInput :: fn sort_order(mut self, n : i32) -> Self |
AttachInput :: fn visibility(mut self, kind : impl Into <String>) -> Self |
AttachInput :: fn audit_class(mut self, class : impl Into <String>) -> Self |
AttachmentRow
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct AttachmentRow |
AttachmentService:AttachmentService
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct AttachmentService |
AttachmentService:attach
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn attach(& self, input : AttachInput) -> Result <AttachmentRow, AssetError> |
AttachmentService:audit
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: fn audit(& self) -> & Arc <dyn AuditSink> |
AttachmentService:can
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn can_view(& self, ctx : & crate::service::policy::PolicyContext, attachment : & AttachmentRow, policy : & dyn crate::service::policy::AttachmentPolicy,) -> Result <bool, AssetError> |
AttachmentService :: async fn can_manage(& self, ctx : & crate::service::policy::PolicyContext, attachment : & AttachmentRow, policy : & dyn crate::service::policy::AttachmentPolicy,) -> Result <bool, AssetError> |
AttachmentService:cascade
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn cascade_on_target_delete(& self, entity_ref : & EntityRef,) -> Result <usize, AssetError> |
AttachmentService:count
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn count_references(& self, asset_id : Uuid) -> Result <u64, AssetError> |
AttachmentService:detach
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn detach(& self, attachment_id : Uuid) -> Result <(), AssetError> |
AttachmentService:get
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn get_by_id(& self, attachment_id : Uuid) -> Result <AttachmentRow, AssetError> |
AttachmentService:grant
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn grant(& self, input : crate::service::grants::GrantInput,) -> Result <crate::service::grants::Grant, AssetError> |
AttachmentService:has
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn has_view_grant(& self, viewer_party_id : Uuid, attachment : & AttachmentRow,) -> Result <bool, AssetError> |
AttachmentService:list
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn list_for_entity(& self, entity_ref : & EntityRef,) -> Result <Vec <AttachmentWithAsset>, AssetError> |
AttachmentService :: async fn list_grants(& self, attachment_id : Uuid,) -> Result <Vec <crate::service::grants::Grant>, AssetError> |
AttachmentService:new
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: fn new(pool : PgPool) -> Self |
AttachmentService :: fn new_with_audit(pool : PgPool, audit : Arc <dyn AuditSink>) -> Self |
AttachmentService:pool
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: fn pool(& self) -> & PgPool |
AttachmentService:reorder
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn reorder(& self, entity_ref : & EntityRef, field_name : & str, ordered_attachment_ids : & Uuid,) -> Result <(), AssetError> |
AttachmentService:revoke
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn revoke(& self, grant_id : Uuid, actor_party_id : Option <Uuid>,) -> Result <(), AssetError> |
AttachmentService:set
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn set_primary(& self, attachment_id : Uuid) -> Result <AttachmentRow, AssetError> |
AttachmentService:soft
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn soft_delete_if_orphaned(& self, asset_id : Uuid) -> Result <bool, AssetError> |
AttachmentService:update
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn update_sort_order(& self, attachment_id : Uuid, new_sort_order : i32,) -> Result <AttachmentRow, AssetError> |
AttachmentService:verify
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
AttachmentService :: async fn verify_ownership(& self, attachment_id : Uuid, entity_ref : & EntityRef,) -> Result <AttachmentRow, AssetError> |
AttachmentWithAsset
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct AttachmentWithAsset |
EntityRef
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct EntityRef |
EntityRef :: fn new(entity_type : impl Into <String>, entity_id : Uuid) -> Self |
FieldNames
Attachment service for managing image attachments with ordering and primary selection.
| Item |
|---|
pub struct FieldNames |
service::audience_grants (other)
Per-asset audience grant rows + DB codecs (Sprint 0.77).
| Item |
|---|
pub const ACTIVE_GRANT_PREDICATE: & str |
fn capability_clause(action : crate::audience::Action) -> & 'static str |
fn parse_audience_kind(kind : & str) -> Result <AudienceKind, AssetError> |
fn parse_surface(surface : & str) -> Result <Surface, AssetError> |
AssetAudienceGrant
Per-asset audience grant rows + DB codecs (Sprint 0.77).
| Item |
|---|
pub struct AssetAudienceGrant |
AssetAudienceGrant :: fn to_active_grant(& self) -> Result <ActiveGrant, AssetError> |
GrantInput
Per-asset audience grant rows + DB codecs (Sprint 0.77).
| Item |
|---|
pub struct GrantInput |
service::audience_migration (other)
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
fn map_legacy_subject(s : & LegacySubject) -> MapOutcome |
DerivedGrant
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
pub struct DerivedGrant |
DropReason
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
pub enum DropReason |
LegacySubject
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
pub struct LegacySubject |
MapOutcome
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
pub enum MapOutcome |
MigrationReport
Fail-closed migration mapping: 0.59 per-page media_audience_entries
| Item |
|---|
pub struct MigrationReport |
MigrationReport :: fn from_subjects(subjects : & LegacySubject) -> Self |
MigrationReport :: fn never_widens(& self) -> bool |
AuditEvent
Audit-log sink trait for attachment lifecycle events.
| Item |
|---|
pub struct AuditEvent |
AuditEvent :: fn is_sensitive(& self) -> bool |
AuditSink
Audit-log sink trait for attachment lifecycle events.
| Item |
|---|
pub trait AuditSink |
NoopAuditSink
Audit-log sink trait for attachment lifecycle events.
| Item |
|---|
pub struct NoopAuditSink |
NoopAuditSink :: async fn emit(& self, _event : AuditEvent) -> Result <(), AssetError> |
NoopAuditSink :: fn is_persistent(& self) -> bool |
Grant
Explicit per-grantee access grants for attachments.
| Item |
|---|
pub struct Grant |
Grant :: fn is_active(& self, now : DateTime <Utc>) -> bool |
GrantInput
Per-asset audience grant rows + DB codecs (Sprint 0.77).
| Item |
|---|
pub struct GrantInput |
AttachDecision
Per-entity-type authorization policy hook for attachments.
| Item |
|---|
pub enum AttachDecision |
AttachmentPolicy
Per-entity-type authorization policy hook for attachments.
| Item |
|---|
pub trait AttachmentPolicy |
PolicyContext
Per-entity-type authorization policy hook for attachments.
| Item |
|---|
pub struct PolicyContext |
PolicyContext :: fn has_perm(& self, perm : & str) -> bool |
variant (other)
Variant model for derived versions of assets.
| Item |
|---|
fn is_servable_default(kind : & str, visibility : Visibility) -> bool |
Variant:Variant
Variant model for derived versions of assets.
| Item |
|---|
pub struct Variant |
Variant:aspect
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn aspect_ratio(& self) -> f64 |
Variant:builder
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn builder() -> VariantBuilder |
Variant:created
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn created_at(& self) -> DateTime <Utc> |
Variant:deleted
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn deleted_at(& self) -> Option <DateTime <Utc>> |
Variant:dimensions
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn dimensions(& self) ->(i32, i32) |
Variant:id
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn id(& self) -> Uuid |
Variant:is
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn is_standard_kind(& self) -> bool |
Variant :: fn is_thumb(& self) -> bool |
Variant :: fn is_landscape(& self) -> bool |
Variant :: fn is_portrait(& self) -> bool |
Variant :: fn is_square(& self) -> bool |
Variant:restore
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn restore(& mut self) |
Variant:soft
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn soft_delete(& mut self) |
Variant:updated
Variant model for derived versions of assets.
| Item |
|---|
Variant :: fn updated_at(& self) -> DateTime <Utc> |
VariantBuilder:VariantBuilder
Variant model for derived versions of assets.
| Item |
|---|
pub struct VariantBuilder |
VariantBuilder:asset
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn asset(mut self, asset_id : Uuid) -> Self |
VariantBuilder:build
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn build(self) -> Variant |
VariantBuilder:dimensions
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn dimensions(mut self, width : i32, height : i32) -> Self |
VariantBuilder:file
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn file_path(mut self, path : impl Into <String>) -> Self |
VariantBuilder:format
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn format(mut self, format : impl Into <String>) -> Self |
VariantBuilder:is
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn is_servable(mut self, is_servable : bool) -> Self |
VariantBuilder:jpeg
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn jpeg(self) -> Self |
VariantBuilder:kind
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn kind(mut self, kind : impl Into <String>) -> Self |
VariantBuilder:large
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn large(self) -> Self |
VariantBuilder:medium
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn medium(self) -> Self |
VariantBuilder:new
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn new() -> Self |
VariantBuilder:png
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn png(self) -> Self |
VariantBuilder:private
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn private(self) -> Self |
VariantBuilder:sha256
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn sha256(mut self, sha256 : impl Into <String>) -> Self |
VariantBuilder:size
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn size_bytes(mut self, size : i64) -> Self |
VariantBuilder:small
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn small(self) -> Self |
VariantBuilder:thumb
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn thumb(self) -> Self |
VariantBuilder:visibility
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn visibility(mut self, visibility : Visibility) -> Self |
VariantBuilder:webp
Variant model for derived versions of assets.
| Item |
|---|
VariantBuilder :: fn webp(self) -> Self |
variant_kinds (other)
Standard variant kinds for image processing.
| Item |
|---|
pub const THUMB: & str |
pub const SMALL: & str |
pub const MEDIUM: & str |
pub const LARGE: & str |
fn max_dimension(kind : & str) -> Option <u32> |
fn is_standard(kind : & str) -> bool |
fn all() -> & 'static & 'static str |
fn larger_than(kind : & str) -> Option <& 'static str> |
fn smaller_than(kind : & str) -> Option <& 'static str> |
variants_read (other)
Format-agnostic variant read seam (Sprint 0.32, Group G).
| Item |
|---|
fn kind_width(kind : & str) -> Option <u32> |
VariantInfo
Format-agnostic variant read seam (Sprint 0.32, Group G).
| Item |
|---|
pub struct VariantInfo |
async fn get_variants(pool : & PgPool, asset_id : Uuid) -> Result <Vec <VariantInfo>, AssetError> |
fn best_variant <'a>(variants : & 'a VariantInfo, kind : & str, preferred_formats : & & str,) -> Option <& 'a VariantInfo> |
Visibility
Visibility levels for assets.
| Item |
|---|
pub enum Visibility |
Visibility :: fn as_str(& self) -> & 'static str |
Visibility :: fn parse(s : & str) -> Option <Self> |
Visibility :: fn is_public(& self) -> bool |
Visibility :: fn requires_auth(& self) -> bool |
Visibility :: fn is_owner_only(& self) -> bool |
Visibility :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result |
visibility_ops (other)
Set an asset's infrastructure visibility (Sprint 0.78).
| Item |
|---|
async fn set_asset_visibility(pool : & PgPool, asset_id : Uuid, visibility : Visibility,) -> Result <(), AssetError> |
How to use it
From this crate's own rustdoc:
use content_assets::{Asset, Attachment, Variant, Visibility, mime_types, variant_kinds};
use uuid::Uuid;
// Create an asset
let asset = Asset::builder()
.file_path("assets/2024/01/photo.jpg")
.original_filename("vacation_photo.jpg")
.content_type(mime_types::JPEG)
.size_bytes(1_048_576) // 1 MB
.sha256("abc123def456...")
.dimensions(1920, 1080)
.title("Beach Sunset")
.alt_text("A beautiful sunset over the ocean")
.visibility(Visibility::Public)
.build();
// Attach to a target object
let attachment = Attachment::builder()
.asset(asset.id)
.target("posts.Post", "post-123")
.field_name("featured_image")
.build();
// Create a thumbnail variant
let thumb = Variant::builder()
.asset(asset.id)
.thumb()
.file_path("variants/abc123/thumb.jpg")
.dimensions(256, 144)
.jpeg()
.build();
Module structure
content_assets
accessaccess_mapassetasset_textattachmentaudiencecommons_importcompositecontent_typeserrorexiffetchhandlersimagingingestlicensemime_typesserviceservice::attachmentsservice::audience_grantsservice::audience_migrationservice::audit_sinkservice::grantsservice::policyvariantvariant_kindsvariants_readvisibilityvisibility_ops
_29 modules: past 25 the diagram stops being readable, so the tree above is the complete picture._
Public surface
`access`
| Item | What it is |
|---|---|
pub enum Subject | A subject that may appear in an Audience — "who is allowed" |
pub struct Audience | The set of subjects allowed to see a scope (page or attachment) |
Audience :: fn of(subjects : impl IntoIterator <Item = Subject>) -> Self | An audience admitting only the given subjects. |
Audience :: fn deny_all() -> Self | The empty (deny-all) audience. |
pub struct Viewer | What a viewer brings to a request: identity + memberships + entitlements |
fn audience_admits(audience : & Audience, viewer : & Viewer) -> bool | Does audience admit viewer? Union over subjects; empty audience denies. |
fn in_ceiling(page : & Audience, attachment : Option <& Audience>, viewer : & Viewer) -> bool | The ceiling check (D1): is viewer admitted by the page and — when the attachment narrows — by the attachment audience too? attachment = None means inherit (the image uses the page audience unchanged) |
pub enum Tier | The quality-gate ladder a variant sits behind (linear; lower = more open) |
pub enum TierRef | The concrete target a Group/Entitlement tier points at. |
pub struct VariantTier | One servable variant with its quality rank and access gate. |
fn variant_satisfied(variant : & VariantTier, viewer : & Viewer) -> bool | Does viewer satisfy this variant's gate? Fail-closed: a Group/Entitlement variant with a missing/mismatched tier_ref is not satisfied. |
pub enum OnDeny | What to do when a viewer qualifies for no variant (outside the ceiling, or inside but satisfying nothing) — chosen per image (D4). |
pub enum AccessDecision | The serving decision: which variant to stream, or deny. |
fn resolve(in_ceiling : bool, variants : & VariantTier, viewer : & Viewer, on_deny : OnDeny, floor : Option <Uuid>,) -> AccessDecision | Resolve the variant to serve (ADR 0006) |
`access_map`
| Item | What it is |
|---|---|
fn parse_tier(min_tier : & str) -> Result <Tier, AssetError> | Parse a variants.min_tier value into a Tier |
fn variant_tier_from_row(variant_id : Uuid, quality_rank : i16, min_tier : & str, tier_ref_group : Option <Uuid>, tier_ref_entitlement : Option <String>,) -> Result <VariantTier, AssetError> | Map a variants row's access columns into a resolver VariantTier |
fn subject_from_row(subject_kind : & str, subject_id : Option <Uuid>,) -> Result <Subject, AssetError> | Map a media_audience_entries row into a resolver Subject (Sprint 0.60, T-0.60.3) |
fn parse_on_deny(on_deny : & str) -> Result <OnDeny, AssetError> | Parse an attachments.on_deny value into OnDeny |
fn audience_mode_narrows(audience_mode : & str) -> Result <bool, AssetError> | Parse an attachments.audience_mode value, returning true when the attachment narrows the page ceiling and false when it inherits |
fn build_viewer(authenticated : bool, user_id : Option <Uuid>, roles : impl IntoIterator <Item = Uuid>, direct_groups : impl IntoIterator <Item = Uuid>, role_bound_groups : impl IntoIterator <Item = Uuid>, entitlements : impl IntoIterator <Item = String>,) -> Viewer | Assemble a resolver Viewer from the raw identity facts the consumer fetches (Sprint 0.60, T-0.60.2) |
`asset`
| Item | What it is |
|---|---|
pub struct Asset | A media asset (file) in the system |
Asset :: fn builder() -> AssetBuilder | Create a new asset builder. |
Asset :: fn is_image(& self) -> bool | Check if this is an image asset. |
Asset :: fn extension(& self) -> Option <& str> | Get the file extension from the original filename. |
Asset :: fn dimensions(& self) -> Option <(i32, i32)> | Get dimensions as a tuple (width, height) if available. |
Asset :: fn can_access(& self, party_id : Option <PartyId>, is_staff : bool) -> bool | Check if a party can access this asset |
Asset :: fn display_source_url(& self) -> & str | The single URL the public credit line should link to |
Asset :: fn license(& self) -> License | Parse license_short_name into a typed License enum |
Asset :: fn human_size(& self) -> String | Get human-readable size. |
Asset :: fn id(& self) -> Uuid | — |
Asset :: fn created_at(& self) -> DateTime <Utc> | — |
Asset :: fn updated_at(& self) -> DateTime <Utc> | — |
Asset :: fn deleted_at(& self) -> Option <DateTime <Utc>> | — |
Asset :: fn soft_delete(& mut self) | Mark as soft-deleted. |
Asset :: fn restore(& mut self) | Restore from soft-deleted state. |
pub struct AssetBuilder | Builder for Asset. |
AssetBuilder :: fn new() -> Self | Create a new builder. |
AssetBuilder :: fn file_path(mut self, path : impl Into <String>) -> Self | Set the storage file path. |
AssetBuilder :: fn original_filename(mut self, name : impl Into <String>) -> Self | Set the original filename. |
AssetBuilder :: fn content_type(mut self, content_type : impl Into <String>) -> Self | Set the content type. |
AssetBuilder :: fn size_bytes(mut self, size : i64) -> Self | Set the file size in bytes. |
AssetBuilder :: fn sha256(mut self, hash : impl Into <String>) -> Self | Set the SHA-256 hash. |
AssetBuilder :: fn is_image(mut self, is_image : bool) -> Self | Set whether this is an image. |
AssetBuilder :: fn dimensions(mut self, width : i32, height : i32) -> Self | Set the image dimensions. |
AssetBuilder :: fn title(mut self, title : impl Into <String>) -> Self | Set the title. |
AssetBuilder :: fn alt_text(mut self, alt_text : impl Into <String>) -> Self | Set the alt text. |
AssetBuilder :: fn caption(mut self, caption : impl Into <String>) -> Self | Set the caption. |
AssetBuilder :: fn notes(mut self, notes : impl Into <String>) -> Self | Set internal notes. |
AssetBuilder :: fn tags(mut self, tags : Vec <String>) -> Self | Set tags. |
AssetBuilder :: fn tag(mut self, tag : impl Into <String>) -> Self | Add a single tag. |
AssetBuilder :: fn metadata(mut self, metadata : JsonValue) -> Self | Set additional metadata. |
AssetBuilder :: fn visibility(mut self, visibility : Visibility) -> Self | Set visibility. |
AssetBuilder :: fn focal(mut self, x : f64, y : f64) -> Self | Set the focal point (X, Y) in 0,1 for aspect-locked crops. |
AssetBuilder :: fn owner(mut self, owner_id : PartyId) -> Self | Set the owner party. |
AssetBuilder :: fn attribution_title(mut self, title : impl Into <String>) -> Self | Set the attribution title (work title as given by the source). |
AssetBuilder :: fn attribution_author(mut self, author : impl Into <String>) -> Self | Set the attribution author / creator name. |
AssetBuilder :: fn attribution_author_url(mut self, url : impl Into <String>) -> Self | Set an optional author profile URL. |
AssetBuilder :: fn source_url(mut self, url : impl Into <String>) -> Self | Set the public-display source URL (e.g., Wikimedia Commons file page) |
AssetBuilder :: fn original_source_url(mut self, url : impl Into <String>) -> Self | Set the upstream provenance URL (e.g., Flickr original) |
AssetBuilder :: fn license(mut self, license : & License) -> Self | Set the license via the typed License enum |
AssetBuilder :: fn license_short_name(mut self, name : impl Into <String>) -> Self | Set the license short name as a free-text string (e.g., from a Wikimedia API response). |
AssetBuilder :: fn license_url(mut self, url : impl Into <String>) -> Self | Set the license URL explicitly (overrides any URL inferred from Self::license). |
AssetBuilder :: fn attribution_required(mut self, required : bool) -> Self | Override the attribution-required flag explicitly |
AssetBuilder :: fn attribution_modified_note(mut self, note : impl Into <String>) -> Self | Manual disclosure note for modifications (cropped, recolored, etc.) |
AssetBuilder :: fn raw_import_metadata(mut self, value : JsonValue) -> Self | Set the raw import metadata blob (audit-only) |
AssetBuilder :: fn build(self) -> Asset | Build the asset |
`asset_text`
| Item | What it is |
|---|---|
pub enum TextKind | Which text field a row holds. |
TextKind :: fn as_str(self) -> & 'static str | The DB string for this kind. |
TextKind :: fn parse(s : & str) -> Option <Self> | Parse a DB string back into a kind. |
pub enum TextSource | How a row's text was produced. |
TextSource :: fn as_str(self) -> & 'static str | — |
TextSource :: fn parse(s : & str) -> Option <Self> | — |
pub enum TextStatus | The review state of a row. |
TextStatus :: fn as_str(self) -> & 'static str | — |
TextStatus :: fn parse(s : & str) -> Option <Self> | — |
pub struct AssetText | One asset_text row: the text for one (asset, locale, kind) plus provenance. |
AssetText :: fn ready_to_translate(& self) -> bool | True when this row is a confirmed source ready to be translated |
AssetText :: fn is_human_confirmed(& self) -> bool | True when this target row holds human-authored text that a human has confirmed — i.e |
fn ready_to_translate(status : TextStatus) -> bool | Free function form of AssetText::ready_to_translate for callers holding only a status (e.g |
fn translation_may_replace(existing : Option <& AssetText>) -> bool | Whether a machine translation may replace the existing target row |
fn text_for(rows : & AssetText, viewer_locale : & str, kind : TextKind) -> String | Render: pick the text for the viewer's locale, else the other non-empty locale, else empty |
AssetText :: fn try_from(r : AssetTextRow) -> Result <Self, Self::Error> | — |
async fn get(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind,) -> Result <Option <AssetText>, AssetError> | Load one row, if present. |
async fn list_for_asset(pool : & PgPool, asset_id : Uuid) -> Result <Vec <AssetText>, AssetError> | Load all rows for one asset (every locale + kind). |
pub struct SuggestedDraft | A draft to write for a generated (suggested) source row. |
async fn record_suggested(pool : & PgPool, draft : & SuggestedDraft) -> Result <(), AssetError> | Write a generated draft as (suggested, needs_review) in the source locale — the first transition of the state machine |
async fn confirm_human(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind, text : & str, confirmed_by : Option <Uuid>,) -> Result <(), AssetError> | Human confirm/correct a row: set its text + (human, confirmed) and stamp confirmed_by/confirmed_at |
pub enum TranslationOutcome | The result of attempting to write a translation into a target locale. |
async fn apply_translation(pool : & PgPool, asset_id : Uuid, target_locale : & str, kind : TextKind, translated_text : & str, source_locale : & str, derived_from_hash : & str, model : Option <& str>,) -> Result <TranslationOutcome, AssetError> | Apply a machine translation to the target locale as (machine_translation, needs_review), recording its provenance (source_locale + derived_from_hash) |
async fn mark_stale(pool : & PgPool, asset_id : Uuid, locale : & str, kind : TextKind, reason : & str,) -> Result <(), AssetError> | Mark a row stale (the source it derived from moved on, but the row is human-confirmed so we never overwrite it) |
`attachment`
| Item | What it is |
|---|---|
pub struct Attachment | An attachment linking an asset to a target object |
Attachment :: fn builder() -> AttachmentBuilder | Create a new attachment builder. |
Attachment :: fn is_for(& self, target_type : & str, target_id : & str) -> bool | Check if this attachment is for the given target. |
Attachment :: fn is_in_field(& self, field_name : & str) -> bool | Check if this attachment is in the given field. |
Attachment :: fn matches(& self, target_type : & str, target_id : & str, field_name : & str) -> bool | Check if this attachment belongs to the given target and field. |
Attachment :: fn id(& self) -> Uuid | — |
Attachment :: fn created_at(& self) -> DateTime <Utc> | — |
Attachment :: fn updated_at(& self) -> DateTime <Utc> | — |
Attachment :: fn deleted_at(& self) -> Option <DateTime <Utc>> | — |
Attachment :: fn soft_delete(& mut self) | Mark as soft-deleted. |
Attachment :: fn restore(& mut self) | Restore from soft-deleted state. |
pub struct AttachmentBuilder | Builder for Attachment. |
AttachmentBuilder :: fn new() -> Self | Create a new builder. |
AttachmentBuilder :: fn asset(mut self, asset_id : Uuid) -> Self | Set the asset ID. |
AttachmentBuilder :: fn target(mut self, target_type : impl Into <String>, target_id : impl Into <String>) -> Self | Set the target. |
AttachmentBuilder :: fn field_name(mut self, field_name : impl Into <String>) -> Self | Set the field name. |
AttachmentBuilder :: fn sort_order(mut self, order : i32) -> Self | Set the sort order. |
AttachmentBuilder :: fn note(mut self, note : impl Into <String>) -> Self | Set a note. |
AttachmentBuilder :: fn created_by(mut self, user_id : Uuid) -> Self | Set who created this attachment. |
AttachmentBuilder :: fn build(self) -> Attachment | Build the attachment |
`audience`
| Item | What it is |
|---|---|
pub enum Surface | The web surface a media request arrives on |
Surface :: fn as_str(self) -> & 'static str | The wire string for this surface (matches the surface CHECK domain). |
pub enum Action | What the requester is trying to do |
pub enum AudienceKind | The kinds of audience a grant can target |
pub struct AssetState | The live state of the asset, loaded fresh per request (never cached — Gate 1.5 Q1: the origin re-checks live state every request). |
AssetState :: fn tier_servable(self) -> bool | The TIER serve precondition: public-tier, clean, servable, not deleted. |
fn required_capability(requested : Action, is_display_kind : bool) -> Action | The capability a request actually requires, given what it is reaching for |
pub struct EntityRefSubject | A namespaced entity reference the actor holds (an entity_ref grant subject) |
pub struct ActorSubjects | The grant-subjects the actor brings, precomputed once per request (Q2 — no per-grant N+1) |
ActorSubjects :: fn anonymous() -> Self | The no-authority anonymous actor. |
pub struct ActiveGrant | One active grant row handed to the evaluator (the SQL shell has already applied the active predicate: revoked_at IS NULL AND (expires_at IS NULL OR expires_at > now())) |
pub struct EntityRefTarget | The namespaced target of an entity_ref grant — mirrors EntityRefSubject minus the entity id (the grant's audience_id is the entity id). |
pub enum Decision | The evaluator's verdict. |
fn kind_valid_on_surface(kind : AudienceKind, surface : Surface) -> bool | Which AudienceKinds are valid on a given surface (Q2 — surface gates kinds) |
fn evaluate(asset : AssetState, actor : & ActorSubjects, surface : Surface, requested_action : Action, grants : & ActiveGrant,) -> Decision | Evaluate a media request |
`commons_import`
| Item | What it is |
|---|---|
pub enum CommonsImportError | Errors from the Commons import path. |
pub struct CommonsImport | Structured Commons import — metadata + direct image URL |
CommonsImport :: fn from_api_response(json : & serde_json::Value, file_title : & str,) -> Result <Self, CommonsImportError> | Parse a Commons API response (formatversion=2) into a CommonsImport |
fn parse_url(url : & str) -> Result <String, CommonsImportError> | Parse a Wikimedia URL (or bare File: title) into the canonical File:NAME title |
async fn fetch_metadata(client : & reqwest::Client, file_title : & str,) -> Result <CommonsImport, CommonsImportError> | Fetch metadata for a Commons file by title |
async fn fetch_image_bytes(image_url : & str, max_bytes : Option <usize>,) -> Result <Vec <u8>, CommonsImportError> | Download image bytes from a URL through the SSRF-hardened infrastructure_fetcher::SafeHttpClient |
`composite`
| Item | What it is |
|---|---|
pub enum CompositeLayout | Layout strategy for the composite image. |
pub enum OutputFormat | Output image format. |
OutputFormat :: fn default() -> Self | — |
pub struct CompositeOptions | Options for image compositing. |
CompositeOptions :: fn default() -> Self | — |
pub enum CompositeError | Error during compositing. |
fn stitch_images(images : & & [u8], options : & CompositeOptions,) -> Result <Vec <u8>, CompositeError> | Stitch multiple images into a single composite image |
fn stitch_image_files(paths : & & str, options : & CompositeOptions,) -> Result <Vec <u8>, CompositeError> | Stitch images from file paths on disk |
`content_types`
| Item | What it is |
|---|---|
pub const IMAGE_TYPES: & & str | Allowed image content types for upload. |
pub struct ContentTypeValidator | Content type validator with whitelist support |
ContentTypeValidator :: fn images_only() -> Self | Create validator allowing only image types. |
ContentTypeValidator :: fn new(allowed : impl IntoIterator <Item = impl Into <String>>) -> Self | Create validator with custom allowed types. |
ContentTypeValidator :: fn is_allowed(& self, content_type : & str) -> bool | Check if content type is allowed. |
ContentTypeValidator :: fn extension_for(content_type : & str) -> & 'static str | Get file extension for a content type |
ContentTypeValidator :: fn allowed_types(& self) -> & String | Get the list of allowed content types. |
ContentTypeValidator :: fn default() -> Self | — |
`error`
| Item | What it is |
|---|---|
pub enum AssetError | Errors that can occur in document operations. |
AssetError :: fn asset_not_found(id : Uuid) -> Self | Create a new AssetNotFound error. |
AssetError :: fn attachment_not_found(id : Uuid) -> Self | Create a new AttachmentNotFound error. |
AssetError :: fn variant_not_found(asset_id : Uuid, kind : impl Into <String>) -> Self | Create a new VariantNotFound error. |
AssetError :: fn duplicate_asset(sha256 : impl Into <String>, existing_id : Uuid) -> Self | Create a new DuplicateAsset error. |
AssetError :: fn invalid_file_type(content_type : impl Into <String>) -> Self | Create a new InvalidFileType error. |
AssetError :: fn unsupported_content_type(content_type : impl Into <String>) -> Self | Create a new UnsupportedContentType error. |
AssetError :: fn file_too_large(size_bytes : i64, max_bytes : i64) -> Self | Create a new FileTooLarge error. |
AssetError :: fn storage_error(message : impl Into <String>) -> Self | Create a new StorageError. |
AssetError :: fn hash_mismatch(expected : impl Into <String>, actual : impl Into <String>) -> Self | Create a new HashMismatch error. |
AssetError :: fn access_denied(id : Uuid) -> Self | Create a new AccessDenied error. |
AssetError :: fn asset_deleted(id : Uuid) -> Self | Create a new AssetDeleted error. |
AssetError :: fn invalid_reorder(message : impl Into <String>) -> Self | Create a new InvalidReorder error. |
AssetError :: fn forbidden(message : impl Into <String>) -> Self | Create a new Forbidden error. |
AssetError :: fn invalid_access_data(message : impl Into <String>) -> Self | Create a new InvalidAccessData error. |
`exif`
| Item | What it is |
|---|---|
pub struct ExifData | Parsed EXIF metadata for one asset (1:1 with the asset_exif row). |
fn extract_exif(bytes : & u8) -> Option <ExifData> | Extract EXIF from image bytes |
async fn get_exif(pool : & PgPool, asset_id : Uuid) -> Result <Option <ExifData>, AssetError> | Load the EXIF row for an asset, if present. |
`fetch`
| Item | What it is |
|---|---|
pub const FETCH_TIMEOUT: Duration | Default per-request fetch timeout. |
pub struct SourceKind | Consumer-defined provenance label for a fetch (the framework can't enumerate all sources) |
SourceKind :: fn new(s : impl Into <String>) -> Self | — |
SourceKind :: fn as_str(& self) -> & str | — |
pub enum FetchErrorKind | Typed failure classes recorded in asset_fetch_log.error_kind. |
FetchErrorKind :: fn as_str(self) -> & 'static str | — |
fn classify_ingest_error(err : & AssetError) -> FetchErrorKind | Classify an ingest-stage failure into a FetchErrorKind for the audit log. |
async fn fetch_and_ingest(pool : & PgPool, storage : & dyn StorageBackend, url : & str, source_kind : & SourceKind, filename : & str, fetch_run_id : Option <Uuid>,) -> Result <UploadResult, AssetError> | Fetch an image URL and ingest it, recording the attempt in asset_fetch_log |
`handlers`
| Item | What it is |
|---|---|
pub const BLOB_MAX_SIZE_BYTES: usize | Hard size cap for blob (non-image) uploads (Sprint 0.64b) |
pub const BLOB_ALLOWED_MIMES: & & str | MIME types the BlobHandler accepts |
pub const INLINE_ELIGIBLE_BLOB_MIMES: & & str | Blob MIME types a browser will render inline (rather than force-download) |
fn requires_sanitizer(content_type : & str) -> bool | Does serving content_type inline require sanitization first? (Sprint 0.93, R16.) |
fn blob_inline_servable_allowed(content_type : & str, sanitized : bool) -> bool | May a blob of content_type be stored as a servable artifact, given whether a sanitizer actually claimed (and stripped) it? Inline-eligible types are refused unless sanitized — fail closed so an unsanitized PDF can never become an inline-servable file (Sprint 0.93, R16) |
pub struct ProcessInput<'a> | Inputs to ContentHandler::process — the bytes to ingest plus the declared MIME, optional focal point, and the original filename |
pub enum Processed | Output of ContentHandler::process (Sprint 0.64b) — either an image plan (canonical + display variants + private original) or a blob plan (a single stored-verbatim file) |
pub struct PreparedBlob | A validated general file ready to store (Sprint 0.64b) |
fn validate_pdf(bytes : & u8) -> Result <(), IngestError> | Validate a PDF on the trusted-operator path (Sprint 0.64b): magic %PDF- prefix + a %%EOF marker in the trailing bytes + non-empty |
pub trait ContentHandler | A handler for one class of media content, identified by MIME type |
pub struct ImageHandler | Handler for the validated image-ingest pipeline (jpeg / png / webp) |
ImageHandler :: fn can_handle(& self, mime : & str) -> bool | — |
ImageHandler :: fn supported_mimes(& self) -> & 'static & 'static str | — |
ImageHandler :: fn name(& self) -> & 'static str | — |
ImageHandler :: fn process(& self, input : ProcessInput <'_>) -> Result <Processed, AssetError> | — |
pub struct BlobHandler | Handler for general files (PDF/doc/binary) stored verbatim and gated like any media (Sprint 0.64b) |
BlobHandler :: fn can_handle(& self, mime : & str) -> bool | — |
BlobHandler :: fn supported_mimes(& self) -> & 'static & 'static str | — |
BlobHandler :: fn name(& self) -> & 'static str | — |
BlobHandler :: fn process(& self, input : ProcessInput <'_>) -> Result <Processed, AssetError> | — |
pub struct HandlerRegistry | Resolves an asset's content_type to a registered ContentHandler |
HandlerRegistry :: fn new() -> Self | An empty registry (no handlers) |
HandlerRegistry :: fn register(& mut self, handler : Box <dyn ContentHandler>) -> & mut Self | Register a handler |
HandlerRegistry :: fn resolve(& self, mime : & str) -> Option <& dyn ContentHandler> | The first registered handler that claims mime, or None. |
HandlerRegistry :: fn require(& self, mime : & str) -> Result <& dyn ContentHandler, AssetError> | Resolve mime or fail with a typed AssetError::UnsupportedContentType — the dispatch point that prevents an unhandled type from silently falling through to the image path |
HandlerRegistry :: fn default() -> Self | Registry pre-loaded with the built-in handlers (image, then blob) |
`imaging`
| Item | What it is |
|---|---|
pub enum ImageError | Error during image processing. |
pub struct ImageProcessor | Image processing utilities |
ImageProcessor :: fn extract_dimensions(content : & u8) -> Result <(u32, u32), ImageError> | Extract dimensions from image bytes |
ImageProcessor :: fn create_thumbnail(content : & u8, max_dimension : u32,) -> Result <(Vec <u8>, u32, u32), ImageError> | Create a thumbnail, maintaining aspect ratio |
ImageProcessor :: fn create_variant(content : & u8, max_dimension : u32, format : ImageFormat,) -> Result <(Vec <u8>, u32, u32), ImageError> | Create a variant with a specific format |
ImageProcessor :: fn is_valid_image(content : & u8) -> bool | Check if content appears to be a valid image |
ImageProcessor :: fn detect_format(content : & u8) -> Option <ImageFormat> | Detect the image format from bytes |
ImageProcessor :: fn perceptual_fingerprint(content : & u8) -> Result <u64, ImageError> | A perceptual fingerprint of what the image LOOKS like |
ImageProcessor :: fn fingerprint_distance(a : u64, b : u64) -> u32 | How many bits two fingerprints differ in, from 0 (identical structure) to 64 |
ImageProcessor :: fn mime_type_for(format : ImageFormat) -> & 'static str | Get the MIME type for an image format. |
`ingest`
| Item | What it is |
|---|---|
pub const MAX_SIZE_BYTES: usize | Max accepted upload size (50 MiB) |
pub const MAX_DIMENSION: u32 | Per-dimension cap (8000 px → 64 MP ceiling, OOM-safe header check). |
pub const ALLOWED_MIMES: & & str | Accepted upload MIME types (declared must also match the magic-byte sniff). |
pub const CANONICAL_JPEG_QUALITY: u8 | Quality of the canonical re-encode used for the dedup hash + public original. |
pub type VariantSpec: (& 'static str, u32, u8, Option <(u32, u32)>) | One display-variant spec: (kind, max_dimension_px, jpeg_quality, crop_aspect) |
pub const SIZES: & VariantSpec | Display variant specs |
pub const ALL_DISPLAY_KINDS: & & str | Every DISPLAY variant kind (in SIZES order) |
pub const IMMEDIATE_ELIGIBLE_KINDS: & & str | Display kinds eligible to be generated in-request (Sprint 0.82-A) |
pub const FAST_FORMATS: & & str | Image formats encoded in-request (Sprint 0.82-A): the FAST codecs only |
pub const ALL_FORMATS: & & str | Every image format produced for a display kind (Sprint 0.82-A): the FAST set plus AVIF |
pub const WORKER_AVIF_SPEED: u8 | ravif encode speed (1..=10; 1 = slowest/best, 10 = fastest/worst) used on the worker path (Sprint 0.82-A) |
pub enum IngestError | Errors from the ingest pipeline. |
pub struct CanonicalImage | Canonical (rotated, EXIF-stripped, re-encoded) image plus its dimensions. |
fn sniff_image_format(bytes : & u8) -> Option <& 'static str> | Identify image format from magic bytes |
fn validate_magic(declared : & str, bytes : & u8) -> Result <(), IngestError> | Verify the declared MIME matches what the magic bytes sniff to |
fn check_dimensions(bytes : & u8) -> Result <(u32, u32), IngestError> | Header-only dimension read with the MAX_DIMENSION cap (OOM-safe). |
fn read_exif_orientation(bytes : & u8) -> u32 | Read the EXIF orientation tag (1–8) from image bytes; 1 (normal) if absent. |
fn apply_orientation(img : DynamicImage, orientation : u32) -> DynamicImage | Apply an EXIF orientation (1–8) to a decoded image. |
fn resize_max(img : & DynamicImage, max_px : u32) -> DynamicImage | Downscale so the larger side is at most max_px; never upscales. |
fn crop_window(src_w : u32, src_h : u32, tw : u32, th : u32, fx : f64, fy : f64,) ->(u32, u32, u32, u32) | Compute the crop window (x, y, w, h) that yields the target aspect tw:th from a src_w × src_h image, centred on the focal point (fx, fy) in 0,1 (clamped) |
fn crop_to_aspect(img : & DynamicImage, tw : u32, th : u32, fx : f64, fy : f64) -> DynamicImage | Crop img to the tw:th aspect centred on focal (fx, fy). |
fn encode_jpeg(img : & DynamicImage, quality : u8) -> Result <Vec <u8>, IngestError> | Encode to JPEG at the given quality (0–100) |
fn encode_webp(img : & DynamicImage, quality : f32) -> Result <Vec <u8>, IngestError> | Encode to WebP at the given quality (0–100, lossy via libwebp) |
fn encode_avif(_img : & DynamicImage, _quality : u8, _speed : u8) -> Result <Vec <u8>, IngestError> | Encode to AVIF (AV1 image format) at the given quality (0–100, lossy via image crate's ravif backend) |
fn canonical_jpeg(bytes : & u8) -> Result <CanonicalImage, IngestError> | Decode arbitrary input, apply EXIF orientation, and re-encode a canonical JPEG (EXIF-stripped) |
fn sha256_hex(bytes : & u8) -> String | Hex-encoded SHA-256 of the given bytes. |
pub struct PreparedVariant | A generated variant's bytes plus its metadata, ready for storage + persist. |
pub struct PreparedIngest | All outputs of the deterministic ingest core, ready to be stored + persisted by the async orchestrator |
fn prepare_ingest(bytes : & u8, declared_mime : & str, focal : Option <(f64, f64)>, kinds : & & str, formats : & & str, avif_speed : u8,) -> Result <PreparedIngest, IngestError> | Run the deterministic, IO-free core of the pipeline: validate, decode, rotate, re-encode the canonical master (EXIF-stripped), and generate all display variants |
pub struct UploadResult | Result of an ingest run. |
pub struct IngestOptions<'a> | — |
IngestOptions<'_> :: fn default() -> Self | — |
async fn ingest(pool : & PgPool, storage : & dyn StorageBackend, bytes : & u8, declared_mime : & str, filename : & str, opts : IngestOptions <'_>,) -> Result <UploadResult, AssetError> | Full ingest: validate + build all outputs, dedup on the canonical hash, then store + persist |
pub trait Sanitizer | A pluggable active-content sanitizer for blob ingest (Sprint 0.81) |
async fn ingest_blob_validated(pool : & PgPool, storage : & dyn StorageBackend, blob : crate::handlers::PreparedBlob, sanitizer : Option <& dyn Sanitizer>, opts : & IngestOptions <'_>,) -> Result <UploadResult, AssetError> | — |
async fn ingest_blob(pool : & PgPool, storage : & dyn StorageBackend, bytes : & u8, declared_mime : & str, filename : & str, sanitizer : Option <& dyn Sanitizer>, opts : & IngestOptions <'_>,) -> Result <UploadResult, AssetError> | Consumer-facing blob ingest entry (Sprint 0.81): the library crate owns the WHOLE blob flow — validate (via the crate::handlers::BlobHandler allowlist + magic/structure/size check) → sanitize (via the injected Sanitizer) → store servable + private raw → persist |
async fn generate_missing_variants(pool : & PgPool, storage : & dyn StorageBackend, asset_id : Uuid,) -> Result <usize, AssetError> | Materialize an existing asset's ABSENT display variants (Sprint 0.81) |
async fn regenerate_variants(pool : & PgPool, storage : & dyn StorageBackend, asset_id : Uuid,) -> Result <usize, AssetError> | Re-generate an asset's display variants from its retained private original, applying the asset's current focal point |
`license`
| Item | What it is |
|---|---|
pub enum License | A content license |
License :: fn short_name(& self) -> & str | Canonical short name (the string we store in license_short_name). |
License :: fn canonical_url(& self) -> & 'static str | Canonical license deed URL for known variants |
License :: fn attribution_required(& self) -> bool | Whether displaying author credit is legally required |
License :: fn fmt(& self, f : & mut fmt::Formatter <'_>) -> fmt::Result | — |
License :: fn from_str(s : & str) -> Result <Self, Self::Err> | Parse a license short-name string into a License |
`mime_types`
| Item | What it is |
|---|---|
pub const JPEG: & str | JPEG image MIME type. |
pub const PNG: & str | PNG image MIME type. |
pub const GIF: & str | GIF image MIME type. |
pub const WEBP: & str | WebP image MIME type. |
pub const SVG: & str | SVG image MIME type. |
pub const BMP: & str | BMP image MIME type. |
pub const TIFF: & str | TIFF image MIME type. |
pub const ICO: & str | ICO image MIME type. |
pub const PDF: & str | PDF document MIME type. |
pub const DOC: & str | Microsoft Word (legacy) MIME type. |
pub const DOCX: & str | Microsoft Word (modern) MIME type. |
pub const XLS: & str | Microsoft Excel (legacy) MIME type. |
pub const XLSX: & str | Microsoft Excel (modern) MIME type. |
pub const PPT: & str | Microsoft PowerPoint (legacy) MIME type. |
pub const PPTX: & str | Microsoft PowerPoint (modern) MIME type. |
pub const JSON: & str | JSON data MIME type. |
pub const XML: & str | XML data MIME type. |
pub const CSV: & str | CSV data MIME type. |
pub const TEXT: & str | Plain text MIME type. |
pub const HTML: & str | HTML MIME type. |
pub const MARKDOWN: & str | Markdown MIME type. |
pub const ZIP: & str | ZIP archive MIME type. |
pub const GZIP: & str | GZIP archive MIME type. |
pub const TAR: & str | TAR archive MIME type. |
pub const MP3: & str | MP3 audio MIME type. |
pub const WAV: & str | WAV audio MIME type. |
pub const OGG_AUDIO: & str | OGG audio MIME type. |
pub const MP4: & str | MP4 video MIME type. |
pub const WEBM: & str | WebM video MIME type. |
pub const OGG_VIDEO: & str | OGG video MIME type. |
pub const OCTET_STREAM: & str | Generic binary data MIME type. |
fn is_image(mime_type : & str) -> bool | Check if a MIME type represents an image. |
fn is_document(mime_type : & str) -> bool | Check if a MIME type represents a document. |
fn is_audio(mime_type : & str) -> bool | Check if a MIME type represents audio. |
fn is_video(mime_type : & str) -> bool | Check if a MIME type represents video. |
fn is_media(mime_type : & str) -> bool | Check if a MIME type represents a media file (image, audio, or video). |
fn extension_for(mime_type : & str) -> Option <& 'static str> | Get file extension for common MIME types. |
fn from_extension(ext : & str) -> Option <& 'static str> | Guess MIME type from file extension. |
`service::attachments`
| Item | What it is |
|---|---|
pub struct FieldNames | Standard field names for attachments. |
pub struct EntityRef | Reference to a target entity (polymorphic association) |
EntityRef :: fn new(entity_type : impl Into <String>, entity_id : Uuid) -> Self | Create a new entity reference. |
pub struct AttachmentRow | Raw attachment row from database |
pub struct AttachInput | Input for AttachmentService::attach — covers the required identity fields + per-attachment policy metadata (visibility + audit class) per Sprint 18.C |
AttachInput :: fn new(tenant_id : Uuid, asset_id : Uuid, entity_ref : EntityRef, field_name : impl Into <String>,) -> Self | New input with the required fields + safe defaults (visibility = "private", audit_class = "normal"). |
AttachInput :: fn uploaded_by(mut self, id : Uuid) -> Self | — |
AttachInput :: fn owner(mut self, id : Uuid) -> Self | — |
AttachInput :: fn sort_order(mut self, n : i32) -> Self | — |
AttachInput :: fn visibility(mut self, kind : impl Into <String>) -> Self | — |
AttachInput :: fn audit_class(mut self, class : impl Into <String>) -> Self | — |
pub struct AttachmentWithAsset | Attachment with joined asset data for listing. |
pub struct AttachmentService | — |
AttachmentService :: fn new(pool : PgPool) -> Self | Create a new service bound to the given pool |
AttachmentService :: fn new_with_audit(pool : PgPool, audit : Arc <dyn AuditSink>) -> Self | Create a service with a custom audit sink |
AttachmentService :: fn pool(& self) -> & PgPool | Access the underlying pool |
AttachmentService :: fn audit(& self) -> & Arc <dyn AuditSink> | Access the configured audit sink |
AttachmentService :: async fn attach(& self, input : AttachInput) -> Result <AttachmentRow, AssetError> | Attach an asset to an entity |
AttachmentService :: async fn list_for_entity(& self, entity_ref : & EntityRef,) -> Result <Vec <AttachmentWithAsset>, AssetError> | List all attachments for an entity with joined asset data |
AttachmentService :: async fn set_primary(& self, attachment_id : Uuid) -> Result <AttachmentRow, AssetError> | Set an attachment as the primary image |
AttachmentService :: async fn update_sort_order(& self, attachment_id : Uuid, new_sort_order : i32,) -> Result <AttachmentRow, AssetError> | Update the sort order of an attachment |
AttachmentService :: async fn reorder(& self, entity_ref : & EntityRef, field_name : & str, ordered_attachment_ids : & Uuid,) -> Result <(), AssetError> | Reorder attachments for an entity within a specific field_name |
AttachmentService :: async fn detach(& self, attachment_id : Uuid) -> Result <(), AssetError> | Detach (soft delete) an attachment |
AttachmentService :: async fn get_by_id(& self, attachment_id : Uuid) -> Result <AttachmentRow, AssetError> | Get a single attachment by ID |
AttachmentService :: async fn count_references(& self, asset_id : Uuid) -> Result <u64, AssetError> | Count live (non-deleted) attachments referencing an asset (Sprint 0.31) |
AttachmentService :: async fn soft_delete_if_orphaned(& self, asset_id : Uuid) -> Result <bool, AssetError> | Soft-delete an asset only if it has no live references |
AttachmentService :: async fn verify_ownership(& self, attachment_id : Uuid, entity_ref : & EntityRef,) -> Result <AttachmentRow, AssetError> | Verify an attachment belongs to the specified entity |
AttachmentService :: async fn grant(& self, input : crate::service::grants::GrantInput,) -> Result <crate::service::grants::Grant, AssetError> | Create an explicit grant on an attachment |
AttachmentService :: async fn revoke(& self, grant_id : Uuid, actor_party_id : Option <Uuid>,) -> Result <(), AssetError> | Revoke a grant (soft-delete) |
AttachmentService :: async fn list_grants(& self, attachment_id : Uuid,) -> Result <Vec <crate::service::grants::Grant>, AssetError> | List active (non-deleted, non-expired) grants for an attachment. |
AttachmentService :: async fn has_view_grant(& self, viewer_party_id : Uuid, attachment : & AttachmentRow,) -> Result <bool, AssetError> | Does the viewer have an explicit view grant on this attachment? Owner is implicitly granted |
AttachmentService :: async fn can_view(& self, ctx : & crate::service::policy::PolicyContext, attachment : & AttachmentRow, policy : & dyn crate::service::policy::AttachmentPolicy,) -> Result <bool, AssetError> | Composite visibility check: explicit grant OR policy hook |
AttachmentService :: async fn can_manage(& self, ctx : & crate::service::policy::PolicyContext, attachment : & AttachmentRow, policy : & dyn crate::service::policy::AttachmentPolicy,) -> Result <bool, AssetError> | Composite manage check: owner OR explicit manage grant OR policy hook |
AttachmentService :: async fn cascade_on_target_delete(& self, entity_ref : & EntityRef,) -> Result <usize, AssetError> | Cascade soft-delete attachments + grants when a target entity is deleted |
`service::audience_grants`
| Item | What it is |
|---|---|
pub const ACTIVE_GRANT_PREDICATE: & str | The active-grant predicate, applied by every serve route's SQL shell so the rule is defined in exactly one place (Gate 1.5 Q3) |
fn capability_clause(action : crate::audience::Action) -> & 'static str | The capability clause for a requested action, to AND onto ACTIVE_GRANT_PREDICATE |
pub struct AssetAudienceGrant | One row of asset_audience_grants, mapped to a typed model. |
pub struct GrantInput | Input shape for creating a grant (the API's POST body, post-validation). |
fn parse_audience_kind(kind : & str) -> Result <AudienceKind, AssetError> | Parse a wire audience_kind into the enum |
fn parse_surface(surface : & str) -> Result <Surface, AssetError> | Parse a wire surface value into the enum |
AssetAudienceGrant :: fn to_active_grant(& self) -> Result <ActiveGrant, AssetError> | Map a row into the resolver's ActiveGrant, mirroring the table's CHECK constraints |
`service::audience_migration`
| Item | What it is |
|---|---|
pub struct LegacySubject | A single 0.59 media_audience_entries subject row to be mapped (the caller has already resolved the narrower page∩attachment scope to the asset). |
pub struct DerivedGrant | A derived 0.77 grant ready to INSERT (the unambiguous, additive outcome of mapping a LegacySubject) |
pub enum DropReason | Why a LegacySubject did NOT produce a grant — recorded in the diff report so an operator can see exactly what the migration declined to widen. |
pub enum MapOutcome | The outcome of mapping one LegacySubject. |
fn map_legacy_subject(s : & LegacySubject) -> MapOutcome | Map one 0.59 subject to its 0.77 outcome — the single designated reference for the migration's decision |
pub struct MigrationReport | The old-allowed-vs-new-allowed diff for the whole batch — the artifact produced before cutover (Gate 1.5 Q3) |
MigrationReport :: fn from_subjects(subjects : & LegacySubject) -> Self | Build the report by mapping every legacy subject through map_legacy_subject. |
MigrationReport :: fn never_widens(& self) -> bool | The migration never widens: every derived grant is additive (admits a scoped principal) and there are no public/customer_group grants |
`service::audit_sink`
| Item | What it is |
|---|---|
pub struct AuditEvent | Per-event audit payload |
AuditEvent :: fn is_sensitive(& self) -> bool | Is this event for a sensitive-class attachment? Used by AttachmentService to refuse sensitive writes when the configured sink is NoopAuditSink. |
pub trait AuditSink | Audit-log sink trait |
pub struct NoopAuditSink | No-op sink for tests + non-audit-critical deployments |
NoopAuditSink :: async fn emit(& self, _event : AuditEvent) -> Result <(), AssetError> | — |
NoopAuditSink :: fn is_persistent(& self) -> bool | — |
`service::grants`
| Item | What it is |
|---|---|
pub struct Grant | One row of attachment_access_grants. |
Grant :: fn is_active(& self, now : DateTime <Utc>) -> bool | True if this grant is currently active (not soft-deleted, not expired). |
pub struct GrantInput | Input shape for creating a new grant. |
`service::policy`
| Item | What it is |
|---|---|
pub struct PolicyContext | Per-request authorization context passed to every policy method |
PolicyContext :: fn has_perm(& self, perm : & str) -> bool | Convenience: check if the viewer has a specific RBAC perm. |
pub enum AttachDecision | Result of AttachmentPolicy::can_attach |
pub trait AttachmentPolicy | Per-entity-type authorization policy for attachments |
`variant`
| Item | What it is |
|---|---|
fn is_servable_default(kind : & str, visibility : Visibility) -> bool | Default serveability for a freshly-ingested variant (Sprint 0.64a) |
pub struct Variant | A derived variant of an asset (thumbnail, resize, format conversion). |
Variant :: fn builder() -> VariantBuilder | Create a new variant builder. |
Variant :: fn is_standard_kind(& self) -> bool | Check if this is a standard variant kind. |
Variant :: fn dimensions(& self) ->(i32, i32) | Get dimensions as a tuple (width, height). |
Variant :: fn is_thumb(& self) -> bool | Check if this variant is a thumbnail. |
Variant :: fn aspect_ratio(& self) -> f64 | Get the aspect ratio (width / height). |
Variant :: fn is_landscape(& self) -> bool | Check if the variant is landscape orientation. |
Variant :: fn is_portrait(& self) -> bool | Check if the variant is portrait orientation. |
Variant :: fn is_square(& self) -> bool | Check if the variant is square. |
Variant :: fn id(& self) -> Uuid | — |
Variant :: fn created_at(& self) -> DateTime <Utc> | — |
Variant :: fn updated_at(& self) -> DateTime <Utc> | — |
Variant :: fn deleted_at(& self) -> Option <DateTime <Utc>> | — |
Variant :: fn soft_delete(& mut self) | Mark as soft-deleted. |
Variant :: fn restore(& mut self) | Restore from soft-deleted state. |
pub struct VariantBuilder | Builder for Variant. |
VariantBuilder :: fn new() -> Self | Create a new builder. |
VariantBuilder :: fn asset(mut self, asset_id : Uuid) -> Self | Set the parent asset ID. |
VariantBuilder :: fn kind(mut self, kind : impl Into <String>) -> Self | Set the variant kind. |
VariantBuilder :: fn thumb(self) -> Self | Set as thumbnail variant. |
VariantBuilder :: fn small(self) -> Self | Set as small variant. |
VariantBuilder :: fn medium(self) -> Self | Set as medium variant. |
VariantBuilder :: fn large(self) -> Self | Set as large variant. |
VariantBuilder :: fn file_path(mut self, path : impl Into <String>) -> Self | Set the storage file path. |
VariantBuilder :: fn dimensions(mut self, width : i32, height : i32) -> Self | Set the dimensions. |
VariantBuilder :: fn format(mut self, format : impl Into <String>) -> Self | Set the output format. |
VariantBuilder :: fn jpeg(self) -> Self | Set format to JPEG. |
VariantBuilder :: fn png(self) -> Self | Set format to PNG. |
VariantBuilder :: fn webp(self) -> Self | Set format to WebP. |
VariantBuilder :: fn size_bytes(mut self, size : i64) -> Self | Set the encoded byte size of this variant on disk. |
VariantBuilder :: fn visibility(mut self, visibility : Visibility) -> Self | Set the visibility of this variant. |
VariantBuilder :: fn private(self) -> Self | Mark this variant private (used for the retained kind = "original"). |
VariantBuilder :: fn sha256(mut self, sha256 : impl Into <String>) -> Self | Set the content hash (used for the kind = "original" audit hash). |
VariantBuilder :: fn is_servable(mut self, is_servable : bool) -> Self | Override serveability explicitly |
VariantBuilder :: fn build(self) -> Variant | Build the variant |
`variant_kinds`
| Item | What it is |
|---|---|
pub const THUMB: & str | Thumbnail variant (256x256 max). |
pub const SMALL: & str | Small variant (640x640 max). |
pub const MEDIUM: & str | Medium variant (1024x1024 max). |
pub const LARGE: & str | Large variant (2048x2048 max). |
fn max_dimension(kind : & str) -> Option <u32> | Get the maximum dimension for a variant kind. |
fn is_standard(kind : & str) -> bool | Check if a variant kind is standard. |
fn all() -> & 'static & 'static str | Get all standard variant kinds in order of size. |
fn larger_than(kind : & str) -> Option <& 'static str> | Get the next larger variant kind. |
fn smaller_than(kind : & str) -> Option <& 'static str> | Get the next smaller variant kind. |
`variants_read`
| Item | What it is |
|---|---|
pub struct VariantInfo | A public display variant (format-agnostic). |
async fn get_variants(pool : & PgPool, asset_id : Uuid) -> Result <Vec <VariantInfo>, AssetError> | Load an asset's public display variants (excludes the private original). |
fn kind_width(kind : & str) -> Option <u32> | The nominal max-dimension (long-edge) pixel width of a display kind, read from crate::ingest::SIZES (the single size source) |
fn best_variant <'a>(variants : & 'a VariantInfo, kind : & str, preferred_formats : & & str,) -> Option <& 'a VariantInfo> | Pick the best variant of kind, preferring formats earliest in preferred_formats (e.g |
`visibility`
| Item | What it is |
|---|---|
pub enum Visibility | Visibility level for an asset |
Visibility :: fn as_str(& self) -> & 'static str | Get the string representation. |
Visibility :: fn parse(s : & str) -> Option <Self> | Parse from string. |
Visibility :: fn is_public(& self) -> bool | Check if this visibility allows public access. |
Visibility :: fn requires_auth(& self) -> bool | Check if this visibility requires authentication. |
Visibility :: fn is_owner_only(& self) -> bool | Check if this visibility is owner-only. |
Visibility :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result | — |
`visibility_ops`
| Item | What it is |
|---|---|
async fn set_asset_visibility(pool : & PgPool, asset_id : Uuid, visibility : Visibility,) -> Result <(), AssetError> | Set an asset's infrastructure visibility and keep its display variants consistent (Sprint 0.78) |
Re-exports. Exported here, defined elsewhere.
| Export | Defined in |
|---|---|
AssetError | error::AssetError |
License | license::License |
Visibility | visibility::Visibility |
set_asset_visibility | visibility_ops::set_asset_visibility |
{Asset,AssetBuilder} | asset::{Asset,AssetBuilder} |
{AttachDecision,AttachmentPolicy,PolicyContext} | policy::{AttachDecision,AttachmentPolicy,PolicyContext} |
{AttachDecision,AttachmentPolicy,PolicyContext} | service::policy::{AttachDecision,AttachmentPolicy,PolicyContext} |
{AttachInput,AttachmentRow,AttachmentService,AttachmentWithAsset,EntityRef,FieldNames,} | service::attachments::{AttachInput,AttachmentRow,AttachmentService,AttachmentWithAsset,EntityRef,FieldNames,} |
{Attachment,AttachmentBuilder} | attachment::{Attachment,AttachmentBuilder} |
{AttachmentRow,AttachmentService,AttachmentWithAsset,EntityRef,FieldNames,} | attachments::{AttachmentRow,AttachmentService,AttachmentWithAsset,EntityRef,FieldNames,} |
{AuditEvent,AuditSink,NoopAuditSink} | audit_sink::{AuditEvent,AuditSink,NoopAuditSink} |
{AuditEvent,AuditSink,NoopAuditSink} | service::audit_sink::{AuditEvent,AuditSink,NoopAuditSink} |
{ContentTypeValidator,IMAGE_TYPES} | content_types::{ContentTypeValidator,IMAGE_TYPES} |
{Grant,GrantInput} | grants::{Grant,GrantInput} |
{Grant,GrantInput} | service::grants::{Grant,GrantInput} |
{HasId,SoftDeletable,Timestamped} | foundation_basemodels::{HasId,SoftDeletable,Timestamped} |
{ImageError,ImageProcessor} | imaging::{ImageError,ImageProcessor} |
{Variant,VariantBuilder} | variant::{Variant,VariantBuilder} |
{apply_translation,confirm_human,getasget_asset_text,list_for_assetaslist_asset_text,mark_stale,ready_to_translate,record_suggested,text_for,translation_may_replace,AssetText,SuggestedDraft,TextKind,TextSource,TextStatus,TranslationOutcome,} | asset_text::{apply_translation,confirm_human,getasget_asset_text,list_for_assetaslist_asset_text,mark_stale,ready_to_translate,record_suggested,text_for,translation_may_replace,AssetText,SuggestedDraft,TextKind,TextSource,TextStatus,TranslationOutcome,} |
{capability_clause,AssetAudienceGrant,GrantInputasAudienceGrantInput,ACTIVE_GRANT_PREDICATE,} | service::audience_grants::{capability_clause,AssetAudienceGrant,GrantInputasAudienceGrantInput,ACTIVE_GRANT_PREDICATE,} |
{evaluate,kind_valid_on_surface,Action,ActiveGrant,ActorSubjects,AssetState,AudienceKind,Decision,EntityRefSubject,EntityRefTarget,Surface,} | audience::{evaluate,kind_valid_on_surface,Action,ActiveGrant,ActorSubjects,AssetState,AudienceKind,Decision,EntityRefSubject,EntityRefTarget,Surface,} |
{fetch_image_bytes,fetch_metadata,parse_urlasparse_commons_url,CommonsImport,CommonsImportError,} | commons_import::{fetch_image_bytes,fetch_metadata,parse_urlasparse_commons_url,CommonsImport,CommonsImportError,} |
{map_legacy_subject,DerivedGrant,DropReason,LegacySubject,MapOutcome,MigrationReport,} | service::audience_migration::{map_legacy_subject,DerivedGrant,DropReason,LegacySubject,MapOutcome,MigrationReport,} |
{stitch_image_files,stitch_images,CompositeError,CompositeLayout,CompositeOptions,OutputFormat,} | composite::{stitch_image_files,stitch_images,CompositeError,CompositeLayout,CompositeOptions,OutputFormat,} |
Boundary
Reaches into foundation, identity, infrastructure.
Shares tier content with 5 other crates: content-calendar, content-calendar-recurrence, content-cms, content-directory-listing, content-notes.
_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) | content |
| Architectural role (taxonomy) | unclassified (baselined) |
| Location | crates/content/assets |
| Vocabulary in force (lexicon) | current |
Tier flow. Which tiers this crate's own edges cross.
flowchart LR n_content["content"] --> n_foundation["foundation"] n_content["content"] --> n_identity["identity"] n_content["content"] --> n_infrastructure["infrastructure"]
Dependencies
Runtime, in this workspace.
| Crate | Tier | Optional | Only on |
|---|---|---|---|
| `foundation-basemodels` | foundation | no | always |
| `identity-parties` | identity | no | always |
| `infrastructure-fetcher` | infrastructure | yes | always |
| `infrastructure-storage` | infrastructure | yes | always |
Runtime, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
ammonia | ^4 | — | yes | always |
async-trait | ^0.1 | — | no | always |
chrono | ^0.4 | serde | no | always |
hex | ^0.4 | — | yes | always |
image | ^0.25 | jpeg, png, gif, webp | yes | always |
kamadak-exif | ^0.6 | — | yes | always |
reqwest | ^0.12 | rustls-tls, json | yes | always |
serde | ^1 | derive | no | always |
serde_json | ^1 | — | no | always |
sha2 | ^0.10 | — | yes | always |
sqlx | ^0.8 | runtime-tokio, postgres, chrono, uuid, json | no | always |
thiserror | ^2 | — | no | always |
tokio | ^1 | full | no | always |
uuid | ^1 | v4, v7, serde, js | no | always |
webp | ^0.3 | — | yes | always |
Development, from outside the workspace.
| Crate | Requirement | Features | Optional | Only on |
|---|---|---|---|---|
tokio-test | ^0.4 | — | no | always |
Build. None.
Depended on by. 3 workspace crates.
Signal flow — what reaches this crate, and what it reaches.
flowchart LR n_application_cms["application-cms"] -->|uses| SELF n_platform_api["platform-api"] -->|uses| SELF n_platform_privacy_scan_api["platform-privacy-scan-api"] -->|uses| SELF SELF["content-assets"] SELF -->|runtime| n_foundation_basemodels["foundation-basemodels"] SELF -->|runtime| n_identity_parties["identity-parties"] SELF -->|runtime| n_infrastructure_fetcher["infrastructure-fetcher"] SELF -->|runtime| n_infrastructure_storage["infrastructure-storage"] classDef self fill:#1f883d,stroke:#1f883d,color:#fff; class SELF self;
Feature flags
| Feature | Enables | On by default |
|---|---|---|
commons-import | dep:reqwest, dep:ammonia, dep:infrastructure-fetcher | no |
default | — | yes |
fetch | ingest, dep:reqwest, dep:infrastructure-fetcher | no |
imaging | dep:image | no |
ingest | imaging, dep:kamadak-exif, dep:webp, dep:sha2, dep:hex, dep:infrastructure-storage | no |
flowchart LR n_commons_import["commons-import"] --> n_dep_reqwest["dep:reqwest"] n_commons_import["commons-import"] --> n_dep_ammonia["dep:ammonia"] n_commons_import["commons-import"] --> n_dep_infrastructure_fetcher["dep:infrastructure-fetcher"] n_default["default"] n_fetch["fetch"] --> n_ingest["ingest"] n_fetch["fetch"] --> n_dep_reqwest["dep:reqwest"] n_fetch["fetch"] --> n_dep_infrastructure_fetcher["dep:infrastructure-fetcher"] n_imaging["imaging"] --> n_dep_image["dep:image"] n_ingest["ingest"] --> n_imaging["imaging"] n_ingest["ingest"] --> n_dep_kamadak_exif["dep:kamadak-exif"] n_ingest["ingest"] --> n_dep_webp["dep:webp"] n_ingest["ingest"] --> n_dep_sha2["dep:sha2"] n_ingest["ingest"] --> n_dep_hex["dep:hex"] n_ingest["ingest"] --> n_dep_infrastructure_storage["dep:infrastructure-storage"]
Targets
| Kind | Name | Source |
|---|---|---|
| lib | content_assets | `src/lib.rs` |
| test | asset_text_state_machine | `tests/asset_text_state_machine.rs` |
| test | migration_013_media_access | `tests/migration_013_media_access.rs` |
| test | migration_016_asset_audience_grants | `tests/migration_016_asset_audience_grants.rs` |
| test | migration_017_audience_migration | `tests/migration_017_audience_migration.rs` |
| test | pg_set_visibility | `tests/pg_set_visibility.rs` |
Error model
| Error type | Named by |
|---|---|
AssetError | apply_translation, audience_mode_narrows, classify_ingest_error, confirm_human, fetch_and_ingest, generate_missing_variants, … (23 total) |
CommonsImportError | fetch_image_bytes, fetch_metadata, parse_url |
CompositeError | stitch_image_files, stitch_images |
ImageError | declared, no public signature returns it |
IngestError | canonical_jpeg, check_dimensions, encode_avif, encode_jpeg, encode_webp, prepare_ingest, … (8 total) |
Operational characteristics
| Property | Evidence |
|---|---|
| async public surface | yes |
| async runtime | yes |
| database access | yes |
| network I/O | yes |
| unsafe code | none detected |
| environment variables | yes |
No unsafe block, unsafe fn, unsafe impl or unsafe trait was found by the parser anywhere in this crate's source.
Configuration
| Variable | Read in |
|---|---|
DATABASE_URL | src/ingest.rs |
Related capabilities
3 workspace crates depend on this one: application-cms, platform-api, platform-privacy-scan-api.
Verification
| Kind | Count |
|---|---|
| Unit tests | 340 |
| Integration tests | 17 |
| Examples | 0 |
| Doctests | 1 |
Evidence by module. How often each public module is named by something executable.
| Module | Tests | Examples | Consumers |
|---|---|---|---|
access | 12 | 0 | 8 |
access_map | 6 | 0 | 5 |
asset | 2 | 0 | 2 |
asset_text | 15 | 0 | 11 |
attachment | 2 | 0 | 1 |
audience | 12 | 0 | 10 |
commons_import | 5 | 0 | 0 |
composite | 6 | 0 | 0 |
content_types | 2 | 0 | 0 |
error | 1 | 0 | 1 |
exif | 3 | 0 | 2 |
fetch | 5 | 0 | 0 |
handlers | 13 | 0 | 5 |
imaging | 2 | 0 | 1 |
ingest | 37 | 0 | 21 |
license | 1 | 0 | 0 |
mime_types | 38 | 0 | 22 |
service::attachments | 6 | 0 | 5 |
service::audience_grants | 6 | 0 | 6 |
service::audience_migration | 6 | 0 | 0 |
service::audit_sink | 3 | 0 | 4 |
service::grants | 2 | 0 | 2 |
service::policy | 3 | 0 | 3 |
variant | 3 | 0 | 1 |
variant_kinds | 9 | 0 | 3 |
variants_read | 4 | 0 | 5 |
visibility | 1 | 0 | 2 |
visibility_ops | 1 | 0 | 1 |
What the tests establish, by name:
check_rejects_bad_enum_values—tests/asset_text_state_machine.rscheck_rejects_machine_translation_without_provenance—tests/asset_text_state_machine.rsfull_state_machine_suggested_human_confirmed_translated—tests/asset_text_state_machine.rslist_and_mark_stale_roundtrip—tests/asset_text_state_machine.rsrecord_suggested_does_not_clobber_human_confirmed—tests/asset_text_state_machine.rstranslation_never_overwrites_human_confirmed_target_marks_it_stale—tests/asset_text_state_machine.rsdegrade_floor_trigger_accepts_public_floor—tests/migration_013_media_access.rsdegrade_floor_trigger_rejects_non_public_floor—tests/migration_013_media_access.rsmigration_013_creates_tables_columns_and_trigger—tests/migration_013_media_access.rsactive_grant_predicate_uses_db_time—tests/migration_016_asset_audience_grants.rsmigration_016_constraints_reject_bad_state—tests/migration_016_asset_audience_grants.rsmigration_016_creates_table_and_constraints—tests/migration_016_asset_audience_grants.rsmigration_017_failclosed_mapping_and_diff—tests/migration_017_audience_migration.rsdemote_public_to_private_makes_display_non_servable—tests/pg_set_visibility.rsidempotent_and_internal_is_non_servable—tests/pg_set_visibility.rsmissing_asset_is_not_found—tests/pg_set_visibility.rspromote_private_to_public_makes_display_servable—tests/pg_set_visibility.rsauthenticated_admits_only_authed—src/access.rsauthenticated_variant_needs_auth—src/access.rsblur_case_outside_ceiling_degrades_to_floor—src/access.rsdegrade_with_no_floor_denies_fail_closed—src/access.rsempty_audience_denies_everyone—src/access.rsentitlement_variant_needs_held_key—src/access.rsgroup_variant_needs_matching_group_ref—src/access.rsin_ceiling_serves_highest_satisfiable_rank—src/access.rsinherit_uses_page_audience_only—src/access.rsnarrow_can_never_widen—src/access.rsnarrow_is_intersection—src/access.rsoutside_ceiling_hard_deny_returns_deny—src/access.rspublic_admits_anyone_including_anon—src/access.rs- _… 327 more_
Documentation coverage
| Measure | Documented | Total |
|---|---|---|
| Public items with rustdoc | 366 | 410 |
Public modules with a //! block | 29 | 29 |
pie showData
title Public items with rustdoc
"Documented" : 366
"No rustdoc detected" : 44
Metrics
| Metric | Value |
|---|---|
| Rust source files | 30 |
| Source lines | 14989 |
| Code lines | 10634 |
| Public API items | 410 |
| Public modules | 29 |
| Tests | 357 |
| Examples | 0 |
| Cargo features | 5 |
| Direct runtime dependencies | 19 |
| Workspace reverse dependencies | 3 |
pie showData
title Public API by kind
"constant" : 51
"enum" : 27
"function" : 74
"method" : 204
"struct" : 49
"trait" : 4
"type alias" : 1
pie showData
title Rust source composition
"Code" : 10634
"Blank or comment" : 4355
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.