DEV Community

Vee Satayamas
Vee Satayamas

Posted on

1 1

A little modification of Actix with a large afford

I want to print a log of unparsed #websocket frames used by #awc 2.0.3. If I used Emacs, I'd only add one line of code. However, using Rust and Actix is not that strangeforward. Besides recompilation, I needed to change Cargo.toml to use local crates. For example, in #awc's Cargo.toml, I changed:

actix-codec = "0.3.0" 
Enter fullscreen mode Exit fullscreen mode

to

actix-codec = { path = "../../actix-net/actix-codec" }
Enter fullscreen mode Exit fullscreen mode

However, after I recompiled the app, this change caused compilation errors because other crates still use different versions of actix-codec. So I changed all affected crates. I ended up modifying six crates as shown in the figure below.

Dependencies between awc and actix-codec

Moreover, rustc 1.54.0 does not accept this code below:

pub fn as_error<T: ResponseError + 'static>(&self) -> Option<&T> { 
      ResponseError::downcast_ref(self.cause.as_ref()) 
}
Enter fullscreen mode Exit fullscreen mode

I presume that a previous version of rustc can. I tried to fix by adding "dyn" as the compiler suggested but it didn't work. So I deleted these three lines. Then rustc 1.54.0 can compile my app and Actix again.

I took too much afford for doing all of these just for printing a little more log. So I wrote this blog out. Maybe I did this in the wrong way. So please suggest to me more proper ways. Or in the worst case, I can read this blog when I forget how did this.

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up