content capa

content-assets

Media assets, file attachments, and variant generation with integrity verification

Media assets, file attachments, and variant generation with integrity verification

Tiercontent
Roleunclassified (baselined)
Pathcrates/content/assets
Edition2021
Targetscontent_assets, asset_text_state_machine, migration_013_media_access, migration_016_asset_audience_grants, migration_017_audience_migration, pg_set_visibility
Public items410 across 29 modules
Tests357

What it is for

# content-assets

Media assets, file attachments, and variant generation with integrity verification.

Core Concepts

To "update" a file, create a new asset and re-attach.

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

_29 modules: past 25 the diagram stops being readable, so the tree above is the complete picture._

Public surface

`access`

ItemWhat it is
pub enum SubjectA subject that may appear in an Audience — "who is allowed"
pub struct AudienceThe set of subjects allowed to see a scope (page or attachment)
Audience :: fn of(subjects : impl IntoIterator <Item = Subject>) -> SelfAn audience admitting only the given subjects.
Audience :: fn deny_all() -> SelfThe empty (deny-all) audience.
pub struct ViewerWhat a viewer brings to a request: identity + memberships + entitlements
fn audience_admits(audience : & Audience, viewer : & Viewer) -> boolDoes audience admit viewer? Union over subjects; empty audience denies.
fn in_ceiling(page : & Audience, attachment : Option <& Audience>, viewer : & Viewer) -> boolThe 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 TierThe quality-gate ladder a variant sits behind (linear; lower = more open)
pub enum TierRefThe concrete target a Group/Entitlement tier points at.
pub struct VariantTierOne servable variant with its quality rank and access gate.
fn variant_satisfied(variant : & VariantTier, viewer : & Viewer) -> boolDoes viewer satisfy this variant's gate? Fail-closed: a Group/Entitlement variant with a missing/mismatched tier_ref is not satisfied.
pub enum OnDenyWhat to do when a viewer qualifies for no variant (outside the ceiling, or inside but satisfying nothing) — chosen per image (D4).
pub enum AccessDecisionThe serving decision: which variant to stream, or deny.
fn resolve(in_ceiling : bool, variants : & VariantTier, viewer : & Viewer, on_deny : OnDeny, floor : Option <Uuid>,) -> AccessDecisionResolve the variant to serve (ADR 0006)

`access_map`

ItemWhat 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>,) -> ViewerAssemble a resolver Viewer from the raw identity facts the consumer fetches (Sprint 0.60, T-0.60.2)

`asset`

