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: Stringlen: usizelimit: usizequeued_tags: Vec<&'static str>

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.

unclosed_tags: Vec<&'static str>

A list of all tags that have been opened but not yet closed.

Implementations

Create a new buffer, with a limit of length_limit.

Finish using the buffer and get the written output. This function will close all unclosed tags for you.

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.

Open an HTML tag.

Note: HTML attributes have not yet been implemented. This function will panic if called with a non-alphabetic tag_name.

Close the most recently opened HTML tag.

Write all queued tags and add them to the unclosed_tags list.

Close all unclosed tags.

Trait Implementations

Formats the value using the given formatter. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more

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