net::uri +linux +x86_64

The net::uri module provides utilities for parsing Uniform Resource Identifiers (RFC 3986).

Index

Types

type uri;

// Undocumented types:
type query_decoder;

Errors

type invalid;

Functions

fn decodequery(const str) query_decoder;
fn encodequery([](str, str)) str;
fn finish(*uri) void;
fn fmt(io::handle, *const uri) (size | io::error);
fn parse(str) (uri | invalid);
fn query_finish(*query_decoder) void;
fn query_next(*query_decoder) ((str, str) | invalid | void);
fn string(*const uri) str;

Types

type uri[link]

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[link]

Show undocumented member
type query_decoder = struct {
	tokenizer: strings::tokenizer,
	bufs: (strio::stream, strio::stream),
};

Errors

type invalid[link]

type invalid = !void;

The URI provided to parse is invalid.

Functions

fn decodequery[link]

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 encodequery[link]

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[link]

fn finish(u: *uri) void;

Frees resources associated with a uri.

fn fmt[link]

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[link]

fn parse(in: str) (uri | invalid);

Parses a URI string into uri structure. The return value must be freed using finish.

fn query_finish[link]

fn query_finish(dec: *query_decoder) void;

Frees resources associated with the query_decoder.

fn query_next[link]

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[link]

fn string(u: *const uri) str;

Formats a uri into a string. The result must be freed by the caller.