glqr

Types

A calendar event for a vEvent payload Create one with calendar_event, add optional fields with the calendar_event_* functions, then convert it with calendar_event_to_string

pub opaque type CalendarEvent

Error correction levels for QR codes

  • L: Recovers 7% of data
  • M: Recovers 15% of data (default)
  • Q: Recovers 25% of data
  • H: Recovers 30% of data https://www.thonky.com/qr-code-tutorial/data-encoding (Step 1)
pub type ErrorCorrectionLevel {
  L
  M
  Q
  H
}

Constructors

  • L
  • M
  • Q
  • H

Error type for QR code generation

pub type GenerateError {
  EmptyValue(String)
  InvalidVersion(Int)
  ProvidedValueExceedsCapacity(value_length: Int, capacity: Int)
  InvalidNumericEncoding(String)
  InvalidAlphanumericEncoding(String)
  InvalidUtf8Encoding(String)
  InvalidRemainingBits(String)
}

Constructors

  • EmptyValue(String)
  • InvalidVersion(Int)
  • ProvidedValueExceedsCapacity(value_length: Int, capacity: Int)
  • InvalidNumericEncoding(String)
  • InvalidAlphanumericEncoding(String)
  • InvalidUtf8Encoding(String)
  • InvalidRemainingBits(String)

Qr

opaque </>

Generated QR code containing the module data Use to_printable, to_svg, or to_bits to convert to different formats

pub opaque type Qr

Config for QR code

  • value: The string value to encode in the QR code
  • error_correction: The error correction level to use (L, M, Q, H) M is the default
  • min_version: The minimum QR code version to use (1-40) 1 is the default
pub type QrConfig {
  QrConfig(
    value: String,
    error_correction: ErrorCorrectionLevel,
    min_version: Int,
  )
}

Constructors

Contact information for a vCard payload Create one with v_card, add optional fields with the v_card_* functions, then convert it with v_card_to_string

pub opaque type VCard

QR code version (1-40) which determines the size of the QR code and the amount of data it can hold Version 1 is 21x21 Version 40 is 177x177 https://www.thonky.com/qr-code-tutorial/character-capacities

pub opaque type Version

Authentication used by a WiFi network

  • Wpa: WPA/WPA2 with the given password
  • Wep: WEP with the given password
  • NoPassword: an open network
pub type WifiAuthentication {
  Wpa(password: String)
  Wep(password: String)
  NoPassword
}

Constructors

  • Wpa(password: String)
  • Wep(password: String)
  • NoPassword

Values

pub fn calendar_event(
  summary summary: String,
  starts_at starts_at: String,
  ends_at ends_at: String,
) -> CalendarEvent

Create a new calendar event Timestamps use the iCalendar format: YYYYMMDDThhmmssZ for UTC (for example 20260719T093000Z) or YYYYMMDDThhmmss for local time

pub fn calendar_event_description(
  event: CalendarEvent,
  description: String,
) -> CalendarEvent

Set a description for the calendar event

pub fn calendar_event_location(
  event: CalendarEvent,
  location: String,
) -> CalendarEvent

Set the location for the calendar event

pub fn calendar_event_to_string(event: CalendarEvent) -> String

Convert the calendar event into its string payload (iCalendar vEvent)

pub fn email(address: String) -> String

Build an email payload, e.g. mailto:hello@example.com Scanning the resulting QR code opens the mail client with the recipient filled in

pub fn error_correction(
  config: QrConfig,
  level: ErrorCorrectionLevel,
) -> QrConfig

Set the error correction level for the QR code config

  • L: Recovers 7% of data
  • M: Recovers 15% of data (default)
  • Q: Recovers 25% of data
  • H: Recovers 30% of data
pub fn generate(config: QrConfig) -> Result(Qr, GenerateError)

Generate a QR code based on the provided config Returns a Qr that can be converted to different formats using to_printable, to_svg, or to_bits

pub fn geo(
  latitude latitude: Float,
  longitude longitude: Float,
) -> String

Build a geographic location payload, e.g. geo:59.3293,18.0686 Scanning the resulting QR code opens the location in the maps app

pub fn min_version(config: QrConfig, version: Int) -> QrConfig

Set the minimum version for the QR code config (1-40) Version 1 is 21x21 Version 40 is 177x177

pub fn new(value: String) -> QrConfig

Create a new QR code config with the provided value and default settings for error correction and minimum version Default error correction level is M (15% recovery) Default minimum version is 1 (21x21)

pub fn phone(number: String) -> String

Build a phone number payload, e.g. tel:+461234567 Scanning the resulting QR code prompts the device to call the number

pub fn print(qr: Qr) -> Nil

Print the QR code to standard output using Unicode block characters This is a convenience for io.println(to_printable(qr)), avoiding the echo pitfall described on to_printable

pub fn sms(
  number number: String,
  message message: String,
) -> String

Build an SMS payload, e.g. smsto:+461234567:Hello! Pass an empty message to only fill in the recipient

pub fn to_bits(qr: Qr) -> #(Int, BitArray)

Convert the QR code into a tuple of (size, bits) where size is the width/height Each bit represents a module: 1 = Dark, 0 = Light To access module at (row, col): bit index = row * size + col

pub fn to_printable(qr: Qr) -> String

Convert the QR code into a printable string representation using Unicode block characters You must use io.println to print this rather than echo, as echo debug-prints the string representation with the newlines escaped as \n

pub fn to_svg(qr: Qr) -> String

Convert the QR code into an SVG string representation

pub fn v_card(name name: String) -> VCard

Create a new vCard with the given full name

pub fn v_card_address(card: VCard, address: String) -> VCard

Set the postal address for the vCard as a single free-form string

pub fn v_card_email(card: VCard, email: String) -> VCard

Set the email address for the vCard

pub fn v_card_job_title(card: VCard, job_title: String) -> VCard

Set the job title for the vCard

pub fn v_card_note(card: VCard, note: String) -> VCard

Set a free-form note for the vCard

pub fn v_card_organization(
  card: VCard,
  organization: String,
) -> VCard

Set the organization for the vCard

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

Set the phone number for the vCard

pub fn v_card_to_string(card: VCard) -> String

Convert the vCard into its string payload (vCard version 3.0)

pub fn v_card_website(card: VCard, website: String) -> VCard

Set the website URL for the vCard

pub fn wifi(
  ssid ssid: String,
  authentication authentication: WifiAuthentication,
  hidden hidden: Bool,
) -> String

Build a WiFi network configuration payload Scanning the resulting QR code prompts the device to join the network

Produces WIFI:S:<ssid>;T:<WPA|WEP|nopass>;P:<password>;H:true;; Special characters in the SSID and password are escaped automatically

Search Document