Struct curl::easy::Easy

source ·
pub struct Easy { /* private fields */ }
Expand description

Raw bindings to a libcurl “easy session”.

This type is the same as the Easy2 type in this library except that it does not contain a type parameter. Callbacks from curl are all controlled via closures on this Easy type, and this type namely has a transfer method as well for ergonomic management of these callbacks.

There’s not necessarily a right answer for which type is correct to use, but as a general rule of thumb Easy is typically a reasonable choice for synchronous I/O and Easy2 is a good choice for asynchronous I/O.

§Examples

Creating a handle which can be used later

use curl::easy::Easy;

let handle = Easy::new();

Send an HTTP request, writing the response to stdout.

use std::io::{stdout, Write};

use curl::easy::Easy;

let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.write_function(|data| {
    stdout().write_all(data).unwrap();
    Ok(data.len())
}).unwrap();
handle.perform().unwrap();

Collect all output of an HTTP request to a vector.

use curl::easy::Easy;

let mut data = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
{
    let mut transfer = handle.transfer();
    transfer.write_function(|new_data| {
        data.extend_from_slice(new_data);
        Ok(new_data.len())
    }).unwrap();
    transfer.perform().unwrap();
}
println!("{:?}", data);

More examples of various properties of an HTTP request can be found on the specific methods as well.

Implementations§

source§

impl Easy

source

pub fn new() -> Easy

Creates a new “easy” handle which is the core of almost all operations in libcurl.

To use a handle, applications typically configure a number of options followed by a call to perform. Options are preserved across calls to perform and need to be reset manually (or via the reset method) if this is not desired.

source

pub fn verbose(&mut self, verbose: bool) -> Result<(), Error>

source

pub fn show_header(&mut self, show: bool) -> Result<(), Error>

source

pub fn progress(&mut self, progress: bool) -> Result<(), Error>

source

pub fn signal(&mut self, signal: bool) -> Result<(), Error>

Same as Easy2::signal

source

pub fn wildcard_match(&mut self, m: bool) -> Result<(), Error>

source

pub fn unix_socket(&mut self, unix_domain_socket: &str) -> Result<(), Error>

source

pub fn unix_socket_path<P: AsRef<Path>>( &mut self, path: Option<P> ) -> Result<(), Error>

source

pub fn abstract_unix_socket(&mut self, addr: &[u8]) -> Result<(), Error>

Same as Easy2::abstract_unix_socket

NOTE: this API can only be used on Linux OS.

source

pub fn write_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(&[u8]) -> Result<usize, WriteError> + Send + 'static,

Set callback for writing received data.

This callback function gets called by libcurl as soon as there is data received that needs to be saved.

The callback function will be passed as much data as possible in all invokes, but you must not make any assumptions. It may be one byte, it may be thousands. If show_header is enabled, which makes header data get passed to the write callback, you can get up to CURL_MAX_HTTP_HEADER bytes of header data passed into it. This usually means 100K.

This function may be called with zero bytes data if the transferred file is empty.

The callback should return the number of bytes actually taken care of. If that amount differs from the amount passed to your callback function, it’ll signal an error condition to the library. This will cause the transfer to get aborted and the libcurl function used will return an error with is_write_error.

If your callback function returns Err(WriteError::Pause) it will cause this transfer to become paused. See unpause_write for further details.

By default data is sent into the void, and this corresponds to the CURLOPT_WRITEFUNCTION and CURLOPT_WRITEDATA options.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using write_function to configure a callback that can reference stack-local data.

§Examples
use std::io::{stdout, Write};
use curl::easy::Easy;

let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.write_function(|data| {
    Ok(stdout().write(data).unwrap())
}).unwrap();
handle.perform().unwrap();

Writing to a stack-local buffer

use std::io::{stdout, Write};
use curl::easy::Easy;

let mut buf = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();

let mut transfer = handle.transfer();
transfer.write_function(|data| {
    buf.extend_from_slice(data);
    Ok(data.len())
}).unwrap();
transfer.perform().unwrap();
source

pub fn read_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(&mut [u8]) -> Result<usize, ReadError> + Send + 'static,

Read callback for data uploads.

This callback function gets called by libcurl as soon as it needs to read data in order to send it to the peer - like if you ask it to upload or post data to the server.

Your function must then return the actual number of bytes that it stored in that memory area. Returning 0 will signal end-of-file to the library and cause it to stop the current transfer.

