pub struct rustls_connection { /* private fields */ }

Implementations§

source§

impl rustls_connection

source

#[no_mangle]
pub extern "C" fn rustls_connection_set_userdata( conn: *mut rustls_connection, userdata: *mut c_void )

Set the userdata pointer associated with this connection. This will be passed to any callbacks invoked by the connection, if you’ve set up callbacks in the config. The pointed-to data must outlive the connection.

source

#[no_mangle]
pub extern "C" fn rustls_connection_set_log_callback( conn: *mut rustls_connection, cb: rustls_log_callback )

Set the logging callback for this connection. The log callback will be invoked with the userdata parameter previously set by rustls_connection_set_userdata, or NULL if no userdata was set.

source

#[no_mangle]
pub extern "C" fn rustls_connection_read_tls( conn: *mut rustls_connection, callback: rustls_read_callback, userdata: *mut c_void, out_n: *mut size_t ) -> rustls_io_result

Read some TLS bytes from the network into internal buffers. The actual network I/O is performed by callback, which you provide. Rustls will invoke your callback with a suitable buffer to store the read bytes into. You don’t have to fill it up, just fill with as many bytes as you get in one syscall. The userdata parameter is passed through directly to callback. Note that this is distinct from the userdata parameter set with rustls_connection_set_userdata. Returns 0 for success, or an errno value on error. Passes through return values from callback. See rustls_read_callback for more details. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.read_tls

source

#[no_mangle]
pub extern "C" fn rustls_connection_write_tls( conn: *mut rustls_connection, callback: rustls_write_callback, userdata: *mut c_void, out_n: *mut size_t ) -> rustls_io_result

Write some TLS bytes to the network. The actual network I/O is performed by callback, which you provide. Rustls will invoke your callback with a suitable buffer containing TLS bytes to send. You don’t have to write them all, just as many as you can in one syscall. The userdata parameter is passed through directly to callback. Note that this is distinct from the userdata parameter set with rustls_connection_set_userdata. Returns 0 for success, or an errno value on error. Passes through return values from callback. See rustls_write_callback for more details. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.write_tls

source

#[no_mangle]
pub extern "C" fn rustls_connection_write_tls_vectored( conn: *mut rustls_connection, callback: rustls_write_vectored_callback, userdata: *mut c_void, out_n: *mut size_t ) -> rustls_io_result

Write all available TLS bytes to the network. The actual network I/O is performed by callback, which you provide. Rustls will invoke your callback with an array of rustls_slice_bytes, each containing a buffer with TLS bytes to send. You don’t have to write them all, just as many as you are willing. The userdata parameter is passed through directly to callback. Note that this is distinct from the userdata parameter set with rustls_connection_set_userdata. Returns 0 for success, or an errno value on error. Passes through return values from callback. See rustls_write_callback for more details. https://docs.rs/rustls/0.20.0/rustls/struct.Writer.html#method.write_vectored

source

#[no_mangle]
pub extern "C" fn rustls_connection_process_new_packets( conn: *mut rustls_connection ) -> rustls_result

Decrypt any available ciphertext from the internal buffer and put it into the internal plaintext buffer, potentially making bytes available for rustls_connection_read(). https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.process_new_packets

source

#[no_mangle]
pub extern "C" fn rustls_connection_wants_read( conn: *const rustls_connection ) -> bool

source

#[no_mangle]
pub extern "C" fn rustls_connection_wants_write( conn: *const rustls_connection ) -> bool

source

#[no_mangle]
pub extern "C" fn rustls_connection_is_handshaking( conn: *const rustls_connection ) -> bool

source

#[no_mangle]
pub extern "C" fn rustls_connection_set_buffer_limit( conn: *mut rustls_connection, n: usize )

Sets a limit on the internal buffers used to buffer unsent plaintext (prior to completing the TLS handshake) and unsent TLS records. By default, there is no limit. The limit can be set at any time, even if the current buffer use is higher. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.set_buffer_limit

source

#[no_mangle]
pub extern "C" fn rustls_connection_send_close_notify( conn: *mut rustls_connection )

Queues a close_notify fatal alert to be sent in the next write_tls call. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.send_close_notify

source

#[no_mangle]
pub extern "C" fn rustls_connection_get_peer_certificate( conn: *const rustls_connection, i: size_t ) -> *const rustls_certificate

Return the i-th certificate provided by the peer. Index 0 is the end entity certificate. Higher indexes are certificates in the chain. Requesting an index higher than what is available returns NULL. The returned pointer is valid until the next mutating function call affecting the connection. A mutating function call is one where the first argument has type struct rustls_connection * (as opposed to const struct rustls_connection *). https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.peer_certificates

source

#[no_mangle]
pub extern "C" fn rustls_connection_get_alpn_protocol( conn: *const rustls_connection, protocol_out: *mut *const u8, protocol_out_len: *mut usize )

Get the ALPN protocol that was negotiated, if any. Stores a pointer to a borrowed buffer of bytes, and that buffer’s len, in the output parameters. The borrow lives as long as the connection. If the connection is still handshaking, or no ALPN protocol was negotiated, stores NULL and 0 in the output parameters. The provided pointer is valid until the next mutating function call affecting the connection. A mutating function call is one where the first argument has type struct rustls_connection * (as opposed to const struct rustls_connection *). https://www.iana.org/assignments/tls-parameters/ https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.alpn_protocol

source

#[no_mangle]
pub extern "C" fn rustls_connection_get_protocol_version( conn: *const rustls_connection ) -> u16

Return the TLS protocol version that has been negotiated. Before this has been decided during the handshake, this will return 0. Otherwise, the u16 version number as defined in the relevant RFC is returned. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.protocol_version https://docs.rs/rustls/0.20.0/rustls/internal/msgs/enums/enum.ProtocolVersion.html

source

#[no_mangle]
pub extern "C" fn rustls_connection_get_negotiated_ciphersuite( conn: *const rustls_connection ) -> *const rustls_supported_ciphersuite

Retrieves the cipher suite agreed with the peer. This returns NULL until the ciphersuite is agreed. The returned pointer lives as long as the program. https://docs.rs/rustls/0.20.0/rustls/enum.Connection.html#method.negotiated_cipher_suite

source

#[no_mangle]
pub extern "C" fn rustls_connection_write( conn: *mut rustls_connection, buf: *const u8, count: size_t, out_n: *mut size_t ) -> rustls_result

Write up to count plaintext bytes from buf into the rustls_connection. This will increase the number of output bytes available to rustls_connection_write_tls. On success, store the number of bytes actually written in *out_n (this may be less than count). https://docs.rs/rustls/0.20.0/rustls/struct.Writer.html#method.write

source

#[no_mangle]
pub extern "C" fn rustls_connection_read( conn: *mut rustls_connection, buf: *mut u8, count: size_t, out_n: *mut size_t ) -> rustls_result

Read up to count plaintext bytes from the rustls_connection into buf. On success, store the number of bytes read in *out_n (this may be less than count). A success with *out_n set to 0 means “all bytes currently available have been read, but more bytes may become available after subsequent calls to rustls_connection_read_tls and rustls_connection_process_new_packets.”

Subtle note: Even though this function only writes to buf and does not read from it, the memory in buf must be initialized before the call (for Rust-internal reasons). Initializing a buffer once and then using it multiple times without zeroizing before each call is fine. https://docs.rs/rustls/0.20.0/rustls/struct.Reader.html#method.read

source

#[no_mangle]
pub extern "C" fn rustls_connection_free(conn: *mut rustls_connection)

Free a rustls_connection. Calling with NULL is fine. Must not be called twice with the same value.

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.