Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub fn builder() -> ClientBuilder

Construct a Client with a customized configuration, see ClientBuilder methods.

Source§

impl Client

Source

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
Source

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
Source

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::ConvertError means that a hostname cannot be converted into [pki_types::ServerName].
  • LibError::HostLookupError means that a DNS server returned no records, i. e. that domain does not exist.
  • LibError::DnsClientError (crate feature hickory) wraps a Hickory DNS client error related to a connection failure or an invalid DNS server response.
  • std::io::Error is 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::StatusOutOfRange means that a Gemini server returned an invalid status code (less than 10 or greater than 69).
  • LibError::DataNotUtf8 is returned when metadata (the text after a status code) is not in UTF-8 and cannot be converted to a string without errors.

Auto Trait Implementations§

§

impl Freeze for Client

§

impl !RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl !UnwindSafe for Client

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more