If you stop the current transfer by returning 0 “pre-maturely” (i.e before the server expected it, like when you’ve said you will upload N bytes and you upload less than N bytes), you may experience that the server “hangs” waiting for the rest of the data that won’t come.

The read callback may return Err(ReadError::Abort) to stop the current operation immediately, resulting in a is_aborted_by_callback error code from the transfer.

The callback can return Err(ReadError::Pause) to cause reading from this connection to pause. See unpause_read for further details.

By default data not input, and this corresponds to the CURLOPT_READFUNCTION and CURLOPT_READDATA options.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using read_function to configure a callback that can reference stack-local data.

§Examples

Read input from stdin

use std::io::{stdin, Read};
use curl::easy::Easy;

let mut handle = Easy::new();
handle.url("https://example.com/login").unwrap();
handle.read_function(|into| {
    Ok(stdin().read(into).unwrap())
}).unwrap();
handle.post(true).unwrap();
handle.perform().unwrap();

Reading from stack-local data:

use std::io::{stdin, Read};
use curl::easy::Easy;

let mut data_to_upload = &b"foobar"[..];
let mut handle = Easy::new();
handle.url("https://example.com/login").unwrap();
handle.post(true).unwrap();

let mut transfer = handle.transfer();
transfer.read_function(|into| {
    Ok(data_to_upload.read(into).unwrap())
}).unwrap();
transfer.perform().unwrap();
source

pub fn seek_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(SeekFrom) -> SeekResult + Send + 'static,

User callback for seeking in input stream.

This function gets called by libcurl to seek to a certain position in the input stream and can be used to fast forward a file in a resumed upload (instead of reading all uploaded bytes with the normal read function/callback). It is also called to rewind a stream when data has already been sent to the server and needs to be sent again. This may happen when doing a HTTP PUT or POST with a multi-pass authentication method, or when an existing HTTP connection is reused too late and the server closes the connection.

The callback function must return SeekResult::Ok on success, SeekResult::Fail to cause the upload operation to fail or SeekResult::CantSeek to indicate that while the seek failed, libcurl is free to work around the problem if possible. The latter can sometimes be done by instead reading from the input or similar.

By default data this option is not set, and this corresponds to the CURLOPT_SEEKFUNCTION and CURLOPT_SEEKDATA options.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using seek_function to configure a callback that can reference stack-local data.

source

pub fn progress_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(f64, f64, f64, f64) -> bool + Send + 'static,

Callback to progress meter function

This function gets called by libcurl instead of its internal equivalent with a frequent interval. While data is being transferred it will be called very frequently, and during slow periods like when nothing is being transferred it can slow down to about one call per second.

The callback gets told how much data libcurl will transfer and has transferred, in number of bytes. The first argument is the total number of bytes libcurl expects to download in this transfer. The second argument is the number of bytes downloaded so far. The third argument is the total number of bytes libcurl expects to upload in this transfer. The fourth argument is the number of bytes uploaded so far.

Unknown/unused argument values passed to the callback will be set to zero (like if you only download data, the upload size will remain 0). Many times the callback will be called one or more times first, before it knows the data sizes so a program must be made to handle that.

Returning false from this callback will cause libcurl to abort the transfer and return is_aborted_by_callback.

If you transfer data with the multi interface, this function will not be called during periods of idleness unless you call the appropriate libcurl function that performs transfers.

progress must be set to true to make this function actually get called.

By default this function calls an internal method and corresponds to CURLOPT_PROGRESSFUNCTION and CURLOPT_PROGRESSDATA.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using progress_function to configure a callback that can reference stack-local data.

source

pub fn ssl_ctx_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(*mut c_void) -> Result<(), Error> + Send + 'static,

Callback to SSL context

This callback function gets called by libcurl just before the initialization of an SSL connection after having processed all other SSL related options to give a last chance to an application to modify the behaviour of the SSL initialization. The ssl_ctx parameter is actually a pointer to the SSL library’s SSL_CTX. If an error is returned from the callback no attempt to establish a connection is made and the perform operation will return the callback’s error code.

This function will get called on all new connections made to a server, during the SSL negotiation. The SSL_CTX pointer will be a new one every time.

To use this properly, a non-trivial amount of knowledge of your SSL library is necessary. For example, you can use this function to call library-specific callbacks to add additional validation code for certificates, and even to change the actual URI of a HTTPS request.

