SrvRecord

Trait SrvRecord 

Source
pub trait SrvRecord {
    type Target: Display + ?Sized;

    // Required methods
    fn target(&self) -> &Self::Target;
    fn port(&self) -> u16;
    fn priority(&self) -> u16;
    fn weight(&self) -> u16;

    // Provided methods
    fn parse(
        &self,
        scheme: impl TryInto<Scheme, Error = impl Into<Error>>,
        path_and_query: impl TryInto<PathAndQuery, Error = impl Into<Error>>,
    ) -> Result<Uri, Error> { ... }
    fn sort_key(&self, rng: impl Rng) -> (u16, Reverse<u32>) { ... }
}
Expand description

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

Required Associated Types§

Source

type Target: Display + ?Sized

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

Required Methods§

Source

fn target(&self) -> &Self::Target

Gets a SRV record’s target.

Source

fn port(&self) -> u16

Gets a SRV record’s port.

Source

fn priority(&self) -> u16

Gets a SRV record’s priority.

Source

fn weight(&self) -> u16

Gets a SRV record’s weight.

Provided Methods§

Source

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

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"
);
Source

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

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

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl SrvRecord for SRV

Source§

type Target = Name

Source§

fn target(&self) -> &Self::Target

Source§

fn port(&self) -> u16

Source§

fn priority(&self) -> u16

Source§

fn weight(&self) -> u16

Implementors§