net::uri+x86_64 +linux

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,
};

// Undocumented types:
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 | nomem);
fn encodequery(pairs: [](str, str)) (str | nomem);
fn finish(u: *uri) void;
fn fmt(out: io::handle, u: *const uri) (size | io::error);
fn parse(in: str) (uri | invalid | nomem);
fn query_finish(dec: *query_decoder) void;
fn query_next(dec: *query_decoder) ((str, str) | invalid | nomem | void);
fn string(u: *const uri) (str | nomem);

Types

type uri[permalink] [source]

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[permalink] [source]

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

Errors

type invalid[permalink] [source]

type invalid = !void;

The URI provided to parse is invalid.

Functions

fn decodequery[permalink] [source]

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[permalink] [source]

fn dup(u: *uri) (uri | nomem);

Duplicates a uri.

fn encodequery[permalink] [source]

fn encodequery(pairs: [](str, str)) (str | nomem);

Encodes (key, value) pairs into a URI query string. The result must be freed by the caller.

fn finish[permalink] [source]

fn finish(u: *uri) void;

Frees resources associated with a uri.

fn fmt[permalink] [source]

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[permalink] [source]

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

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

fn query_finish[permalink] [source]

fn query_finish(dec: *query_decoder) void;

Frees resources associated with the query_decoder.

fn query_next[permalink] [source]

fn query_next(dec: *query_decoder) ((str, str) | invalid | nomem | 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[permalink] [source]

fn string(u: *const uri) (str | nomem);

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