inertia_rust

Struct InertiaConfig

Source
pub struct InertiaConfig<T, V>
where T: 'static, V: ToString,
{ pub url: &'static str, pub version: InertiaVersion<V>, pub template_path: &'static str, pub template_resolver: &'static (dyn Fn(&'static str, ViewData, &'static T) -> TemplateResolverOutput + Send + Sync + 'static), pub template_resolver_data: &'static T, pub with_ssr: bool, pub custom_ssr_client: Option<SsrClient>, pub view_data: Option<Map<String, Value>>, pub reflash_inertia_session: Box<dyn Fn(Option<InertiaTemporarySession>) -> Result<(), InertiaError> + Send + Sync>, }
Expand description

A configuration struct for initializing Inertia. You can directly fill the struct or use the builder fluent syntax by calling InertiaConfig::builder(), and finally InertiaConfig::build().

Note that, even with builder, most of fields are mandatory and trying to build without filling them will cause your application to panic!

  • url - A valid href of the currentapplication
  • version - The current asset version of the application. See Asset versioning for more details.
  • template_path - The path for the root html template.
  • template_resolver - A function that renders the given root template html. Check more details at Inertia::template_resolver document string.
  • template_resolver_data - The third parameter of your template resolver. Inertia will pass it by reference when calling the resolver function. If you don’t plan to use it, just pass an empty tuple (both here and in your template resolver).
  • with_ssr - Whether Server-side Rendering should be enabled.
  • custom_ssr_client - An Option<SsrClient> with the Inertia Server address. If None is given, SsrClient::default will be used.
  • view_data - Optional view data to be passed to the root template. It must be handled by the provided template_resolver.

Fields§

§url: &'static str§version: InertiaVersion<V>§template_path: &'static str§template_resolver: &'static (dyn Fn(&'static str, ViewData, &'static T) -> TemplateResolverOutput + Send + Sync + 'static)§template_resolver_data: &'static T§with_ssr: bool§custom_ssr_client: Option<SsrClient>§view_data: Option<Map<String, Value>>§reflash_inertia_session: Box<dyn Fn(Option<InertiaTemporarySession>) -> Result<(), InertiaError> + Send + Sync>

Implementations§

Source§

impl<T, V> InertiaConfig<T, V>
where T: 'static, V: ToString,

Source

pub fn builder() -> InertiaConfigBuilder<T, V>

Instatiates a new InertiaConfigBuilder instance. It must be configured using a fluent syntax.

§Examples
use inertia_rust::{InertiaVersion, InertiaConfig};
let inertia_config = InertiaConfig::builder()
    .set_url("http://localhost:8080")
    .set_version(InertiaVersion::Literal("v1"))
    .set_template_path("path/to/template.html")
    .set_template_resolver(&your_template_resolver)
    .set_template_resolver_data(&())
    .build();

Auto Trait Implementations§

§

impl<T, V> Freeze for InertiaConfig<T, V>
where V: Freeze,

§

impl<T, V> !RefUnwindSafe for InertiaConfig<T, V>

§

impl<T, V> !Send for InertiaConfig<T, V>

§

impl<T, V> !Sync for InertiaConfig<T, V>

§

impl<T, V> Unpin for InertiaConfig<T, V>
where V: Unpin,

§

impl<T, V> !UnwindSafe for InertiaConfig<T, V>

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> 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 = 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> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T