// Generated by Lisette bindgen
// Source: mime (Go stdlib)
// Go: 1.25.10
// Lisette: 0.3.0

import "go:io"

/// A WordEncoder is an RFC 2047 encoded-word encoder.
pub struct WordEncoder(byte)

pub const BEncoding: WordEncoder = 98

pub const QEncoding: WordEncoder = 113

/// AddExtensionType sets the MIME type associated with
/// the extension ext to typ. The extension should begin with
/// a leading dot, as in ".html".
pub fn AddExtensionType(ext: string, typ: string) -> Result<(), error>

/// ExtensionsByType returns the extensions known to be associated with the MIME
/// type typ. The returned extensions will each begin with a leading dot, as in
/// ".html". When typ has no associated extensions, ExtensionsByType returns an
/// nil slice.
pub fn ExtensionsByType(typ: string) -> Result<Slice<string>, error>

/// FormatMediaType serializes mediatype t and the parameters
/// param as a media type conforming to RFC 2045 and RFC 2616.
/// The type and parameter names are written in lower-case.
/// When any of the arguments result in a standard violation then
/// FormatMediaType returns the empty string.
pub fn FormatMediaType(t: string, param: Map<string, string>) -> string

/// ParseMediaType parses a media type value and any optional
/// parameters, per RFC 1521.  Media types are the values in
/// Content-Type and Content-Disposition headers (RFC 2183).
/// On success, ParseMediaType returns the media type converted
/// to lowercase and trimmed of white space and a non-nil map.
/// If there is an error parsing the optional parameter,
/// the media type will be returned along with the error
/// [ErrInvalidMediaParameter].
/// The returned map, params, maps from the lowercase
/// attribute to the attribute value with its case preserved.
pub fn ParseMediaType(v: string) -> Partial<(string, Map<string, string>), error>

/// TypeByExtension returns the MIME type associated with the file extension ext.
/// The extension ext should begin with a leading dot, as in ".html".
/// When ext has no associated type, TypeByExtension returns "".
/// 
/// Extensions are looked up first case-sensitively, then case-insensitively.
/// 
/// The built-in table is small but on unix it is augmented by the local
/// system's MIME-info database or mime.types file(s) if available under one or
/// more of these names:
/// 
/// 	/usr/local/share/mime/globs2
/// 	/usr/share/mime/globs2
/// 	/etc/mime.types
/// 	/etc/apache2/mime.types
/// 	/etc/apache/mime.types
/// 
/// On Windows, MIME types are extracted from the registry.
/// 
/// Text types have the charset parameter set to "utf-8" by default.
pub fn TypeByExtension(ext: string) -> string

/// A WordDecoder decodes MIME headers containing RFC 2047 encoded-words.
pub struct WordDecoder {
  pub CharsetReader: Option<fn(string, io.Reader) -> Result<io.Reader, error>>,
}

/// ErrInvalidMediaParameter is returned by [ParseMediaType] if
/// the media type value was found but there was an error parsing
/// the optional parameters
pub var ErrInvalidMediaParameter: error

impl WordDecoder {
  /// Decode decodes an RFC 2047 encoded-word.
  fn Decode(self: Ref<WordDecoder>, word: string) -> Result<string, error>

  /// DecodeHeader decodes all encoded-words of the given string. It returns an
  /// error if and only if [WordDecoder.CharsetReader] of d returns an error.
  fn DecodeHeader(self: Ref<WordDecoder>, header: string) -> Result<string, error>
}

impl WordEncoder {
  /// Encode returns the encoded-word form of s. If s is ASCII without special
  /// characters, it is returned unchanged. The provided charset is the IANA
  /// charset name of s. It is case insensitive.
  fn Encode(self, charset: string, s: string) -> string
}
