lisette-stdlib 0.2.13

Little language inspired by Rust that compiles to Go
Documentation
// Generated by Lisette bindgen
// Source: net/mail (Go stdlib)
// Go: 1.25.10
// Lisette: 0.2.1

import "go:io"
import "go:mime"
import "go:time"

/// ParseAddress parses a single RFC 5322 address, e.g. "Barry Gibbs <bg@example.com>"
pub fn ParseAddress(address: string) -> Result<Ref<Address>, error>

/// ParseAddressList parses the given string as a list of addresses.
pub fn ParseAddressList(list: string) -> Result<Slice<Ref<Address>>, error>

/// ParseDate parses an RFC 5322 date string.
pub fn ParseDate(date: string) -> Result<time.Time, error>

/// ReadMessage reads a message from r.
/// The headers are parsed, and the body of the message will be available
/// for reading from msg.Body.
pub fn ReadMessage(r: io.Reader) -> Result<Ref<Message>, error>

/// Address represents a single mail address.
/// An address such as "Barry Gibbs <bg@example.com>" is represented
/// as Address{Name: "Barry Gibbs", Address: "bg@example.com"}.
pub struct Address {
  pub Name: string,
  pub Address: string,
}

/// An AddressParser is an RFC 5322 address parser.
pub struct AddressParser {
  pub WordDecoder: Option<Ref<mime.WordDecoder>>,
}

/// A Header represents the key-value pairs in a mail message header.
pub struct Header(Map<string, Slice<string>>)

/// A Message represents a parsed mail message.
pub struct Message {
  pub Header: Header,
  pub Body: Option<io.Reader>,
}

pub var ErrHeaderNotPresent: error

impl Address {
  /// String formats the address as a valid RFC 5322 address.
  /// If the address's name contains non-ASCII characters
  /// the name will be rendered according to RFC 2047.
  fn String(self: Ref<Address>) -> string
}

impl AddressParser {
  /// Parse parses a single RFC 5322 address of the
  /// form "Gogh Fir <gf@example.com>" or "foo@example.com".
  fn Parse(self: Ref<AddressParser>, address: string) -> Result<Ref<Address>, error>

  /// ParseList parses the given string as a list of comma-separated addresses
  /// of the form "Gogh Fir <gf@example.com>" or "foo@example.com".
  fn ParseList(self: Ref<AddressParser>, list: string) -> Result<Slice<Ref<Address>>, error>
}

impl Header {
  /// AddressList parses the named header field as a list of addresses.
  fn AddressList(self, key: string) -> Result<Slice<Ref<Address>>, error>

  /// Date parses the Date header field.
  fn Date(self) -> Result<time.Time, error>

  /// Get gets the first value associated with the given key.
  /// It is case insensitive; CanonicalMIMEHeaderKey is used
  /// to canonicalize the provided key.
  /// If there are no values associated with the key, Get returns "".
  /// To access multiple values of a key, or to use non-canonical keys,
  /// access the map directly.
  fn Get(self, key: string) -> string
}