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§
Required Methods§
Provided Methods§
Sourcefn parse(
&self,
scheme: impl TryInto<Scheme, Error = impl Into<Error>>,
path_and_query: impl TryInto<PathAndQuery, Error = impl Into<Error>>,
) -> Result<Uri, Error>
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"
);
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.