pub async fn write_msg<W: AsyncWriteExt + Unpin>( writer: &mut W, msg: &impl Serialize, ) -> Result<()>