gazetta_core/view/
mod.rs

1//  Copyright (C) 2015 Steven Allen
2//
3//  This file is part of gazetta.
4//
5//  This program is free software: you can redistribute it and/or modify it under the terms of the
6//  GNU General Public License as published by the Free Software Foundation version 3 of the
7//  License.
8//
9//  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
10//  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See
11//  the GNU General Public License for more details.
12//
13//  You should have received a copy of the GNU General Public License along with this program.  If
14//  not, see <http://www.gnu.org/licenses/>.
15//
16
17use std::fmt;
18
19use crate::render::Gazetta;
20
21mod index;
22mod page;
23mod site;
24
25pub use self::index::{Index, Paginate};
26pub use self::page::{Content, Page};
27pub use self::site::Site;
28
29pub struct Context<'a, G>
30where
31    G: Gazetta,
32{
33    pub page: &'a Page<'a, G>,
34    pub site: &'a Site<'a, G>,
35}
36
37impl<'a, G> Copy for Context<'a, G>
38where
39    G: Gazetta + 'a,
40    G::PageMeta: 'a,
41    G::SiteMeta: 'a,
42{
43}
44
45impl<'a, G> Clone for Context<'a, G>
46where
47    G: Gazetta + 'a,
48    G::PageMeta: 'a,
49    G::SiteMeta: 'a,
50{
51    fn clone(&self) -> Self {
52        *self
53    }
54}
55
56impl<'a, G> fmt::Debug for Context<'a, G>
57where
58    G: Gazetta + 'a,
59    G::PageMeta: fmt::Debug + 'a,
60    G::SiteMeta: fmt::Debug + 'a,
61{
62    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
63        f.debug_struct("Context")
64            .field("site", &self.site)
65            .field("page", &self.page)
66            .finish()
67    }
68}