feat(fs): kxio::fs::new(...)
now accepts impl Into<PathBuf>
This commit is contained in:
parent
4f990f907c
commit
a0262a4d05
2 changed files with 5 additions and 5 deletions
|
@ -8,7 +8,7 @@
|
|||
///
|
||||
/// NOTE: running this program with `cargo run --example get` will create and delete the file
|
||||
/// `example-readme.md` in the current directory.
|
||||
use std::path::{Path, PathBuf};
|
||||
use std::path::Path;
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> kxio::Result<()> {
|
||||
|
@ -18,7 +18,7 @@ async fn main() -> kxio::Result<()> {
|
|||
// Create a `FileSystem` object for accessing files within the current directory.
|
||||
// The object created will return a `PathTraveral` error result if there is an attempt to\
|
||||
// access a file outside of this directory.
|
||||
let fs: kxio::fs::FileSystem = kxio::fs::new(PathBuf::from("./"));
|
||||
let fs: kxio::fs::FileSystem = kxio::fs::new("./");
|
||||
|
||||
// The URL we will fetch - the readme for this library.
|
||||
let url = "https://git.kemitix.net/kemitix/kxio/raw/branch/main/README.md";
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
//! Create a new `FileSystem` to access a directory using `kxio::fs::new(path)`.
|
||||
//! Create a new `TempFileSystem` to access a temporary directory using `kxio::fs::temp()?`;
|
||||
//!
|
||||
//! `TempFileSystem` derefs automaticalyl to `FileSystem` so can be used anywhere
|
||||
//! `TempFileSystem` derefs automatically to `FileSystem` so can be used anywhere
|
||||
//! you would use `FileSystem`.
|
||||
//!
|
||||
//! ```
|
||||
|
@ -81,8 +81,8 @@ pub use system::{DirHandle, FileHandle, FileSystem, PathHandle};
|
|||
/// Any attempt to access outside this base will result in a
|
||||
/// `error::Error::PathTraversal` error when attempting the
|
||||
/// opertation.
|
||||
pub const fn new(base: PathBuf) -> FileSystem {
|
||||
FileSystem::new(base)
|
||||
pub fn new(base: impl Into<PathBuf>) -> FileSystem {
|
||||
FileSystem::new(base.into())
|
||||
}
|
||||
|
||||
/// Creates a new `TempFileSystem` for a temporary directory.
|
||||
|
|
Loading…
Reference in a new issue