ItemWhat it is
pub struct AssetA media asset (file) in the system
Asset :: fn builder() -> AssetBuilderCreate a new asset builder.
Asset :: fn is_image(& self) -> boolCheck 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) -> boolCheck if a party can access this asset
Asset :: fn display_source_url(& self) -> & strThe single URL the public credit line should link to
Asset :: fn license(& self) -> LicenseParse license_short_name into a typed License enum
Asset :: fn human_size(& self) -> StringGet 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 AssetBuilderBuilder for Asset.
AssetBuilder :: fn new() -> SelfCreate a new builder.
AssetBuilder :: fn file_path(mut self, path : impl Into <String>) -> SelfSet the storage file path.
AssetBuilder :: fn original_filename(mut self, name : impl Into <String>) -> SelfSet the original filename.
AssetBuilder :: fn content_type(mut self, content_type : impl Into <String>) -> SelfSet the content type.
AssetBuilder :: fn size_bytes(mut self, size : i64) -> SelfSet the file size in bytes.
AssetBuilder :: fn sha256(mut self, hash : impl Into <String>) -> SelfSet the SHA-256 hash.
AssetBuilder :: fn is_image(mut self, is_image : bool) -> SelfSet whether this is an image.
AssetBuilder :: fn dimensions(mut self, width : i32, height : i32) -> SelfSet the image dimensions.
AssetBuilder :: fn title(mut self, title : impl Into <String>) -> SelfSet the title.
AssetBuilder :: fn alt_text(mut self, alt_text : impl Into <String>) -> SelfSet the alt text.
AssetBuilder :: fn caption(mut self, caption : impl Into <String>) -> SelfSet the caption.
AssetBuilder :: fn notes(mut self, notes : impl Into <String>) -> SelfSet internal notes.
AssetBuilder :: fn tags(mut self, tags : Vec <String>) -> SelfSet tags.
AssetBuilder :: fn tag(mut self, tag : impl Into <String>) -> SelfAdd a single tag.
AssetBuilder :: fn metadata(mut self, metadata : JsonValue) -> SelfSet additional metadata.
AssetBuilder :: fn visibility(mut self, visibility : Visibility) -> SelfSet visibility.
AssetBuilder :: fn focal(mut self, x : f64, y : f64) -> SelfSet the focal point (X, Y) in 0,1 for aspect-locked crops.
AssetBuilder :: fn owner(mut self, owner_id : PartyId) -> SelfSet the owner party.
AssetBuilder :: fn attribution_title(mut self, title : impl Into <String>) -> SelfSet the attribution title (work title as given by the source).
AssetBuilder :: fn attribution_author(mut self, author : impl Into <String>) -> SelfSet the attribution author / creator name.
AssetBuilder :: fn attribution_author_url(mut self, url : impl Into <String>) -> SelfSet an optional author profile URL.
AssetBuilder :: fn source_url(mut self, url : impl Into <String>) -> SelfSet the public-display source URL (e.g., Wikimedia Commons file page)
AssetBuilder :: fn original_source_url(mut self, url : impl Into <String>) -> SelfSet the upstream provenance URL (e.g., Flickr original)
AssetBuilder :: fn license(mut self, license : & License) -> SelfSet the license via the typed License enum
AssetBuilder :: fn license_short_name(mut self, name : impl Into <String>) -> SelfSet 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>) -> SelfSet the license URL explicitly (overrides any URL inferred from Self::license).
AssetBuilder :: fn attribution_required(mut self, required : bool) -> SelfOverride the attribution-required flag explicitly
AssetBuilder :: fn attribution_modified_note(mut self, note : impl Into <String>) -> SelfManual disclosure note for modifications (cropped, recolored, etc.)
AssetBuilder :: fn raw_import_metadata(mut self, value : JsonValue) -> SelfSet the raw import metadata blob (audit-only)
AssetBuilder :: fn build(self) -> AssetBuild the asset

`asset_text`

