@@ -19,23 +19,51 @@ use std::hashmap::HashMap;
19
19
use std:: to_bytes;
20
20
use std:: uint;
21
21
22
+ /// A Uniform Resource Locator (URL). A URL is a form of URI (Uniform Resource
23
+ /// Identifier) that includes network location information, such as hostname or
24
+ /// port number.
25
+ ///
26
+ /// # Example
27
+ ///
28
+ /// ```rust
29
+ /// let url = Url { scheme: ~"https",
30
+ /// user: Some(UserInfo { user: ~"username", pass: None }),
31
+ /// host: ~"example.com",
32
+ /// port: Some(~"8080"),
33
+ /// path: ~"/foo/bar",
34
+ /// query: ~[(~"baz", ~"qux")],
35
+ /// fragment: Some(~"quz") };
36
+ /// // https://[email protected] :8080/foo/bar?baz=qux#quz
37
+ /// ```
22
38
#[ deriving( Clone , Eq ) ]
23
39
pub struct Url {
40
+ /// The scheme part of a URL, such as `https` in the above example.
24
41
scheme : ~str ,
42
+ /// A URL subcomponent for user authentication. `username` in the above example.
25
43
user : Option < UserInfo > ,
44
+ /// A domain name or IP address. For example, `example.com`.
26
45
host : ~str ,
46
+ /// A TCP port number, for example `8080`.
27
47
port : Option < ~str > ,
48
+ /// The path component of a URL, for example `/foo/bar`.
28
49
path : ~str ,
50
+ /// The query component of a URL. `~[(~"baz", ~"qux")]` represents the
51
+ /// fragment `baz=qux` in the above example.
29
52
query : Query ,
53
+ /// The fragment component, such as `quz`. Doesn't include the leading `#` character.
30
54
fragment : Option < ~str >
31
55
}
32
56
57
+ /// An optional subcomponent of a URI authority component.
33
58
#[ deriving( Clone , Eq ) ]
34
59
pub struct UserInfo {
60
+ /// The user name.
35
61
user : ~str ,
62
+ /// Password or other scheme-specific authentication information.
36
63
pass : Option < ~str >
37
64
}
38
65
66
+ /// Represents the query component of a URI.
39
67
pub type Query = ~[ ( ~str , ~str ) ] ;
40
68
41
69
impl Url {
0 commit comments