// find all models
let cakes: Vec<cake::Model> = Cake::find().all(db).await?;
// find and filter
let chocolate: Vec<cake::Model> = Cake::find()
.filter(cake::Column::Name.contains("chocolate"))
.all(db)
.await?;
// find one model
let cheese: Option<cake::Model> = Cake::find_by_id(1).one(db).await?;
let cheese: cake::Model = cheese.unwrap();
// find related models (lazy)
let fruits: Vec<fruit::Model> = cheese.find_related(Fruit).all(db).await?;
// find related models (eager)
let cake_with_fruits: Vec<(cake::Model, Vec<fruit::Model>)> =
Cake::find().find_with_related(Fruit).all(db).await?;
Entity 的 find*、insert、update、delete 方法,可以直观的进行基本的 CRUD 操作。Select、Insert、Update 和 Delete 结构,它们每个都有自己的 API 用于更高级的操作。SelectStatement、InsertStatement、UpdateStatement 和 DeleteStatement,它们有丰富的 API 供您处理 SQL 语法树。Selector、Inserter、Updater 和 Deleter,负责针对数据库连接执行语句。use aes::Aes128;
use block_modes::{BlockMode, Cbc};
use block_modes::block_padding::Pkcs7;
use hex_literal::hex;
// create an alias for convenience
type Aes128Cbc = Cbc<Aes128, Pkcs7>;
let key = hex!("000102030405060708090a0b0c0d0e0f");
let iv = hex!("f0f1f2f3f4f5f6f7f8f9fafbfcfdfeff");
let plaintext = b"Hello world!";
let cipher = Aes128Cbc::new_from_slices(&key, &iv).unwrap();
// buffer must have enough space for message+padding
let mut buffer = [0u8; 32];
// copy message to the buffer
let pos = plaintext.len();
buffer[..pos].copy_from_slice(plaintext);
let ciphertext = cipher.encrypt(&mut buffer, pos).unwrap();
assert_eq!(ciphertext, hex!("1b7a4c403124ae2fb52bedc534d82fa8"));
// re-create cipher mode instance and decrypt the message
let cipher = Aes128Cbc::new_from_slices(&key, &iv).unwrap();
let mut buf = ciphertext.to_vec();
let decrypted_ciphertext = cipher.decrypt(&mut buf).unwrap();
assert_eq!(decrypted_ciphertext, plaintext);

图片地址:https://img.gejiba.com/image/zqi53
config file :
---
dest: ~/Documents
dirs:
- ~/Documents-source
once: false
timeinfo: false
static_mode: false
sleep: 1000
codes:
hst: History
cnt: Century
cs: Computer Science
en: English
chin: Chinese
mt: Mathematics
sp: Sports
phy: Physics
ch: Chemestry
glb: Global
gr: Greek
fr: French
asg: Assignments
Before :
~/Documents-source/hst/<fr> <hst>.18th <cnt>.Consulate.pdf
~/Documents-source/Computer/cs.algorithms and data structures.dvi
~/Documents-source/very/deep/meaning/gr.statues weren't white.mp4
~/Documents-source/such/nested/asg.mt.integration.tex
~/Documents-source/chin.Great Wall.odt
After :
~/Documents/French History/18th Century/Consulate.pdf
~/Documents/Computer Science/algorithms and data structures.dvi
~/Documents/Greek/statues weren't white.mp4
~/Documents/Assignments/Mathematics/integration.tex
~/Documents/Chinese/Great Wall.odt
x86_64-unknown-none 目标。一些功能包括:use simple_undo::Undo;
let mut message = Undo::new(String::new());
message.update(|text| text.push_str("Simple ")); // 步骤1
message.update(|text| text.push_str("undo !")); // 步骤2
assert_eq!(*message, "Simple undo !");
message.undo(); // "Simple " 撤销步骤2
message.undo(); // "" 撤销步骤1
message.redo(); // "Simple " 再执行步骤1
message.update(|text| text.push_str("redo !"));
assert_eq!(*message, "Simple redo !");
let result: String = message.unwrap();
assert_eq!(result, "Simple redo !");
mongodb 性能的经验:Making slow Rust code fast | patrickfreed's blogFrom 日报小组 长琴
原文作者:Rust语言中文社区;如有侵权,请联系管理员删除。