Overview of cef-dll-sys
devcef-dll-sys crate provides generated Rust bindings for the Chromium Embedded Framework (CEF) C API. It is designed to work with prebuilt CEF binaries across any supported platform.repository·dev·Indexed 19 days ago
https://github.com/tauri-apps/cef-rsRust bindings for the Chromium Embedded Framework (CEF), enabling the embedding of a Chromium-based browser engine into Rust applications. The project includes the `cef` crate for high-level safe abstractions, `cef-dll-sys` for raw C API bindings, and utility tools such as `download-cef` for acquiring binaries, `export-cef-dir` for managing directory structures, and `bundle-cef-app` for packaging applications.
cef-dll-sys crate provides generated Rust bindings for the Chromium Embedded Framework (CEF) C API. It is designed to work with prebuilt CEF binaries across any supported platform.get-latest utility downloads the list of available versions from the Chromium Embedded Framework (CEF) Automated Builds page. It is used to determine the most recent CEF version available for every platform supported by cef-rs.download-cef package provides utility functions designed to download and extract prebuilt Chromium Embedded Framework (CEF) archives. This utility supports multiple platforms and automates the process of acquiring the necessary binaries for use with cef-rs.cef crate provides Rust bindings for the Chromium Embedded Framework (CEF), allowing you to embed a Chromium-based browser engine into your Rust applications.export-cef-dir tool allows you to export files from a prebuilt Chromium Embedded Framework (CEF) archive on any supported platform. The resulting directory structure is specifically designed to be compatible with the requirements of the cef-dll-sys crate.When building a project that depends on cef-dll-sys, you must point the build process to the directory containing the exported CEF binaries. This is done by setting the CEF_PATH environment variable to the absolute path of your exported directory.
# Example: setting CEF_PATH to a local directory
export CEF_PATH="~/.local/share/cef"After installing the shared binaries, you must set environment variables so the system can locate the CEF libraries.
export CEF_PATH="$HOME/.local/share/cef"
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CEF_PATH"export CEF_PATH="$HOME/.local/share/cef"
export DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH:$CEF_PATH:$CEF_PATH/Chromium Embedded Framework.framework/Libraries"$env:CEF_PATH="$env:USERPROFILE/.local/share/cef"
$env:PATH="$env:PATH;$env:CEF_PATH"To speed up builds of the cef crate, you can pre-install shared CEF binaries to a local directory. If you skip this, the cef-dll-sys crate will download and extract these files into its OUT_DIR for every build. You should repeat this step whenever you upgrade to a new version of the cef crate.
Linux or macOS:
cargo run -p export-cef-dir -- --force $HOME/.local/share/cefWindows (PowerShell):
cargo run -p export-cef-dir -- --force $env:USERPROFILE/.local/share/cefcargo run -p export-cef-dir -- --force $HOME/.local/share/cefTo update the Rust bindings for the Chromium Embedded Framework (CEF), you must download a prebuilt CEF archive for your supported platform and then run the bindgen process. This process updates the cef-dll-sys crate (the raw C API bindings) and subsequently regenerates the safe Rust bindings in the cef crate.
bindgen tool against the C API for the cef-dll-sys crate.cef crate.To ensure the application can find and load the CEF DLLs/libraries at runtime, you must update the platform-specific library loader path using the CEF_PATH environment variable.
### Linux
```sh
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$CEF_PATH"export DYLD_FALLBACK_LIBRARY_PATH="$DYLD_FALLBACK_LIBRARY_PATH:$CEF_PATH"$env:PATH = "$env:PATH;$env:CEF_PATH"You can customize the application bundle by adding metadata to your Cargo.toml. This allows you to define the name of the macOS helper and specify a resource directory to be included in the bundle.
[package.metadata.cef.bundle]
helper_name = "cefsimple_helper"
resources_path = "resources"[package.metadata.cef.bundle]
helper_name = "cefsimple_helper"
resources_path = "resources"The MessageRouter facilitates asynchronous communication between the Renderer process (JavaScript) and the Browser process (Rust) using a request/response pattern.
In JavaScript, the router exposes a query function (configured via js_query_function). This function expects a single object argument with the following members:
request: A string or ArrayBuffer containing the query data.on_success: A callback function executed when the browser process returns a successful response.on_failure: A callback function executed if the query fails.persistent: (Optional) A boolean indicating if the request should be kept in the router's tracking map.Calling this function returns a unique request_id immediately.
The RendererSideRouter captures the request and sends it to the browser process. The browser process uses a BrowserSideRouter to find a registered BrowserSideHandler. The handler processes the request and uses a BrowserSideRouterCallback to send the result back.
Users can cancel a specific request using the function configured via js_cancel_function, passing the request_id as an integer. If a special RESERVED_ID is used, all requests associated with the current context_id are canceled.