Struct leptos_config::LeptosOptions

source ·
pub struct LeptosOptions {
    pub output_name: String,
    pub site_root: String,
    pub site_pkg_dir: String,
    pub env: Env,
    pub site_addr: SocketAddr,
    pub reload_port: u32,
    pub reload_external_port: Option<u32>,
    pub reload_ws_protocol: ReloadWSProtocol,
    pub not_found_path: String,
    pub hash_file: String,
    pub hash_files: bool,
}
Expand description

This struct serves as a convenient place to store details used for configuring Leptos. It’s used in our actix and axum integrations to generate the correct path for WASM, JS, and Websockets, as well as other configuration tasks. It shares keys with cargo-leptos, to allow for easy interoperability

Fields§

§output_name: String

The name of the WASM and JS files generated by wasm-bindgen. Defaults to the crate name with underscores instead of dashes

§site_root: String

The path of the all the files generated by cargo-leptos. This defaults to ‘.’ for convenience when integrating with other tools.

§site_pkg_dir: String

The path of the WASM and JS files generated by wasm-bindgen from the root of your app By default, wasm-bindgen puts them in pkg.

§env: Env

Used to configure the running environment of Leptos. Can be used to load dev constants and keys v prod, or change things based on the deployment environment I recommend passing in the result of env::var("LEPTOS_ENV")

§site_addr: SocketAddr

Provides a way to control the address leptos is served from. Using an env variable here would allow you to run the same code in dev and prod Defaults to 127.0.0.1:3000

§reload_port: u32

The port the Websocket watcher listens on. Should match the reload_port in cargo-leptos(if using). Defaults to 3001

§reload_external_port: Option<u32>

The port the Websocket watcher listens on when on the client, e.g., when behind a reverse proxy. Defaults to match reload_port

§reload_ws_protocol: ReloadWSProtocol

The protocol the Websocket watcher uses on the client: ws in most cases, wss when behind a reverse https proxy. Defaults to ws

§not_found_path: String

The path of a custom 404 Not Found page to display when statically serving content, defaults to site_root/404.html

§hash_file: String

The file name of the hash text file generated by cargo-leptos. Defaults to hash.txt.

§hash_files: bool

If true, hashes will be generated for all files in the site_root and added to their file names. Defaults to true.

Implementations§

source§

impl LeptosOptions

source

pub fn builder( ) -> LeptosOptionsBuilder<((), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building LeptosOptions. On the builder, call .output_name(...)(optional), .site_root(...)(optional), .site_pkg_dir(...)(optional), .env(...)(optional), .site_addr(...)(optional), .reload_port(...)(optional), .reload_external_port(...)(optional), .reload_ws_protocol(...)(optional), .not_found_path(...)(optional), .hash_file(...)(optional), .hash_files(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of LeptosOptions.

Trait Implementations§

source§

impl Clone for LeptosOptions

source§

fn clone(&self) -> LeptosOptions

Returns a copy 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 LeptosOptions

source§

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

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

impl Default for LeptosOptions

source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for LeptosOptions

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more

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

source§

fn from(t: T) -> T

Returns the argument unchanged.

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

§

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>,

§

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>,

§

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<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,