Given this example from the tokio-serde docs:
How do I find where the highlighted
.send method is coming from?
serialized is a SymmetricallyFramed (docs.rs/tokio-serde/latest/tokio_serde/type.SymmetricallyFramed.html)
- which is an type definition for Framed (docs.rs/tokio-serde/latest/tokio_serde/struct.Framed.html)
- which doesn't seem to have a 'send' method (tokio_serde::Framed - Rust)
- and doesn't seem to have a 'send' method in its implemented traits (docs.rs/tokio-serde/latest/tokio_serde/struct.Framed.html#trait-implementations)
I guess I'm missing something basic or slightly less basic. I've written a small amount of Rust but have limited experience with in-depth libraries and navigating around these things.
Thanks in advance! Sorry I can only put two links in a post as a new member.
Yeah, this is an annoying example.
send method comes from the
futures-util crate, in the
SinkExt trait. I am guessing it is re-exported in the
futures crate's prelude. There is a implementation of
SinkExt for any type that implements
Such transitive impls don't show up in docs. I dug it up with rust-analyzer.
Well, I feel like less of an idiot now I will try to get more information through rust analyzer in future.
Check it out with the following steps:
Framed implements futures_sink::Sink trait
futures_util crate reexports the
futures_sink::Sink trait in
futures_util::sink mod and defines a subtrait
SinkExt as well as a blanket impl to have all types implemented with
Sink also implements
futures crate reexports
futures::prelude which is imported by the end user
tokio-serde only needs
futures_sink::Sink trait for
Framed, and the user can gain extra functionality (like
send method) from
SinkExt trait through
Foreign traits are only usable if they are explicitly imported, so if you can't find the method in the inherent impl, look at the crates/traits imported by the current module.