Make trait ChainHandle object-safe & clonable #447
Labels
I: logic
Internal: related to the relaying logic
O: new-feature
Objective: cause to add a new feature or support
Milestone
Crate
relayer
Summary & problem definition
The
ChainHandle
trait is currently clonable thanks to its bound onClone
, which impliesSized
, which in turn makes theChainHandle
non-object-safe.https://github.com/informalsystems/ibc-rs/blob/65e4f268efc176d861d30949dc7bde049e0b3bb5/relayer/src/chain/handle.rs#L177
This means that we cannot make objects out of the
ChainHandle
trait. So the compiler will forbid something of the kind:The precise error is as follows:
See more details on object safety here:
https://rust-lang.github.io/rfcs/0255-object-safety.html#detailed-design
Proposal
At @romac's suggestion, we can replace the
Clone
bound withDynClone
instead, and obtain object safety. https://github.com/kardeiz/objekt-clonable may also be an option. Then we can do this:Alternative solutions include splitting the handle trait into the handle proper + a constructor, or adding specific
where
clauses cf. this. But theDynClone
method seems the most robust and simple.For Admin Use
The text was updated successfully, but these errors were encountered: