Skip to content

Improve Path ergonomics #545

@Kinrany

Description

@Kinrany

Is your feature request related to a problem or challenge? Please describe what you are trying to do.

Path is central to object_store, but manipulating values of this type can be hard because its API is mostly structured around one-way parsing.

Describe the solution you'd like
Expand Paths API. In no particular order:

  • fn empty() constructor, equivalent to Path::from("/")
  • fn is_empty(&self) -> bool, true if self.raw is empty
  • fn len(&self) -> usize, equivalent to .parts().count()
  • fn prefix(&self) -> Self, dual to the existing Parts::filename
    • Bikeshedding: fn folder?
  • Change parts to return a custom iterator that is fused and double-ended.
  • Implement Expand in addition to FromIterator

Describe alternatives you've considered
One could argue that Path is not designed to be used as a standalone type. But then I would expect it to be internal to object_store, with all APIs using String instead.

Additional context
PR: #546

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions