├── .gitignore ├── Cargo.toml ├── README.md └── Cargo.lock /.gitignore: -------------------------------------------------------------------------------- 1 | /target 2 | -------------------------------------------------------------------------------- /Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "rsqlite3" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | libc = "*" 10 | c2rust-bitfields="*" 11 | num-traits="*" 12 | f128 = "*" 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # sqlite3 Rewritten in RiiR Rust 🦀🦀🦀 2 | 3 | Finally, one of the best written software paired with one of the best writable programming language‽ Fearless and memory safe, since the uncountable amount of `unsafe {}` blocks makes you not care anymore. 4 | 5 | ## Build and run 6 | 7 | ```shell 8 | $ cargo +nightly build --release 9 | # ... bunch of stuff I choose not to understand/read 10 | warning: `rsqlite3` (bin "rsqlite3") generated 37 warnings (24 duplicates) 11 | Finished release [optimized] target(s) in 39.84s 12 | $ ./target/release/rsqlite3 13 | -- Loading resources from /home/epilys/.sqliterc 14 | SQLite version 3.37.0 2021-10-17 10:31:09 15 | Enter ".help" for usage hints. 16 | Connected to a transient in-memory database. 17 | Use ".open FILENAME" to reopen on a persistent database. 18 | sqlite> .open rrrrrruuuuuust.db 19 | sqlite> CREATE TABLE opinions(x); 20 | sqlite> insert into opinions(x) values (hex(randomblob(16))); 21 | sqlite> insert into opinions(x) values (hex(randomblob(16))); 22 | sqlite> insert into opinions(x) values (hex(randomblob(16))); 23 | sqlite> insert into opinions(x) values (hex(randomblob(16))); 24 | sqlite> select * from opinions; 25 | x 26 | -------------------------------- 27 | 343D4BE24D07A96F8550B0942F664A6C 28 | D6289536E4A8057EB44754358EACD31A 29 | B4CA8E714CB57B11E7336263D214F30F 30 | A6491CA289ABF90EB2D76F5E1F919272 31 | sqlite> PRAGMA journal_mode = wal; 32 | journal_mode 33 | ------------ 34 | wal 35 | sqlite> PRAGMA integrity_check; 36 | integrity_check 37 | --------------- 38 | ok 39 | sqlite> VACUUM; 40 | sqlite> ^D 41 | ``` 42 | 43 | ## Wait, what? 44 | 45 | This is just the sqlite3 code passed throught the 46 | [`c2rust`](https://c2rust.com/) transpiler, along with some cleanup from me. 47 | I've found no way to hook it to sqlite3's testing harnesses yet so I doubt it's 48 | completely functional; but opening the shell seems to work. 49 | 50 | I am suspicious that a lot of code under ifdefs or not is lost through the transpilation, because the binary size difference is substantial: 51 | 52 | ```shell 53 | $ du -sh $(which sqlite3) 54 | 9.5M /home/epilys/.local/bin/sqlite3 55 | $ du -sh target/release/rsqlite3 56 | 5.1M target/release/rsqlite3 57 | ``` 58 | -------------------------------------------------------------------------------- /Cargo.lock: -------------------------------------------------------------------------------- 1 | # This file is automatically @generated by Cargo. 2 | # It is not intended for manual editing. 3 | version = 3 4 | 5 | [[package]] 6 | name = "autocfg" 7 | version = "1.0.1" 8 | source = "registry+https://github.com/rust-lang/crates.io-index" 9 | checksum = "cdb031dd78e28731d87d56cc8ffef4a8f36ca26c38fe2de700543e627f8a464a" 10 | 11 | [[package]] 12 | name = "c2rust-bitfields" 13 | version = "0.3.0" 14 | source = "registry+https://github.com/rust-lang/crates.io-index" 15 | checksum = "eb34f0c0ace43530b2df7f18bc69ee0c4082158aa451ece29602f8c841e73764" 16 | dependencies = [ 17 | "c2rust-bitfields-derive", 18 | ] 19 | 20 | [[package]] 21 | name = "c2rust-bitfields-derive" 22 | version = "0.2.1" 23 | source = "registry+https://github.com/rust-lang/crates.io-index" 24 | checksum = "3dd1601a7b828ab874d890e5a895563ca8ad485bdd3d2a359f148c8b72537241" 25 | dependencies = [ 26 | "proc-macro2", 27 | "quote", 28 | "syn", 29 | ] 30 | 31 | [[package]] 32 | name = "cc" 33 | version = "1.0.71" 34 | source = "registry+https://github.com/rust-lang/crates.io-index" 35 | checksum = "79c2681d6594606957bbb8631c4b90a7fcaaa72cdb714743a437b156d6a7eedd" 36 | 37 | [[package]] 38 | name = "f128" 39 | version = "0.2.9" 40 | source = "registry+https://github.com/rust-lang/crates.io-index" 41 | checksum = "0b7d29530784c8b9e49eccb10c95abc69ac72e9e7eb29cb2649b13e08f766d2c" 42 | dependencies = [ 43 | "f128_input", 44 | "f128_internal", 45 | "libc", 46 | "num-traits", 47 | ] 48 | 49 | [[package]] 50 | name = "f128_input" 51 | version = "0.2.1" 52 | source = "registry+https://github.com/rust-lang/crates.io-index" 53 | checksum = "18a821a6f74745607a8c99c932a8f513e6e7d6ee63725ec95511edf4a94510bb" 54 | dependencies = [ 55 | "f128_internal", 56 | ] 57 | 58 | [[package]] 59 | name = "f128_internal" 60 | version = "0.2.2" 61 | source = "registry+https://github.com/rust-lang/crates.io-index" 62 | checksum = "9708a33de3cda4e6636670c1af561635fe249cb817dda1a14ec18fe9dda0a99d" 63 | dependencies = [ 64 | "cc", 65 | "libc", 66 | "num-traits", 67 | ] 68 | 69 | [[package]] 70 | name = "libc" 71 | version = "0.2.105" 72 | source = "registry+https://github.com/rust-lang/crates.io-index" 73 | checksum = "869d572136620d55835903746bcb5cdc54cb2851fd0aeec53220b4bb65ef3013" 74 | 75 | [[package]] 76 | name = "num-traits" 77 | version = "0.2.14" 78 | source = "registry+https://github.com/rust-lang/crates.io-index" 79 | checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" 80 | dependencies = [ 81 | "autocfg", 82 | ] 83 | 84 | [[package]] 85 | name = "proc-macro2" 86 | version = "1.0.32" 87 | source = "registry+https://github.com/rust-lang/crates.io-index" 88 | checksum = "ba508cc11742c0dc5c1659771673afbab7a0efab23aa17e854cbab0837ed0b43" 89 | dependencies = [ 90 | "unicode-xid", 91 | ] 92 | 93 | [[package]] 94 | name = "quote" 95 | version = "1.0.10" 96 | source = "registry+https://github.com/rust-lang/crates.io-index" 97 | checksum = "38bc8cc6a5f2e3655e0899c1b848643b2562f853f114bfec7be120678e3ace05" 98 | dependencies = [ 99 | "proc-macro2", 100 | ] 101 | 102 | [[package]] 103 | name = "rsqlite3" 104 | version = "0.1.0" 105 | dependencies = [ 106 | "c2rust-bitfields", 107 | "f128", 108 | "libc", 109 | "num-traits", 110 | ] 111 | 112 | [[package]] 113 | name = "syn" 114 | version = "1.0.81" 115 | source = "registry+https://github.com/rust-lang/crates.io-index" 116 | checksum = "f2afee18b8beb5a596ecb4a2dce128c719b4ba399d34126b9e4396e3f9860966" 117 | dependencies = [ 118 | "proc-macro2", 119 | "quote", 120 | "unicode-xid", 121 | ] 122 | 123 | [[package]] 124 | name = "unicode-xid" 125 | version = "0.2.2" 126 | source = "registry+https://github.com/rust-lang/crates.io-index" 127 | checksum = "8ccb82d61f80a663efe1f787a51b16b5a51e3314d6ac365b08639f52387b33f3" 128 | --------------------------------------------------------------------------------