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

chore: Clarify FS Plugin Rust Side Exposure #2590

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/content/docs/plugin/file-system.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ Install the fs plugin to get started.

The fs plugin is available in both JavaScript and Rust.

:::note[Rust Exposure]

The exposed API on the Rust side is mostly intended to manipulate the [Scope](#scopes) of the plugin.
It does expose some APIs to access the file system on mobile, but the recommendation is to use [`tokio::fs`](https://docs.rs/tokio/latest/tokio/fs/index.html) or the
Copy link
Member

Choose a reason for hiding this comment

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

For Android the tokio or std APIs won't work if you're using e.g. the dialog API (which returns a content:// URI instead of a path to the file). We might also need more changes for iOS to properly request for permissions to access some files (for instance photos, or the Files location).
I think in the end when the FS plugin is marked as stable, we'll recommend using it even for Rust code unless your app is desktop-only.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

:flip-table: 😂
Alright, so we recommend std/tokio for desktop and our api for mobile?

Choose a reason for hiding this comment

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

we'll fallback to std for desktop, so if you need cross platform support for e.g. reading resources and dialog-selected files, you need to use our own API wrapper

Choose a reason for hiding this comment

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

so I think we should skip this note and also document the Rust API instead

[`std::fs`](https://doc.rust-lang.org/std/fs/index.html) for accessing the file system.

:::

<Tabs>
<TabItem label="JavaScript" >

Expand Down
Loading