pub struct CreateEvent {
pub url: Url,
pub language_id: Option<String>,
}
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.observe(|trigger: Trigger<CreateEvent>, mut commands: Commands| {
match &trigger.event().language_id {
Some(x) if x == "turtle" => {
commands
.entity(trigger.entity())
.insert((TurtleLang, DynLang(Box::new(TurtleHelper))));
return;
}
_ => {}
}
if trigger.event().url.as_str().ends_with(".ttl") {
commands
.entity(trigger.entity())
.insert((TurtleLang, DynLang(Box::new(TurtleHelper))));
return;
}
});
Fields§
§url: Url
§language_id: Option<String>
Trait Implementations§
Source§impl Component for CreateEvent
impl Component for CreateEvent
Source§const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
const STORAGE_TYPE: StorageType = bevy_ecs::component::StorageType::SparseSet
A constant indicating the storage type used for this component.
Source§fn register_component_hooks(_hooks: &mut ComponentHooks)
fn register_component_hooks(_hooks: &mut ComponentHooks)
Called when registering this component, allowing mutable access to its
ComponentHooks
.impl Event for CreateEvent
Auto 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<C> Bundle for Cwhere
C: Component,
impl<C> Bundle for Cwhere
C: Component,
fn component_ids( components: &mut Components, storages: &mut Storages, ids: &mut impl FnMut(ComponentId), )
unsafe fn from_components<T, F>(ctx: &mut T, func: &mut F) -> C
Source§fn get_component_ids(
components: &Components,
ids: &mut impl FnMut(Option<ComponentId>),
)
fn get_component_ids( components: &Components, ids: &mut impl FnMut(Option<ComponentId>), )
Source§impl<C> DynamicBundle for Cwhere
C: Component,
impl<C> DynamicBundle for Cwhere
C: Component,
fn get_components(self, func: &mut impl FnMut(StorageType, OwningPtr<'_>))
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more