pub struct Client { /* private fields */ }Implementations§
Source§impl Client
impl Client
Sourcepub fn builder() -> ClientBuilder
pub fn builder() -> ClientBuilder
Construct a Client with a customized configuration,
see ClientBuilder methods.
Source§impl Client
impl Client
Sourcepub async fn request(&self, url: impl IntoUrl) -> Result<ThisResponse, LibError>
pub async fn request(&self, url: impl IntoUrl) -> Result<ThisResponse, LibError>
Perform a Gemini request with the specified URL.
Host and port (1965 by default) are parsed from url
after scheme and userinfo checks.
On success, Response is returned.
Automatically follows redirections up to 5 times.
To avoid this behavior, use Client::request_with_no_redirect,
this function is also called here under the hood.
Returns an error if a scheme is not gemini:// or
a userinfo portion (user:password@) is present in the URL.
To avoid this checks, most probably for proxying requests,
use Client::request_with_host.
§Errors
Sourcepub async fn request_with_no_redirect(
&self,
url: impl IntoUrl,
) -> Result<ThisResponse, LibError>
pub async fn request_with_no_redirect( &self, url: impl IntoUrl, ) -> Result<ThisResponse, LibError>
Perform a Gemini request with the specified URL
without following redirections.
Host and port (1965 by default) are parsed from url
after scheme and userinfo checks.
On success, Response is returned.
§Errors
InvalidUrl::ParseErrormeans that the given URL cannot be parsed.InvalidUrl::SchemeNotGeminiis returned when a scheme is notgemini://, for proxying requests useClient::request_with_host.InvalidUrl::UserinfoPresentis returned when the given URL contains a userinfo portion (user:password@) – it is forbidden by the Gemini specification.- See
Client::request_with_hostfor the rest.
Sourcepub async fn request_with_host(
&self,
url_str: &str,
host: &str,
port: u16,
) -> Result<ThisResponse, LibError>
pub async fn request_with_host( &self, url_str: &str, host: &str, port: u16, ) -> Result<ThisResponse, LibError>
Perform a Gemini request with the specified host, port and URL.
Non-gemini:// URLs is OK if the remote server supports proxying.
§Errors
InvalidUrl::ConvertErrormeans that a hostname cannot be converted into [pki_types::ServerName].LibError::HostLookupErrormeans that a DNS server returned no records, i. e. that domain does not exist.LibError::DnsClientError(crate featurehickory) wraps a Hickory DNS client error related to a connection failure or an invalid DNS server response.std::io::Erroris returned in many cases: could not open a TCP connection, perform a TLS handshake, write to or read from the TCP stream. Check the ErrorKind and/or the inner error if you need to determine what exactly happened.LibError::StatusOutOfRangemeans that a Gemini server returned an invalid status code (less than 10 or greater than 69).LibError::DataNotUtf8is returned when metadata (the text after a status code) is not in UTF-8 and cannot be converted to a string without errors.