I pass a state object as self to an async fn handler(mut self, ...) function. As one of self's fields I want to have an log: Arc<TcpStream> so that I can log.write(json_msg) to a tcp connected logging service. Invariably, I encounter the error:
the trait `serde::Serialize` is not implemented for `std::net::TcpStream`
I assume there is an idiomatic way of doing this or should I impl De-Serializer for the TcpStream?
I want the TcpStream created before entering the async fn. In the async fn I only want to call the write(...) as method of a stream object in one of self's fields. The problem therefore is how to move a TcpStream field of an object into an async fc?
SOLVED: Easy (...in the end...): removed serde serialization from the selfstruct. As a singleton it didn't need any so serde was putting unnecessary constraints on the fields (among which the TcpStream).