31 releases (breaking)

0.24.0 Jan 10, 2024
0.23.2 Nov 2, 2023
0.23.1 Oct 22, 2023
0.23.0 Jan 31, 2023
0.4.0 Jul 30, 2020

#319 in Database interfaces

Download history 14/week @ 2023-12-21 3/week @ 2023-12-28 23/week @ 2024-01-04 15/week @ 2024-01-11 4/week @ 2024-01-18 3/week @ 2024-01-25 1/week @ 2024-02-08 5/week @ 2024-02-15 21/week @ 2024-02-22 92/week @ 2024-02-29 34/week @ 2024-03-07 27/week @ 2024-03-14 36/week @ 2024-03-28 21/week @ 2024-04-04

88 downloads per month
Used in 3 crates

MIT license

435KB
9K SLoC

Rust Firebird Client

Build Crate API github sponsors

A Firebird client library to Rust programing language

How to use

Examples

Goals

  • Rust Api
  • Dynamic link with fbclient
  • Dynamic loading the fbclient(.dll or .so)
  • ARM support
  • Firebird embedded support

ko-fi


lib.rs:

Rust Firebird Client

How to use it

1. Start by choosing the lib variation you want

// To use the offcial ('native') Firebird client .dll/.so/.dylib
// (needs to find dll at build time)
rsfbclient::builder_native().with_dyn_link()
// Or using dynamic loading
rsfbclient::builder_native().with_dyn_load("/my/firebird/here/lib/libfbclient.so")
// Or using the pure rust implementation
rsfbclient::builder_pure_rust()

2. Set your connection params

// For a remote server, using a dynamically linked native client
let mut conn = rsfbclient::builder_native()
    .with_dyn_link()
    .with_remote()
    .host("my.host.com.br")
    .db_name("awesome.fdb")
    .connect()?
// Or if you need a embedded/local only access
let mut conn = rsfbclient::builder_native()
    .with_dyn_link()
    .with_embedded()
    .db_name("/path/to/awesome.fdb")
    .connect()?

You also can choose a string connection configuration

// Using the native Firebird client
rsfbclient::builder_native()
    .from_string("firebird://SYSDBA:masterkey@my.host.com.br:3050/awesome.fdb?charset=ascii")
// Or using the pure rust implementation
rsfbclient::builder_pure_rust()
    .from_string("firebird://SYSDBA:masterkey@my.host.com.br:3050/awesome.fdb?charset=ascii")

3. Now you can use the lib

let rows = conn.query_iter("select col_a, col_b, col_c from test", ())?;
...

Simple Connection/Transaction

Sometimes you will need store the Connection and Transaction types into a struct field without care about Firebird Client variation. To do this, you can use the SimpleConnection and SimpleTransaction types.

To use, you only need use the From trait, calling the into() method. Example:

let mut conn: SimpleConnection = rsfbclient::builder_native()
    .with_dyn_link()
    .with_remote()
    .host("my.host.com.br")
    .db_name("awesome.fdb")
    .connect()?
    .into();

Cargo features

All features can be used at the same time if needed.

linking

Will use the dynamic library of the official fbclient at runtime and compiletime. Used in systems where there is already a firebird client installed and configured.

dynamic_loading

Can find the official fbclient native library by path at runtime, does not need the library at compiletime. Useful when you need to build in a system without a firebird client installed.

pure_rust

Uses a pure rust implementation of the firebird wire protocol, does not need the native library at all. Useful for cross-compilation and allow a single binary to be deployed without needing to install the firebird client.

Dependencies

~8–17MB
~208K SLoC