2020-12-12から1日間の記事一覧

Rust Disel DBのデフォルト値を使いつつ、model bindと共存する

fetch処理前提 例えば、select * from ...と全カラム取得する場合、bindするmodelの定義は #[derive(Debug, Clone, Queryable, Identifiable)] pub struct Account { pub id: String, pub name: String, pub email: String, pub password: String, pub avata…

Rust validatorを導入する

actix-webにvalidation処理を導入したので記録しておきます。 使用したcrateはこちら。 GitHub - Keats/validator: Simple validation for Rust structs Cargo.toml validator = { version = "0.12", features = ["derive"] } deriveを指定することでstruct…

Rust UUIDとパスワードハッシュを生成する

UUIDの生成 uuid crateを使用します。 uuid - Rust Cargo.toml uuid = { version = "0.8.1", features = ["serde", "v4"] } 生成処理のサンプル use uuid::Uuid; let uuid = Uuid::new_v4().to_hyphenated().to_string(); パスワードハッシング アルゴリズム…