Skip to main content

ConnectConfig

Struct ConnectConfig 

Source
pub struct ConnectConfig {
Show 14 fields pub host: String, pub port: u16, pub database: String, pub user: String, pub password: String, pub role: Option<String>, pub charset: String, pub dialect: i32, pub wire_crypt: WireCrypt, pub connect_timeout: Option<Duration>, pub page_size: Option<i32>, pub timezone: Option<String>, pub parallel_workers: Option<i32>, pub native_data_types: bool,
}
Expand description

Tudo o que é necessário para abrir uma conexão com um servidor Firebird.

Fields§

§host: String

Nome ou IP do servidor Firebird.

§port: u16

Porta TCP do servidor Firebird. O padrão do Firebird é 3050.

§database: String

Caminho ou alias do banco de dados no servidor (ex.: employee ou /data/db.fdb).

§user: String

Nome do usuário Firebird.

§password: String

Senha do usuário Firebird.

§role: Option<String>

Papel SQL opcional usado na conexão (ROLE).

§charset: String

Charset da conexão (padrão UTF8).

§dialect: i32

Dialeto SQL (padrão 3).

§wire_crypt: WireCrypt

Política de criptografia da comunicação.

§connect_timeout: Option<Duration>

Timeout de TCP + handshake.

§page_size: Option<i32>

Tamanho da página para crate::Connection::create_database.

§timezone: Option<String>

Fuso horário da sessão (FB4+), ex.: America/Sao_Paulo.

§parallel_workers: Option<i32>

Número de workers paralelos para a conexão (FB5).

§native_data_types: bool

Quando true, emite SET BIND OF INT128/DECFLOAT/TIME ZONE TO NATIVE logo após o attach (FB4+). Útil quando o servidor está com DataTypeCompatibility ligado e coage esses tipos para os legados — assim eles voltam como Int128/DecFloat/TimeTz em vez de aproximações.

Implementations§

Source§

impl ConnectConfig

Source

pub fn new() -> Self

Começa a partir dos padrões (localhost:3050, usuário SYSDBA, UTF8, dialeto 3).

Examples found in repository?
examples/dump.rs (line 12)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn host(self, host: impl Into<String>) -> Self

Define o host ou IP do servidor Firebird.

Examples found in repository?
examples/dump.rs (line 13)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn port(self, port: u16) -> Self

Define a porta TCP do servidor Firebird.

Examples found in repository?
examples/dump.rs (lines 14-19)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn database(self, db: impl Into<String>) -> Self

Define o banco por alias ou caminho no servidor.

Examples found in repository?
examples/dump.rs (line 20)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn user(self, user: impl Into<String>) -> Self

Define o usuário Firebird.

Examples found in repository?
examples/dump.rs (line 21)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn password(self, password: impl Into<String>) -> Self

Define a senha do usuário Firebird.

Examples found in repository?
examples/dump.rs (line 22)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn role(self, role: impl Into<String>) -> Self

Define o papel SQL (ROLE) usado após o login.

Source

pub fn charset(self, charset: impl Into<String>) -> Self

Define o charset da conexão, como UTF8, WIN1252 ou ISO8859_1.

Source

pub fn dialect(self, dialect: i32) -> Self

Define o dialeto SQL. Use 3 para bancos modernos.

Source

pub fn wire_crypt(self, wc: WireCrypt) -> Self

Define se a comunicação deve ser criptografada, quando disponível ou obrigatoriamente.

Examples found in repository?
examples/dump.rs (line 23)
11fn main() -> Result<()> {
12    let cfg = ConnectConfig::new()
13        .host(std::env::var("FB_HOST").unwrap_or_else(|_| "127.0.0.1".into()))
14        .port(
15            std::env::var("FB_PORT")
16                .ok()
17                .and_then(|p| p.parse().ok())
18                .unwrap_or(3555),
19        )
20        .database(std::env::var("FB_DB").unwrap_or_else(|_| "employee".into()))
21        .user(std::env::var("FB_USER").unwrap_or_else(|_| "SYSDBA".into()))
22        .password(std::env::var("FB_PASSWORD").expect("set FB_PASSWORD"))
23        .wire_crypt(WireCrypt::Enabled);
24
25    let mut conn = Connection::connect(&cfg)?;
26    println!("conectado: protocolo v{}", conn.protocol_version());
27    let tx = conn.begin()?;
28
29    let sql = "SELECT emp_no, first_name FROM employee WHERE emp_no = 2";
30    let stmt = conn.prepare(&tx, sql)?;
31    println!(
32        "\nstmt_type={} colunas={}",
33        stmt.stmt_type(),
34        stmt.columns().len()
35    );
36    for c in stmt.columns() {
37        println!(
38            "  [{}] name={:?} field={:?} relation={:?} alias={:?} owner={:?} type={} sub={} scale={} len={}",
39            c.index,
40            c.name(),
41            c.field,
42            c.relation,
43            c.alias,
44            c.owner,
45            c.sql_type,
46            c.sub_type,
47            c.scale,
48            c.length
49        );
50    }
51
52    stmt.drop_statement(&mut conn)?;
53    tx.commit(&mut conn)?;
54    conn.close()?;
55    Ok(())
56}
Source

pub fn connect_timeout(self, t: Duration) -> Self

Define o tempo máximo para abrir o socket TCP e completar o handshake.

Source

pub fn page_size(self, size: i32) -> Self

Define o tamanho de página ao criar um banco novo com crate::Connection::create_database.

Source

pub fn timezone(self, tz: impl Into<String>) -> Self

Define o fuso horário da sessão, por exemplo America/Sao_Paulo.

Source

pub fn parallel_workers(self, n: i32) -> Self

Define o número de workers paralelos solicitado ao servidor Firebird 5.

Source

pub fn native_data_types(self, on: bool) -> Self

Pede os tipos nativos (INT128/DECFLOAT/WITH TIME ZONE) após o attach. Veja ConnectConfig::native_data_types.

Trait Implementations§

Source§

impl Clone for ConnectConfig

Source§

fn clone(&self) -> ConnectConfig

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ConnectConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for ConnectConfig

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V