pub struct AppPaths { /* private fields */ }Expand description
The resolved directories of one installation.
Implementations§
Source§impl AppPaths
impl AppPaths
Sourcepub fn resolve(identifier: &str) -> Result<Self, NativeError>
pub fn resolve(identifier: &str) -> Result<Self, NativeError>
The directories for identifier, from the environment or the platform
defaults.
The four RAHTI_NATIVE_*_DIR variables win where they are set, which
is how an Android host passes in directories only the Java side knows
and how a test gets a temporary tree without touching the real one.
Sourcepub fn from_host(
identifier: &str,
data: impl Into<PathBuf>,
cache: impl Into<PathBuf>,
resources: impl Into<PathBuf>,
) -> Result<Self, NativeError>
pub fn from_host( identifier: &str, data: impl Into<PathBuf>, cache: impl Into<PathBuf>, resources: impl Into<PathBuf>, ) -> Result<Self, NativeError>
The directories the host already knows.
Android’s are only reachable from the Java side, so the Tauri shell asks Tauri for them and hands them over rather than this crate trying to derive something it cannot see.
Sourcepub fn identifier(&self) -> &str
pub fn identifier(&self) -> &str
The application identifier these paths were built for.
Sourcepub fn data(&self) -> &Path
pub fn data(&self) -> &Path
Durable application data: the database, uploads, the session key, logs. Survives until the user uninstalls or clears the application’s data.
Sourcepub fn public(&self) -> PathBuf
pub fn public(&self) -> PathBuf
Where the application’s static assets are served from.
Under data, not under resources, because Android’s are not files
until stage_public_assets has copied them out of the package.
Windows could serve straight from the installation directory, and
deliberately does not: one path that behaves the same on both platforms
is worth more than one avoided copy of a few hundred kilobytes.
Sourcepub fn bundled_public(&self) -> PathBuf
pub fn bundled_public(&self) -> PathBuf
Where the assets are staged from — the copy inside the package.
Sourcepub fn spill(&self) -> PathBuf
pub fn spill(&self) -> PathBuf
Where a large upload is spooled while it arrives.
Cache rather than data: the file exists for one request, and an operating system that reclaims it between requests has taken nothing.
Sourcepub fn secret_file(&self) -> PathBuf
pub fn secret_file(&self) -> PathBuf
The per-installation session key.
Sourcepub fn prepare(&self) -> Result<(), NativeError>
pub fn prepare(&self) -> Result<(), NativeError>
Create every directory the application writes into.
Idempotent, and called before anything else reads a path — a first launch has none of them, and an SQLite file cannot be created in a directory that is not there.
Sourcepub fn sqlite_url(&self) -> String
pub fn sqlite_url(&self) -> String
A DATABASE_URL for the local SQLite file.
Absolute, because a relative one resolves against a working directory
an installed application does not control. mode=rwc because a first
launch has no file yet.
Sourcepub fn apply_environment(&self, public: &Path)
pub fn apply_environment(&self, public: &Path)
Put the resolved paths where the application will read them.
Called before initialize_application, because the generated router
reads RAHTI_PUBLIC_DIR while it is being built and an upload reads
RAHTI_SPILL_DIR on the first request that spills.
public is passed rather than taken from Self::public because it
is the one path that is not always the packaged one: a cargo rahti native dev run has no bundle to stage from and serves the project’s
own public/ directly, which is also what makes a stylesheet edit
visible without a rebuild. See [resolve_public].
Set rather than defaulted: std::env::set_var overwrites, and that is
deliberate. An installed application inherits the environment of
whoever launched it, and a developer with RAHTI_PUBLIC_DIR exported
for their own checkout would otherwise have a shipped application
serving assets out of their source tree.
Sourcepub fn apply_sqlite_database_url(&self)
pub fn apply_sqlite_database_url(&self)
Point DATABASE_URL at the local SQLite file.
Separate from apply_environment because it
is the one path decision a native package must not make on the
application’s behalf. A project on PostgreSQL or MySQL has a database
somewhere else, and silently rewriting its connection string to a local
SQLite file would start the application against an empty database that
looks like a working one. See crate::DatabaseMode.