pub struct EventBatch<'a> { /* private fields */ }
Expand description
§An object that describes a batch of events
This is only available by reference, not by ownership, since the data needs to outlive the plugin API call and is stored elsewhere (in a wrapper struct that’s not exposed to plugin developers)
Implementations§
Source§impl EventBatch<'_>
impl EventBatch<'_>
Sourcepub fn add(&mut self, event: impl EventToBytes) -> Result<()>
pub fn add(&mut self, event: impl EventToBytes) -> Result<()>
§Add an event to a batch
The event can be any type, but please note that the framework may have different
opinions on this. For example, only source plugins with the syscall
source can generate
events other than source::PluginEvent
Note: to generate such events, you may use
the source::SourcePluginInstance::plugin_event
helper method.
Sourcepub fn reserve(&mut self, num_events: usize)
pub fn reserve(&mut self, num_events: usize)
§Reserve space for a specific number of events
If your plugin knows it’s going to generate a specific number of events in a particular batch, it can call this method to preallocate some space and save a bit of overhead.
The passed value is only a hint, the actual batch can be smaller or larger than the reserved size, but that mostly defeats the purpose of reserving space