How to Do Database Query with SQLX in Rust
· 13 min read
In the Axum web development with Rust, need to implement generate a safe password hash.
In this blog, I will introduce how to generate it with Rust
Argon2
.
JWT, or JSON Web Token, is a compact and self-contained way of securely transmitting information between parties as a JSON object.
Today want share how to implement a stream endpoint in Rust using the Tonic framework.
[dependencies]
anyhow = "1.0.82"
chrono = { version = "0.4.38", features = ["serde"] }
derive_builder = "0.20.0"
futures = "0.3.30"
prost = "0.12.4"
prost-types = "0.12.4"
tokio = { version = "1.40.0", features = ["rt", "rt-multi-thread", "macros"] }
tokio-stream = "0.1.15"
tonic = { version = "0.11.0", features = ["zstd", "tls"] }
tonic-build = "0.11.0"
uuid = { version = "1.10.0", features=["v4"]}
fake = { version="2.9.2", features=["derive", "chrono"]}
tracing = "0.1.40"
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
[build-dependencies]
anyhow = "1.0.82"
tonic-build = "0.11.0"
Let's build a Simple RPC Service with Tonic: Social
, and it's only have greet endpoint to welcome the user.
[dependencies]
anyhow = "1.0.82"
prost = "0.12.4"
prost-types = "0.12.4"
tonic = { version = "0.11.0", features = ["zstd", "tls"] }
[build-dependencies]
anyhow = "1.0.82"
tonic-build = "0.11.0"
CREATE TYPE gender AS ENUM('female', 'male', 'unknown');
CREATE TABLE user_info(
email varchar(128) NOT NULL PRIMARY KEY,
name varchar(64) NOT NULL,
gender gender DEFAULT 'unknown',
);
[dependencies]
sha1-checked = "0.10.0"
base16ct = { version="0.2.0", features=["alloc"] }
Sha1::new()
hasher.update(content)
hasher.try_finalize()
to get the hashlet arr = hf.hash();
arr.to_vec()
#[derive(Debug, Subcommand)]
pub enum GitSubCommand {
#[command(name = "init", about = "init a git repo")]
Init(InitOpts),
#[command(name = "add", about = "add files into index")]
Add(AddOpts),
}