ItemWhat it is
pub enum TextKindWhich text field a row holds.
TextKind :: fn as_str(self) -> & 'static strThe DB string for this kind.
TextKind :: fn parse(s : & str) -> Option <Self>Parse a DB string back into a kind.
pub enum TextSourceHow a row's text was produced.
TextSource :: fn as_str(self) -> & 'static str
TextSource :: fn parse(s : & str) -> Option <Self>
pub enum TextStatusThe review state of a row.
TextStatus :: fn as_str(self) -> & 'static str
TextStatus :: fn parse(s : & str) -> Option <Self>
pub struct AssetTextOne asset_text row: the text for one (asset, locale, kind) plus provenance.
AssetText :: fn ready_to_translate(& self) -> boolTrue when this row is a confirmed source ready to be translated
AssetText :: fn is_human_confirmed(& self) -> boolTrue when this target row holds human-authored text that a human has confirmed — i.e
fn ready_to_translate(status : TextStatus) -> boolFree function form of AssetText::ready_to_translate for callers holding only a status (e.g
fn translation_may_replace(existing : Option <& AssetText>) -> boolWhether a machine translation may replace the existing target row
fn text_for(rows : & AssetText, viewer_locale : & str, kind : TextKind) -> StringRender: 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 SuggestedDraftA 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 TranslationOutcomeThe 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`

ItemWhat it is
pub struct AttachmentAn attachment linking an asset to a target object
Attachment :: fn builder() -> AttachmentBuilderCreate a new attachment builder.
Attachment :: fn is_for(& self, target_type : & str, target_id : & str) -> boolCheck if this attachment is for the given target.
Attachment :: fn is_in_field(& self, field_name : & str) -> boolCheck if this attachment is in the given field.
Attachment :: fn matches(& self, target_type : & str, target_id : & str, field_name : & str) -> boolCheck 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 AttachmentBuilderBuilder for Attachment.
AttachmentBuilder :: fn new() -> SelfCreate a new builder.
AttachmentBuilder :: fn asset(mut self, asset_id : Uuid) -> SelfSet the asset ID.
AttachmentBuilder :: fn target(mut self, target_type : impl Into <String>, target_id : impl Into <String>) -> SelfSet the target.
AttachmentBuilder :: fn field_name(mut self, field_name : impl Into <String>) -> SelfSet the field name.
AttachmentBuilder :: fn sort_order(mut self, order : i32) -> SelfSet the sort order.
AttachmentBuilder :: fn note(mut self, note : impl Into <String>) -> SelfSet a note.
AttachmentBuilder :: fn created_by(mut self, user_id : Uuid) -> SelfSet who created this attachment.
AttachmentBuilder :: fn build(self) -> AttachmentBuild the attachment

`audience`

ItemWhat it is
pub enum SurfaceThe web surface a media request arrives on
Surface :: fn as_str(self) -> & 'static strThe wire string for this surface (matches the surface CHECK domain).
pub enum ActionWhat the requester is trying to do
pub enum AudienceKindThe kinds of audience a grant can target
pub struct AssetStateThe 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) -> boolThe TIER serve precondition: public-tier, clean, servable, not deleted.
fn required_capability(requested : Action, is_display_kind : bool) -> ActionThe capability a request actually requires, given what it is reaching for
pub struct EntityRefSubjectA namespaced entity reference the actor holds (an entity_ref grant subject)
pub struct ActorSubjectsThe grant-subjects the actor brings, precomputed once per request (Q2 — no per-grant N+1)
ActorSubjects :: fn anonymous() -> SelfThe no-authority anonymous actor.
pub struct ActiveGrantOne 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 EntityRefTargetThe namespaced target of an entity_ref grant — mirrors EntityRefSubject minus the entity id (the grant's audience_id is the entity id).
pub enum DecisionThe evaluator's verdict.
fn kind_valid_on_surface(kind : AudienceKind, surface : Surface) -> boolWhich AudienceKinds are valid on a given surface (Q2 — surface gates kinds)
fn evaluate(asset : AssetState, actor : & ActorSubjects, surface : Surface, requested_action : Action, grants : & ActiveGrant,) -> DecisionEvaluate a media request

`commons_import`

ItemWhat it is
pub enum CommonsImportErrorErrors from the Commons import path.
pub struct CommonsImportStructured 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`

ItemWhat it is
pub enum CompositeLayoutLayout strategy for the composite image.
pub enum OutputFormatOutput image format.
OutputFormat :: fn default() -> Self
pub struct CompositeOptionsOptions for image compositing.
CompositeOptions :: fn default() -> Self
pub enum CompositeErrorError 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`

ItemWhat it is
pub const IMAGE_TYPES: & & strAllowed image content types for upload.
pub struct ContentTypeValidatorContent type validator with whitelist support
ContentTypeValidator :: fn images_only() -> SelfCreate validator allowing only image types.
ContentTypeValidator :: fn new(allowed : impl IntoIterator <Item = impl Into <String>>) -> SelfCreate validator with custom allowed types.
ContentTypeValidator :: fn is_allowed(& self, content_type : & str) -> boolCheck if content type is allowed.
ContentTypeValidator :: fn extension_for(content_type : & str) -> & 'static strGet file extension for a content type
ContentTypeValidator :: fn allowed_types(& self) -> & StringGet the list of allowed content types.
ContentTypeValidator :: fn default() -> Self

`error`

ItemWhat it is
pub enum AssetErrorErrors that can occur in document operations.
AssetError :: fn asset_not_found(id : Uuid) -> SelfCreate a new AssetNotFound error.
AssetError :: fn attachment_not_found(id : Uuid) -> SelfCreate a new AttachmentNotFound error.
AssetError :: fn variant_not_found(asset_id : Uuid, kind : impl Into <String>) -> SelfCreate a new VariantNotFound error.
AssetError :: fn duplicate_asset(sha256 : impl Into <String>, existing_id : Uuid) -> SelfCreate a new DuplicateAsset error.
AssetError :: fn invalid_file_type(content_type : impl Into <String>) -> SelfCreate a new InvalidFileType error.
AssetError :: fn unsupported_content_type(content_type : impl Into <String>) -> SelfCreate a new UnsupportedContentType error.
AssetError :: fn file_too_large(size_bytes : i64, max_bytes : i64) -> SelfCreate a new FileTooLarge error.
AssetError :: fn storage_error(message : impl Into <String>) -> SelfCreate a new StorageError.
AssetError :: fn hash_mismatch(expected : impl Into <String>, actual : impl Into <String>) -> SelfCreate a new HashMismatch error.
AssetError :: fn access_denied(id : Uuid) -> SelfCreate a new AccessDenied error.
AssetError :: fn asset_deleted(id : Uuid) -> SelfCreate a new AssetDeleted error.
AssetError :: fn invalid_reorder(message : impl Into <String>) -> SelfCreate a new InvalidReorder error.
AssetError :: fn forbidden(message : impl Into <String>) -> SelfCreate a new Forbidden error.
AssetError :: fn invalid_access_data(message : impl Into <String>) -> SelfCreate a new InvalidAccessData error.

`exif`

ItemWhat it is
pub struct ExifDataParsed 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`

ItemWhat it is
pub const FETCH_TIMEOUT: DurationDefault per-request fetch timeout.
pub struct SourceKindConsumer-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 FetchErrorKindTyped failure classes recorded in asset_fetch_log.error_kind.
FetchErrorKind :: fn as_str(self) -> & 'static str
fn classify_ingest_error(err : & AssetError) -> FetchErrorKindClassify 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`

ItemWhat it is
pub const BLOB_MAX_SIZE_BYTES: usizeHard size cap for blob (non-image) uploads (Sprint 0.64b)
pub const BLOB_ALLOWED_MIMES: & & strMIME types the BlobHandler accepts
pub const INLINE_ELIGIBLE_BLOB_MIMES: & & strBlob MIME types a browser will render inline (rather than force-download)
fn requires_sanitizer(content_type : & str) -> boolDoes serving content_type inline require sanitization first? (Sprint 0.93, R16.)
fn blob_inline_servable_allowed(content_type : & str, sanitized : bool) -> boolMay 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 ProcessedOutput 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 PreparedBlobA 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 ContentHandlerA handler for one class of media content, identified by MIME type
pub struct ImageHandlerHandler 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 BlobHandlerHandler 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 HandlerRegistryResolves an asset's content_type to a registered ContentHandler
HandlerRegistry :: fn new() -> SelfAn empty registry (no handlers)
HandlerRegistry :: fn register(& mut self, handler : Box <dyn ContentHandler>) -> & mut SelfRegister 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() -> SelfRegistry pre-loaded with the built-in handlers (image, then blob)

`imaging`

ItemWhat it is
pub enum ImageErrorError during image processing.
pub struct ImageProcessorImage 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) -> boolCheck 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) -> u32How many bits two fingerprints differ in, from 0 (identical structure) to 64
ImageProcessor :: fn mime_type_for(format : ImageFormat) -> & 'static strGet the MIME type for an image format.

`ingest`

ItemWhat it is
pub const MAX_SIZE_BYTES: usizeMax accepted upload size (50 MiB)
pub const MAX_DIMENSION: u32Per-dimension cap (8000 px → 64 MP ceiling, OOM-safe header check).
pub const ALLOWED_MIMES: & & strAccepted upload MIME types (declared must also match the magic-byte sniff).
pub const CANONICAL_JPEG_QUALITY: u8Quality 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: & VariantSpecDisplay variant specs
pub const ALL_DISPLAY_KINDS: & & strEvery DISPLAY variant kind (in SIZES order)
pub const IMMEDIATE_ELIGIBLE_KINDS: & & strDisplay kinds eligible to be generated in-request (Sprint 0.82-A)
pub const FAST_FORMATS: & & strImage formats encoded in-request (Sprint 0.82-A): the FAST codecs only
pub const ALL_FORMATS: & & strEvery image format produced for a display kind (Sprint 0.82-A): the FAST set plus AVIF
pub const WORKER_AVIF_SPEED: u8ravif encode speed (1..=10; 1 = slowest/best, 10 = fastest/worst) used on the worker path (Sprint 0.82-A)
pub enum IngestErrorErrors from the ingest pipeline.
pub struct CanonicalImageCanonical (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) -> u32Read the EXIF orientation tag (1–8) from image bytes; 1 (normal) if absent.
fn apply_orientation(img : DynamicImage, orientation : u32) -> DynamicImageApply an EXIF orientation (1–8) to a decoded image.
fn resize_max(img : & DynamicImage, max_px : u32) -> DynamicImageDownscale 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) -> DynamicImageCrop 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) -> StringHex-encoded SHA-256 of the given bytes.
pub struct PreparedVariantA generated variant's bytes plus its metadata, ready for storage + persist.
pub struct PreparedIngestAll 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 UploadResultResult 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 SanitizerA 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`

ItemWhat it is
pub enum LicenseA content license
License :: fn short_name(& self) -> & strCanonical short name (the string we store in license_short_name).
License :: fn canonical_url(& self) -> & 'static strCanonical license deed URL for known variants
License :: fn attribution_required(& self) -> boolWhether 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`

ItemWhat it is
pub const JPEG: & strJPEG image MIME type.
pub const PNG: & strPNG image MIME type.
pub const GIF: & strGIF image MIME type.
pub const WEBP: & strWebP image MIME type.
pub const SVG: & strSVG image MIME type.
pub const BMP: & strBMP image MIME type.
pub const TIFF: & strTIFF image MIME type.
pub const ICO: & strICO image MIME type.
pub const PDF: & strPDF document MIME type.
pub const DOC: & strMicrosoft Word (legacy) MIME type.
pub const DOCX: & strMicrosoft Word (modern) MIME type.
pub const XLS: & strMicrosoft Excel (legacy) MIME type.
pub const XLSX: & strMicrosoft Excel (modern) MIME type.
pub const PPT: & strMicrosoft PowerPoint (legacy) MIME type.
pub const PPTX: & strMicrosoft PowerPoint (modern) MIME type.
pub const JSON: & strJSON data MIME type.
pub const XML: & strXML data MIME type.
pub const CSV: & strCSV data MIME type.
pub const TEXT: & strPlain text MIME type.
pub const HTML: & strHTML MIME type.
pub const MARKDOWN: & strMarkdown MIME type.
pub const ZIP: & strZIP archive MIME type.
pub const GZIP: & strGZIP archive MIME type.
pub const TAR: & strTAR archive MIME type.
pub const MP3: & strMP3 audio MIME type.
pub const WAV: & strWAV audio MIME type.
pub const OGG_AUDIO: & strOGG audio MIME type.
pub const MP4: & strMP4 video MIME type.
pub const WEBM: & strWebM video MIME type.
pub const OGG_VIDEO: & strOGG video MIME type.
pub const OCTET_STREAM: & strGeneric binary data MIME type.
fn is_image(mime_type : & str) -> boolCheck if a MIME type represents an image.
fn is_document(mime_type : & str) -> boolCheck if a MIME type represents a document.
fn is_audio(mime_type : & str) -> boolCheck if a MIME type represents audio.
fn is_video(mime_type : & str) -> boolCheck if a MIME type represents video.
fn is_media(mime_type : & str) -> boolCheck 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`

ItemWhat it is
pub struct FieldNamesStandard field names for attachments.
pub struct EntityRefReference to a target entity (polymorphic association)
EntityRef :: fn new(entity_type : impl Into <String>, entity_id : Uuid) -> SelfCreate a new entity reference.
pub struct AttachmentRowRaw attachment row from database
pub struct AttachInputInput 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>,) -> SelfNew 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 AttachmentWithAssetAttachment with joined asset data for listing.
pub struct AttachmentService
AttachmentService :: fn new(pool : PgPool) -> SelfCreate a new service bound to the given pool
AttachmentService :: fn new_with_audit(pool : PgPool, audit : Arc <dyn AuditSink>) -> SelfCreate a service with a custom audit sink
AttachmentService :: fn pool(& self) -> & PgPoolAccess 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`

ItemWhat it is
pub const ACTIVE_GRANT_PREDICATE: & strThe 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 strThe capability clause for a requested action, to AND onto ACTIVE_GRANT_PREDICATE
pub struct AssetAudienceGrantOne row of asset_audience_grants, mapped to a typed model.
pub struct GrantInputInput 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`

