pub struct InertiaShared {
pub auth: Option<Value>,
pub flash: Option<Value>,
pub csrf: Option<String>,
pub extra: Option<Value>,
}Expand description
Shared props that are merged into every Inertia response.
Use this struct to pass common data (auth, flash messages, CSRF tokens) to all Inertia responses via middleware.
§Example
use ferro_inertia::InertiaShared;
use serde_json::json;
let shared = InertiaShared::new()
.auth(json!({
"id": 1,
"name": "John Doe",
"email": "john@example.com"
}))
.csrf("token123")
.flash(json!({
"success": "Profile updated!"
}));Fields§
§auth: Option<Value>Authenticated user data (if any)
flash: Option<Value>Flash messages from the session
csrf: Option<String>CSRF token
extra: Option<Value>Additional custom shared props
Implementations§
Sourcepub fn new() -> InertiaShared
pub fn new() -> InertiaShared
Create a new empty shared props container.
Sourcepub fn auth(self, auth: impl Serialize) -> InertiaShared
pub fn auth(self, auth: impl Serialize) -> InertiaShared
Set authenticated user data.
Sourcepub fn flash(self, flash: impl Serialize) -> InertiaShared
pub fn flash(self, flash: impl Serialize) -> InertiaShared
Set flash messages.
Sourcepub fn csrf(self, token: impl Into<String>) -> InertiaShared
pub fn csrf(self, token: impl Into<String>) -> InertiaShared
Set CSRF token.
Sourcepub fn with(self, extra: impl Serialize) -> InertiaShared
pub fn with(self, extra: impl Serialize) -> InertiaShared
Set additional custom shared props.
These will be flattened into the shared props object.
Sourcepub fn merge_into(&self, props: &mut Value)
pub fn merge_into(&self, props: &mut Value)
Merge shared props into a props object.
Trait Implementations§
Source§fn clone(&self) -> InertiaShared
fn clone(&self) -> InertiaShared
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§fn default() -> InertiaShared
fn default() -> InertiaShared
Returns the “default value” for a type. Read more
Source§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,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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