Struct rustdoc::html::length_limit::HtmlWithLimit
source · pub(super) struct HtmlWithLimit {
buf: String,
len: usize,
limit: usize,
queued_tags: Vec<&'static str>,
unclosed_tags: Vec<&'static str>,
}
Expand description
A buffer that allows generating HTML with a length limit.
This buffer ensures that:
- all tags are closed,
- tags are closed in the reverse order of when they were opened (i.e., the correct HTML order),
- no tags are left empty (e.g.,
<em></em>
) due to the length limit being reached, - all text is escaped.
Fields§
§buf: String
§len: usize
§limit: usize
A list of tags that have been requested to be opened via Self::open_tag()
but have not actually been pushed to buf
yet. This ensures that tags are not
left empty (e.g., <em></em>
) due to the length limit being reached.
A list of all tags that have been opened but not yet closed.
Implementations§
source§impl HtmlWithLimit
impl HtmlWithLimit
sourcepub(super) fn new(length_limit: usize) -> Self
pub(super) fn new(length_limit: usize) -> Self
Create a new buffer, with a limit of length_limit
.
sourcepub(super) fn finish(self) -> String
pub(super) fn finish(self) -> String
Finish using the buffer and get the written output. This function will close all unclosed tags for you.
sourcepub(super) fn push(&mut self, text: &str) -> ControlFlow<(), ()>
pub(super) fn push(&mut self, text: &str) -> ControlFlow<(), ()>
Write some plain text to the buffer, escaping as needed.
This function skips writing the text if the length limit was reached
and returns ControlFlow::Break
.
sourcepub(super) fn open_tag(&mut self, tag_name: &'static str)
pub(super) fn open_tag(&mut self, tag_name: &'static str)
Open an HTML tag.
Note: HTML attributes have not yet been implemented.
This function will panic if called with a non-alphabetic tag_name
.
sourcefn flush_queue(&mut self)
fn flush_queue(&mut self)
Write all queued tags and add them to the unclosed_tags
list.
Close all unclosed tags.
Trait Implementations§
Auto Trait Implementations§
impl RefUnwindSafe for HtmlWithLimit
impl Send for HtmlWithLimit
impl Sync for HtmlWithLimit
impl Unpin for HtmlWithLimit
impl UnwindSafe for HtmlWithLimit
Blanket Implementations§
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: 88 bytes