Struct EppClient

Source
pub struct EppClient<C: Connector> { /* private fields */ }
Expand description

An EppClient provides an interface to sending EPP requests to a registry

Once initialized, the EppClient instance can serialize EPP requests to XML and send them to the registry and deserialize the XML responses from the registry to local types.

§Examples

use epp_client::EppClient;
use epp_client::domain::DomainCheck;
use epp_client::common::NoExtension;

// Create an instance of EppClient
let timeout = Duration::from_secs(5);
let mut client = match EppClient::connect("registry_name".to_string(), ("example.com".to_owned(), 7000), None, timeout).await {
    Ok(client) => client,
    Err(e) => panic!("Failed to create EppClient: {}",  e)
};

// Make a EPP Hello call to the registry
let greeting = client.hello().await.unwrap();
println!("{:?}", greeting);

// Execute an EPP Command against the registry with distinct request and response objects
let domain_check = DomainCheck { domains: &["eppdev.com", "eppdev.net"] };
let response = client.transact(&domain_check, "transaction-id").await.unwrap();
response.res_data.unwrap().list
    .iter()
    .for_each(|chk| println!("Domain: {}, Available: {}", chk.id, chk.available));

The output would look like this:

Domain: eppdev.com, Available: 1
Domain: eppdev.net, Available: 1

Implementations§

Source§

impl EppClient<RustlsConnector>

Source

pub async fn connect( registry: String, server: (String, u16), identity: Option<(Vec<Certificate>, PrivateKey)>, timeout: Duration, ) -> Result<Self, Error>

Connect to the specified addr and hostname over TLS

The registry is used as a name in internal logging; host provides the host name and port to connect to), hostname is sent as the TLS server name indication and identity provides optional TLS client authentication (using) rustls as the TLS implementation. The timeout limits the time spent on any underlying network operations.

Alternatively, use EppClient::new() with any established AsyncRead + AsyncWrite + Unpin implementation.

Source§

impl<C: Connector> EppClient<C>

Source

pub async fn new( connector: C, registry: String, timeout: Duration, ) -> Result<Self, Error>

Create an EppClient from an already established connection

Source

pub async fn hello(&mut self) -> Result<Greeting, Error>

Executes an EPP Hello call and returns the response as a Greeting

Source

pub async fn transact<'c, 'e, Cmd, Ext>( &mut self, data: impl Into<RequestData<'c, 'e, Cmd, Ext>>, id: &str, ) -> Result<Response<Cmd::Response, Ext::Response>, Error>
where Cmd: Transaction<Ext> + Command + 'c, Ext: Extension + 'e,

Source

pub async fn transact_xml(&mut self, xml: &str) -> Result<String, Error>

Accepts raw EPP XML and returns the raw EPP XML response to it. Not recommended for direct use but sometimes can be useful for debugging

Source

pub fn xml_greeting(&self) -> String

Returns the greeting received on establishment of the connection in raw xml form

Source

pub fn greeting(&self) -> Result<Greeting, Error>

Returns the greeting received on establishment of the connection as an Greeting

Source

pub async fn reconnect(&mut self) -> Result<(), Error>

Source

pub async fn shutdown(self) -> Result<(), Error>

Auto Trait Implementations§

§

impl<C> Freeze for EppClient<C>
where C: Freeze, <C as Connector>::Connection: Freeze,

§

impl<C> RefUnwindSafe for EppClient<C>

§

impl<C> Send for EppClient<C>
where C: Send, <C as Connector>::Connection: Send,

§

impl<C> Sync for EppClient<C>
where C: Sync, <C as Connector>::Connection: Sync,

§

impl<C> Unpin for EppClient<C>
where C: Unpin,

§

impl<C> UnwindSafe for EppClient<C>

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, 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<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