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§
- chars
- Common characters expressed as a single byte each, according to UTF-8.
- extensions
- Parsing utilities and constants for Kvarn extensions.
- parse
- General parsing complying to the HTTP standards.
- prelude
- The prelude for common web application utilities.
Macros§
- build_
bytes - Convenience macro to create a
Bytes
from multiple&[u8]
sources. - field_
str - 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.
- fmt_
field - Adds a
$field
to thestd::fmt::DebugStruct
,$f
from$self
. - fmt_
fields fmt_field!
but multiple.- ident_
str - Return stringified representation of
$item
. This uses similar techniques toident_str!
. - starts_
with_ any - Tests if the first arguments starts with any of the following.
Structs§
- Clean
Debug - Implements
Debug
from theDisplay
implementation ofvalue
. - Critical
Request Components - Critical components from request to apply to response.
- Present
Arguments - The arguments and name of a single
Present
extension. - Present
Arguments Iter - An iterator of
str
for the arguments inPresentArguments
- Present
Extensions - The
Present
extensions parsed from a file containing them. - Present
Extensions Iter - An iterator of
PresentArguments
fromPresentExtensions
- Quoted
StrSplit Iter - Iterator for
quoted_str_split
. Returns owned strings. - Value
Quality Set - A pair of a value string and a quality of said value.
- Writeable
Bytes - A writeable
Bytes
.
Enums§
- Bytes
Cow Bytes
but potentiallyBytesMut
, which enables e.g. changing the data without allocations when chainingPresent
extensions.
Traits§
- AsClean
Debug - Trait to enable
.as_clean
to get aCleanDebug
for the variable.
Functions§
- empty_
clone_ request - Clones a
Request
, discarding the body. - empty_
clone_ response - Clones a
Response
, discarding the body. - encode_
quoted_ str - Encodes, to be decoded by
quoted_str_split
,src
by appending todest
. - get_
body_ length_ request - Gets the body length from the
Request::headers
ofrequest
. - get_
body_ length_ response - Gets the body length of a
response
. - hardcoded_
error_ body - Get a hardcoded error message.
- header_
eq - Checks the equality of value of
name
inheaders
andvalue
. Value does not need to be all lowercase; the equality operation ignores the cases. - is_
valid_ header_ value_ byte - Checks
byte
if it’s a valid byte forHeaderValue
s. - join
- Joins the items in
iter
with aseparator
using 1 allocation. - list_
header - Parses a header with a value-quality list of pairs.
- make_
path - Makes a
PathBuf
using one allocation. - method_
has_ response_ body - Does a response of type
method
have a body? - percent_
decode - Decodes the URI encoding.
- quoted_
str_ split - Shell-like splitting of
s
. - remove_
all_ headers - Removes all headers from
headers
withname
. - sanitize_
request - Sanitizes
request
for unwanted data and returns critical components. - set_
content_ length - Sets the
content-length
ofheaders
tolen
. - split_
response - Splits a
Response
into a emptyResponse
and it’s body. - valid_
method - Check if
bytes
starts with a validMethod
. - valid_
version - Checks if
bytes
starts with a validVersion