Crate kvarn_utils

Source
Expand description

Utility functions for web application development.

This includes

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 the std::fmt::DebugStruct, $f from $self.
fmt_fields
fmt_field! but multiple.
ident_str
Return stringified representation of $item. This uses similar techniques to ident_str!.
starts_with_any
Tests if the first arguments starts with any of the following.

Structs§

CleanDebug
Implements Debug from the Display implementation of value.
CriticalRequestComponents
Critical components from request to apply to response.
PresentArguments
The arguments and name of a single Present extension.
PresentArgumentsIter
An iterator of str for the arguments in PresentArguments
PresentExtensions
The Present extensions parsed from a file containing them.
PresentExtensionsIter
An iterator of PresentArguments from PresentExtensions
QuotedStrSplitIter
Iterator for quoted_str_split. Returns owned strings.
ValueQualitySet
A pair of a value string and a quality of said value.
WriteableBytes
A writeable Bytes.

Enums§

BytesCow
Bytes but potentially BytesMut, which enables e.g. changing the data without allocations when chaining Present extensions.

Traits§

AsCleanDebug
Trait to enable .as_clean to get a CleanDebug 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 to dest.
get_body_length_request
Gets the body length from the Request::headers of request.
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 in headers and value. 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 for HeaderValues.
join
Joins the items in iter with a separator 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 with name.
sanitize_request
Sanitizes request for unwanted data and returns critical components.
set_content_length
Sets the content-length of headers to len.
split_response
Splits a Response into a empty Response and it’s body.
valid_method
Check if bytes starts with a valid Method.
valid_version
Checks if bytes starts with a valid Version