ItemWhat it is
pub struct LegacySubjectA 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 DerivedGrantA derived 0.77 grant ready to INSERT (the unambiguous, additive outcome of mapping a LegacySubject)
pub enum DropReasonWhy 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 MapOutcomeThe outcome of mapping one LegacySubject.
fn map_legacy_subject(s : & LegacySubject) -> MapOutcomeMap one 0.59 subject to its 0.77 outcome — the single designated reference for the migration's decision
pub struct MigrationReportThe 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) -> SelfBuild the report by mapping every legacy subject through map_legacy_subject.
MigrationReport :: fn never_widens(& self) -> boolThe migration never widens: every derived grant is additive (admits a scoped principal) and there are no public/customer_group grants

`service::audit_sink`

ItemWhat it is
pub struct AuditEventPer-event audit payload
AuditEvent :: fn is_sensitive(& self) -> boolIs this event for a sensitive-class attachment? Used by AttachmentService to refuse sensitive writes when the configured sink is NoopAuditSink.
pub trait AuditSinkAudit-log sink trait
pub struct NoopAuditSinkNo-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`

ItemWhat it is
pub struct GrantOne row of attachment_access_grants.
Grant :: fn is_active(& self, now : DateTime <Utc>) -> boolTrue if this grant is currently active (not soft-deleted, not expired).
pub struct GrantInputInput shape for creating a new grant.

`service::policy`

ItemWhat it is
pub struct PolicyContextPer-request authorization context passed to every policy method
PolicyContext :: fn has_perm(& self, perm : & str) -> boolConvenience: check if the viewer has a specific RBAC perm.
pub enum AttachDecisionResult of AttachmentPolicy::can_attach
pub trait AttachmentPolicyPer-entity-type authorization policy for attachments

`variant`

ItemWhat it is
fn is_servable_default(kind : & str, visibility : Visibility) -> boolDefault serveability for a freshly-ingested variant (Sprint 0.64a)
pub struct VariantA derived variant of an asset (thumbnail, resize, format conversion).
Variant :: fn builder() -> VariantBuilderCreate a new variant builder.
Variant :: fn is_standard_kind(& self) -> boolCheck 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) -> boolCheck if this variant is a thumbnail.
Variant :: fn aspect_ratio(& self) -> f64Get the aspect ratio (width / height).
Variant :: fn is_landscape(& self) -> boolCheck if the variant is landscape orientation.
Variant :: fn is_portrait(& self) -> boolCheck if the variant is portrait orientation.
Variant :: fn is_square(& self) -> boolCheck 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 VariantBuilderBuilder for Variant.
VariantBuilder :: fn new() -> SelfCreate a new builder.
VariantBuilder :: fn asset(mut self, asset_id : Uuid) -> SelfSet the parent asset ID.
VariantBuilder :: fn kind(mut self, kind : impl Into <String>) -> SelfSet the variant kind.
VariantBuilder :: fn thumb(self) -> SelfSet as thumbnail variant.
VariantBuilder :: fn small(self) -> SelfSet as small variant.
VariantBuilder :: fn medium(self) -> SelfSet as medium variant.
VariantBuilder :: fn large(self) -> SelfSet as large variant.
VariantBuilder :: fn file_path(mut self, path : impl Into <String>) -> SelfSet the storage file path.
VariantBuilder :: fn dimensions(mut self, width : i32, height : i32) -> SelfSet the dimensions.
VariantBuilder :: fn format(mut self, format : impl Into <String>) -> SelfSet the output format.
VariantBuilder :: fn jpeg(self) -> SelfSet format to JPEG.
VariantBuilder :: fn png(self) -> SelfSet format to PNG.
VariantBuilder :: fn webp(self) -> SelfSet format to WebP.
VariantBuilder :: fn size_bytes(mut self, size : i64) -> SelfSet the encoded byte size of this variant on disk.
VariantBuilder :: fn visibility(mut self, visibility : Visibility) -> SelfSet the visibility of this variant.
VariantBuilder :: fn private(self) -> SelfMark this variant private (used for the retained kind = "original").
VariantBuilder :: fn sha256(mut self, sha256 : impl Into <String>) -> SelfSet the content hash (used for the kind = "original" audit hash).
VariantBuilder :: fn is_servable(mut self, is_servable : bool) -> SelfOverride serveability explicitly
VariantBuilder :: fn build(self) -> VariantBuild the variant

`variant_kinds`

ItemWhat it is
pub const THUMB: & strThumbnail variant (256x256 max).
pub const SMALL: & strSmall variant (640x640 max).
pub const MEDIUM: & strMedium variant (1024x1024 max).
pub const LARGE: & strLarge variant (2048x2048 max).
fn max_dimension(kind : & str) -> Option <u32>Get the maximum dimension for a variant kind.
fn is_standard(kind : & str) -> boolCheck if a variant kind is standard.
fn all() -> & 'static & 'static strGet 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`

