Skip to main content

ZeroBounce

Struct ZeroBounce 

Source
pub struct ZeroBounce {
    pub api_key: String,
    pub base_url: String,
    pub client: Client,
    pub url_provider: ZBUrlProvider,
}

Fields§

§api_key: String§base_url: String§client: Client§url_provider: ZBUrlProvider

Implementations§

Source§

impl ZeroBounce

Source

pub fn bulk_validation_file_submit( &self, zb_file: &ZBFile, ) -> ZBResult<ZBFileFeedback>

Source

pub fn bulk_validation_file_status_check( &self, file_id: &str, ) -> ZBResult<ZBFileStatus>

Source

pub fn bulk_validation_result_fetch( &self, file_id: &str, ) -> ZBResult<ZBBulkResponse>

Source

pub fn bulk_validation_result_fetch_with_options( &self, file_id: &str, options: &ZBGetFileOptions, ) -> ZBResult<ZBBulkResponse>

Bulk validation getfile with optional v2 query parameters (download_type, activity_data).

Source

pub fn bulk_validation_result_delete( &self, file_id: &str, ) -> ZBResult<ZBFileFeedback>

Source

pub fn ai_scoring_file_submit( &self, zb_file: &ZBFile, ) -> ZBResult<ZBFileFeedback>

Source

pub fn ai_scoring_file_status_check( &self, file_id: &str, ) -> ZBResult<ZBFileStatus>

Source

pub fn ai_scoring_result_fetch(&self, file_id: &str) -> ZBResult<ZBBulkResponse>

Source

pub fn ai_scoring_result_fetch_with_options( &self, file_id: &str, options: &ZBGetFileOptions, ) -> ZBResult<ZBBulkResponse>

AI scoring getfile with optional download_type (activity_data is not sent).

Source

pub fn ai_scoring_result_delete( &self, file_id: &str, ) -> ZBResult<ZBFileFeedback>

Source§

impl ZeroBounce

Source

pub fn get_inbox_placement_providers(&self) -> ZBResult<Value>

Seed providers available for new tests. GET /providers

Source

pub fn get_inbox_placement_test_types(&self) -> ZBResult<Value>

Supported test types and the default one. GET /test-types

Source

pub fn create_inbox_placement_test( &self, name: &str, options: &CreateInboxPlacementTestOptions, ) -> ZBResult<Value>

Create an inbox placement test. POST /test

name must be non-empty and at most 64 characters. Spends one inbox test.

Source

pub fn get_inbox_placement_test(&self, test_id: &str) -> ZBResult<Value>

A test and its placement results. GET /test/{id}

Source

pub fn list_inbox_placement_tests( &self, options: &ListInboxPlacementTestsOptions, ) -> ZBResult<Value>

List tests, newest first. GET /tests

Source

pub fn delete_inbox_placement_test(&self, test_id: &str) -> ZBResult<Value>

Delete a finished test. DELETE /test/{id}

The API may answer with 204 No Content. An empty 2xx is a success and comes back as Value::Null.

Source

pub fn get_inbox_placement_webhook(&self) -> ZBResult<Value>

The webhook URL saved on this API key. GET /webhook

Source

pub fn set_inbox_placement_webhook(&self, webhook_url: &str) -> ZBResult<Value>

Save the URL finished results are posted to. PUT /webhook

Source§

impl ZeroBounce

Source

pub fn send_email_finder_file( &self, domain_column: u32, options: &ZBEmailFinderFileOptions, file_name: &str, reader: impl Read, ) -> ZBResult<ZBFileFeedback>

Submit a file to the bulk email finder (POST /email-finder/sendfile).

domain_column is required and 1-based. Either first_name_column or full_name_column must be set on options: the API has no way to guess a person from a domain alone and rejects a file that carries neither.

Source

pub fn email_finder_file_status(&self, file_id: &str) -> ZBResult<String>

Source

pub fn email_finder_result_fetch( &self, file_id: &str, ) -> ZBResult<ZBBulkResponse>

Download a finished bulk email finder file (GET /email-finder/getfile).

On success the bytes come back as ZBBulkResponse::Content. A JSON body, including an HTTP 200 carrying {"success": false}, is an error, the same as bulk_validation_result_fetch.

Source

pub fn email_finder_result_delete( &self, file_id: &str, ) -> ZBResult<ZBFileFeedback>

Delete a bulk email finder file and its results (GET /email-finder/deletefile).

Source

pub fn domain_search_file_status(&self, file_id: &str) -> ZBResult<String>

Source

