pub struct Paths {
pub site: PathBuf,
pub content: PathBuf,
pub build: PathBuf,
pub template: PathBuf,
}Expand description
Represents the necessary directory paths for the site generator.
Fields§
§site: PathBufThe site output directory
content: PathBufThe content directory
build: PathBufThe build directory
template: PathBufThe template directory
Implementations§
Source§impl Paths
impl Paths
Sourcepub fn builder() -> PathsBuilder
pub fn builder() -> PathsBuilder
Creates a new builder for configuring Paths
§Examples
use ssg::Paths;
let paths = Paths::builder()
.site("out")
.content("docs")
.build_dir("tmp")
.template("tpl")
.build()
.expect("valid paths");
assert_eq!(paths.site.to_str(), Some("out"));Sourcepub fn default_paths() -> Self
pub fn default_paths() -> Self
Creates paths with default directories
§Examples
use ssg::Paths;
let paths = Paths::default_paths();
assert_eq!(paths.site.to_str(), Some("public"));
assert_eq!(paths.content.to_str(), Some("content"));
assert_eq!(paths.build.to_str(), Some("build"));
assert_eq!(paths.template.to_str(), Some("templates"));Source§impl Paths
impl Paths
Sourcepub fn validate(&self) -> Result<(), SsgError>
pub fn validate(&self) -> Result<(), SsgError>
Validates all paths in the configuration
§Examples
use ssg::Paths;
use std::path::PathBuf;
let good = Paths::default_paths();
assert!(good.validate().is_ok());
let bad = Paths {
site: PathBuf::from("../escape"),
content: PathBuf::from("content"),
build: PathBuf::from("build"),
template: PathBuf::from("templates"),
};
assert!(bad.validate().is_err());§Errors
Returns SsgError::PathTraversal if any path contains ..,
SsgError::Validation for malformed paths, or
SsgError::SymlinkForbidden if a path points at a symlink.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Paths
impl RefUnwindSafe for Paths
impl Send for Paths
impl Sync for Paths
impl Unpin for Paths
impl UnsafeUnpin for Paths
impl UnwindSafe for Paths
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more