Skip to main content

_cef_server_t

Struct _cef_server_t 

Source
#[repr(C)]
pub struct _cef_server_t {
Show 14 fields pub base: cef_base_ref_counted_t, pub get_task_runner: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> *mut _cef_task_runner_t>, pub shutdown: Option<unsafe extern "C" fn(self_: *mut _cef_server_t)>, pub is_running: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> c_int>, pub get_address: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> cef_string_userfree_t>, pub has_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> c_int>, pub is_valid_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int) -> c_int>, pub send_http200_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, content_type: *const cef_string_t, data: *const c_void, data_size: usize)>, pub send_http404_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int)>, pub send_http500_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, error_message: *const cef_string_t)>, pub send_http_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, response_code: c_int, content_type: *const cef_string_t, content_length: i64, extra_headers: cef_string_multimap_t)>, pub send_raw_data: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>, pub close_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int)>, pub send_web_socket_message: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>,
}
Expand description

Structure representing a server that supports HTTP and WebSocket requests. Server capacity is limited and is intended to handle only a small number of simultaneous connections (e.g. for communicating between applications on localhost). The functions of this structure are safe to call from any thread in the brower process unless otherwise indicated.

NOTE: This struct is allocated DLL-side.

Fields§

§base: cef_base_ref_counted_t

Base structure.

§get_task_runner: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> *mut _cef_task_runner_t>

Returns the task runner for the dedicated server thread.

§shutdown: Option<unsafe extern "C" fn(self_: *mut _cef_server_t)>

Stop the server and shut down the dedicated server thread. See cef_server_handler_t::OnServerCreated documentation for a description of server lifespan.

§is_running: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> c_int>

Returns true (1) if the server is currently running and accepting incoming connections. See cef_server_handler_t::OnServerCreated documentation for a description of server lifespan. This function must be called on the dedicated server thread.

§get_address: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> cef_string_userfree_t>

Returns the server address including the port number.

§has_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t) -> c_int>

Returns true (1) if the server currently has a connection. This function must be called on the dedicated server thread.

§is_valid_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int) -> c_int>

Returns true (1) if |connection_id| represents a valid connection. This function must be called on the dedicated server thread.

§send_http200_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, content_type: *const cef_string_t, data: *const c_void, data_size: usize)>

Send an HTTP 200 “OK” response to the connection identified by |connection_id|. |content_type| is the response content type (e.g. “text/html”), |data| is the response content, and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. The connection will be closed automatically after the response is sent.

§send_http404_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int)>

Send an HTTP 404 “Not Found” response to the connection identified by |connection_id|. The connection will be closed automatically after the response is sent.

§send_http500_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, error_message: *const cef_string_t)>

Send an HTTP 500 “Internal Server Error” response to the connection identified by |connection_id|. |error_message| is the associated error message. The connection will be closed automatically after the response is sent.

§send_http_response: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, response_code: c_int, content_type: *const cef_string_t, content_length: i64, extra_headers: cef_string_multimap_t)>

Send a custom HTTP response to the connection identified by |connection_id|. |response_code| is the HTTP response code sent in the status line (e.g. 200), |content_type| is the response content type sent as the “Content-Type” header (e.g. “text/html”), |content_length| is the expected content length, and |extra_headers| is the map of extra response headers. If |content_length| is >= 0 then the “Content-Length” header will be sent. If |content_length| is 0 then no content is expected and the connection will be closed automatically after the response is sent. If |content_length| is < 0 then no “Content-Length” header will be sent and the client will continue reading until the connection is closed. Use the SendRawData function to send the content, if applicable, and call CloseConnection after all content has been sent.

§send_raw_data: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>

Send raw data directly to the connection identified by |connection_id|. |data| is the raw data and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. No validation of |data| is performed internally so the client should be careful to send the amount indicated by the “Content-Length” header, if specified. See SendHttpResponse documentation for intended usage.

§close_connection: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int)>

Close the connection identified by |connection_id|. See SendHttpResponse documentation for intended usage.

§send_web_socket_message: Option<unsafe extern "C" fn(self_: *mut _cef_server_t, connection_id: c_int, data: *const c_void, data_size: usize)>

Send a WebSocket message to the connection identified by |connection_id|. |data| is the response content and |data_size| is the size of |data| in bytes. The contents of |data| will be copied. See cef_server_handler_t::OnWebSocketRequest documentation for intended usage.

Trait Implementations§

Source§

impl Clone for _cef_server_t

Source§

fn clone(&self) -> _cef_server_t

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for _cef_server_t

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Copy for _cef_server_t

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.