Source

Struct Source 

Source
pub struct Source<SourceMeta = (), EntryMeta = ()>
where SourceMeta: Meta, EntryMeta: Meta,
{ pub title: String, pub root: PathBuf, pub origin: String, pub prefix: String, pub entries: Vec<Entry<EntryMeta>>, pub static_entries: Vec<StaticEntry>, pub stylesheets: Vec<PathBuf>, pub javascript: Vec<PathBuf>, pub icon: Option<PathBuf>, pub well_known: Option<PathBuf>, pub meta: SourceMeta, }
Expand description

The Source object reads and interprets a source directory.

The fields are intentionally public. Feel free to manually generate or modify this structure.

Fields§

§title: String

The website’s title.

By default, this field is read from gazetta.yaml.

§root: PathBuf

The source root directory.

This is specified on construction.

§origin: String

The website origin (http://mydomain.com:1234)

By default, this field is derived from the value of base in gazetta.yaml.

§prefix: String

The directory under the origin at which this site will be hosted (e.g. “/”).

By default, this field is derived from the value of base in gazetta.yaml.

§entries: Vec<Entry<EntryMeta>>

The website content to be rendered.

By default, this list is populated with Entries generated from files with the basename index under the root directory excluding:

  1. Files under directories named “static”.

  2. Files under assets/.

§static_entries: Vec<StaticEntry>

The website content to be deployed as-is (no rendering).

By default, this list is populated with directories under the root directory named “static” excluding:

  1. Directories under directories named “static”.

  2. Directories under assets/.

§stylesheets: Vec<PathBuf>

The website stylesheets. When rendered, these will be concatenated into a single stylesheet.

By default, this list is populated by the files in is assets/stylesheets/ in lexicographical order.

§javascript: Vec<PathBuf>

The website javascript. When rendered, these will be concatenated into a single javascript file.

By default, this list is populated by the files in is assets/javascript/ in lexicographical order.

§icon: Option<PathBuf>

The path to the website’s icon.

By default, this points to assets/icon.png (if it exists).

§well_known: Option<PathBuf>

The path to the .well-known directory.

By default, this points to .well-known.

§meta: SourceMeta

Additional metadata read from gazetta.yaml.

Implementations§

Source§

impl<SourceMeta, EntryMeta> Source<SourceMeta, EntryMeta>
where SourceMeta: Meta, EntryMeta: Meta,

Source

pub fn index<'a>( &'a self, ) -> Result<IndexedSource<'a, SourceMeta, EntryMeta>, SourceError>

Build the IndexedSource for this Source.

Source

pub fn new<P: AsRef<Path>>(root: P) -> Result<Self, AnnotatedError<SourceError>>

Parse a source directory to create a new source.

Source

pub fn reload(&mut self) -> Result<(), AnnotatedError<SourceError>>

Reload from the source directory.

Call this after changing source files.

Trait Implementations§

Source§

impl<SourceMeta, EntryMeta> Clone for Source<SourceMeta, EntryMeta>
where SourceMeta: Meta + Clone, EntryMeta: Meta + Clone,

Source§

fn clone(&self) -> Source<SourceMeta, EntryMeta>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<SourceMeta, EntryMeta> Debug for Source<SourceMeta, EntryMeta>
where SourceMeta: Meta + Debug, EntryMeta: Meta + Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<SourceMeta, EntryMeta> Freeze for Source<SourceMeta, EntryMeta>
where SourceMeta: Freeze,

§

impl<SourceMeta, EntryMeta> RefUnwindSafe for Source<SourceMeta, EntryMeta>
where SourceMeta: RefUnwindSafe, EntryMeta: RefUnwindSafe,

§

impl<SourceMeta, EntryMeta> Send for Source<SourceMeta, EntryMeta>
where SourceMeta: Send, EntryMeta: Send,

§

impl<SourceMeta, EntryMeta> Sync for Source<SourceMeta, EntryMeta>
where SourceMeta: Sync, EntryMeta: Sync,

§

impl<SourceMeta, EntryMeta> Unpin for Source<SourceMeta, EntryMeta>
where SourceMeta: Unpin, EntryMeta: Unpin,

§

impl<SourceMeta, EntryMeta> UnwindSafe for Source<SourceMeta, EntryMeta>
where SourceMeta: UnwindSafe, EntryMeta: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> ErasedDestructor for T
where T: 'static,