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:

Types

pub opaque type CalendarEvent
pub opaque type VCard
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 phone(number: String) -> String

Build a phone URI.

pub fn sms(to to: String, body body: String) -> String

Build an SMS payload.

pub fn url(href: String) -> String

Return a URL payload unchanged.

pub fn vcard() -> VCard

Create an empty vCard builder.

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_address(card: VCard, address: String) -> VCard

Set the address field.

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_email(card: VCard, email: String) -> VCard

Set the e-mail address.

pub fn with_location(
  event: CalendarEvent,
  loc: String,
) -> CalendarEvent

Set the event location.

pub fn with_name(card: VCard, name: String) -> VCard

Set the display name.

pub fn with_organization(card: VCard, org: String) -> VCard

Set the organization field.

pub fn with_phone(card: VCard, phone: String) -> VCard

Set the phone number.

pub fn with_title(card: VCard, title: String) -> VCard

Set the title field.

pub fn with_url(card: VCard, url: String) -> VCard

Set the URL field.

Search Document