Skip to main content

26 posts tagged with "rust"

View All Tags

How Rust Trait Works Internally

· 4 min read
forfd8960
Author

Rust's traits are a powerful feature that enables polymorphism and code reuse. Internally, traits are implemented using a combination of static dispatch (monomorphization) and dynamic dispatch (vtable) mechanisms, depending on how they are used. Here's a detailed breakdown of how traits work internally:

Compare Rust and Golang Programming

· 11 min read
forfd8960
Author

In this blog, I will share the programming difference between Rust and Golang, Include:

  • How they use different syntax to declare data type.
  • How rust and golang define the common behavior(interface vs trait).
  • How rust and golang struct to implement the common behavior.
  • What's the difference between rust and golang about Error Handling.
  • How they define complex data type(struct).
  • How they define enum.
  • How they Obtaining and using third-party libraries.
  • What's the difference between rust and golang when write unit test.
  • What's the difference between rust and golang about async programming.

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"