By default this function calls an internal method and corresponds to CURLOPT_SSL_CTX_FUNCTION and CURLOPT_SSL_CTX_DATA.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using progress_function to configure a callback that can reference stack-local data.

source

pub fn debug_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(InfoType, &[u8]) + Send + 'static,

Specify a debug callback

debug_function replaces the standard debug function used when verbose is in effect. This callback receives debug information, as specified in the type argument.

By default this option is not set and corresponds to the CURLOPT_DEBUGFUNCTION and CURLOPT_DEBUGDATA options.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using debug_function to configure a callback that can reference stack-local data.

source

pub fn header_function<F>(&mut self, f: F) -> Result<(), Error>
where F: FnMut(&[u8]) -> bool + Send + 'static,

Callback that receives header data

This function gets called by libcurl as soon as it has received header data. The header callback will be called once for each header and only complete header lines are passed on to the callback. Parsing headers is very easy using this. If this callback returns false it’ll signal an error to the library. This will cause the transfer to get aborted and the libcurl function in progress will return is_write_error.

A complete HTTP header that is passed to this function can be up to CURL_MAX_HTTP_HEADER (100K) bytes.

It’s important to note that the callback will be invoked for the headers of all responses received after initiating a request and not just the final response. This includes all responses which occur during authentication negotiation. If you need to operate on only the headers from the final response, you will need to collect headers in the callback yourself and use HTTP status lines, for example, to delimit response boundaries.

When a server sends a chunked encoded transfer, it may contain a trailer. That trailer is identical to a HTTP header and if such a trailer is received it is passed to the application using this callback as well. There are several ways to detect it being a trailer and not an ordinary header: 1) it comes after the response-body. 2) it comes after the final header line (CR LF) 3) a Trailer: header among the regular response-headers mention what header(s) to expect in the trailer.

For non-HTTP protocols like FTP, POP3, IMAP and SMTP this function will get called with the server responses to the commands that libcurl sends.

By default this option is not set and corresponds to the CURLOPT_HEADERFUNCTION and CURLOPT_HEADERDATA options.

Note that the lifetime bound on this function is 'static, but that is often too restrictive. To use stack data consider calling the transfer method and then using header_function to configure a callback that can reference stack-local data.

§Examples
use std::str;

use curl::easy::Easy;

let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();
handle.header_function(|header| {
    print!("header: {}", str::from_utf8(header).unwrap());
    true
}).unwrap();
handle.perform().unwrap();

Collecting headers to a stack local vector

use std::str;

use curl::easy::Easy;

let mut headers = Vec::new();
let mut handle = Easy::new();
handle.url("https://www.rust-lang.org/").unwrap();

{
    let mut transfer = handle.transfer();
    transfer.header_function(|header| {
        headers.push(str::from_utf8(header).unwrap().to_string());
        true
    }).unwrap();
    transfer.perform().unwrap();
}

println!("{:?}", headers);
source

pub fn fail_on_error(&mut self, fail: bool) -> Result<(), Error>

source

pub fn url(&mut self, url: &str) -> Result<(), Error>

Same as Easy2::url

source

pub fn port(&mut self, port: u16) -> Result<(), Error>

Same as Easy2::port

source

pub fn connect_to(&mut self, list: List) -> Result<(), Error>

source

pub fn path_as_is(&mut self, as_is: bool) -> Result<(), Error>

source

pub fn proxy(&mut self, url: &str) -> Result<(), Error>

Same as Easy2::proxy

source

pub fn proxy_port(&mut self, port: u16) -> Result<(), Error>

source

pub fn proxy_cainfo(&mut self, cainfo: &str) -> Result<(), Error>

source

pub fn proxy_capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

source

pub fn proxy_sslcert(&mut self, sslcert: &str) -> Result<(), Error>

source

pub fn proxy_sslcert_type(&mut self, kind: &str) -> Result<(), Error>

source

pub fn proxy_sslcert_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn proxy_sslkey(&mut self, sslkey: &str) -> Result<(), Error>

source

pub fn proxy_sslkey_type(&mut self, kind: &str) -> Result<(), Error>

source

pub fn proxy_sslkey_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn proxy_key_password(&mut self, password: &str) -> Result<(), Error>

source

pub fn proxy_type(&mut self, kind: ProxyType) -> Result<(), Error>

source

pub fn noproxy(&mut self, skip: &str) -> Result<(), Error>

source

pub fn http_proxy_tunnel(&mut self, tunnel: bool) -> Result<(), Error>

