net::uri
The net::uri module provides utilities for parsing Uniform Resource Identifiers (RFC 3986).
Index
Types
type uri = struct {
scheme: str,
host: (str | ip::addr),
port: u16,
userinfo: str,
path: str,
query: str,
fragment: str,
};
type query_decoder = struct {
tokenizer: strings::tokenizer,
bufs: (memio::stream, memio::stream),
};
Errors
type invalid = !void;
Functions
fn decodequery(q: const str) query_decoder;
fn dup(u: *uri) uri;
fn encodequery(pairs: [](str, str)) str;
fn finish(u: *uri) void;
fn fmt(out: io::handle, u: *const uri) (size | io::error);
fn parse(in: str) (uri | invalid);
fn query_finish(dec: *query_decoder) void;
fn query_next(dec: *query_decoder) ((str, str) | invalid | void);
fn string(u: *const uri) str;
Types
type uri
type uri = struct {
scheme: str,
host: (str | ip::addr),
port: u16,
userinfo: str,
path: str,
query: str,
fragment: str,
};
Representation of a parsed URI.
type query_decoder
Show undocumented member
type query_decoder = struct {
tokenizer: strings::tokenizer,
bufs: (memio::stream, memio::stream),
};
Errors
type invalid
type invalid = !void;
The URI provided to parse is invalid.
Functions
fn decodequery
fn decodequery(q: const str) query_decoder;
Initializes a decoder for a query string. Use query_next to walk it. The caller must call query_finish once they're done using it.
fn dup
fn dup(u: *uri) uri;
Duplicates a uri.
fn encodequery
fn encodequery(pairs: [](str, str)) str;
Encodes (key, value) pairs into a URI query string. The result must be freed by the caller.
fn finish
fn finish(u: *uri) void;
Frees resources associated with a uri.
fn fmt
fn fmt(out: io::handle, u: *const uri) (size | io::error);
Writes a formatted uri to an io::handle. Returns the number of bytes written.
fn parse
fn parse(in: str) (uri | invalid);
Parses a URI string into uri structure. The return value must be freed using finish.
fn query_finish
fn query_finish(dec: *query_decoder) void;
Frees resources associated with the query_decoder.
fn query_next
fn query_next(dec: *query_decoder) ((str, str) | invalid | void);
Retrieves the next (key, value) pair from the query. The return value is borrowed from the decoder and will be replaced on the next call, use strings::dup to extend its lifetime.
fn string
fn string(u: *const uri) str;
Formats a uri into a string. The result must be freed by the caller.