XU XUv0.8.8
中文

API

#mime

import: #mime

counts: 4 fns, 0 methods, 1 types, 0 consts, 0 ifaces

Media-type parse and type-by-extension.

struct MediaType

XuAPI
pub struct MediaType {
    pub typ string
    pub keys []string
    pub vals []string
}

Purpose

MIME type helpers aligned with `mime` (ParseMediaType + TypeByExtension builtins). No map type: parameters are parallel keys/vals slices. TypeByExtension uses hardcoded table only (no /etc/mime.types, no Windows registry).

Parameters

typ string
field (string)
keys []string
field ([]string)
vals []string
field ([]string)

parse_media_type

XuAPI
pub fn parse_media_type(v &string) MediaType

Purpose

Parse as media type. Throws on failure.

Parameters

v &string
value (borrowed; caller keeps it; type &string)

Returns

MediaType — a value of this type

format_media_type

XuAPI
pub fn format_media_type(mt &MediaType) string

Purpose

Format as media type.

Parameters

mt &MediaType
mt (borrowed; caller keeps it; type &MediaType)

Returns

string — result string

type_by_extension

XuAPI
pub fn type_by_extension(ext &string) string

Purpose

Type by extension.

Parameters

ext &string
ext (borrowed; caller keeps it; type &string)

Returns

string — result string

extensions_by_type

XuAPI
pub fn extensions_by_type(typ &string) []string

Purpose

Extensions by type.

Parameters

typ &string
typ (borrowed; caller keeps it; type &string)

Returns

[]string — slice result