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 currentapplicationversion
- 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 atInertia::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
- AnOption<SsrClient>
with the Inertia Server address. IfNone
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 providedtemplate_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,
impl<T, V> InertiaConfig<T, V>where
T: 'static,
V: ToString,
Sourcepub fn builder() -> InertiaConfigBuilder<T, V>
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> 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