add note about plugin feature in cargo

closes #1
This commit is contained in:
Joe Ardent 2023-07-28 15:38:24 -07:00
parent 33cf49b354
commit 7dc8760fa4

View file

@ -109,14 +109,26 @@ fn main() {
} }
``` ```
after adding it to your project's dependencies (eg, `cargo add julid-rs`; note the package name is after adding it to your project's dependencies (eg, `cargo add julid-rs`; the package name is
"julid-rs", but the library name as used in your `use` statements is just "julid"). By default, it "julid-rs", but the library name as used in your `use` statements is just "julid"). By default, it
will also include trait implementations for using Julids with will also include trait implementations for using Julids with
[SQLx](https://github.com/launchbadge/sqlx), and serializing/deserializing with [SQLx](https://github.com/launchbadge/sqlx), and serializing/deserializing with
[Serde](https://serde.rs/), via the `sqlx` and `serde` features, respectively. One final default [Serde](https://serde.rs/), via the `sqlx` and `serde` features, respectively. One final default
optional feature, `chrono`, uses the Chrono crate to return the timestamp as a optional feature, `chrono`, uses the Chrono crate to return the timestamp as a
[`DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) by adding a `created_at(&self)` [`DateTime`](https://docs.rs/chrono/latest/chrono/struct.DateTime.html) by adding a
method to `Julid`. `created_at(&self)` method to `Julid`. See the simple
[example](https://gitlab.com/nebkor/julid/-/blob/main/examples/benchmark.rs) in the repo.
Something to note: don't enable the `plugin` feature in your Cargo.toml if you're using this crate
inside your Rust application, *especially* if you're also loading it as an extension in SQLite in
your application. You'll get a long and confusing runtime panic due to there being multiple
entrypoints defined with the same name.
## Safety
There is one `unsafe fn` in this project, `sqlite_julid_init()`, and it is only built for the
`plugin` feature. The reason for it is that it's interacting with foreign code (SQLite itself) via
the C interface, which is inherently unsafe. If you are not building the plugin, there is no
`unsafe` code.
# Thanks # Thanks