Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): allow swapping the assets implementation #9141

Merged
merged 2 commits into from
Mar 11, 2024

Conversation

lucasfernog
Copy link
Member

The current Context::assets_mut is useless since you must provide a type that matches the generic arg in Context, so we're dropping it in favor of a Box instead.

Additionally, during codegen you can now define your custom assets implementation (by default we embed the frontendDist assets):

struct MyAssets {
...
}
impl tauri::Assets for MyAssets {
...
}

fn main() {
  let assets = MyAssets {};
  tauri::generate_context(
    assets = assets
  );
}

@lucasfernog lucasfernog requested a review from a team as a code owner March 10, 2024 12:33
@lucasfernog lucasfernog changed the title feat(core): allow swapping the assets implemenetation feat(core): allow swapping the assets implementation Mar 10, 2024
amrbashir
amrbashir previously approved these changes Mar 11, 2024
Comment on lines 390 to 391
#[allow(clippy::borrowed_box)]
pub fn assets(&self) -> &Box<dyn Assets> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any reason not to return &dyn Assets here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops forgot i could use as_ref, gonna push

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants