dbiewlite-core 0.5.0

Shared database operations for DBiewLite (SQLite, DuckDB, Parquet)
/// What a person who typed `cargo install dbiewlite-tui` has no other way to learn.
///
/// Neither published crate carries a licence file: `LICENSE` sits at the repository
/// root, outside both package directories, so `cargo package` leaves it behind and
/// `cargo` unpacks the tarball to a registry cache no one reads. This const is the
/// whole path by which an installed DBiewLite can answer "what did I just install".
///
/// It is deliberately **not** a dependency-licence dump. The Rust crates are built
/// from source and `Cargo.toml` already names them, so three hundred transitive
/// entries would bury the two facts that are genuinely surprising: this binary
/// contains an entire SQLite and an entire DuckDB, and DuckDB brings a vendored C++
/// world of its own that ships without its licence files.
///
/// A literal rather than `include_str!`: a published crate holds no part of the
/// repository around it, so an include reaching over to `LICENSE` resolves in a
/// checkout and fails for everyone who installs from the registry.
///
/// The versions here are pinned by `Cargo.lock` — `libsqlite3-sys` and
/// `libduckdb-sys` — and go stale silently when those move. Re-read them from the
/// vendored sources when bumping either.
pub const LICENSES: &str = "\
DBiewLite — its own source is MIT.

    Copyright (c) 2026 Ivapo
    https://github.com/Ivapo/DBiewLite/blob/main/LICENSE

This binary is statically linked, so it carries two database engines that are not
DBiewLite's work and are not covered by that licence:

    SQLite 3.49.1
    Project   https://sqlite.org
    Bundled   through rusqlite's `bundled` feature (libsqlite3-sys)
    Licence   Public domain. SQLite's authors ask for no notice at all — the
              amalgamation carries a blessing where a licence would go.

    DuckDB v1.5.5 (d8cdaa33fd)
    Project   https://github.com/duckdb/duckdb
    Bundled   through duckdb's `bundled` feature (libduckdb-sys)
    Licence   MIT, Copyright 2021-2026 Stichting DuckDB Foundation

DuckDB in turn compiles in about twenty-six vendored C and C++ libraries — among
them thrift and mbedtls (Apache-2.0), zstd, re2, snappy and lz4 (BSD), fmt,
brotli, yyjson and miniz (MIT), and libpg_query (the PostgreSQL licence). All are
permissive and none is copyleft, so what they ask for is attribution, which is
this notice. DuckDB's amalgamated tarball ships no licence files for any of them;
the authoritative texts are under third_party/ in the DuckDB repository at the
source id above.

Everything else is a Rust crate compiled from source and named in Cargo.toml,
MIT or Apache-2.0 but for one: option-ext (MPL-2.0), reached through dirs. The
MPL binds that crate's own files and nothing it is linked into.

This records provenance and is not legal advice.";

#[cfg(test)]
mod tests {
    use super::LICENSES;

    /// The notice names versions that move whenever `libsqlite3-sys` or
    /// `libduckdb-sys` is bumped, and nothing about a stale one looks wrong —
    /// it just quietly attributes the wrong release. So ask the libraries that
    /// actually linked, rather than trusting the text or the lockfile.
    #[test]
    fn notice_names_the_versions_that_linked() {
        let sqlite = rusqlite::version();
        assert!(
            LICENSES.contains(&format!("SQLite {sqlite}")),
            "LICENSES names a different SQLite than the one linked ({sqlite})"
        );

        let duckdb: String = duckdb::Connection::open_in_memory()
            .unwrap()
            .query_row("SELECT version()", [], |r| r.get(0))
            .unwrap();
        assert!(
            LICENSES.contains(&format!("DuckDB {duckdb}")),
            "LICENSES names a different DuckDB than the one linked ({duckdb})"
        );
    }
}