Skip to main content

Backend

Trait Backend 

Source
pub trait Backend:
    Sized
    + Send
    + Sync {
    const DEFAULT_PATH: &'static str;
    const CACHE_PATHS: &'static [&'static str];

    // Required methods
    fn path(&self) -> &Path;
    fn init(
        project: &Project,
    ) -> impl Future<Output = Result<Self, FailToInitBackend>> + Send;
    fn supports(&self, platform: TargetPlatform) -> bool;
    fn build(
        &self,
        project: &Project,
        platform: TargetPlatform,
        options: BuildOptions,
    ) -> impl Future<Output = Result<PathBuf>> + Send;
    fn package(
        &self,
        project: &Project,
        platform: TargetPlatform,
        options: PackageOptions,
    ) -> impl Future<Output = Result<Artifact>> + Send;
    fn clean(
        &self,
        project: &Project,
        platform: TargetPlatform,
    ) -> impl Future<Output = Result<()>> + Send;
}
Expand description

Trait for backends in a WaterUI project.

A backend handles building and packaging for specific platforms. Each backend knows:

  • Which platforms it supports
  • How to build Rust code for those platforms
  • How to package artifacts for distribution

Required Associated Constants§

Source

const DEFAULT_PATH: &'static str

The default relative path for this backend (e.g., “android”, “apple”).

Source

const CACHE_PATHS: &'static [&'static str]

Paths relative to the backend directory that should be preserved during re-scaffolding.

These typically contain build caches that are expensive to regenerate. During reinit_backend(), only items NOT in this list are deleted before calling init().

Required Methods§

Source

fn path(&self) -> &Path

Get the relative path for this backend instance.

This is relative to Backends::path().

Source

fn init( project: &Project, ) -> impl Future<Output = Result<Self, FailToInitBackend>> + Send

Initialize the backend for the given project.

Creates necessary files/folders for the backend at project.backend_path::<Self>(). Returns the initialized backend configuration.

Source

fn supports(&self, platform: TargetPlatform) -> bool

Check if this backend supports the given platform.

Source

fn build( &self, project: &Project, platform: TargetPlatform, options: BuildOptions, ) -> impl Future<Output = Result<PathBuf>> + Send

Build the Rust library for the target platform.

Returns the target directory path where the built library is located.

Source

fn package( &self, project: &Project, platform: TargetPlatform, options: PackageOptions, ) -> impl Future<Output = Result<Artifact>> + Send

Package the project for the target platform.

Returns the artifact (e.g., .app, .apk, binary).

Source

fn clean( &self, project: &Project, platform: TargetPlatform, ) -> impl Future<Output = Result<()>> + Send

Clean build artifacts for the platform.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl Backend for AndroidBackend

Source§

const DEFAULT_PATH: &'static str = "android"

Source§

const CACHE_PATHS: &'static [&'static str]

Source§

impl Backend for AppleBackend

Source§

const DEFAULT_PATH: &'static str = "apple"

Source§

const CACHE_PATHS: &'static [&'static str]

Source§

impl Backend for Esp32Backend

Source§

const DEFAULT_PATH: &'static str = "esp32"

Source§

const CACHE_PATHS: &'static [&'static str]

Source§

impl Backend for Gtk4Backend

Source§

const DEFAULT_PATH: &'static str = "gtk4"

Source§

const CACHE_PATHS: &'static [&'static str]

Source§

impl Backend for HydrolysisBackend

Source§

const DEFAULT_PATH: &'static str = "hydrolysis"

Source§

const CACHE_PATHS: &'static [&'static str]

Source§

impl Backend for WinUiBackend

Source§

const DEFAULT_PATH: &'static str = "winui"

Source§

const CACHE_PATHS: &'static [&'static str]