This is going to be a part of a library and I want people to be able to impl that trait for themselves on their own structs. But I don't want them to be able to change the propagate_update method at all, so it would be public for my crate, but not for theirs. Is that possible in Rust ? Or should I change something ?
This will not compile as self.update doesn't exist in the Propagator trait, it needs to be a subtrait of Component to do so. The blanket implementation impl<T> Prop for T where T: Componentis also useful to automatically implement Propagator on types implementing Component
Oh yes, true thank you. When you say, it automatically is implemented on types that implement Component, can I still override it for some specific types (that propagate_update method needs to be different for a NodeComponent struct) ?
Not without enabling the specialization nightly feature. Unfortunately, the theoretical model hasn't been fully worked out yet, so you'd probably be stuck using the nightly compiler for quite a while.
If you want to have a trait that can only have implementations provided by your crate, you can use privacy annotations to seal it.
Because the whole point of this thing, is that I can implement whatever I want for this method, but other people can't.
This should be the method for the standard Component