Skip to content

Add struct and type doc comments for extra::url::* #10752

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 4, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions src/libextra/url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,51 @@ use std::hashmap::HashMap;
use std::to_bytes;
use std::uint;

/// A Uniform Resource Locator (URL). A URL is a form of URI (Uniform Resource
/// Identifier) that includes network location information, such as hostname or
/// port number.
///
/// # Example
///
/// ```rust
/// let url = Url { scheme: ~"https",
/// user: Some(UserInfo { user: ~"username", pass: None }),
/// host: ~"example.com",
/// port: Some(~"8080"),
/// path: ~"/foo/bar",
/// query: ~[(~"baz", ~"qux")],
/// fragment: Some(~"quz") };
/// // https://[email protected]:8080/foo/bar?baz=qux#quz
/// ```
#[deriving(Clone, Eq)]
pub struct Url {
/// The scheme part of a URL, such as `https` in the above example.
scheme: ~str,
/// A URL subcomponent for user authentication. `username` in the above example.
user: Option<UserInfo>,
/// A domain name or IP address. For example, `example.com`.
host: ~str,
/// A TCP port number, for example `8080`.
port: Option<~str>,
/// The path component of a URL, for example `/foo/bar`.
path: ~str,
/// The query component of a URL. `~[(~"baz", ~"qux")]` represents the
/// fragment `baz=qux` in the above example.
query: Query,
/// The fragment component, such as `quz`. Doesn't include the leading `#` character.
fragment: Option<~str>
}

/// An optional subcomponent of a URI authority component.
#[deriving(Clone, Eq)]
pub struct UserInfo {
/// The user name.
user: ~str,
/// Password or other scheme-specific authentication information.
pass: Option<~str>
}

/// Represents the query component of a URI.
pub type Query = ~[(~str, ~str)];

impl Url {
Expand Down