Skip to main content

AppPaths

Struct AppPaths 

Source
pub struct AppPaths { /* private fields */ }
Expand description

The resolved directories of one installation.

Implementations§

Source§

impl AppPaths

Source

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.

Source

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.

Source

pub fn identifier(&self) -> &str

The application identifier these paths were built for.

Source

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.

Source

pub fn config(&self) -> &Path

User-visible configuration the application chooses to persist.

Source

pub fn cache(&self) -> &Path

Data the operating system may delete without asking.

Source

pub fn resources(&self) -> &Path

The package’s read-only installed files. Never written to.

Source

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.

Source

pub fn bundled_public(&self) -> PathBuf

Where the assets are staged from — the copy inside the package.

Source

pub fn database(&self) -> PathBuf

The SQLite file, for an application whose database is local.

Source

pub fn uploads(&self) -> PathBuf

Files the application saved on the user’s behalf.

Source

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.

Source

pub fn logs(&self) -> PathBuf

Application logs.

Source

pub fn temp(&self) -> PathBuf

Short-lived scratch files.

Source

pub fn exports(&self) -> PathBuf

Files the application exports for the user to keep.

Source

pub fn secret_file(&self) -> PathBuf

The per-installation session key.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Clone for AppPaths

Source§

fn clone(&self) -> AppPaths

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for AppPaths

Source§

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

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

impl Eq for AppPaths

Source§

impl PartialEq for AppPaths

Source§

fn eq(&self, other: &AppPaths) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for AppPaths

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

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FromRef<T> for T
where T: Clone,

Source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,

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

Source§

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

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