Zooming in on Observability with Rust and eBPF
https://blog.redsift.com/labs/zooming-in-on-observability/
网络安全大神Peter Parkanyi用Rust程序和eBPF来"窥探"Zoom程序的内容。最近Zoom因为新冠病毒而大火一把,而且又因为美国政府担心Zoom的服务器绕中国一圈再回到美国引发安全顾虑又大火一把。这个博文值得关注。
Lambda
服务的简易webappA sample webapp project which deploys on AWS Lambda
https://github.com/bachrc/rust-aws-lambda
一个可以部署AWSLambda
服务的简易webapp。因为得到SilentByte
的启发:https://silentbyte.com/writing-aws-lambda-functions-in-rust
Notes on Parsing in Rust
https://blog.wesleyac.com/posts/rust-parsing
学习笔记:用Rust来写编译程序。
slip 0.1.0: protect your error strings against reverse-engineering
https://hub.docker.com/r/michaelfbryan/mdbook-docker-image
slip 0.1.0: 保护你程序的错误代码字符串被逆向工程获取。
安装:
cargo install --path unslip
使用,直接产生秘密字符串:
unslip key
系统环境变量设置:
#### Linux$ export SLIP_KEY= #### Windows$ set SLIP_KEY=
Type-level Rust编程
Type-level Programming in Rust
http://willcrichton.net/notes/type-level-programming/
Type-level Rust编程。英文的学习笔记,大家自己欣赏哈~
Github Actions to build Rust Binaries Automatically
https://github.com/zackify/flydb/blob/master/.github/workflows/build-binary.yml
Github自动编译Rust二进制代码的配置文件的一个例子:
name: Build Binarieson: release: types: # This configuration does not affect the page_build event above - createdjobs: build_for_mac: name: MacOS runs-on: macos-10.15 steps: - uses: actions/checkout@master - uses: actions-rs/cargo@v1 with: command: build args: --release - name: Rename binary run: mv target/release/flydb flydb-macos64 - name: Upload to release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} run: | curl \ -f \ -sSL \ -XPOST \ -H "Authorization: token $GITHUB_TOKEN" \ -H "Content-Length: $(stat -f%z flydb-macos64)" \ -H "Content-Type: application/octet-stream" \ --upload-file "flydb-macos64" \ "https://uploads.github.com/repos/$GITHUB_REPOSITORY/releases/$(jq --raw-output '.release.id' $GITHUB_EVENT_PATH)/assets?name=flydb-macos64" build_for_pi: name: Raspberry Pi runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable target: armv7-unknown-linux-gnueabihf override: true - uses: actions-rs/cargo@v1 with: use-cross: true command: build args: --release --target armv7-unknown-linux-gnueabihf - name: Rename binary run: mv target/armv7-unknown-linux-gnueabihf/release/flydb flydb-armv7-pi - name: Upload to release uses: JasonEtco/upload-to-release@d648f1babf776de9cad881320bd9e9818fc3b262 with: args: flydb-armv7-pi application/octet-stream env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_for_android: name: Android runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master - uses: actions-rs/toolchain@v1 with: toolchain: stable target: aarch64-linux-android override: true - uses: actions-rs/cargo@v1 with: use-cross: true command: build args: --release --target aarch64-linux-android - name: Rename binary run: mv target/aarch64-linux-android/release/flydb flydb-linux-android - name: Upload to release uses: JasonEtco/upload-to-release@d648f1babf776de9cad881320bd9e9818fc3b262 with: args: flydb-linux-android application/octet-stream env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} build_for_linux: name: Linux runs-on: ubuntu-18.04 steps: - uses: actions/checkout@master - uses: actions-rs/cargo@v1 with: command: build args: --release - name: Rename binary run: mv target/release/flydb flydb-linux-amd64 - name: Upload to release uses: JasonEtco/upload-to-release@d648f1babf776de9cad881320bd9e9818fc3b262 with: args: flydb-linux-amd64 application/octet-stream env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
rust语言学习笔记:理解structs
Understanding rust lang - structs notes
https://www.staszewski.me/rust-struct-notes/
波兰小伙子Kamil Staszewski
的Rust语言学习笔记。
什么是struct
:
struct
可以让我们创建有内容的数据结构,struct
数据结构的写法有点类似Typescript
语言中的interface
接口, 当然很多别的编程语言的接口的实现也很类似:
struct Player {
name: String,
health: u32,
mana: u32,
}
要实现一个struct
我们就要给它创建一个实例,我们依照它的定义用K/V方式给它赋值:
let player1 = Player {
name: String::from("Kamil"),
health: 100,
mana: 100,
};
至此,我们还不能直接用println!
宏来打印出来,否则会遇到Player doesn't implement std::fmt::Display: Player cannot be formatted with the default formatte
这样的错误。因为这里struct
还没有实现它的trait
,这就需要我们参照官方文档自己来实现一个。我们可以加这样的注释#[derive(Debug)]
也可以用缺省的格式:?
,或者在println!
宏里面用花括号来表示缺省格式。然后我们可以试一试:
#[derive(Debug)] // annotationstruct Player { name: String, health: u32, mana: u32,}
let player1 = Player { name: String::from("Kamil"), health: 100, mana: 100,};
println!("Players data {:?}, player1);
怎么更新数据:
let player1 = Player { name: String::from("Kamil"), health: 100, mana: 100,};
let player2 = Player { name: String::from("Gustav"), ..player1}; // player2 has the same health and mana values as player1
也可以直接给实例的某个键赋值,不过要记得加上mut
关键字保证数据结构的实例可以更改:
let mut player1 = Player { name: String::from("Kamil"), health: 100, mana: 100,};
player1.name = String::from("Some other name");
给数据结构struct
添加函数(方法):
rust语言添加函数非常方便,首先它又一个可以自引用的语法&self
,这个跟JS的this
和Python的self
非常类似。 我们必须用impl
关键字并加上数据结构的名字来'实现'实例,记住我们在函数内部用&self
来应用数据机构本身:
struct Player { name: String, health: u32, mana: u32,}
impl Player { fn multiply_by(&self, n: u32) -> u32 { self.health * n }}
let player1 = Player { name: String::from("Kamil"), health: 100, mana: 100,};
println!("Players multipied health {:?}", player1.multiply_by(3));
作者的GitHub:https://www.github.com/staszewski
From 日报小组 BobQ