foundation tier

foundation-basemodels

Foundation traits for rust-framework-workspace: UUID primary keys, timestamps, and soft delete

Foundation traits for rust-framework-workspace: UUID primary keys, timestamps, and soft delete

Tierfoundation
Roleunclassified (baselined)
Pathcrates/foundation/basemodels
Edition2021
Targetsfoundation_basemodels
Public items2 across 0 modules
Tests43

What it is for

# foundation-basemodels

Foundation traits for rust-framework-workspace: UUID primary keys, timestamps, and soft delete.

All domain models in the rust-framework-workspace ecosystem must implement these traits:

Example

use foundation_basemodels::{HasId, Timestamped, SoftDeletable};
use uuid::Uuid;
use chrono::{DateTime, Utc};

struct Person {
id: Uuid,
name: String,
created_at: DateTime<Utc>,
updated_at: DateTime<Utc>,
deleted_at: Option<DateTime<Utc>>,
}

impl HasId for Person {
fn id(&self) -> Uuid { self.id }
}

impl Timestamped for Person {
fn created_at(&self) -> DateTime<Utc> { self.created_at }
fn updated_at(&self) -> DateTime<Utc> { self.updated_at }
}

impl SoftDeletable for Person {
fn deleted_at(&self) -> Option<DateTime<Utc>> { self.deleted_at }
}

Capabilities

Id

# foundation-basemodels

Item
pub type Id: Uuid

Timestamp

# foundation-basemodels

Item
pub type Timestamp: DateTime <Utc>

How to use it

From this crate's own rustdoc:

use foundation_basemodels::{HasId, Timestamped, SoftDeletable};
use uuid::Uuid;
use chrono::{DateTime, Utc};

struct Person {
    id: Uuid,
    name: String,
    created_at: DateTime<Utc>,
    updated_at: DateTime<Utc>,
    deleted_at: Option<DateTime<Utc>>,
}

impl HasId for Person {
    fn id(&self) -> Uuid { self.id }
}

impl Timestamped for Person {
    fn created_at(&self) -> DateTime<Utc> { self.created_at }
    fn updated_at(&self) -> DateTime<Utc> { self.updated_at }
}

impl SoftDeletable for Person {
    fn deleted_at(&self) -> Option<DateTime<Utc>> { self.deleted_at }
}

Module structure

No public modules: the crate root is its whole surface.

Public surface

`crate root`

ItemWhat it is
pub type Id: UuidType alias for the standard ID type (UUID)
pub type Timestamp: DateTime <Utc>Type alias for the standard timestamp type

Re-exports. Exported here, defined elsewhere.

ExportDefined in
BaseModelErrorerror::BaseModelError
Uuiduuid::Uuid
{DateTime,Utc}chrono::{DateTime,Utc}
{HasId,SoftDeletable,Timestamped}traits::{HasId,SoftDeletable,Timestamped}
{NilUuidError,NonNilUuid,NonNilUuidFromStrError}non_nil_uuid::{NilUuidError,NonNilUuid,NonNilUuidFromStrError}

Boundary

Depends on no other workspace tier.

Shares tier foundation with 27 other crates: foundation-audit-log, foundation-bounded-io, foundation-conversation-closure, foundation-crypto-sign, foundation-decisioning, foundation-encounter-vocabulary, foundation-fs-metadata, foundation-i18n, … (27 total).

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

Where it sits

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

Dependencies

Runtime, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
chrono^0.4serdenoalways
serde^1derivenoalways
sqlx^0.8runtime-tokio, postgres, chrono, uuid, jsonyesalways
thiserror^2noalways
uuid^1v4, v7, serde, jsnoalways

Development, from outside the workspace.

CrateRequirementFeaturesOptionalOnly on
serde_json^1noalways
tokio^1fullnoalways
tokio-test^0.4noalways

Build. None.

Depended on by. 59 workspace crates.

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

flowchart LR
  consumers["59 consumer crates"] -->|uses| SELF
  SELF["foundation-basemodels"]
  classDef self fill:#1f883d,stroke:#1f883d,color:#fff;
  class SELF self;

Feature flags

FeatureEnablesOn by default
defaultyes
sqlxdep:sqlxno
flowchart LR
  n_default["default"]
  n_sqlx["sqlx"] --> n_dep_sqlx["dep:sqlx"]

Targets

KindNameSource
libfoundation_basemodels`src/lib.rs`

Error model

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

Operational characteristics

PropertyEvidence
async public surfacenone detected
async runtimenone detected
database accessyes
network I/Onone detected
unsafe codenone detected
environment variablesnone detected

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

Configuration

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

59 workspace crates depend on this one: content-assets, content-calendar, content-calendar-recurrence, content-cms, content-directory-listing, content-notes, domain-agreements, domain-billing, domain-catalog, domain-classify, domain-comments, domain-contact, … (59 total).

Verification

KindCount
Unit tests43
Integration tests0
Examples0
Doctests1

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

ModuleTestsExamplesConsumers
crate root205

What the tests establish, by name:

Documentation coverage

MeasureDocumentedTotal
Public items with rustdoc22
Public modules with a //! block00
pie showData
    title Public items with rustdoc
    "Documented" : 2
    "No rustdoc detected" : 0

Metrics

MetricValue
Rust source files5
Source lines937
Code lines497
Public API items2
Public modules0
Tests43
Examples0
Cargo features2
Direct runtime dependencies5
Workspace reverse dependencies59
pie showData
    title Public API by kind
    "type alias" : 2
pie showData
    title Rust source composition
    "Code" : 497
    "Blank or comment" : 440

Generation

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

All foundation · Manual