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

Support paths without trailing nulls #65

Open
robin-nitrokey opened this issue Jul 3, 2024 · 1 comment
Open

Support paths without trailing nulls #65

robin-nitrokey opened this issue Jul 3, 2024 · 1 comment

Comments

@robin-nitrokey
Copy link
Member

Once factor that makes dealing with Paths somewhat awkward at the moment is the requirement for a trailing null. For example, I cannot have a split_at(&self, n: usize) -> (&Path, &Path) function because the first part would not have a trailing null. But allocating a PathBuf would often be wasteful because it might be discarded directly, or may only be used for comparison and not for a littlefs2 API call.

We could support this by introducing a third path type that does not require a trailing null, let’s call it PathView. It could be created without overhead from a PathBuf or Path and could be used for comparison. To use it with a littefs2 API call, it would need to be converted to a PathBuf.

Do you think it is worth having a separate type for this or should we just accept the current limitations?

@robin-nitrokey
Copy link
Member Author

An alternative could be to make the trailing null byte in Path optional. littlefs2 could then internally copy paths to a buffer to add the trailing null if needed.

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

No branches or pull requests

1 participant