Created
November 10, 2014 21:05
-
-
Save aturon/5c7ed1bd41f1f3bdfcec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Types: Path and path (later being unsized) | |
impl Deref<path> for Path { ... } | |
fn new<T: BytesContainer>(path: T) -> Path | |
fn dir(&self) -> &path | |
impl Path { | |
fn new<T: BytesContainer>(path: T) -> Path | |
fn push<T: BytesContainer>(&mut self, path: T) | |
fn push_many<T: BytesContainer>(&mut self, paths: &[T]); | |
fn pop(&mut self) -> bool; | |
fn set_filename<T: BytesContainer>(&mut self, filename: T); | |
fn set_extension<T: BytesContainer>(&mut self, extension: T); | |
} | |
// inspection | |
impl path { | |
fn as_str(&self) -> Option<&str> | |
fn as_bytes<'a>(&'a self) -> &'a [u8]; | |
fn into_vec(self) -> Vec<u8>; | |
fn to_owned(&self) -> Path; | |
fn is_absolute(&self) -> bool; | |
fn is_relative(&self) -> bool; | |
fn is_ancestor_of(&self, other: &path) -> bool; | |
// path_relative_to may be better? talk to kballard | |
fn path_relative_from(&self, base: &path) -> Option<Path>; | |
fn ends_with_path(&self, child: &path) -> bool; | |
fn dir(&self) -> &path; | |
fn file(&self) -> Option<&path>; | |
fn root_path(&self) -> Option<&path>; | |
fn filestem(&self) -> Option<&path>; // probably ok if ..json has no extension | |
// This seems problematic, because we can't provide the guarantee below | |
// fn extension(&self) -> Option<&path>; | |
// This seems like a reasonable alternative | |
fn extension(&self) -> Option<&str>; // conflates no extension | |
// with a non-str extension; possibly make this a separate enum | |
fn extension_bytes(&self) -> Option<&[u8]>; | |
} | |
// derivation | |
impl path { | |
fn join<T: BytesContainer>(&self, path: T) -> Path | |
fn join_many<T: BytesContainer>(&self, paths: &[T]) -> Path; | |
fn with_filename<T: BytesContainer>(&self, filename: T) -> Path; | |
fn with_extension<T: BytesContainer>(&self, extension: T) -> Path; | |
} | |
// Principle: if you take a path slice and get an owned version, you should get the same thing back | |
// s/normalized/sanitized/g |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment