Module tools

Source
Expand description

Some tools and enhancements to the used libraries, there should be no references to Context and other “larger” entities here.

Structs§

MailTo
Struct containing all mailto information
SystemTime
A measurement of the system clock, useful for talking to external entities like the file system or other processes.
TempPathGuard 🔒
A guard which will remove the path when dropped.
Time
A measurement of the system clock, useful for talking to external entities like the file system or other processes.

Constants§

BROTLI_BUFSZ 🔒
Compressor/decompressor buffer size.

Traits§

IsNoneOrEmpty 🔒
ToOption 🔒

Functions§

buf_compress 🔒
Compresses buf to Vec using brotli. Note that it handles an empty buf as a special value that remains empty after compression, otherwise brotli would add its metadata to it which is not nice because this function is used for compression of strings stored in the db and empty strings are common there. This approach is not strictly correct because nowhere in the brotli documentation is said that an empty buffer can’t be a result of compression of some input, but i think this will never break.
buf_decompress 🔒
Decompresses buf to Vec using brotli. See buf_compress() for why we don’t pass an empty buffer to brotli decompressor.
create_folder 🔒
create_id 🔒
Generate an unique ID.
create_outgoing_rfc724_mid 🔒
Function generates a Message-ID that can be used for a new outgoing message.
create_smeared_timestamp 🔒
Returns a timestamp that is guaranteed to be unique.
create_smeared_timestamps 🔒
delete_file 🔒
duration_to_str
Converts duration to string representation suitable for logs.
extract_address_from_receive_header 🔒
get_abs_path 🔒
Expand paths relative to $BLOBDIR into absolute paths.
get_filebytes 🔒
get_filemeta
Returns the (width, height) of the given image buffer.
get_filesuffix_lc
get_release_timestamp
Returns the last release timestamp as a unix timestamp compatible for comparison with time() and database times.
gm2local_offset 🔒
inc_and_check 🔒
Increments *t and checks that it equals to expected after that.
maybe_add_time_based_warnings 🔒
maybe_warn_on_bad_time 🔒
maybe_warn_on_outdated 🔒
open_file
open_file_std
parse_mailto
Parse mailto urls
parse_receive_header 🔒
parse_receive_headers 🔒
parses “receive”-headers
read_dir
Reads directory and returns a vector of directory entries.
read_file
Reads the file and returns its context as a byte vector.
remove_subject_prefix
sanitize_filename 🔒
Create a safe name based on a messy input string.
single_value 🔒
If collection contains exactly one element, return this element. Otherwise, return None.
smeared_time 🔒
Returns the current smeared timestamp,
time 🔒
time_elapsed 🔒
timestamp_to_str
Converts Unix time in seconds to a local timestamp string.
truncate 🔒
Shortens a string to a specified length and adds “[…]” to the end of the shortened string.
truncate_by_lines 🔒
Shortens a string to a specified line count and adds “[…]” to the end of the shortened string.
truncate_msg_text 🔒
Shortens a message text if necessary according to the configuration. Adds “[…]” to the end of the shortened text.
validate_id 🔒
Returns true if given string is a valid ID.
write_file 🔒
Write a the given content to provided file path.