Struct json_api::doc::link::Link
[−]
[src]
pub struct Link { pub href: Uri, pub meta: Map<Value>, // some fields omitted }
Fields
href: Uri
meta: Map<Value>
Methods
impl Link
[src]
fn build() -> LinkBuilder
[src]
Methods from Deref<Target = Uri>
fn path_and_query(&self) -> Option<&PathAndQuery>
[src]
Returns the path & query components of the Uri
fn path(&self) -> &str
[src]
Get the path of this Uri
.
Both relative and absolute URIs contain a path component, though it might be the empty string. The path component is case sensitive.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|--------|
|
path
If the URI is *
then the path component is equal to *
.
Examples
A relative URI
let uri: Uri = "/hello/world".parse().unwrap(); assert_eq!(uri.path(), "/hello/world");
An absolute URI
let uri: Uri = "http://example.org/hello/world".parse().unwrap(); assert_eq!(uri.path(), "/hello/world");
fn scheme(&self) -> Option<&str>
[src]
Get the scheme of this Uri
.
The URI scheme refers to a specification for assigning identifiers within that scheme. Only absolute URIs contain a scheme component, but not all absolute URIs will contain a scheme component. Although scheme names are case-insensitive, the canonical form is lowercase.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|-|
|
scheme
Examples
Absolute URI
let uri: Uri = "http://example.org/hello/world".parse().unwrap(); assert_eq!(uri.scheme(), Some("http"));
Relative URI
let uri: Uri = "/hello/world".parse().unwrap(); assert!(uri.scheme().is_none());
[src]
Get the authority of this Uri
.
The authority is a hierarchical element for naming authority such that the remainder of the URI is delegated to that authority. For HTTP, the authority consists of the host and port. The host portion of the authority is case-insensitive.
The authority also includes a username:password
component, however
the use of this is deprecated and should be avoided.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|-------------------------------|
|
authority
This function will be renamed to authority
in the next semver release.
Examples
Absolute URI
let uri: Uri = "http://example.org:80/hello/world".parse().unwrap(); assert_eq!(uri.authority_part().map(|a| a.as_str()), Some("example.org:80"));
Relative URI
let uri: Uri = "/hello/world".parse().unwrap(); assert!(uri.authority_part().is_none());
fn host(&self) -> Option<&str>
[src]
Get the host of this Uri
.
The host subcomponent of authority is identified by an IP literal encapsulated within square brackets, an IPv4 address in dotted- decimal form, or a registered name. The host subcomponent is case-insensitive.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|---------|
|
host
Examples
Absolute URI
let uri: Uri = "http://example.org:80/hello/world".parse().unwrap(); assert_eq!(uri.host(), Some("example.org"));
Relative URI
let uri: Uri = "/hello/world".parse().unwrap(); assert!(uri.host().is_none());
fn port(&self) -> Option<u16>
[src]
Get the port of this Uri
.
The port subcomponent of authority is designated by an optional port number in decimal following the host and delimited from it by a single colon (":") character. A value is only returned if one is specified in the URI string, i.e., default port values are not returned.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|-|
|
port
Examples
Absolute URI with port
let uri: Uri = "http://example.org:80/hello/world".parse().unwrap(); assert_eq!(uri.port(), Some(80));
Absolute URI without port
let uri: Uri = "http://example.org/hello/world".parse().unwrap(); assert!(uri.port().is_none());
Relative URI
let uri: Uri = "/hello/world".parse().unwrap(); assert!(uri.port().is_none());
fn query(&self) -> Option<&str>
[src]
Get the query string of this Uri
, starting after the ?
.
The query component contains non-hierarchical data that, along with data in the path component, serves to identify a resource within the scope of the URI's scheme and naming authority (if any). The query component is indicated by the first question mark ("?") character and terminated by a number sign ("#") character or by the end of the URI.
abc://username:password@example.com:123/path/data?key=value&key2=value2#fragid1
|-------------------|
|
query
Examples
Absolute URI
let uri: Uri = "http://example.org/hello/world?key=value".parse().unwrap(); assert_eq!(uri.query(), Some("key=value"));
Relative URI with a query string component
let uri: Uri = "/hello/world?key=value&foo=bar".parse().unwrap(); assert_eq!(uri.query(), Some("key=value&foo=bar"));
Relative URI without a query string component
let uri: Uri = "/hello/world".parse().unwrap(); assert!(uri.query().is_none());
Trait Implementations
impl Clone for Link
[src]
fn clone(&self) -> Link
[src]
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Debug for Link
[src]
impl Default for Link
[src]
impl PartialEq for Link
[src]
fn eq(&self, __arg_0: &Link) -> bool
[src]
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &Link) -> bool
[src]
This method tests for !=
.
impl Deref for Link
[src]
type Target = Uri
The resulting type after dereferencing.
fn deref(&self) -> &Self::Target
[src]
Dereferences the value.
impl Display for Link
[src]
fn fmt(&self, f: &mut Formatter) -> Result
[src]
Formats the value using the given formatter. Read more
impl FromStr for Link
[src]
type Err = Error
The associated error which can be returned from parsing.
fn from_str(value: &str) -> Result<Self, Self::Err>
[src]
Parses a string s
to return a value of this type. Read more
impl<'de> Deserialize<'de> for Link
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more