mirror of
https://github.com/tauri-apps/plugins-workspace.git
synced 2026-09-24 21:40:48 +02:00
chore: update documentation
This commit is contained in:
@@ -274,27 +274,36 @@ async fn send(
|
||||
}
|
||||
}
|
||||
|
||||
/// Initializes the plugin with the default [`Builder`], i.e. without a custom TLS [`Connector`].
|
||||
pub fn init<R: Runtime>() -> TauriPlugin<R> {
|
||||
Builder::default().build()
|
||||
}
|
||||
|
||||
/// Builder for the WebSocket plugin, used to configure a custom TLS [`Connector`] before calling [`Builder::build`].
|
||||
#[derive(Default)]
|
||||
pub struct Builder {
|
||||
tls_connector: Option<Connector>,
|
||||
}
|
||||
|
||||
impl Builder {
|
||||
/// Creates a new [`Builder`] with no custom TLS [`Connector`] configured.
|
||||
pub fn new() -> Self {
|
||||
Self {
|
||||
tls_connector: None,
|
||||
}
|
||||
}
|
||||
|
||||
/// Sets the TLS [`Connector`] used to establish `wss://` connections.
|
||||
///
|
||||
/// When this is not called (or is called with [`Connector::Plain`]) and a `rustls-tls` or
|
||||
/// `rustls-tls-native-roots` feature is enabled, [`Builder::build`] installs `rustls`'s `ring`
|
||||
/// crypto provider as the process default if none is installed yet.
|
||||
pub fn tls_connector(mut self, connector: Connector) -> Self {
|
||||
self.tls_connector.replace(connector);
|
||||
self
|
||||
}
|
||||
|
||||
/// Builds the plugin, registering the `connect` and `send` commands and the shared connection state.
|
||||
pub fn build<R: Runtime>(self) -> TauriPlugin<R> {
|
||||
PluginBuilder::new("websocket")
|
||||
.invoke_handler(tauri::generate_handler![connect, send])
|
||||
|
||||
Reference in New Issue
Block a user