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>
impl EppClient<RustlsConnector>
Sourcepub async fn connect(
registry: String,
server: (String, u16),
identity: Option<(Vec<Certificate>, PrivateKey)>,
timeout: Duration,
) -> Result<Self, Error>
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>
impl<C: Connector> EppClient<C>
Sourcepub async fn new(
connector: C,
registry: String,
timeout: Duration,
) -> Result<Self, Error>
pub async fn new( connector: C, registry: String, timeout: Duration, ) -> Result<Self, Error>
Create an EppClient
from an already established connection
Sourcepub async fn hello(&mut self) -> Result<Greeting, Error>
pub async fn hello(&mut self) -> Result<Greeting, Error>
Executes an EPP Hello call and returns the response as a Greeting
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>
Sourcepub async fn transact_xml(&mut self, xml: &str) -> Result<String, Error>
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
Sourcepub fn xml_greeting(&self) -> String
pub fn xml_greeting(&self) -> String
Returns the greeting received on establishment of the connection in raw xml form
Sourcepub fn greeting(&self) -> Result<Greeting, Error>
pub fn greeting(&self) -> Result<Greeting, Error>
Returns the greeting received on establishment of the connection as an Greeting