no method named `map_err` found for type `async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _>` in the current scope
--> hyxe_user\src\client_account.rs:57:22
|
57 | .map_err(|err| AccountError::IoError(err.to_string()))
| ^^^^^^^
|
= note: the method `map_err` exists but the following trait bounds were not satisfied:
`&async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
`&mut async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
`async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
the trait bound `impl core::future::future::Future: std::io::Write` is not satisfied
--> hyxe_user\src\client_account.rs:53:9
|
53 | async_bincode::serialize_into(async_std::fs::File::open(location), self.inner.deref())
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::io::Write` is not implemented for `impl core::future::future::Future`
|
= note: required by `async_bincode::serialize_into`
Thank for your reply. This is the new compiler-output:
error[E0599]: no method named `map_err` found for type `async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _>` in the current scope
--> hyxe_user\src\client_account.rs:61:22
|
61 | .map_err(|err| AccountError::IoError(err.to_string()))
| ^^^^^^^
|
= note: the method `map_err` exists but the following trait bounds were not satisfied:
`&async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
`&async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_stream::TryStreamExt`
`&mut async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
`&mut async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_stream::TryStreamExt`
`async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_future::TryFutureExt`
`async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _> : futures_util::try_stream::TryStreamExt`
Looks like it's getting closer. It doesn't appear that AsyncBincodeReader is auto-converting to the type representing Self?
error[E0271]: type mismatch resolving `<impl core::future::future::Future as core::future::future::Future>::Output == std::result::Result<client_account::ClientNetworkAccount<'static>, misc::AccountError<std::string::String>>`
--> hyxe_user\src\client_account.rs:56:48
|
56 | pub async fn load(self, location: &str) -> Result<Self, AccountError<String>> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected struct `async_bincode::reader::AsyncBincodeReader`, found struct `client_account::ClientNetworkAccount`
|
= note: expected type `std::result::Result<async_bincode::reader::AsyncBincodeReader<async_std::io::buf_reader::BufReader<async_std::fs::file::File>, _>, _>`
found type `std::result::Result<client_account::ClientNetworkAccount<'static>, _>`
= note: the return type of a function must have a statically known size
Since there is no await inside this function body, this is syntax sugar for a future that immediately returns the value in the body. Therefore it turns into this:
The problem here is that the body of this function is something of the kind Future<Item=Future<Item=Result<Self, AccountError<String>>>>. There is an extra future here.
The same problem appears in your async block inside the and_then.
You should not return futures from async functions or blocks, instead you should await them and return the result.