source

pub fn interface(&mut self, interface: &str) -> Result<(), Error>

source

pub fn set_local_port(&mut self, port: u16) -> Result<(), Error>

source

pub fn local_port_range(&mut self, range: u16) -> Result<(), Error>

source

pub fn dns_servers(&mut self, servers: &str) -> Result<(), Error>

source

pub fn dns_cache_timeout(&mut self, dur: Duration) -> Result<(), Error>

source

pub fn doh_url(&mut self, url: Option<&str>) -> Result<(), Error>

source

pub fn doh_ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error>

source

pub fn doh_ssl_verify_host(&mut self, verify: bool) -> Result<(), Error>

source

pub fn doh_ssl_verify_status(&mut self, verify: bool) -> Result<(), Error>

source

pub fn buffer_size(&mut self, size: usize) -> Result<(), Error>

source

pub fn upload_buffer_size(&mut self, size: usize) -> Result<(), Error>

source

pub fn tcp_nodelay(&mut self, enable: bool) -> Result<(), Error>

source

pub fn tcp_keepalive(&mut self, enable: bool) -> Result<(), Error>

source

pub fn tcp_keepintvl(&mut self, dur: Duration) -> Result<(), Error>

source

pub fn tcp_keepidle(&mut self, dur: Duration) -> Result<(), Error>

source

pub fn address_scope(&mut self, scope: u32) -> Result<(), Error>

source

pub fn username(&mut self, user: &str) -> Result<(), Error>

source

pub fn password(&mut self, pass: &str) -> Result<(), Error>

source

pub fn http_auth(&mut self, auth: &Auth) -> Result<(), Error>

source

pub fn aws_sigv4(&mut self, param: &str) -> Result<(), Error>

source

pub fn proxy_username(&mut self, user: &str) -> Result<(), Error>

source

pub fn proxy_password(&mut self, pass: &str) -> Result<(), Error>

source

pub fn proxy_auth(&mut self, auth: &Auth) -> Result<(), Error>

source

pub fn netrc(&mut self, netrc: NetRc) -> Result<(), Error>

Same as Easy2::netrc

source

pub fn autoreferer(&mut self, enable: bool) -> Result<(), Error>

source

pub fn accept_encoding(&mut self, encoding: &str) -> Result<(), Error>

source

pub fn transfer_encoding(&mut self, enable: bool) -> Result<(), Error>

source

pub fn follow_location(&mut self, enable: bool) -> Result<(), Error>

source

pub fn unrestricted_auth(&mut self, enable: bool) -> Result<(), Error>

source

pub fn max_redirections(&mut self, max: u32) -> Result<(), Error>

source

pub fn post_redirections( &mut self, redirects: &PostRedirections ) -> Result<(), Error>

source

pub fn put(&mut self, enable: bool) -> Result<(), Error>

Same as Easy2::put

source

pub fn post(&mut self, enable: bool) -> Result<(), Error>

Same as Easy2::post

source

pub fn post_fields_copy(&mut self, data: &[u8]) -> Result<(), Error>

source

pub fn post_field_size(&mut self, size: u64) -> Result<(), Error>

source

pub fn httppost(&mut self, form: Form) -> Result<(), Error>

source

pub fn referer(&mut self, referer: &str) -> Result<(), Error>

source

pub fn useragent(&mut self, useragent: &str) -> Result<(), Error>

source

pub fn http_headers(&mut self, list: List) -> Result<(), Error>

source

pub fn cookie(&mut self, cookie: &str) -> Result<(), Error>

Same as Easy2::cookie

source

pub fn cookie_file<P: AsRef<Path>>(&mut self, file: P) -> Result<(), Error>

source

pub fn cookie_jar<P: AsRef<Path>>(&mut self, file: P) -> Result<(), Error>

source

pub fn cookie_session(&mut self, session: bool) -> Result<(), Error>

source

pub fn cookie_list(&mut self, cookie: &str) -> Result<(), Error>

source

pub fn get(&mut self, enable: bool) -> Result<(), Error>

Same as Easy2::get

source

pub fn ignore_content_length(&mut self, ignore: bool) -> Result<(), Error>

source

pub fn http_content_decoding(&mut self, enable: bool) -> Result<(), Error>

source

pub fn http_transfer_decoding(&mut self, enable: bool) -> Result<(), Error>

source

pub fn range(&mut self, range: &str) -> Result<(), Error>

Same as Easy2::range

source

