Expand description
§roomrs
Room-style local SQLite persistence library for Rust.
This is the facade crate: it re-exports the public API from the internal crates. See the repository README for the full design document.
Re-exports§
pub use roomrs_core::rusqlite;
Macros§
- migrations_
dir migrations_dir!("migrations")— 디렉터리의{from}_{to}_이름.sql파일들을 컴파일 타임에 임베드해Vec<Migration>으로 전개 (명세 §8.2).- params
- A macro making it more convenient to pass longer lists of
parameters as a
&[&dyn ToSql].
Structs§
- Async
Handle - Async handle returned by
db.run_async(). - Col
- 컬럼 참조 — 비교 콤비네이터의 시작점
- Column
Meta - 컬럼 메타 —
#[entity]생성, 스냅샷 대조·생성에 사용 (명세 §7) - Column
Snapshot - 컬럼 스냅샷
- Database
- roomrs 코어 데이터베이스 — 사용자는
#[database]생성 타입으로 감싸 쓴다 - Database
Builder - 빌더 (명세 §5.4)
- Diff
Plan - Structured migration plan between two snapshots (spec §8.1/§8.4).
- Embedded
Schema - Compile-time embedded schema snapshot (spec §8.4, decision 21c).
- Invalidation
Filter - Row-level invalidation condition for a live query.
- Invalidation
Filter Builder - Builder for
InvalidationFilter. - Invalidation
Group Builder - Builder for an AND predicate group.
- Live
Query - 라이브 쿼리 — 단일 구체 타입 (명세 §5.6).
의존 테이블 write 시 자동 재조회 emit. drop = 구독 해제.
recv/recv_timeout은 호출 스레드를 블로킹한다. async에서는into_stream을 쓴다. 마지막 DB 핸들 drop은 notifier 스레드 종료까지 join할 수 있다. - Migration
- 마이그레이션 스텝 — 세 소스(SQL 파일/인라인 SQL/코드)의 공통 표현 (명세 §8.2)
- Query
- 쿼리 빌더 진입점 (명세 §5.3)
- Schema
Def - 테이블 스키마 정의 —
#[database]매크로가 엔티티 메타에서 구성 - Schema
Snapshot - 스키마 스냅샷 — 리포에 커밋되는 검증 진실 소스 (명세 §7.1)
- Select
Builder - SELECT 빌더 — 조건·정렬·페이지 조합
- Subscription
Guard - 콜백 구독 가드 — drop = 해지
- Sync
Handle - 동기 핸들 —
db.run_sync()반환 타입 (명세 §5.0). 모든 작업은 read/write 통합 풀에서 커넥션을 체크아웃한다. - Table
Meta - 테이블 메타 —
#[database]가 엔티티에서 수집 - Table
Snapshot - 테이블 스냅샷
- Tx
- A synchronous transaction bound to its checked-out connection and thread.
Enums§
- Error
- roomrs 단일 에러 타입 — 공개 API는 전부 이 타입으로 반환한다
- Expr
- WHERE 식 트리
- Migration
Policy - 마이그레이션 정책 (명세 §8 — M1은 Auto 최소 동작만, M3에서 완성)
- Order
- 정렬 방향
- ToSql
Output ToSqlOutputrepresents the possible output types for implementers of theToSqltrait.
Constants§
- SCHEMA_
DIR_ RELATIVE - Standard snapshot directory relative to the crate manifest (spec §7.2).
Traits§
- Build
Async Ext - Asynchronous build extensions for
DatabaseBuilder. - Database
Spec #[database]생성물이 구현하는 스펙 trait — core 빌더가 타입드 DB를 돌려줄 수 있게 한다- Entity
- 테이블 매핑 메타.
#[entity]생성물. - Execute
- 핸들 대칭 실행자 (명세 §5.3 [C-6]) —
동기 =
Result<R>, 비동기 = BoxedFuture.#[database]생성 핸들 래퍼에도 구현된다. - FromRow
- 쿼리 결과 한 행을 값으로 변환하는 trait.
엔티티는
#[entity]매크로가 구현을 생성하고, 프리미티브·튜플은 아래 매크로로 일괄 구현한다. - Insertable
- INSERT 지원 메타.
#[entity]생성물 (명세 §12c — autoincrement PK 항상 생략). - Into
DbValue - 빌더 값 변환 —
&str포함 흔한 타입 열거 (코히어런스 안전) - Migration
Step - 수동 코드 스텝 trait — (from,to) 쌍 모델 [C-3] (명세 §8.3)
- Params
- Trait used for sets of parameter passed into SQL statements/queries.
- Relation
View - 관계 뷰 — 부모 엔티티 + 자식 컬렉션 조립 (Room @Embedded+@Relation 대응).
#[derive(Relation)]이 구현을 생성한다. - SqlContext
- DAO 공용 실행 컨텍스트 (명세 §5.9) —
풀-바운드(
SyncHandle: 호출마다 통합 풀 체크아웃)와 tx-바운드(Tx: 트랜잭션 커넥션 고정)를 하나의 trait로 통일한다. - ToSql
- A trait for types that can be converted into SQLite values. Returns
crate::Error::ToSqlConversionFailureif the conversion fails. - Watch
Context - DAO watch 컨텍스트 (명세 §5.6) — 풀-바운드 전용. Tx 구현은 “트랜잭션에서 라이브 불가” 에러를 첫 emit으로 전달한다.
Functions§
- check_
schema_ snapshot - 스냅샷 ↔ 엔티티 메타 일치 검사 — CI/check용 (명세 §7.4a)
- col
- 컬럼 참조 시작점
- compress_
snapshot - Compress snapshot JSON bytes with miniz_oxide (raw deflate, level 8).
- decompress_
snapshot - Decompress bytes produced by
compress_snapshot. - diff_
plan - Compute a structured diff plan from
oldtonew(spec §8.1, §8.4). - diff_
sql - 자동 diff 초안 SQL 생성 (명세 §8.1) — 절대 자동 실행하지 않는다(비목표).
diff_plan위에 렌더: 안전 연산은 실행문, 파괴적 항목은-- TODO(파괴적)주석, 경고는-- 경고주석으로 출력한다. - export_
schema_ for_ test - Snapshot export/stale-check helper called by the test that
#[database]generates (spec §7.4, decisions 21b/28). - list_
snapshot_ versions - List every
{db_name}.{N}.jsonsnapshot indir, sorted ascending by version.Nis parsed strictly (digits only, no leading zeros), so duplicate versions are impossible by file name. A missing directory yields an empty list. - outputs_
to_ values - ToSqlOutput 목록을 소유 Value 목록으로 변환
- params_
from_ iter - Constructor function for a
ParamsFromIter. See its documentation for more. - resolve_
schema_ dir - Resolve the snapshot directory: the
ROOMRS_SCHEMA_DIRenvironment variable wins when set and non-empty, otherwise{manifest_dir}/migrations/schema(spec §7.2, decision 21). - snapshot_
file_ name - File name of a versioned snapshot:
{db_name}.{version}.json(decision 21 — thecurrent.jsonsingle-file model is gone). - snapshot_
path - Full path of a versioned snapshot inside a schema directory.
- to_
owned_ value - ToSql 값을 소유
Value로 변환 — 비동기 경로의 ’static 확보용 (명세 §2.4) - write_
schema_ snapshot - 스냅샷 파일 생성/갱신 — 개발 플로우용 (명세 §7.4a).
경로:
resolve_schema_dir(manifest_dir)/{DB_NAME}.{VERSION}.json
Type Aliases§
- Result
- roomrs 공용 Result 별칭
Attribute Macros§
- dao
#[dao]— trait DSL을 소비해 동기 DAO 구현을 생성 (명세 §5.2). 메서드 속성:#[query("…")]·#[insert(on_conflict/keep_pk)]·#[update("…")]·#[delete("…")]- database
#[database(entities(…), daos(…), version = N)]— DB 진입점 생성 (명세 §5.4)- entity
#[entity(table = "…")]— 구조체를 테이블에 매핑 (명세 §5.1). 필드 속성:#[pk(autoincrement)]·#[column(name/unique/index/default/ignore)]·#[json]
Derive Macros§
- Relation
#[derive(Relation)]— 관계 뷰 조립 코드 생성 (명세 결정 로그 7)