pub fn domain_search_result_fetch( &self, file_id: &str, ) -> ZBResult<ZBBulkResponse>

Download a finished bulk domain search file (GET /domain-search/getfile).

Same success and error rules as email_finder_result_fetch.

Source

pub fn domain_search_result_delete( &self, file_id: &str, ) -> ZBResult<ZBFileFeedback>

Delete a bulk domain search file and its results (GET /domain-search/deletefile).

Source

pub fn send_evaluated_file(&self, file_id: &str) -> ZBResult<ZBFileFeedback>

Submit a finished evaluation for validation. POST /v2/send-evaluated-file/

LIVE: this takes the list evaluator’s file_id as a form field, not the file upload the docs describe — an upload is rejected with “file_id: This field is required”. It returns a new validation job’s file_id, which answers “File cannot be found” for a short while after it is accepted.

Source

pub fn send_domain_search_file( &self, domain_column: u32, has_header_row: Option<bool>, file_name: &str, reader: impl Read, ) -> ZBResult<ZBFileFeedback>

Submit a file to bulk domain search (POST /domain-search/sendfile).

has_header_row is omitted when None, so the account default applies.

Source

pub fn send_list_evaluator_file( &self, email_address_column: u32, file_name: &str, reader: impl Read, ) -> ZBResult<ZBFileFeedback>

Source

pub fn get_list_evaluator_result(&self, file_id: &str) -> ZBResult<Value>

Source

pub fn add_filter( &self, rule: &str, target: &str, value: &str, ) -> ZBResult<Value>

Source

pub fn list_filters(&self, use_post: bool) -> ZBResult<Value>

Source

pub fn delete_filter( &self, rule: &str, target: &str, value: &str, ) -> ZBResult<Value>

Source

pub fn list_s3_files( &self, bucket: Option<&str>, search: Option<&str>, ) -> ZBResult<Vec<S3ListFileEntry>>

Source

pub fn validate_s3_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Validate a file in your Amazon S3 bucket (POST /validateS3file).

file_name is the full path as returned by list_s3_files.

Source

pub fn score_s3_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

AI score a file in your Amazon S3 bucket (POST /scoreS3file).

Source

pub fn export_s3_file( &self, file_id: &str, export_bucket: Option<&str>, ) -> ZBResult<ZBFileFeedback>

Export a validated or scored file back to Amazon S3 (POST /exportS3file).

Pass None to use the export bucket from your ZeroBounce settings. Note the field name: export_sftp_file takes export_path.

Source

pub fn email_finder_s3_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Run the email finder on a file in your Amazon S3 bucket (POST /emailFinderS3file).

file_name is the full path as returned by list_s3_files.

Source

pub fn domain_search_s3_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Run domain search on a file in your Amazon S3 bucket (POST /domainSearchS3file).

Source

pub fn validate_sftp_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Validate a file from your SFTP/FTP server (POST /validateSFTPfile).

LIVE: file_name is required here too, although the docs list it as optional for this one endpoint.

Source

pub fn score_sftp_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Score a file from your SFTP/FTP server (POST /scoreSFTPfile).

file_name is a plain name such as my_file.txt.

Source

pub fn email_finder_sftp_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Run the email finder on a file from your SFTP/FTP server (POST /emailFinderSFTPfile).

Source

pub fn domain_search_sftp_file( &self, file_name: &str, has_header_row: bool, remove_duplicates: Option<bool>, return_url: &str, ) -> ZBResult<ZBFileFeedback>

Run domain search on a file from your SFTP/FTP server (POST /domainSearchSFTPfile).

Source

pub fn export_sftp_file( &self, file_id: &str, export_path: Option<&str>, ) -> ZBResult<ZBFileFeedback>

Export a validated or scored file back to your SFTP/FTP server (POST /exportSFTPfile).

Note the field name: this endpoint takes export_path, not the export_bucket that export_s3_file uses. Pass None to use the export path from your ZeroBounce settings.

Source§

impl ZeroBounce

Source

pub fn validate_email_and_ip( &self, email: &str, ip_address: &str, ) -> ZBResult<ZBValidation>

Source

pub fn validate_email_with_options( &self, email: &str, ip_address: &str, options: &ZBValidateOptions, ) -> ZBResult<ZBValidation>

Source

pub fn validate_email(&self, email: &str) -> ZBResult<ZBValidation>

Source

pub fn batch_validate( &self, emails_and_ip_addresses: Vec<(String, String)>, ) -> ZBResult<ZBBatchValidation>

Source

