I have a complex async function:
impl Session {
async fn handle_connection(self) -> Result<Whatever> { ... }
}
This function is doing a lot of nested async calls and captures quite a lot of state.
I can invoke it and measure the size of the returned Future with std::mem::size_of_val
.
However, for that I need to construct a Session
value and the future.
Is there a way of computing the size of the returned Future without invoking the method?
I mean - sth like std::mem::size_of::<the return type of Session::handle_connection>()
?
I need to put the computed value into the Session field itself, so the session knows how much memory it uses. So I've got a chicken-and-egg problem here if the only way to compute the size is to create a Session first.