tsubakuro-rust-core

Crates.iotsubakuro-rust-core
lib.rstsubakuro-rust-core
version0.5.0
created_at2025-03-13 06:09:56.180031+00
updated_at2025-09-25 00:51:00.225921+00
descriptioncore library to access Tsurugi for Rust
homepagehttps://github.com/project-tsurugi/tsubakuro-rust/tree/master/tsubakuro-rust-core
repositoryhttps://github.com/project-tsurugi/tsubakuro-rust/tree/master/tsubakuro-rust-core
max_upload_size
id1590526
size657,373
tsurugidb-maintainers (github:project-tsurugi:tsurugidb-maintainers)

documentation

https://docs.rs/tsubakuro_rust_core/

README

tsubakuro-rust-core

tsubakuro-rust-core is the core library to access Tsurugi for Rust.

tsubakuro-rust-core is a port from Tsubakuro/Java, but it does not cover all functions.

Target

  • Tsurugi 1.6.0 or later.

Limitations

  • Provide SQL service only.
  • Only TCP connection is available.

Crate features

Default feature include the following features.

  • with_bigdecimal - Enable decimal via bigdecimal.
  • with_rust_decimal - Enable decimal via rust_decimal.
  • with_chrono - Enable date/time via chrono.
  • with_time - Enable date/time via time.

Rust version requirements

The Minimum Supported Rust Version (MSRV) is currently Rust 1.84.1.

How to use

Add tsubakuro-rust-core as a dependency to your Cargo.toml file:

[dependencies]
tsubakuro-rust-core = "0.5.0"

Example

connect example

use std::time::Duration;
use log::warn;
use tsubakuro_rust_core::prelude::*;

async fn example() -> Result<(), TgError> {
    let endpoint = Endpoint::parse("tcp://localhost:12345")?;

    let mut connection_option = ConnectionOption::new();
    connection_option.set_endpoint(endpoint);
    connection_option.set_application_name("Tsubakuro/Rust example");
    connection_option.set_session_label("example session");
    connection_option.set_default_timeout(Duration::from_secs(10));

    // connect
    let session = Session::connect(&connection_option).await?;

    // make SqlClient
    let client: SqlClient = session.make_client();

    // execute SQL
    let result = example_transaction(&client).await;

    // session close
    if let Err(e) = session.close().await {
        warn!("session close error. {}", e);
    }

    result
}

See example.rs for more examples.

How to build

Need protoc command since used prost.
(For example, to install protoc on Ubuntu 22.04, execute apt install protobuf-compiler)

If proto files in tsubakuro-proto has been modified, copy from there.

cd tsubakuro-rust-core
cp -rp /path/to/tsubakuro/modules/proto/src/main/protos .

Then build with cargo.

cd tsubakuro-rust-core
cargo build

How to test

cd tsubakuro-rust-core
cargo test

See also tsubakuro-rust-dbtest.

License

Apache License, Version 2.0

Commit count: 408

cargo fmt