Closed iamjpotts closed 1 year ago
This pr interestingly surfaced another issue related to HttpConnector
/ HttpsConnector
by the CI, which has been resolved by putting struct HyperBackend
inside the macro rule.
I think this looks fine, just one small question I had! Thank you!
The other examples unwrap or otherwise deal with an
Err
result in theirmain
function.This one defines its own error enumeration, with
ipfs_api::Error
as one of the possibilities, and shows how to make that work with rust's?
automatic error conversion, in two scenarios.Scenario 1, where the function has an
IpfsClient
variable.Scenario 2, where the function accepts a parameter that implements the
IpfsApi
type. In this scenario, the generic must be constrained to use the implementation's error type - that is, the type onBackend::Error
- otherwise the compiler will complain that it doesn't know whatBackend<A>::Error
is.It may seem that this should be obvious looking at this example, but the IDE could not resolve any methods of an
IpfsClient
variable, which lead to using an&IpfsApi
instead. However, without further constrainingIpfsApi::Error
(which isBackend::Error
), it was confusing to figure out how to do it.