pub struct FsContentProvider { /* private fields */ }Expand description
Filesystem-backed ContentProvider for the build-time pipeline.
Resolves keys relative to a configured root directory. This is the
default adapter used by ssg build and is intentionally a thin
wrapper around std::fs::read so the existing batch pipeline keeps
its byte-identical behaviour (AC9).
§Examples
use ssg_core::{ContentProvider, FsContentProvider};
let dir = tempfile::tempdir().unwrap();
std::fs::write(dir.path().join("a.md"), b"# A").unwrap();
let fs = FsContentProvider::new(dir.path());
assert_eq!(fs.fetch("a.md").unwrap(), b"# A");Implementations§
Source§impl FsContentProvider
impl FsContentProvider
Sourcepub fn new<P: Into<PathBuf>>(root: P) -> Self
pub fn new<P: Into<PathBuf>>(root: P) -> Self
Constructs an FsContentProvider rooted at root.
root is typically the site directory — every fetched key is
resolved as root.join(key).
§Examples
use ssg_core::FsContentProvider;
let dir = tempfile::tempdir().unwrap();
let fs = FsContentProvider::new(dir.path());
assert_eq!(fs.root(), dir.path());Trait Implementations§
Source§impl Clone for FsContentProvider
impl Clone for FsContentProvider
Source§fn clone(&self) -> FsContentProvider
fn clone(&self) -> FsContentProvider
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 ContentProvider for FsContentProvider
impl ContentProvider for FsContentProvider
Source§fn fetch(&self, key: &str) -> ProviderResult<Vec<u8>>
fn fetch(&self, key: &str) -> ProviderResult<Vec<u8>>
Fetches the raw bytes for
key, or returns an error. Read moreSource§fn contains(&self, key: &str) -> bool
fn contains(&self, key: &str) -> bool
Reports whether
key exists without materialising the bytes. Read moreSource§fn fetch_string(&self, key: &str) -> ProviderResult<String>
fn fetch_string(&self, key: &str) -> ProviderResult<String>
Convenience: fetches
key and decodes as UTF-8. Read moreAuto Trait Implementations§
impl Freeze for FsContentProvider
impl RefUnwindSafe for FsContentProvider
impl Send for FsContentProvider
impl Sync for FsContentProvider
impl Unpin for FsContentProvider
impl UnsafeUnpin for FsContentProvider
impl UnwindSafe for FsContentProvider
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