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: StringNome ou IP do servidor Firebird.
port: u16Porta TCP do servidor Firebird. O padrão do Firebird é 3050.
database: StringCaminho ou alias do banco de dados no servidor (ex.: employee ou /data/db.fdb).
user: StringNome do usuário Firebird.
password: StringSenha do usuário Firebird.
role: Option<String>Papel SQL opcional usado na conexão (ROLE).
charset: StringCharset da conexão (padrão UTF8).
dialect: i32Dialeto SQL (padrão 3).
wire_crypt: WireCryptPolí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: boolQuando 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
impl ConnectConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Começa a partir dos padrões (localhost:3050, usuário SYSDBA, UTF8, dialeto 3).
Examples found in repository?
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}Sourcepub fn host(self, host: impl Into<String>) -> Self
pub fn host(self, host: impl Into<String>) -> Self
Define o host ou IP do servidor Firebird.
Examples found in repository?
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}Sourcepub fn port(self, port: u16) -> Self
pub fn port(self, port: u16) -> Self
Define a porta TCP do servidor Firebird.
Examples found in repository?
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}Sourcepub fn database(self, db: impl Into<String>) -> Self
pub fn database(self, db: impl Into<String>) -> Self
Define o banco por alias ou caminho no servidor.
Examples found in repository?
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}Sourcepub fn user(self, user: impl Into<String>) -> Self
pub fn user(self, user: impl Into<String>) -> Self
Define o usuário Firebird.
Examples found in repository?
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}Sourcepub fn password(self, password: impl Into<String>) -> Self
pub fn password(self, password: impl Into<String>) -> Self
Define a senha do usuário Firebird.
Examples found in repository?
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}Sourcepub fn role(self, role: impl Into<String>) -> Self
pub fn role(self, role: impl Into<String>) -> Self
Define o papel SQL (ROLE) usado após o login.
Sourcepub fn charset(self, charset: impl Into<String>) -> Self
pub fn charset(self, charset: impl Into<String>) -> Self
Define o charset da conexão, como UTF8, WIN1252 ou ISO8859_1.
Sourcepub fn wire_crypt(self, wc: WireCrypt) -> Self
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?
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}Sourcepub fn connect_timeout(self, t: Duration) -> Self
pub fn connect_timeout(self, t: Duration) -> Self
Define o tempo máximo para abrir o socket TCP e completar o handshake.
Sourcepub fn page_size(self, size: i32) -> Self
pub fn page_size(self, size: i32) -> Self
Define o tamanho de página ao criar um banco novo com crate::Connection::create_database.
Sourcepub fn timezone(self, tz: impl Into<String>) -> Self
pub fn timezone(self, tz: impl Into<String>) -> Self
Define o fuso horário da sessão, por exemplo America/Sao_Paulo.
Sourcepub fn parallel_workers(self, n: i32) -> Self
pub fn parallel_workers(self, n: i32) -> Self
Define o número de workers paralelos solicitado ao servidor Firebird 5.
Sourcepub fn native_data_types(self, on: bool) -> Self
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
impl Clone for ConnectConfig
Source§fn clone(&self) -> ConnectConfig
fn clone(&self) -> ConnectConfig
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more