Skip to main content

LivewireRequest

Struct LivewireRequest 

Source
pub struct LivewireRequest { /* private fields */ }
Expand description

One request’s mutable Livewire state.

Implementations§

Source§

impl LivewireRequest

Source

pub fn current() -> Option<Arc<Self>>

The request’s state, created on first use, or None outside a request.

§Panics

Panics when the request-local store is unavailable, which only happens outside the application.

Source

pub fn push_mounting(&self, id: &str) -> StackGuard<'_>

Marks a component as mounting, and returns a guard that unmarks it when dropped.

Source

pub fn mounting(&self) -> Option<String>

The component that is mounting now, which is the parent of a component being mounted inside it.

Source

pub fn push_rendering(&self, id: &str) -> StackGuard<'_>

Marks a component as rendering, and returns a guard that unmarks it when dropped.

Source

pub fn rendering(&self) -> Option<String>

The component that is rendering now.

Source

pub fn render_depth(&self) -> usize

How many components are rendering, which is the depth a nested render reports.

Source

pub fn register(&self, id: &str, state: ComponentState)

Registers a component’s state, replacing any state under the same ID.

Source

pub fn remember_page(&self, path: &str, method: &str, origin: &str)

Remembers the page this request rendered, which a mount records and an update replays.

Source

pub fn page(&self) -> Option<PageContext>

The page this request rendered, when one did.

Source

pub fn read<T>( &self, id: &str, read: impl FnOnce(&ComponentState) -> T, ) -> Option<T>

Reads a component’s state.

Source

pub fn change(&self, id: &str, change: impl FnOnce(&mut ComponentState))

Changes a component’s state, creating it when the component is not registered yet.

Source

pub fn has_rendered(&self) -> bool

Whether any component rendered in this request, which decides whether the page needs the runtime at all.

Source

pub fn forget(&self, id: &str)

Forgets a component’s state, after its last render.

Source

pub fn add_child(&self, parent: &str, child: Child)

Records that a component rendered a nested component.

Source

pub fn children(&self, parent: &str) -> Vec<Child>

The nested components a component rendered.

Source

pub fn add_asset(&self, asset: &str) -> bool

Records an asset the response reports, returning whether it is new.

Source

pub fn take_assets(&self) -> Vec<String>

Takes the assets the response reports, in the order they were added.

Source

pub fn mark_styles_rendered(&self)

Records that the page called livewire_styles() itself, so the response does not add them again.

Source

pub fn styles_rendered(&self) -> bool

Whether the page called livewire_styles() itself.

Source

pub fn mark_scripts_rendered(&self)

Records that the page called livewire_scripts() itself, so the response does not add them again.

Source

pub fn scripts_rendered(&self) -> bool

Whether the page called livewire_scripts() itself.

Source

pub fn first_asset_render(&self, asset: &str) -> bool

Marks an asset as rendered in this request, returning false when it already was.

Source

pub fn first_script_render(&self, script: &str) -> bool

Marks a script as rendered in this request, returning false when it already was.

Source

pub fn add_stream(&self, stream: Stream)

Records a streamed chunk.

Source

pub fn take_streams(&self) -> Vec<Stream>

Takes the streamed chunks, in the order they were sent.

Source

pub fn is_streaming(&self) -> bool

Whether anything streamed, so the response is an event stream.

Source

pub fn computed(&self, component: &str, name: &str) -> Option<Value>

The memoized value of a computed property, if this request computed it already.

Source

pub fn set_computed(&self, component: &str, name: &str, value: Value)

Memoizes a computed property’s value for the rest of the request.

Source

pub fn forget_computed(&self, component: &str, name: &str)

Forgets a computed property, so the next read recomputes it.

Source

pub fn first_checksum_check(&self) -> bool

Whether this request already checked the client’s checksum-failure allowance. The batch checks once, however many components it updates.

Source

pub fn set_http_request(&self, request: Arc<Request>)

Keeps the HTTP request being handled, so an action can reach it.

Source

pub fn http_request(&self) -> Option<Arc<Request>>

The HTTP request being handled, or None outside a request.

Source

pub fn set_persistent(&self, key: &str, value: Value)

Records a value the route’s persistent middleware resolved.

Source

pub fn persistent(&self, key: &str) -> Option<Value>

Reads a value the route’s persistent middleware resolved.

Trait Implementations§

Source§

impl Debug for LivewireRequest

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for LivewireRequest

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl !Freeze for LivewireRequest

§

impl Forget for LivewireRequest

§

impl Move for LivewireRequest

§

impl RefUnwindSafe for LivewireRequest

§

impl Send for LivewireRequest

§

impl Sync for LivewireRequest

§

impl Unpin for LivewireRequest
where Align4<u32>: Unpin, Align1<u8>: Unpin, *const LeafNode<String, ComponentState> is !null: Unpin, Box<(String, ComponentState)>: Unpin, *const u8 is !null: Unpin, *const LeafNode<String, SetValZST> is !null: Unpin, Box<(String, SetValZST)>: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin, Arc<Request>: Unpin,

§

impl UnsafeUnpin for LivewireRequest

§

impl UnwindSafe for LivewireRequest

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, N> NotifiedBy<T> for N
where T: Notification<N>,

Source§

fn __routes(&self) -> Vec<Route>

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more