DEV Community

Vee Satayamas
Vee Satayamas

Posted on

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.

Oldest comments (0)