Skip to main content

DatabaseSpec

Trait DatabaseSpec 

Source
pub trait DatabaseSpec: Sized {
    const VERSION: u32;
    const DB_NAME: &'static str;
    const SNAPSHOT_HASH: Option<u64> = None;
    const EMBEDDED_SCHEMAS: &'static [EmbeddedSchema] = _;
    const SNAPSHOT_FILE_SEEN: bool = true;

    // Required methods
    fn schema() -> SchemaDef;
    fn from_database(db: Database) -> Self;
}
Expand description

#[database] 생성물이 구현하는 스펙 trait — core 빌더가 타입드 DB를 돌려줄 수 있게 한다

Required Associated Constants§

Source

const VERSION: u32

스키마 버전

Source

const DB_NAME: &'static str

Snake-case database name — snapshot files are named {DB_NAME}.{version}.json (spec §7.2, decision 21). The #[database] macro derives this from the struct identifier.

Provided Associated Constants§

Source

const SNAPSHOT_HASH: Option<u64> = None

컴파일 타임에 읽은 현재 버전 스냅샷 파일 해시 — 파일 부재 시 None (명세 §7.4b)

Source

const EMBEDDED_SCHEMAS: &'static [EmbeddedSchema] = _

Embedded snapshots in ascending version order (spec §8.4, decision 21c). Filled in by the #[database] macro; empty when no snapshot files exist.

Source

const SNAPSHOT_FILE_SEEN: bool = true

Whether the current-version snapshot file existed when the #[database] macro expanded (decision 28, D-3b). Defaults to true so manual DatabaseSpec impls are unaffected. When false, the export test keeps failing even after the file exists and matches, until a rebuild re-expands the macro and embeds the snapshot — closing the fail-open window where SNAPSHOT_HASH and the embedded chain silently stay stale.

Required Methods§

Source

fn schema() -> SchemaDef

엔티티들의 DDL 수집

Source

fn from_database(db: Database) -> Self

core Database를 감싸 사용자 DB 타입 생성

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§