Struct EventBatch

Source
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<'_>

Source

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.

Source

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

Trait Implementations§

Source§

impl<'a> Debug for EventBatch<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for EventBatch<'a>

§

impl<'a> !RefUnwindSafe for EventBatch<'a>

§

impl<'a> !Send for EventBatch<'a>

§

impl<'a> !Sync for EventBatch<'a>

§

impl<'a> Unpin for EventBatch<'a>

§

impl<'a> !UnwindSafe for EventBatch<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.