FullstackContext

Struct FullstackContext 

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

The context provided by dioxus fullstack for server-side rendering.

This context will only be set on the server during the initial streaming response and inside server functions.

Implementations§

Source§

impl FullstackContext

Source

pub fn new(parts: Parts) -> FullstackContext

Create a new streaming context. You should not need to call this directly. Dioxus fullstack will provide this context for you.

Source

pub fn commit_initial_chunk(&mut self)

Commit the initial chunk of the response. This will be called automatically if you are using the dioxus router when the suspense boundary above the router is resolved. Otherwise, you will need to call this manually to start the streaming part of the response.

Once this method has been called, the http response parts can no longer be modified.

Source

pub fn streaming_state(&self) -> StreamingStatus

Get the current status of the streaming response. This method is reactive and will cause the current reactive context to rerun when the status changes.

Source

pub fn parts_mut(&self) -> RwLockWriteGuard<'_, RawRwLock, Parts>

Access the http request parts mutably. This will allow you to modify headers and other parts of the request.

Source

pub async fn scope<F, R>(self, fut: F) -> R
where F: Future<Output = R>,

Run a future within the scope of this FullstackContext.

Source

pub fn extension<T>(&self) -> Option<T>
where T: Clone + Send + Sync + 'static,

Extract an extension from the current request.

Source

pub async fn extract<T, M>() -> Result<T, ServerFnError>

Extract an axum extractor from the current request.

The body of the request is always empty when using this method, as the body can only be consumed once in the server function extractors.

Source

pub fn current() -> Option<FullstackContext>

Get the current FullstackContext if it exists. This will return None if called on the client or outside of a streaming response on the server or server function.

Source

pub fn current_http_status(&self) -> HttpError

Get the current HTTP status for the route. This will default to 200 OK, but can be modified by calling FullstackContext::commit_error_status with an error.

Source

pub fn set_current_http_status(&mut self, status: HttpError)

Source

pub fn add_response_header( &self, key: impl Into<HeaderName>, value: impl Into<HeaderValue>, )

Add a header to the response. This will be sent to the client when the response is committed.

Source

pub fn take_response_headers(&self) -> Option<HeaderMap>

Take the response headers out of the context. This will leave the context without any headers, so it should only be called once when the response is being committed.

Source

pub fn commit_http_status(status: StatusCode, message: Option<String>)

Set the current HTTP status for the route. This will be used when committing the response to the client.

Source

pub fn commit_error_status(error: impl Into<CapturedError>) -> HttpError

Commit the CapturedError as the current HTTP status for the route. This will attempt to downcast the error to known types and set the appropriate status code. If the error type is unknown, it will default to StatusCode::INTERNAL_SERVER_ERROR.

Trait Implementations§

Source§

impl Clone for FullstackContext

Source§

fn clone(&self) -> FullstackContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FullstackContext

Source§

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

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

impl PartialEq for FullstackContext

Source§

fn eq(&self, other: &FullstackContext) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<T> InitializeFromFunction<T> for T

Source§

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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: 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Source§

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Source§

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Source§

fn super_from(input: T) -> O

Convert from a type to another type.
Source§

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Source§

fn super_into(self) -> O

Convert from a type to another type.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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

impl<T> DependencyElement for T
where T: 'static + PartialEq + Clone,

Source§

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