feat(fs): kxio::fs::new(...) now accepts impl Into<PathBuf>
All checks were successful
Rust / build (map[name:stable]) (push) Successful in 1m22s
Rust / build (map[name:nightly]) (push) Successful in 3m50s
Release Please / Release-plz (push) Successful in 32s

This commit is contained in:
Paul Campbell 2024-11-09 19:34:01 +00:00
parent 4f990f907c
commit a0262a4d05
2 changed files with 5 additions and 5 deletions

View file

@ -8,7 +8,7 @@
/// ///
/// NOTE: running this program with `cargo run --example get` will create and delete the file /// NOTE: running this program with `cargo run --example get` will create and delete the file
/// `example-readme.md` in the current directory. /// `example-readme.md` in the current directory.
use std::path::{Path, PathBuf}; use std::path::Path;
#[tokio::main] #[tokio::main]
async fn main() -> kxio::Result<()> { 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. // 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\ // The object created will return a `PathTraveral` error result if there is an attempt to\
// access a file outside of this directory. // 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. // The URL we will fetch - the readme for this library.
let url = "https://git.kemitix.net/kemitix/kxio/raw/branch/main/README.md"; let url = "https://git.kemitix.net/kemitix/kxio/raw/branch/main/README.md";

View file

@ -3,7 +3,7 @@
//! Create a new `FileSystem` to access a directory using `kxio::fs::new(path)`. //! 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()?`; //! 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`. //! 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 /// Any attempt to access outside this base will result in a
/// `error::Error::PathTraversal` error when attempting the /// `error::Error::PathTraversal` error when attempting the
/// opertation. /// opertation.
pub const fn new(base: PathBuf) -> FileSystem { pub fn new(base: impl Into<PathBuf>) -> FileSystem {
FileSystem::new(base) FileSystem::new(base.into())
} }
/// Creates a new `TempFileSystem` for a temporary directory. /// Creates a new `TempFileSystem` for a temporary directory.