Trait hotg_rune_cli::run::multi::SourceBackedCapability [−][src]
pub trait SourceBackedCapability: Send + Debug + Sized + 'static {
type Source: Debug + Send + Sync + 'static;
type Builder: Builder + Debug + Send + Sync + 'static;
fn generate(&mut self, buffer: &mut [u8]) -> Result<usize, Error>;
fn from_builder(
builder: Self::Builder,
source: &Self::Source
) -> Result<Self, Error>;
}
Expand description
A Capability
which can be created by from some source object and a
Builder
.
Note
This exists because of the way capabilities were initially designed and switching to an improved API would break every Rune that has been compiled (which I’m okay with because we have version numbers) as well as the C++ runtime (which I’m not okay with because un-breaking it requires a lot of work).
The process for setting up a capability is very similar to what you’d do in an OO language.
- Create a new instance of the object in an incomplete state
- Go through each of the fields and set them
- Use the object to generate data