#[non_exhaustive]pub struct Publishable { /* private fields */ }Expand description
Files a plugin ships in its binary that plugin:publish copies into the
app, all under one PublishTag. A module that names itself a plugin
contributes it with m.contribute(..).
Each path is relative to the tag’s folder, with / between segments. The
boot (and check) fails when a module that does not name itself a plugin
contributes one, and when a path is not safe: empty, longer than 255 bytes
(also once placed in its folder), or with a segment longer than 128 bytes;
an empty, . or .. segment, a leading /, a \, a : or a control
character; one of <>"|?*; a segment ending in . or a space; a segment
named after a Windows device (con, prn, aux, nul, conin$,
conout$, com0 to com9, lpt0 to lpt9, com¹ to com³, lpt¹ to
lpt³, in any case, with or without an extension); two paths of one
plugin under one tag that differ only in case (their lower-case forms or
their upper-case forms are equal), or a path that another of them needs
as its folder (admin beside admin/edit.html). Under locales the
first segment is the locale.
use navree_kernel::{PublishTag, Publishable};
let views = Publishable::new(PublishTag::Views)
.file("list.html", b"<ul><li>Simran Kaur: fees of \xe2\x82\xb91,00,000 are due</li></ul>")
.file("show.html", b"<p></p>");
assert_eq!(views.tag(), PublishTag::Views);
assert_eq!(views.files().count(), 2);Implementations§
Source§impl Publishable
impl Publishable
Sourcepub fn new(tag: PublishTag) -> Publishable
pub fn new(tag: PublishTag) -> Publishable
No files yet, under tag.
Sourcepub fn file(
self,
path: impl Into<Cow<'static, str>>,
bytes: &'static [u8],
) -> Publishable
pub fn file( self, path: impl Into<Cow<'static, str>>, bytes: &'static [u8], ) -> Publishable
Adds a file: path relative to the tag’s folder, bytes embedded in
the binary (with include_bytes!, say).
Sourcepub fn tag(&self) -> PublishTag
pub fn tag(&self) -> PublishTag
The tag the files are published under.