Skip to content

feat: Allow getting inner PathBuf from SafePathBuf#14908

Merged
Legend-Master merged 3 commits into
tauri-apps:devfrom
joshuamegnauth54:impl-into-pathbuf-safepath
Mar 24, 2026
Merged

feat: Allow getting inner PathBuf from SafePathBuf#14908
Legend-Master merged 3 commits into
tauri-apps:devfrom
joshuamegnauth54:impl-into-pathbuf-safepath

Conversation

@joshuamegnauth54

Copy link
Copy Markdown
Contributor

SafePathBuf implements AsRef<Path> which is ergonomic and useful. However, some APIs take owned PathBufs. This leads to clunky code where the caller has to get a &Path from the SafePathBuf then take ownership of that path. Ideally, if a user has a SafePathBuf and needs a PathBuf, they won't need to allocate again just to get the inner PathBuf back.

@joshuamegnauth54 joshuamegnauth54 requested a review from a team as a code owner February 7, 2026 02:48
@github-actions

github-actions Bot commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Package Changes Through 38f4e08

There are 9 changes which include tauri-macos-sign with patch, tauri-build with patch, tauri with minor, tauri-bundler with patch, tauri-cli with patch, @tauri-apps/cli with patch, tauri-runtime-wry with minor, tauri-runtime with minor, tauri-utils with minor

Planned Package Versions

The following package releases are the planned based on the context of changes in this pull request.

package current next
tauri-utils 2.8.3 2.9.0
tauri-macos-sign 2.3.3 2.3.4
tauri-bundler 2.8.1 2.8.2
tauri-runtime 2.10.1 2.11.0
tauri-runtime-wry 2.10.1 2.11.0
tauri-codegen 2.5.5 2.5.6
tauri-macros 2.5.5 2.5.6
tauri-plugin 2.5.4 2.5.5
tauri-build 2.5.6 2.5.7
tauri 2.10.3 2.11.0
@tauri-apps/cli 2.10.1 2.10.2
tauri-cli 2.10.1 2.10.2

Add another change file through the GitHub UI by following this link.


Read about change files or the docs at github.com/jbolda/covector

@sftse

sftse commented Feb 20, 2026

Copy link
Copy Markdown
Contributor

Is SafePathBuf being used standalone by a consumer? I'm not sure why the type was exposed as pub, I can't find public functions that return or take this type except the constructors.

@Legend-Master

Copy link
Copy Markdown
Contributor

Is SafePathBuf being used standalone by a consumer? I'm not sure why the type was exposed as pub, I can't find public functions that return or take this type except the constructors.

tauri-plugin-fs for an instance uses it, not familiar with the history about this struct though

https://docs.rs/tauri-plugin-fs/latest/tauri_plugin_fs/enum.SafeFilePath.html

Legend-Master
Legend-Master previously approved these changes Mar 4, 2026

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, could you also add a change file?

https://github.com/tauri-apps/tauri/blob/dev/.changes/README.md

@Legend-Master Legend-Master added this to the 2.11 milestone Mar 4, 2026
@sftse

sftse commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

@Legend-Master
CI is upset about something, do we need to rerun?

SafePathBuf implements AsRef<Path> which is ergonomic and useful.
However, some APIs take owned PathBufs. This leads to clunky code where
the caller has to get a &Path from the SafePathBuf then take ownership
of that path. Ideally, if a user has a SafePathBuf and needs a PathBuf,
they won't need to allocate again just to get the inner PathBuf back.
@joshuamegnauth54

Copy link
Copy Markdown
Contributor Author

Hi! Sorry for the late response. I force pushed to add a changes file. Sorry, I didn't know I needed one since the change was trivial. 😅

Comment thread .changes/safepathbuf_into_pathbuf.md Outdated

@Legend-Master Legend-Master left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, I will merge this after we got all the patch version bump PRs released and starting to merge for the next minor (2.11)

The change file is needed since this is a user facing change despite being trivial

@Legend-Master Legend-Master merged commit 4017a7e into tauri-apps:dev Mar 24, 2026
19 checks passed
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
* Allow getting inner PathBuf from SafePathBuf

SafePathBuf implements AsRef<Path> which is ergonomic and useful.
However, some APIs take owned PathBufs. This leads to clunky code where
the caller has to get a &Path from the SafePathBuf then take ownership
of that path. Ideally, if a user has a SafePathBuf and needs a PathBuf,
they won't need to allocate again just to get the inner PathBuf back.

* Apply suggestion from @Legend-Master
razein97 pushed a commit to razein97/tauri that referenced this pull request Apr 30, 2026
* Allow getting inner PathBuf from SafePathBuf

SafePathBuf implements AsRef<Path> which is ergonomic and useful.
However, some APIs take owned PathBufs. This leads to clunky code where
the caller has to get a &Path from the SafePathBuf then take ownership
of that path. Ideally, if a user has a SafePathBuf and needs a PathBuf,
they won't need to allocate again just to get the inner PathBuf back.

* Apply suggestion from @Legend-Master
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.

3 participants