Skip to content

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

Merged
lucasfernog merged 2 commits intodevfrom
refactor/context-assets
Mar 11, 2024
Merged

feat(core): allow swapping the assets implementation#9141
lucasfernog merged 2 commits intodevfrom
refactor/context-assets

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