You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
However when trying to use a LocalActorRef<StorageActor> I get
size for values of type `(dyn StorageActor + 'static)` cannot be known at compilation time
the trait `Sized` is not implemented for `(dyn StorageActor + 'static)`
I'm still fairly new to rust, and after reading https://huonw.github.io/blog/2015/01/object-safety/ I still don't fully understand what the specific blocker is. - could it be in the Actor trait fn actor_ref(&self, ctx: &ActorContext) -> LocalActorRef<Self> which seems to match up to the link under References Self - There’s two fundamental ways in which this can happen, as an argument or as a return value
Cheers
Cameron
The text was updated successfully, but these errors were encountered:
It's not currently possible to use a trait object in place of an Actor type for LocalActorRefs, there is too much reliance on using the type directly, with requirements for it to be Sized. I do think it's possible to remove this limitation in the future, but will require a little more thought.
As a workaround, you could potentially create a Storage trait, which has async read and write methods, and implementations of it calling some underlying LocalActorRef respectively - this is a pattern that I've used myself in Coerce, when writing the actor persistence storage system with support for multiple backends: https://github.com/LeonHartley/Coerce-rs/blob/master/coerce/src/persistent/journal/storage.rs#L14
I would like to define a custom actor trait like the following :
However when trying to use a
LocalActorRef<StorageActor>
I getI'm still fairly new to rust, and after reading https://huonw.github.io/blog/2015/01/object-safety/ I still don't fully understand what the specific blocker is. - could it be in the Actor trait
fn actor_ref(&self, ctx: &ActorContext) -> LocalActorRef<Self>
which seems to match up to the link underReferences Self - There’s two fundamental ways in which this can happen, as an argument or as a return value
Cheers
Cameron
The text was updated successfully, but these errors were encountered: