Crate kvarn_utils
source · [−]Expand description
Utility functions for web application development.
This includes
- commonly used
chars
, - a
build_bytes
macro to create aBytes
from bytes slices with one allocation, WriteableBytes
to optimize performance when creating a newBytes
of unknown length,hardcoded_error_body
to get a hard-coded error response.CleanDebug
and it’s traitAsCleanDebug
to get aDebug
implementation wired to the item’sDisplay
implementation.
Modules
Common characters expressed as a single byte each, according to UTF-8.
Parsing utilities and constants for Kvarn extensions.
General parsing complying to the HTTP standards.
The prelude for common web application utilities.
Macros
Convenience macro to create a Bytes
from multiple &[u8]
sources.
Stringify $field on $self. This only returns the field name. This is constructed to make your IDE recognize the input as the actual field. This means renaming is applied to the string returned from this when you rename a field in your IDE.
Adds a $field
to the std::fmt::DebugStruct
, $f
from $self
.
fmt_field!
but multiple.
Return stringified representation of $item
.
This uses similar techniques to ident_str!
.
Tests if the first arguments starts with any of the following.
Structs
Critical components from request to apply to response.
The arguments and name of a single Present
extension.
An iterator of str
for the arguments in PresentArguments
The Present
extensions parsed from a file containing them.
An iterator of PresentArguments
from PresentExtensions
Iterator for quoted_str_split
.
Returns owned strings.
Should only be used from within Kvarn! A super-unsafe pointer. Must be used with great care.
A pair of a value string and a quality of said value.
A writeable Bytes
.
Traits
Trait to enable .as_clean
to get a CleanDebug
for the variable.
Functions
Clones a Request
, discarding the body.
Clones a Response
, discarding the body.
Encodes, to be decoded by quoted_str_split
, src
by appending to dest
.
Gets the body length from the Request::headers
of request
.
Gets the body length of a response
.
Get a hardcoded error message.
Checks the equality of value of name
in headers
and value
.
Value does not need to be all lowercase; the equality operation ignores the cases.
Checks byte
if it’s a valid byte for HeaderValue
s.
Joins the items in iter
with a separator
using 1 allocation.
Parses a header with a value-quality list of pairs.
Does a request of type method
have a body?
Does a response of type method
have a body?
Decodes the URI encoding.
Shell-like splitting of s
.
Casts &T
to *mut T
for getting mutable access from a immutable reference.
Removes all headers from headers
with name
.
Sanitizes request
for unwanted data and returns critical components.
Sets the content-length
of headers
to len
.
Check if bytes
starts with a valid Method
.
Checks if bytes
starts with a valid Version