Skip to main content

Rust Implement Tonic Stream Endpoint

· 5 min read
forfd8960
Author

Today want share how to implement a stream endpoint in Rust using the Tonic framework.

the dependency

[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"

Rust Generate SHA1 Hash

· One min read
forfd8960
Author

the crate

[dependencies]
sha1-checked = "0.10.0"
base16ct = { version="0.2.0", features=["alloc"] }

Generate SHA1 Hash bytes

  • build sha1 hasher with Sha1::new()
  • update the hasher with hasher.update(content)
  • call hasher.try_finalize() to get the hash
  • generate hash bytes with
let arr = hf.hash();
arr.to_vec()

How Git Works

· 14 min read
forfd8960
Author

The internals want to know about Git

We as developers often use git to manage our code. But do you know how git works?

And as a Curious developer, I want to know how git works.

Some questions I want to know are:

  • How git stores the data(the code, the image etc)
  • What happens when run git add
  • How does git knowns which file is untracked.
  • Where does the data is been stored.
  • How git store the commit when you run git commit -m "message"
  • How git restore the repo when checkout to another branch.

Implement Git with Rust Part0

· 5 min read
forfd8960
Author

What is Git

We use git to manage our code, and do version control.

  • generally, I use git init or git clone to start a project locally.
  • And do some work in the git repo.
  • And then use git add to add the files to the staging area.
  • And then use git commit to commit the changes to the local repository.
  • And then use git push to push the files to the remote repository.
  • And then use git pull origin master to pull the changes from the remote repository.
  • use git checkout -b <new_branch> to create and checkout to a new branch.
  • use git rebase master to rebase changes from master to the current branch.

Rust Json Parser

· 6 min read
forfd8960
Author

What is Json

What is Json

JSON (JavaScript Object Notation) is a lightweight data-interchange format. It is easy for humans to read and write. It is easy for machines to parse and generate. It is based on a subset of the JavaScript Programming Language Standard ECMA-262 3rd Edition - December 1999.