Crates.io | faf-http-date |
lib.rs | faf-http-date |
version | 0.1.0 |
source | src |
created_at | 2021-03-31 22:01:34.070771 |
updated_at | 2021-03-31 22:01:34.070771 |
description | FAST date generation for HTTP Date header (no_std) |
homepage | https://github.com/errantmind/faf-http-date |
repository | https://github.com/errantmind/faf-http-date |
max_upload_size | |
id | 376353 |
size | 21,806 |
Quickly (~20ns) generate a date for an HTTP header, formatted to be fully compliant with RFCs 822/1123/2616. This is used in the faf web server
This crate is simple, you pass a buffer to the provided function. The function populates the buffer with the date
&str
or String
. See the examples belowThis is a heavily optimized, stripped, and otherwise modified version of pyfisch/httpdate
// Format: b"Thu, 01 Jan 1970 00:00:00 GMT"
let mut buf = faf_http_date::get_date_buff_no_key();
faf_http_date::get_date_no_key(&mut buf);
// Optional, convert to str
let date_str = unsafe { std::str::from_utf8_unchecked(&buf[..]) };
Format: b"Date: Thu, 01 Jan 1970 00:00:00 GMT" (notice the 'Date: ' at the first)
let mut buf = faf_http_date::get_date_buff_with_key();
faf_http_date::get_date_with_key(&mut buf);
// Optional, convert to str
let date_str = unsafe { std::str::from_utf8_unchecked(&buf[..]) };