pub struct CreateEvent {
pub url: Url,
pub language_id: Option<String>,
/* private fields */
}Expand description
Event triggers when a document is opened
Example
#[derive(Component)]
pub struct TurtleLang;
#[derive(Debug)]
pub struct TurtleHelper;
impl LangHelper for TurtleHelper {
fn keyword(&self) -> &[&'static str] {
&[
"@prefix",
"@base",
"a",
]
}
}
let mut world = World::new();
// This example tells the ECS system that the document is Turtle,
// adding Turtle specific components
world.add_observer(|trigger: On<CreateEvent>, mut commands: Commands| {
match &trigger.event().language_id {
Some(x) if x == "turtle" => {
commands
.entity(trigger.event_target())
.insert((TurtleLang, DynLang(Box::new(TurtleHelper))));
return;
}
_ => {}
}
if trigger.event().url.as_str().ends_with(".ttl") {
commands
.entity(trigger.event_target())
.insert((TurtleLang, DynLang(Box::new(TurtleHelper))));
return;
}
});Fields§
§url: Url§language_id: Option<String>Trait Implementations§
Source§impl EntityEvent for CreateEvent
impl EntityEvent for CreateEvent
Source§fn event_target(&self) -> Entity
fn event_target(&self) -> Entity
The
Entity “target” of this EntityEvent. When triggered, this will run observers that watch for this specific entity.Source§fn event_target_mut(&mut self) -> &mut Entity
fn event_target_mut(&mut self) -> &mut Entity
Returns a mutable reference to the
Entity “target” of this EntityEvent. When triggered, this will run observers that watch for this specific entity. Read moreAuto Trait Implementations§
impl Freeze for CreateEvent
impl RefUnwindSafe for CreateEvent
impl Send for CreateEvent
impl Sync for CreateEvent
impl Unpin for CreateEvent
impl UnwindSafe for CreateEvent
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoResult<T> for T
impl<T> IntoResult<T> for T
Source§fn into_result(self) -> Result<T, RunSystemError>
fn into_result(self) -> Result<T, RunSystemError>
Converts this type into the system output type.