pub trait GXExt:
Default
+ Debug
+ Send
+ Sync
+ 'static {
type UserEvent: UserEvent + Send + Sync + 'static;
// Required methods
fn update_sources(&mut self) -> impl Future<Output = Result<()>> + Send;
fn do_cycle(&mut self, event: &mut Event<Self::UserEvent>) -> Result<()>;
fn is_ready(&self) -> bool;
fn clear(&mut self);
fn empty_event(&mut self) -> Self::UserEvent;
}Expand description
Trait to extend the event loop
The Graphix event loop has two steps,
- update event sources, polls external async event sources like netidx, sockets, files, etc
- do cycle, collects all the events and delivers them to the dataflow graph as a batch of “everything that happened”
As such to extend the event loop you must implement two things. A function to poll your own external event sources, and a function to take the events you got from those sources and represent them to the dataflow graph. You represent them either by setting generic variables (bindid -> value map), or by setting some custom structures that you define as part of your UserEvent implementation.
Your Graphix builtins can access both your custom structure, to register new
event sources, etc, and your custom user event structure, to receive events
who’s types do not fit nicely as Value. If your event payload does fit
nicely as a Value, then just use a variable.
Required Associated Types§
Required Methods§
Sourcefn update_sources(&mut self) -> impl Future<Output = Result<()>> + Send
fn update_sources(&mut self) -> impl Future<Output = Result<()>> + Send
Update your custom event sources
Your update_sources MUST be cancel safe.
Sourcefn do_cycle(&mut self, event: &mut Event<Self::UserEvent>) -> Result<()>
fn do_cycle(&mut self, event: &mut Event<Self::UserEvent>) -> Result<()>
Collect events that happened and marshal them into the event structure
for delivery to the dataflow graph. do_cycle will be called, and a
batch of events delivered to the graph until is_ready returns false.
It is possible that a call to update_sources will result in
multiple calls to do_cycle, but it is not guaranteed that
update_sources will not be called again before is_ready
returns false.
Sourcefn empty_event(&mut self) -> Self::UserEvent
fn empty_event(&mut self) -> Self::UserEvent
Create and return an empty custom event structure
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.