pub fn resume_from(&mut self, from: u64) -> Result<(), Error>

source

pub fn custom_request(&mut self, request: &str) -> Result<(), Error>

source

pub fn fetch_filetime(&mut self, fetch: bool) -> Result<(), Error>

source

pub fn nobody(&mut self, enable: bool) -> Result<(), Error>

Same as Easy2::nobody

source

pub fn in_filesize(&mut self, size: u64) -> Result<(), Error>

source

pub fn upload(&mut self, enable: bool) -> Result<(), Error>

Same as Easy2::upload

source

pub fn max_filesize(&mut self, size: u64) -> Result<(), Error>

source

pub fn time_condition(&mut self, cond: TimeCondition) -> Result<(), Error>

source

pub fn time_value(&mut self, val: i64) -> Result<(), Error>

source

pub fn timeout(&mut self, timeout: Duration) -> Result<(), Error>

source

pub fn low_speed_limit(&mut self, limit: u32) -> Result<(), Error>

source

pub fn low_speed_time(&mut self, dur: Duration) -> Result<(), Error>

source

pub fn max_send_speed(&mut self, speed: u64) -> Result<(), Error>

source

pub fn max_recv_speed(&mut self, speed: u64) -> Result<(), Error>

source

pub fn max_connects(&mut self, max: u32) -> Result<(), Error>

source

pub fn maxage_conn(&mut self, max_age: Duration) -> Result<(), Error>

source

pub fn fresh_connect(&mut self, enable: bool) -> Result<(), Error>

source

pub fn forbid_reuse(&mut self, enable: bool) -> Result<(), Error>

source

pub fn connect_timeout(&mut self, timeout: Duration) -> Result<(), Error>

source

pub fn ip_resolve(&mut self, resolve: IpResolve) -> Result<(), Error>

source

pub fn resolve(&mut self, list: List) -> Result<(), Error>

source

pub fn connect_only(&mut self, enable: bool) -> Result<(), Error>

source

pub fn ssl_cert<P: AsRef<Path>>(&mut self, cert: P) -> Result<(), Error>

source

pub fn ssl_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn ssl_cert_type(&mut self, kind: &str) -> Result<(), Error>

source

pub fn ssl_key<P: AsRef<Path>>(&mut self, key: P) -> Result<(), Error>

source

pub fn ssl_key_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn ssl_key_type(&mut self, kind: &str) -> Result<(), Error>

source

pub fn key_password(&mut self, password: &str) -> Result<(), Error>

source

pub fn ssl_cainfo_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn proxy_ssl_cainfo_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn ssl_engine(&mut self, engine: &str) -> Result<(), Error>

source

pub fn ssl_engine_default(&mut self, enable: bool) -> Result<(), Error>

source

pub fn http_version(&mut self, version: HttpVersion) -> Result<(), Error>

source

pub fn ssl_version(&mut self, version: SslVersion) -> Result<(), Error>

source

pub fn proxy_ssl_version(&mut self, version: SslVersion) -> Result<(), Error>

source

pub fn ssl_min_max_version( &mut self, min_version: SslVersion, max_version: SslVersion ) -> Result<(), Error>

source

pub fn proxy_ssl_min_max_version( &mut self, min_version: SslVersion, max_version: SslVersion ) -> Result<(), Error>

source

pub fn ssl_verify_host(&mut self, verify: bool) -> Result<(), Error>

source

pub fn proxy_ssl_verify_host(&mut self, verify: bool) -> Result<(), Error>

source

pub fn ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error>

source

pub fn proxy_ssl_verify_peer(&mut self, verify: bool) -> Result<(), Error>

source

pub fn cainfo<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

Same as Easy2::cainfo

source

pub fn issuer_cert<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

source

pub fn proxy_issuer_cert<P: AsRef<Path>>( &mut self, path: P ) -> Result<(), Error>

source

pub fn issuer_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn proxy_issuer_cert_blob(&mut self, blob: &[u8]) -> Result<(), Error>

source

pub fn capath<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

Same as Easy2::capath

source

pub fn crlfile<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

source

pub fn proxy_crlfile<P: AsRef<Path>>(&mut self, path: P) -> Result<(), Error>

source

pub fn certinfo(&mut self, enable: bool) -> Result<(), Error>

source

pub fn random_file<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>

source

pub fn egd_socket<P: AsRef<Path>>(&mut self, p: P) -> Result<(), Error>

source

