logos.std.io.net.url

Module std · package logos-std

Types

structUrl

struct Url

Parsed absolute URL: scheme "://" host [":" port] [path] ["?" query]. Components are stored raw (not percent-decoded); the fragment is not retained.

Fields

host: String

Host component, without the port.

path: String

Path; empty when absent, otherwise starts with /.

port: i32

Port, or -1 when unspecified — callers pick the scheme default.

query: String

Query string without the leading ?; empty when absent.

scheme: String

Scheme, without the :// separator (e.g. http).

Functions

fnurl_decode

fn url_decode(src: *const u8, len: i64, out: &mut String, plus_is_space: bool) -> i64

Decodes percent-encoded bytes [src, src+len), appending to out. If plus_is_space is true, + decodes to a space (form-urlencoded mode). Returns the number of bytes appended, or -1 on malformed input (truncated % escape, non-hex digit); on error out may already hold partially decoded bytes.

fnurl_decode_form_str

fn url_decode_form_str(src: &[u8], out: &mut String) -> i64

Decodes form-urlencoded src into out, with + decoded as space. Returns the number of bytes appended, or -1 on malformed input.

fnurl_decode_str

fn url_decode_str(src: &[u8], out: &mut String) -> i64

Decodes percent-encoded src into out; returns bytes appended, or -1 on malformed input. + passes through unchanged (component mode).

fnurl_default_port_s

fn url_default_port_s(scheme: &String) -> i32

Returns the default port for a well-known scheme (http = 80, https = 443), or -1 if unknown.

fnurl_encode_component

fn url_encode_component(src: *const u8, len: i64, out: &mut String) -> void

Percent-encodes bytes [src, src+len), appending to out. Bytes outside the RFC 3986 unreserved set (A-Za-z0-9-._~) become uppercase %XX.

fnurl_encode_component_str

fn url_encode_component_str(src: &[u8], out: &mut String) -> void

Percent-encodes src, appending to out (see url_encode_component).

fnurl_encode_query_form

fn url_encode_query_form(src: *const u8, len: i64, out: &mut String) -> void

Encodes bytes [src, src+len) as application/x-www-form-urlencoded, appending to out. Same as url_encode_component except space (0x20) becomes +.

fnurl_encode_query_form_str

fn url_encode_query_form_str(src: &[u8], out: &mut String) -> void

Form-urlencodes src, appending to out (see url_encode_query_form).

fnurl_format

fn url_format(u: &Url, out: &mut String) -> void

Serializes u, appending to out. Port is omitted when -1 or equal to the scheme’s default; ? appears only when query is non-empty. Path is emitted verbatim — caller supplies the leading /.

fnurl_parse

fn url_parse(s: &[u8]) -> Option

Parses an absolute URL of the form scheme://host[:port][path][?query][#fragment]. Returns None on malformed input (bad scheme, empty host, non-numeric or >65535 port). The fragment is parsed off and discarded; components are not percent-decoded.