pub struct ScopeId(pub usize);
Expand description
A component’s unique identifier.
ScopeId
is a usize
that acts a key for the internal slab of Scopes. This means that the key is not unqiue across
time. We do try and guarantee that between calls to wait_for_work
, no ScopeIds will be recycled in order to give
time for any logic that relies on these IDs to properly update.
Tuple Fields§
§0: usize
Implementations§
§impl ScopeId
impl ScopeId
pub fn owner<S>(self) -> Owner<S>where
S: AnyStorage,
pub fn owner<S>(self) -> Owner<S>where
S: AnyStorage,
Get the owner for the current scope.
§impl ScopeId
impl ScopeId
pub fn current_scope_id(self) -> Option<ScopeId>
pub fn current_scope_id(self) -> Option<ScopeId>
Get the current scope id
pub fn consume_context<T>(self) -> Option<T>where
T: 'static + Clone,
pub fn consume_context<T>(self) -> Option<T>where
T: 'static + Clone,
Consume context from the current scope
pub fn consume_context_from_scope<T>(self, scope_id: ScopeId) -> Option<T>where
T: 'static + Clone,
pub fn consume_context_from_scope<T>(self, scope_id: ScopeId) -> Option<T>where
T: 'static + Clone,
Consume context from the current scope
pub fn has_context<T>(self) -> Option<T>where
T: 'static + Clone,
pub fn has_context<T>(self) -> Option<T>where
T: 'static + Clone,
Check if the current scope has a context
pub fn provide_context<T>(self, value: T) -> Twhere
T: 'static + Clone,
pub fn provide_context<T>(self, value: T) -> Twhere
T: 'static + Clone,
Provide context to the current scope
pub fn suspend(self, task: Task) -> Option<Option<VNode>>
pub fn suspend(self, task: Task) -> Option<Option<VNode>>
Suspended a component on a specific task and then return None
pub fn push_future(
self,
fut: impl Future<Output = ()> + 'static,
) -> Option<Task>
pub fn push_future( self, fut: impl Future<Output = ()> + 'static, ) -> Option<Task>
Pushes the future onto the poll queue to be polled after the component renders.
pub fn spawn(self, fut: impl Future<Output = ()> + 'static)
pub fn spawn(self, fut: impl Future<Output = ()> + 'static)
Spawns the future but does not return the [TaskId
]
pub fn generation(self) -> Option<usize>
pub fn generation(self) -> Option<usize>
Get the current render since the inception of this component
This can be used as a helpful diagnostic when debugging hooks/renders, etc
pub fn parent_scope(self) -> Option<ScopeId>
pub fn parent_scope(self) -> Option<ScopeId>
Get the parent of the current scope if it exists
pub fn needs_update(self)
pub fn needs_update(self)
Mark the current scope as dirty, causing it to re-render
pub fn schedule_update(&self) -> Arc<dyn Fn() + Sync + Send>
pub fn schedule_update(&self) -> Arc<dyn Fn() + Sync + Send>
Create a subscription that schedules a future render for the reference component. Unlike Self::needs_update
, this function will work outside of the dioxus runtime.
§Notice: you should prefer using [dioxus_core::schedule_update_any
] and [Self::scope_id
]
pub fn in_runtime<T>(self, f: impl FnOnce() -> T) -> T
pub fn in_runtime<T>(self, f: impl FnOnce() -> T) -> T
Run a closure inside of scope’s runtime
Trait Implementations§
§impl<'de> Deserialize<'de> for ScopeId
impl<'de> Deserialize<'de> for ScopeId
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScopeId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<ScopeId, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Ord for ScopeId
impl Ord for ScopeId
§impl PartialOrd for ScopeId
impl PartialOrd for ScopeId
§impl Serialize for ScopeId
impl Serialize for ScopeId
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for ScopeId
impl Eq for ScopeId
impl StructuralPartialEq for ScopeId
Auto Trait Implementations§
impl Freeze for ScopeId
impl RefUnwindSafe for ScopeId
impl Send for ScopeId
impl Sync for ScopeId
impl Unpin for ScopeId
impl UnwindSafe for ScopeId
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
§impl<T> CallHasher for T
impl<T> CallHasher for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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>
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>
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