pub fn batch_validate_with_options( &self, emails_and_ip_addresses: Vec<(String, String)>, options: &ZBValidateOptions, ) -> ZBResult<ZBBatchValidation>

Source§

impl ZeroBounce

Source

pub fn get_credits(&self) -> ZBResult<i64>

Source

pub fn get_api_usage( &self, start_date: NaiveDate, end_date: NaiveDate, ) -> ZBResult<ApiUsage>

Source

pub fn get_api_usage_overall(&self) -> ZBResult<ApiUsage>

Source

pub fn get_activity_data(&self, email: &str) -> ZBResult<ActivityData>

Source

pub fn score_email(&self, email: &str) -> ZBResult<ScoreEmailResponse>

Source

pub fn score_email_post(&self, email: &str) -> ZBResult<ScoreEmailResponse>

Source

pub fn find_email( &self, domain: &str, first_name: &str, middle_name: &str, last_name: &str, ) -> ZBResult<FindEmailResponse>

👎Deprecated since 1.2.0:

Use find_email_v2 instead. The new version supports both domain and company_name parameters.

Deprecated: Use find_email_v2 instead.

This function is kept for backward compatibility but will be removed in a future version.

Source

pub fn find_email_v2(&self) -> FindEmailV2Builder<'_>

Find an email address using either a domain or company name.

Returns a builder that allows you to set parameters using method chaining.

§Requirements
  • Exactly one of domain or company_name must be provided (XOR requirement)
  • first_name is optional; without it the API answers with the domain’s address formats, the same as domain_search_v2
§Example
use zero_bounce::ZeroBounce;
use zero_bounce::utility::ZBResult;
 
let zb = ZeroBounce::new("your_api_key");
// Using domain
let result = zb.find_email_v2()
    .first_name("John")
    .domain("example.com")
    .last_name("Doe")
    .call()?;
// Or using company name
let result = zb.find_email_v2()
    .first_name("John")
    .company_name("Example Inc")
    .last_name("Doe")
    .call()?;
👎Deprecated since 1.2.0:

Use domain_search_v2 instead. The new version supports both domain and company_name parameters.

Deprecated: Use domain_search_v2 instead.

This function is kept for backward compatibility but will be removed in a future version.

Source

pub fn domain_search_v2(&self) -> DomainSearchV2Builder<'_>

Search for email formats using either a domain or company name.

Returns a builder that allows you to set parameters using method chaining.

§Requirements

Exactly one of domain or company_name must be provided (XOR requirement).

§Example
use zero_bounce::ZeroBounce;
use zero_bounce::utility::ZBResult;
 
let zb = ZeroBounce::new("your_api_key");
// Using domain
let result = zb.domain_search_v2()
    .domain("example.com")
    .call()?;
// Or using company name
let result = zb.domain_search_v2()
    .company_name("Example Inc")
    .call()?;
Source§

impl ZeroBounce

Source

pub fn new(api_key: &str) -> ZeroBounce

Create a new ZeroBounce client instance with the default API URL.

§Arguments
  • api_key - Your ZeroBounce API key
§Example
use zero_bounce::ZeroBounce;

let zb = ZeroBounce::new("your_api_key");
§Panics

When the HTTP client cannot be built (for example, the TLS backend fails to initialise), as reqwest::blocking::Client::new() does. with_base_url returns that as an error instead.

Source

pub fn with_base_url<T>(api_key: &str, base_url: T) -> ZBResult<ZeroBounce>
where T: Into<String>,

Create a new ZeroBounce client instance with a custom base URL.

§Arguments
  • api_key - Your ZeroBounce API key
  • base_url - Base URL. Can be:
    • ApiBaseUrl::Default - Uses the default API URL
    • ApiBaseUrl::USA - Uses the USA API URL
    • ApiBaseUrl::EU - Uses the EU API URL
    • String or &str - Uses a custom URL string
§Errors

Returns ZBError::ExplicitError when base_url is not an https:// URL. http:// is accepted only for the exact hosts 127.0.0.1, localhost and [::1], for local tests. Also when the HTTP client cannot be built.

§Example
use zero_bounce::{ZeroBounce, ApiBaseUrl};

// Using enum
let zb = ZeroBounce::with_base_url("your_api_key", ApiBaseUrl::USA)?;

// Using custom string
let zb = ZeroBounce::with_base_url("your_api_key", "https://custom-api.example.com/v2/")?;

Trait Implementations§

Source§

impl Debug for ZeroBounce

Names the type and every field, with the API key shown as ***.

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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