[][src]Trait srv_rs::SrvRecord

pub trait SrvRecord {
    type Target: Display + ?Sized;
    pub fn target(&self) -> &Self::Target;
pub fn port(&self) -> u16;
pub fn priority(&self) -> u16;
pub fn weight(&self) -> u16; pub fn parse(
        &self,
        scheme: impl TryInto<Scheme, Error = impl Into<Error>>,
        path_and_query: impl TryInto<PathAndQuery, Error = impl Into<Error>>
    ) -> Result<Uri, Error> { ... }
pub fn sort_key(&self, rng: impl Rng) -> (u16, Reverse<u32>) { ... } }

Representation of types that contain the fields of a SRV record.

Associated Types

type Target: Display + ?Sized[src]

Type representing the SRV record's target. Must implement Display so it can be used to create a Uri.

Loading content...

Required methods

pub fn target(&self) -> &Self::Target[src]

Gets a SRV record's target.

pub fn port(&self) -> u16[src]

Gets a SRV record's port.

pub fn priority(&self) -> u16[src]

Gets a SRV record's priority.

pub fn weight(&self) -> u16[src]

Gets a SRV record's weight.

Loading content...

Provided methods

pub fn parse(
    &self,
    scheme: impl TryInto<Scheme, Error = impl Into<Error>>,
    path_and_query: impl TryInto<PathAndQuery, Error = impl Into<Error>>
) -> Result<Uri, Error>
[src]

Parses a SRV record into a URI with a given scheme (e.g. https) and path_and_query (used as a suffix in the URI).

use srv_rs::{resolver::libresolv::LibResolvSrvRecord, SrvRecord};
let record = LibResolvSrvRecord {
    priority: 1,
    weight: 100,
    port: 8211,
    target: String::from("srv-client-rust.deshaw.org"),
};
assert_eq!(
    &record.parse("https", "/")?.to_string(),
    "https://srv-client-rust.deshaw.org:8211/"
);
assert_eq!(
    &record.parse("http", "/bar")?.to_string(),
    "http://srv-client-rust.deshaw.org:8211/bar"
);

pub fn sort_key(&self, rng: impl Rng) -> (u16, Reverse<u32>)[src]

Generates a key to sort a SRV record by priority and weight per RFC 2782.

Loading content...

Implementations on Foreign Types

impl SrvRecord for SRV[src]

type Target = Name

Loading content...

Implementors

impl SrvRecord for LibResolvSrvRecord[src]

type Target = str

Loading content...