pub fn ssl_cipher_list(&mut self, ciphers: &str) -> Result<(), Error>

source

pub fn proxy_ssl_cipher_list(&mut self, ciphers: &str) -> Result<(), Error>

source

pub fn ssl_sessionid_cache(&mut self, enable: bool) -> Result<(), Error>

source

pub fn ssl_options(&mut self, bits: &SslOpt) -> Result<(), Error>

source

pub fn proxy_ssl_options(&mut self, bits: &SslOpt) -> Result<(), Error>

source

pub fn pinned_public_key(&mut self, pubkey: &str) -> Result<(), Error>

source

pub fn time_condition_unmet(&mut self) -> Result<bool, Error>

source

pub fn effective_url(&mut self) -> Result<Option<&str>, Error>

source

pub fn effective_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>

source

pub fn response_code(&mut self) -> Result<u32, Error>

source

pub fn http_connectcode(&mut self) -> Result<u32, Error>

source

pub fn filetime(&mut self) -> Result<Option<i64>, Error>

source

pub fn download_size(&mut self) -> Result<f64, Error>

source

pub fn upload_size(&mut self) -> Result<f64, Error>

source

pub fn content_length_download(&mut self) -> Result<f64, Error>

source

pub fn total_time(&mut self) -> Result<Duration, Error>

source

pub fn namelookup_time(&mut self) -> Result<Duration, Error>

source

pub fn connect_time(&mut self) -> Result<Duration, Error>

source

pub fn appconnect_time(&mut self) -> Result<Duration, Error>

source

pub fn pretransfer_time(&mut self) -> Result<Duration, Error>

source

pub fn starttransfer_time(&mut self) -> Result<Duration, Error>

source

pub fn redirect_time(&mut self) -> Result<Duration, Error>

source

pub fn redirect_count(&mut self) -> Result<u32, Error>

source

pub fn redirect_url(&mut self) -> Result<Option<&str>, Error>

source

pub fn redirect_url_bytes(&mut self) -> Result<Option<&[u8]>, Error>

source

pub fn header_size(&mut self) -> Result<u64, Error>

source

pub fn request_size(&mut self) -> Result<u64, Error>

source

pub fn content_type(&mut self) -> Result<Option<&str>, Error>

source

pub fn content_type_bytes(&mut self) -> Result<Option<&[u8]>, Error>

source

pub fn os_errno(&mut self) -> Result<i32, Error>

source

pub fn primary_ip(&mut self) -> Result<Option<&str>, Error>

source

pub fn primary_port(&mut self) -> Result<u16, Error>

source

pub fn local_ip(&mut self) -> Result<Option<&str>, Error>

source

pub fn local_port(&mut self) -> Result<u16, Error>

source

pub fn cookies(&mut self) -> Result<List, Error>

source

pub fn pipewait(&mut self, wait: bool) -> Result<(), Error>

source

pub fn http_09_allowed(&mut self, allow: bool) -> Result<(), Error>

source

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

source

pub fn transfer<'data, 'easy>(&'easy mut self) -> Transfer<'easy, 'data>

Creates a new scoped transfer which can be used to set callbacks and data which only live for the scope of the returned object.

An Easy handle is often reused between different requests to cache connections to servers, but often the lifetime of the data as part of each transfer is unique. This function serves as an ability to share an Easy across many transfers while ergonomically using possibly stack-local data as part of each transfer.

Configuration can be set on the Easy and then a Transfer can be created to set scoped configuration (like callbacks). Finally, the perform method on the Transfer function can be used.

When the Transfer option is dropped then all configuration set on the transfer itself will be reset.

source

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

source

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

source

pub fn url_encode(&mut self, s: &[u8]) -> String

source

pub fn url_decode(&mut self, s: &str) -> Vec<u8>

source

pub fn reset(&mut self)

Same as Easy2::reset

source

pub fn recv(&mut self, data: &mut [u8]) -> Result<usize, Error>

Same as Easy2::recv

source

pub fn send(&mut self, data: &[u8]) -> Result<usize, Error>

Same as Easy2::send

source

pub fn raw(&self) -> *mut CURL

Same as Easy2::raw

source

pub fn take_error_buf(&self) -> Option<String>

Trait Implementations§

source§

impl Debug for Easy

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for Easy

§

impl Send for Easy

§

impl !Sync for Easy

§

impl Unpin for Easy

§

impl !UnwindSafe for Easy

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

§

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

§

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.