realm-codec 0.1.1

Parser and writer for Realm binary database files (v9) — read tables, build new files
Documentation
  • Coverage
  • 100%
    56 out of 56 items documented2 out of 29 items with examples
  • Size
  • Source code size: 74.3 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 709.2 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • pinkha-app/pinkha
    5 2 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • gloiiire

realm-codec

Parser and writer for Realm binary database files (format version 9).

Read an existing .realm file without the Realm SDK. Write a new .realm file from Rust data.

Reading

use realm_codec::RealmFile;

let realm = RealmFile::open("/path/to/file.realm")?;

if let Some(table) = realm.table("class_BlockDataModel") {
    println!("{} rows", table.rows.len());
    for row in &table.rows {
        println!("{}", table.get(row, "content").as_str());
    }
}

Writing

use realm_codec::{RealmBuilder, ColumnType, Value};

let mut builder = RealmBuilder::new();
builder
    .table("class_Note")
    .column("id",   ColumnType::String)
    .column("body", ColumnType::String)
    .column("done", ColumnType::Bool)
    .row(vec![
        Value::String("1".into()),
        Value::String("Buy milk".into()),
        Value::Bool(false),
    ]);

builder.write("/path/to/out.realm")?;
// or: let bytes = builder.to_bytes();

Supported column types

Realm type Value variant Read Write
Int Value::Int ✓ ✓
Bool Value::Bool ✓ ✓
String Value::String ✓ ✓
Data Value::String ✓ ✓
Float Value::Float ✓ ✓
Double Value::Float ✓ ✓
Timestamp Value::Timestamp ✓ ✓
Link Value::Link ✓ ✓

Features

  • Zero dependencies
  • Parses Realm v9 format: NodeHeader, Group, spec arrays, full B-tree column traversal
  • Writes valid Realm v9 files readable by the Realm SDK and this crate
  • Round-trip tested: RealmBuilder → to_bytes() → RealmFile::from_bytes()

License

MIT OR Apache-2.0