Struct cargo_packager::config::NsisConfig
source · #[non_exhaustive]pub struct NsisConfig {
pub compression: Option<NsisCompression>,
pub template: Option<PathBuf>,
pub preinstall_section: Option<String>,
pub header_image: Option<PathBuf>,
pub sidebar_image: Option<PathBuf>,
pub installer_icon: Option<PathBuf>,
pub install_mode: NSISInstallerMode,
pub languages: Option<Vec<String>>,
pub custom_language_files: Option<HashMap<String, PathBuf>>,
pub display_language_selector: bool,
pub appdata_paths: Option<Vec<String>>,
}
Expand description
The NSIS format configuration.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.compression: Option<NsisCompression>
Set the compression algorithm used to compress files in the installer.
template: Option<PathBuf>
A custom .nsi
template to use.
See the default template here https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/installer.nsi
preinstall_section: Option<String>
Logic of an NSIS section that will be ran before the install section.
See the available libraries, dlls and global variables here https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/installer.nsi
§Example
[package.metadata.packager.nsis]
preinstall-section = """
; Setup custom messages
LangString webview2AbortError ${LANG_ENGLISH} "Failed to install WebView2! The app can't run without it. Try restarting the installer."
LangString webview2DownloadError ${LANG_ARABIC} "خطأ: فشل تنزيل WebView2 - $0"
Section PreInstall
; <section logic here>
SectionEnd
Section AnotherPreInstall
; <section logic here>
SectionEnd
"""
header_image: Option<PathBuf>
The path to a bitmap file to display on the header of installers pages.
The recommended dimensions are 150px x 57px.
The path to a bitmap file for the Welcome page and the Finish page.
The recommended dimensions are 164px x 314px.
installer_icon: Option<PathBuf>
The path to an icon file used as the installer icon.
install_mode: NSISInstallerMode
Whether the installation will be for all users or just the current user.
languages: Option<Vec<String>>
A list of installer languages.
By default the OS language is used. If the OS language is not in the list of languages, the first language will be used.
To allow the user to select the language, set display_language_selector
to true
.
See https://github.com/kichik/nsis/tree/9465c08046f00ccb6eda985abbdbf52c275c6c4d/Contrib/Language%20files for the complete list of languages.
custom_language_files: Option<HashMap<String, PathBuf>>
An key-value pair where the key is the language and the
value is the path to a custom .nsi
file that holds the translated text for cargo-packager’s custom messages.
See https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/languages/English.nsh for an example .nsi
file.
Note: the key must be a valid NSIS language and it must be added to NsisConfig
languages array,
display_language_selector: bool
Whether to display a language selector dialog before the installer and uninstaller windows are rendered or not.
By default the OS language is selected, with a fallback to the first language in the languages
array.
appdata_paths: Option<Vec<String>>
List of paths where your app stores data. This options tells the uninstaller to provide the user with an option (disabled by default) whether they want to rmeove your app data or keep it.
The path should use a constant from https://nsis.sourceforge.io/Docs/Chapter4.html#varconstant
in addition to $IDENTIFIER
, $PUBLISHER
and $PRODUCTNAME
, for example, if you store your
app data in C:\\Users\\<user>\\AppData\\Local\\<your-company-name>\\<your-product-name>
you’d need to specify
[package.metadata.packager.nsis]
appdata-paths = ["$LOCALAPPDATA/$PUBLISHER/$PRODUCTNAME"]
Implementations§
source§impl NsisConfig
impl NsisConfig
sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new NsisConfig
.
sourcepub fn compression(self, compression: NsisCompression) -> Self
pub fn compression(self, compression: NsisCompression) -> Self
Set the compression algorithm used to compress files in the installer.
sourcepub fn template<P: Into<PathBuf>>(self, template: P) -> Self
pub fn template<P: Into<PathBuf>>(self, template: P) -> Self
Set a custom .nsi
template to use.
See the default template here https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/installer.nsi
sourcepub fn preinstall_section<S: Into<String>>(self, preinstall_section: S) -> Self
pub fn preinstall_section<S: Into<String>>(self, preinstall_section: S) -> Self
Set the logic of an NSIS section that will be ran before the install section.
See the available libraries, dlls and global variables here https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/installer.nsi
§Example
[package.metadata.packager.nsis]
preinstall-section = """
; Setup custom messages
LangString webview2AbortError ${LANG_ENGLISH} "Failed to install WebView2! The app can't run without it. Try restarting the installer."
LangString webview2DownloadError ${LANG_ARABIC} "خطأ: فشل تنزيل WebView2 - $0"
Section PreInstall
; <section logic here>
SectionEnd
Section AnotherPreInstall
; <section logic here>
SectionEnd
"""
sourcepub fn header_image<P: Into<PathBuf>>(self, header_image: P) -> Self
pub fn header_image<P: Into<PathBuf>>(self, header_image: P) -> Self
Set the path to a bitmap file to display on the header of installers pages.
The recommended dimensions are 150px x 57px.
Set the path to a bitmap file for the Welcome page and the Finish page.
The recommended dimensions are 164px x 314px.
sourcepub fn installer_icon<P: Into<PathBuf>>(self, installer_icon: P) -> Self
pub fn installer_icon<P: Into<PathBuf>>(self, installer_icon: P) -> Self
Set the path to an icon file used as the installer icon.
sourcepub fn install_mode(self, install_mode: NSISInstallerMode) -> Self
pub fn install_mode(self, install_mode: NSISInstallerMode) -> Self
Set whether the installation will be for all users or just the current user.
sourcepub fn languages<I, S>(self, languages: I) -> Self
pub fn languages<I, S>(self, languages: I) -> Self
Set a list of installer languages.
By default the OS language is used. If the OS language is not in the list of languages, the first language will be used.
To allow the user to select the language, set display_language_selector
to true
.
See https://github.com/kichik/nsis/tree/9465c08046f00ccb6eda985abbdbf52c275c6c4d/Contrib/Language%20files for the complete list of languages.
sourcepub fn custom_language_files<I, S, P>(self, custom_language_files: I) -> Self
pub fn custom_language_files<I, S, P>(self, custom_language_files: I) -> Self
Set a map of key-value pair where the key is the language and the
value is the path to a custom .nsi
file that holds the translated text for cargo-packager’s custom messages.
See https://github.com/crabnebula-dev/cargo-packager/blob/main/crates/packager/src/nsis/languages/English.nsh for an example .nsi
file.
Note: the key must be a valid NSIS language and it must be added to NsisConfig
languages array,
sourcepub fn display_language_selector(self, display: bool) -> Self
pub fn display_language_selector(self, display: bool) -> Self
Set wether to display a language selector dialog before the installer and uninstaller windows are rendered or not.
By default the OS language is selected, with a fallback to the first language in the languages
array.
sourcepub fn appdata_paths<I, S>(self, appdata_paths: I) -> Self
pub fn appdata_paths<I, S>(self, appdata_paths: I) -> Self
Set a list of paths where your app stores data. This options tells the uninstaller to provide the user with an option (disabled by default) whether they want to rmeove your app data or keep it.
The path should use a constant from https://nsis.sourceforge.io/Docs/Chapter4.html#varconstant
in addition to $IDENTIFIER
, $PUBLISHER
and $PRODUCTNAME
, for example, if you store your
app data in C:\\Users\\<user>\\AppData\\Local\\<your-company-name>\\<your-product-name>
you’d need to specify
[package.metadata.packager.nsis]
appdata-paths = ["$LOCALAPPDATA/$PUBLISHER/$PRODUCTNAME"]
Trait Implementations§
source§impl Clone for NsisConfig
impl Clone for NsisConfig
source§fn clone(&self) -> NsisConfig
fn clone(&self) -> NsisConfig
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for NsisConfig
impl Debug for NsisConfig
source§impl Default for NsisConfig
impl Default for NsisConfig
source§fn default() -> NsisConfig
fn default() -> NsisConfig
source§impl<'de> Deserialize<'de> for NsisConfig
impl<'de> Deserialize<'de> for NsisConfig
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for NsisConfig
impl RefUnwindSafe for NsisConfig
impl Send for NsisConfig
impl Sync for NsisConfig
impl Unpin for NsisConfig
impl UnwindSafe for NsisConfig
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
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>
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>
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 moresource§impl<T> Pointable for T
impl<T> Pointable for T
source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian()
.