pub struct PathsBuilder {
pub site: Option<PathBuf>,
pub content: Option<PathBuf>,
pub build: Option<PathBuf>,
pub template: Option<PathBuf>,
}Expand description
Builder for creating Paths configurations
Fields§
§site: Option<PathBuf>The site output directory
content: Option<PathBuf>The content directory
build: Option<PathBuf>The build directory
template: Option<PathBuf>The template directory
Implementations§
Source§impl PathsBuilder
impl PathsBuilder
Sourcepub fn site<P: Into<PathBuf>>(self, path: P) -> Self
pub fn site<P: Into<PathBuf>>(self, path: P) -> Self
Sets the site output directory
§Examples
use ssg::PathsBuilder;
let b = PathsBuilder::default().site("dist");
assert_eq!(b.site.as_deref().and_then(|p| p.to_str()), Some("dist"));Sourcepub fn content<P: Into<PathBuf>>(self, path: P) -> Self
pub fn content<P: Into<PathBuf>>(self, path: P) -> Self
Sets the content directory
§Examples
use ssg::PathsBuilder;
let b = PathsBuilder::default().content("posts");
assert_eq!(b.content.as_deref().and_then(|p| p.to_str()), Some("posts"));Sourcepub fn build_dir<P: Into<PathBuf>>(self, path: P) -> Self
pub fn build_dir<P: Into<PathBuf>>(self, path: P) -> Self
Sets the build directory
§Examples
use ssg::PathsBuilder;
let b = PathsBuilder::default().build_dir("work");
assert_eq!(b.build.as_deref().and_then(|p| p.to_str()), Some("work"));Sourcepub fn template<P: Into<PathBuf>>(self, path: P) -> Self
pub fn template<P: Into<PathBuf>>(self, path: P) -> Self
Sets the template directory
§Examples
use ssg::PathsBuilder;
let b = PathsBuilder::default().template("layouts");
assert_eq!(b.template.as_deref().and_then(|p| p.to_str()), Some("layouts"));Sourcepub fn relative_to<P: AsRef<Path>>(self, base: P) -> Self
pub fn relative_to<P: AsRef<Path>>(self, base: P) -> Self
Sets all paths relative to a base directory
§Examples
use ssg::PathsBuilder;
let paths = PathsBuilder::default()
.relative_to("site")
.build()
.expect("valid");
assert!(paths.site.ends_with("public"));
assert!(paths.content.ends_with("content"));Sourcepub fn build(self) -> Result<Paths, SsgError>
pub fn build(self) -> Result<Paths, SsgError>
Builds the Paths configuration
§Returns
Result<Paths>- The configured paths if valid
§Examples
use ssg::PathsBuilder;
let paths = PathsBuilder::default().build().expect("defaults valid");
assert_eq!(paths.site.to_str(), Some("public"));§Errors
Returns an error if:
- Required paths are missing
- Paths are invalid or unsafe
- Unable to create necessary directories
Trait Implementations§
Source§impl Clone for PathsBuilder
impl Clone for PathsBuilder
Source§fn clone(&self) -> PathsBuilder
fn clone(&self) -> PathsBuilder
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for PathsBuilder
impl Debug for PathsBuilder
Source§impl Default for PathsBuilder
impl Default for PathsBuilder
Source§fn default() -> PathsBuilder
fn default() -> PathsBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for PathsBuilder
impl RefUnwindSafe for PathsBuilder
impl Send for PathsBuilder
impl Sync for PathsBuilder
impl Unpin for PathsBuilder
impl UnsafeUnpin for PathsBuilder
impl UnwindSafe for PathsBuilder
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