ItemWhat it is
pub struct VariantInfoA 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`

ItemWhat it is
pub enum VisibilityVisibility level for an asset
Visibility :: fn as_str(& self) -> & 'static strGet the string representation.
Visibility :: fn parse(s : & str) -> Option <Self>Parse from string.
Visibility :: fn is_public(& self) -> boolCheck if this visibility allows public access.
Visibility :: fn requires_auth(& self) -> boolCheck if this visibility requires authentication.
Visibility :: fn is_owner_only(& self) -> boolCheck if this visibility is owner-only.
Visibility :: fn fmt(& self, f : & mut std::fmt::Formatter <'_>) -> std::fmt::Result

`visibility_ops`

ItemWhat 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.

ExportDefined in
AssetErrorerror::AssetError
Licenselicense::License
Visibilityvisibility::Visibility
set_asset_visibilityvisibility_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)
Locationcrates/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.

CrateTierOptionalOnly on
`foundation-basemodels`foundationnoalways
`identity-parties`identitynoalways
`infrastructure-fetcher`infrastructureyesalways
`infrastructure-storage`infrastructureyesalways

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
ammonia^4yesalways
async-trait^0.1noalways
chrono^0.4serdenoalways
hex^0.4yesalways
image^0.25jpeg, png, gif, webpyesalways
kamadak-exif^0.6yesalways
reqwest^0.12rustls-tls, jsonyesalways
serde^1derivenoalways
serde_json^1noalways
sha2^0.10yesalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonnoalways
thiserror^2noalways
tokio^1fullnoalways
uuid^1v4, v7, serde, jsnoalways
webp^0.3yesalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
tokio-test^0.4noalways

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

FeatureEnablesOn by default
commons-importdep:reqwest, dep:ammonia, dep:infrastructure-fetcherno
defaultyes
fetchingest, dep:reqwest, dep:infrastructure-fetcherno
imagingdep:imageno
ingestimaging, dep:kamadak-exif, dep:webp, dep:sha2, dep:hex, dep:infrastructure-storageno
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

KindNameSource
libcontent_assets`src/lib.rs`
testasset_text_state_machine`tests/asset_text_state_machine.rs`
testmigration_013_media_access`tests/migration_013_media_access.rs`
testmigration_016_asset_audience_grants`tests/migration_016_asset_audience_grants.rs`
testmigration_017_audience_migration`tests/migration_017_audience_migration.rs`
testpg_set_visibility`tests/pg_set_visibility.rs`

Error model

Error typeNamed by
AssetErrorapply_translation, audience_mode_narrows, classify_ingest_error, confirm_human, fetch_and_ingest, generate_missing_variants, … (23 total)
CommonsImportErrorfetch_image_bytes, fetch_metadata, parse_url
CompositeErrorstitch_image_files, stitch_images
ImageErrordeclared, no public signature returns it
IngestErrorcanonical_jpeg, check_dimensions, encode_avif, encode_jpeg, encode_webp, prepare_ingest, … (8 total)

Operational characteristics

PropertyEvidence
async public surfaceyes
async runtimeyes
database accessyes
network I/Oyes
unsafe codenone detected
environment variablesyes

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

Configuration

VariableRead in
DATABASE_URLsrc/ingest.rs

3 workspace crates depend on this one: application-cms, platform-api, platform-privacy-scan-api.

Verification

KindCount
Unit tests340
Integration tests17
Examples0
Doctests1

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

ModuleTestsExamplesConsumers
access1208
access_map605
asset202
asset_text15011
attachment201
audience12010
commons_import500
composite600
content_types200
error101
exif302
fetch500
handlers1305
imaging201
ingest37021
license100
mime_types38022
service::attachments605
service::audience_grants606
service::audience_migration600
service::audit_sink304
service::grants202
service::policy303
variant301
variant_kinds903
variants_read405
visibility102
visibility_ops101

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc366410
Public modules with a //! block2929
pie showData
    title Public items with rustdoc
    "Documented" : 366
    "No rustdoc detected" : 44

Metrics

MetricValue
Rust source files30
Source lines14989
Code lines10634
Public API items410
Public modules29
Tests357
Examples0
Cargo features5
Direct runtime dependencies19
Workspace reverse dependencies3
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.

Todas las content · Manual