diff --git a/rinja/src/error.rs b/rinja/src/error.rs index 25c195b6..e0648394 100644 --- a/rinja/src/error.rs +++ b/rinja/src/error.rs @@ -1,6 +1,7 @@ use std::convert::Infallible; use std::fmt::{self, Display}; +/// The [`Result`](std::result::Result) type with [`Error`] as default error type pub type Result = std::result::Result; /// rinja error type diff --git a/rinja/src/filters/escape.rs b/rinja/src/filters/escape.rs index b2ba0a17..3f4f0012 100644 --- a/rinja/src/filters/escape.rs +++ b/rinja/src/filters/escape.rs @@ -108,8 +108,10 @@ impl Escaper for Text { /// E.g. in an [`Html`] context, any and all generated text can be used in HTML/XML text nodes and /// attributes, without for for maliciously injected data. pub trait Escaper: Copy { + /// Escaped the input string `string` into `fmt` fn write_escaped_str(&self, fmt: W, string: &str) -> fmt::Result; + /// Escaped the input char `c` into `fmt` #[inline] fn write_escaped_char(&self, fmt: W, c: char) -> fmt::Result { self.write_escaped_str(fmt, c.encode_utf8(&mut [0; 4])) @@ -118,9 +120,12 @@ pub trait Escaper: Copy { /// Used internally by rinja to select the appropriate escaper pub trait AutoEscape { + /// The wrapped or converted result type type Escaped: fmt::Display; + /// Early error testing for the input value, usually [`Infallible`] type Error: Into; + /// Used internally by rinja to select the appropriate escaper fn rinja_auto_escape(&self) -> Result; } @@ -132,6 +137,7 @@ pub struct AutoEscaper<'a, T: ?Sized, E> { } impl<'a, T: ?Sized, E> AutoEscaper<'a, T, E> { + /// Used internally by rinja to select the appropriate escaper #[inline] pub fn new(text: &'a T, escaper: E) -> Self { Self { text, escaper } @@ -214,7 +220,9 @@ impl<'a, T: HtmlSafe + ?Sized> AutoEscape for &AutoEscaper<'a, T, Html> { /// ); /// ``` pub enum MaybeSafe { + /// The contained value does not need escaping Safe(T), + /// The contained value needs to be escaped NeedsEscaping(T), } @@ -424,6 +432,7 @@ pub struct Writable<'a, S: ?Sized>(pub &'a S); /// Used internally by rinja to select the appropriate [`write!()`] mechanism pub trait WriteWritable { + /// Used internally by rinja to select the appropriate [`write!()`] mechanism fn rinja_write(&self, dest: &mut W) -> fmt::Result; } @@ -431,6 +440,7 @@ pub trait WriteWritable { /// /// Types implementing this trait can be written without needing to employ an [`fmt::Formatter`]. pub trait FastWritable { + /// Used internally by rinja to speed up writing some types. fn write_into(&self, dest: &mut W) -> fmt::Result; } diff --git a/rinja/src/filters/json.rs b/rinja/src/filters/json.rs index 48bdbcb5..debada2e 100644 --- a/rinja/src/filters/json.rs +++ b/rinja/src/filters/json.rs @@ -55,7 +55,15 @@ struct ToJsonPretty { indent: I, } +/// A prefix usable for indenting [prettified JSON data](json_pretty) +/// +/// ``` +/// # use rinja::filters::AsIndent; +/// assert_eq!(4.as_indent(), " "); +/// assert_eq!(" -> ".as_indent(), " -> "); +/// ``` pub trait AsIndent { + /// Borrow `self` as prefix to use. fn as_indent(&self) -> &str; } diff --git a/rinja/src/lib.rs b/rinja/src/lib.rs index a3012e3f..3e168080 100644 --- a/rinja/src/lib.rs +++ b/rinja/src/lib.rs @@ -57,6 +57,7 @@ #![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))] #![deny(elided_lifetimes_in_paths)] #![deny(unreachable_pub)] +#![deny(missing_docs)] mod error; pub mod filters;