qrkit/content
Domain-specific helpers that produce QR-ready payload strings.
iCalendar and vCard renderers in this module follow RFC 5545 and RFC 2426 to the byte level:
- Lines are terminated with
CRLF(\r\n) (RFC 5545 §3.1, RFC 2426 §2.1). - Lines longer than 75 octets are folded with
CRLF<space>(RFC 5545 §3.1, RFC 2426 §2.6). Folding is byte-based and does not split inside a multi-byte UTF-8 sequence. - TEXT-value escape helpers strip raw
CRandNULand escape\,\n,,,;(RFC 5545 §3.3.11, RFC 2426 §2.4.2). event_to_stringemits the RFC-requiredPRODID(VCALENDAR- level) plusUIDandDTSTAMP(VEVENT-level).UIDis derived deterministically from the event’s title and timestamps so the same event produces the same UID across runs;DTSTAMPdefaults to the event’sstart_unix(no clock is available in a pure rendering function).event_to_stringinall_daymode bumpsDTENDtostart_date + 1 daywhen the caller passedend_unix == start_unix, matching RFC 5545 §3.6.1’s non-inclusive-end requirement for DATE-valued events.vcard_to_stringalways emits the RFC 2426 MANDATORYNandFNproperties; when the caller did not set a name they are emitted with empty values (N:;;;;andFN:) so the structure is still RFC-conformant.
Types
pub opaque type CalendarEvent
pub type WifiSecurity {
Open
Wep
Wpa
Wpa2
Wpa3
}
Constructors
-
Open -
Wep -
Wpa -
Wpa2 -
Wpa3
Values
pub fn email(
to to: String,
subject subject: String,
body body: String,
) -> String
Build a mailto: payload conformant to RFC 6068.
The to field is encoded as an addr-spec (RFC 6068 §2): the
structural separators @ and , are kept literal, as are the
some-delims characters (!, $, ', (, ), *, +,
;, :) — only characters that would actually break URI parsing
in this position (space, ?, &, #, <, >, control bytes,
non-ASCII) are percent-encoded. The subject and body hfvalues
keep the wider RFC 3986 percent-encoding the stdlib provides so
? / & / # / space / % are still escaped in those fields.
(#21)
pub fn event(
title title: String,
start_unix start_unix: Int,
end_unix end_unix: Int,
) -> CalendarEvent
Create a calendar event payload builder.
pub fn event_to_string(event: CalendarEvent) -> String
Render a calendar event as an iCalendar payload, RFC 5545
conformant. Includes the required PRODID / UID / DTSTAMP
properties (#14). In all_day mode DTEND is bumped to
start + 1 day when the caller passed end_unix == start_unix
so the resulting DATE range is non-inclusive per §3.6.1 (#16).
Unix timestamps before the epoch are floor-divided so negative
inputs format correctly (#9), and the year is clamped to
[1, 9999] to preserve the 4-digit-year fixed-width format
(#10).
pub fn geo(
latitude latitude: Float,
longitude longitude: Float,
) -> String
Build a geo URI.
pub fn vcard_to_string(card: VCard) -> String
Render the vCard as a text payload, RFC 2426 conformant.
The mandatory N and FN properties are always emitted —
when no name was set via with_name they are
emitted with empty values (N:;;;; and FN:) so the structure
matches RFC 2426 §3.1.1 / §3.1.2. Lines are CRLF-terminated and
folded at 75 octets per RFC 2426 §2.1 / §2.6.
pub fn wifi(
ssid ssid: String,
password password: String,
security security: WifiSecurity,
hidden hidden: Bool,
) -> String
Build a WiFi payload string.
pub fn with_all_day(
event: CalendarEvent,
all_day: Bool,
) -> CalendarEvent
Toggle all-day rendering.
pub fn with_description(
event: CalendarEvent,
desc: String,
) -> CalendarEvent
Set the event description.
pub fn with_location(
event: CalendarEvent,
loc: String,
) -> CalendarEvent
Set the event location.