pub struct SearchIndex {
pub entries: Vec<SearchEntry>,
}Expand description
The complete search index written to search-index.json.
Fields§
§entries: Vec<SearchEntry>All indexed pages.
Implementations§
Source§impl SearchIndex
impl SearchIndex
Sourcepub fn build(site_dir: &Path) -> Result<Self, SsgError>
pub fn build(site_dir: &Path) -> Result<Self, SsgError>
Build a search index from all HTML files in site_dir.
Walks the directory recursively, extracts content from each
.html file, and returns the populated index.
§Examples
use ssg::search::SearchIndex;
use tempfile::tempdir;
let dir = tempdir().unwrap();
// Empty dir ⇒ empty index, never an error.
let idx = SearchIndex::build(dir.path()).unwrap();
assert!(idx.is_empty());Sourcepub fn write(&self, site_dir: &Path) -> Result<(), SsgError>
pub fn write(&self, site_dir: &Path) -> Result<(), SsgError>
Write the index to search-index.json in the given directory.
§Examples
use ssg::search::SearchIndex;
use tempfile::tempdir;
let dir = tempdir().unwrap();
let idx = SearchIndex::build(dir.path()).unwrap();
idx.write(dir.path()).unwrap();
assert!(dir.path().join("search-index.json").exists());Trait Implementations§
Source§impl Clone for SearchIndex
impl Clone for SearchIndex
Source§fn clone(&self) -> SearchIndex
fn clone(&self) -> SearchIndex
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 SearchIndex
impl Debug for SearchIndex
Source§impl Default for SearchIndex
impl Default for SearchIndex
Source§fn default() -> SearchIndex
fn default() -> SearchIndex
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for SearchIndex
impl<'de> Deserialize<'de> for SearchIndex
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for SearchIndex
impl RefUnwindSafe for SearchIndex
impl Send for SearchIndex
impl Sync for SearchIndex
impl Unpin for SearchIndex
impl UnsafeUnpin for SearchIndex
impl UnwindSafe for SearchIndex
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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§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