### Initialize and use Liquid Glass in Tauri Source: https://docs.rs/tauri-plugin-liquid-glass/latest/index.html Demonstrates how to register the liquid-glass plugin within the Tauri builder and access its API using the LiquidGlassExt trait. This example checks for platform support and prints the result to the console during the setup phase. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Access the plugin API via extension trait let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` -------------------------------- ### Apply and Configure Liquid Glass Effects Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/desktop.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides examples for enabling, customizing, and disabling the liquid glass effect on a specific window using LiquidGlassConfig. ```rust use tauri_plugin_liquid_glass::{LiquidGlassExt, LiquidGlassConfig, GlassMaterialVariant}; fn apply_glass(app: tauri::AppHandle, window: tauri::WebviewWindow) { // Enable with default settings app.liquid_glass().set_effect(&window, Default::default()).unwrap(); // Enable with custom settings app.liquid_glass().set_effect(&window, LiquidGlassConfig { corner_radius: 24.0, tint_color: Some("#ffffff20".into()), variant: GlassMaterialVariant::Sidebar, ..Default::default() }).unwrap(); // Disable app.liquid_glass().set_effect(&window, LiquidGlassConfig { enabled: false, ..Default::default() }).unwrap(); } ``` -------------------------------- ### Initialize Tauri Liquid Glass Plugin Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html Initializes the liquid-glass plugin for a Tauri application. It registers command handlers for checking support and setting effects, and manages the necessary state for the plugin's functionality, including platform-specific setup for macOS. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Access the plugin API via extension trait let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` -------------------------------- ### Plugin Initialization Function Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html The core function to initialize the liquid-glass plugin for Tauri. It sets up the plugin with a unique identifier, registers command handlers, and performs setup logic, including platform-specific configurations. ```rust use tauri::{ plugin::{Builder, TauriPlugin}, Manager, Runtime, }; pub fn init() -> TauriPlugin { Builder::new("liquid-glass") .invoke_handler(tauri::generate_handler![ commands::is_glass_supported, commands::set_liquid_glass_effect, ]) .setup(|app, _api| { // Manage the LiquidGlass struct for the extension trait app.manage(LiquidGlass::new(app.clone())); #[cfg(target_os = "macos")] { app.manage(glass_effect::GlassViewRegistry::default()); } Ok(()) }) .build() } ``` -------------------------------- ### GET /glass/equivalent Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=u32+-%3E+bool Checks the equivalence of a GlassMaterialVariant against a provided key. ```APIDOC ## GET /glass/equivalent ### Description Determines if a GlassMaterialVariant is equivalent to a given key, typically used for material matching logic. ### Method GET ### Endpoint /glass/equivalent ### Parameters #### Query Parameters - **variant** (string) - Required - The GlassMaterialVariant identifier. - **key** (u32) - Required - The key to compare against the variant. ### Request Example { "variant": "frosted", "key": 12345 } ### Response #### Success Response (200) - **equivalent** (boolean) - Returns true if the variant matches the key. #### Response Example { "equivalent": true } ``` -------------------------------- ### Safely Get Ok Value (Nightly Only) Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Introduces `into_ok`, a nightly-only experimental API that returns the contained `Ok` value without panicking. It's designed as a compile-time safeguard against Results that cannot produce errors. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### Access Liquid Glass Plugin API via Extension Trait Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html?search= Shows how to use the LiquidGlassExt trait to access the Liquid Glass plugin's functionality from different Tauri application contexts like AppHandle, App, and WebviewWindow. Includes examples for checking support and applying effects. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; fn example(app: tauri::AppHandle, window: tauri::WebviewWindow) { // Check if supported let supported = app.liquid_glass().is_supported(); // Apply effect app.liquid_glass().set_effect(&window, Default::default()).unwrap(); } ``` -------------------------------- ### Convert Result to Option Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=u32+-%3E+bool Examples of converting Result types into Option types using ok() and err() methods, which consume the Result and discard the unwanted variant. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); let x: Result = Ok(2); assert_eq!(x.err(), None); let x: Result = Err("Nothing here"); assert_eq!(x.err(), Some("Nothing here")); ``` -------------------------------- ### Cloning a Result in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Provides an example of cloning a `Result` in Rust, where both `T` and `E` must implement the `Clone` trait. This creates a duplicate of the `Result` value. ```rust fn clone(&self) -> Result where T: Clone, E: Clone ``` -------------------------------- ### init() Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/fn.init.html?search=u32+-%3E+bool Initializes the liquid-glass plugin within the Tauri application builder. ```APIDOC ## [FUNCTION] init ### Description Initializes the liquid-glass plugin for a Tauri application. This must be called during the application setup phase to register the plugin and enable extension traits. ### Method Rust Function ### Endpoint tauri_plugin_liquid_glass::init() -> TauriPlugin ### Parameters #### Path Parameters - **R** (Runtime) - Required - The Tauri runtime type. ### Request Example ```rust tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) ``` ### Response #### Success Response - **TauriPlugin** (Object) - The initialized plugin instance to be consumed by the Tauri builder. ### Response Example ```rust // Plugin is registered and ready for use via LiquidGlassExt trait ``` ``` -------------------------------- ### Initialization and Usage Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search=u32+-%3E+bool How to initialize the plugin and access the API via the LiquidGlassExt extension trait. ```APIDOC ## Initialization ### Description Initialize the liquid-glass plugin within the Tauri builder to enable glass effect capabilities. ### Method Rust Function ### Endpoint tauri_plugin_liquid_glass::init() ### Request Example ```rust tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) ``` ## Accessing API ### Description Use the LiquidGlassExt trait to interact with the plugin features, such as checking for platform support. ### Method Trait Extension ### Parameters - **app** (AppHandle) - Required - The Tauri application handle. ### Response #### Success Response - **supported** (bool) - Returns true if Liquid Glass is supported on the current macOS version. ### Response Example ```rust let supported = app.liquid_glass().is_supported(); ``` ``` -------------------------------- ### GET /is_glass_supported Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/commands.rs.html?search=std%3A%3Avec Checks if the liquid glass effect is supported on the current platform. ```APIDOC ## GET /is_glass_supported ### Description Checks if the liquid glass effect is supported on the current platform. Returns true if running on macOS 26+ with NSGlassEffectView available. ### Method GET ### Endpoint plugin:liquid-glass|is_glass_supported ### Response #### Success Response (200) - **supported** (boolean) - True if the glass effect is supported, false otherwise. #### Response Example { "data": true } ``` -------------------------------- ### Cloning a Result Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides an example of cloning a `Result` type in Rust. This requires both the `T` and `E` types within the `Result` to implement the `Clone` trait. ```rust impl Clone for Result where T: Clone, E: Clone, { fn clone(&self) -> Result { // ... implementation details ... } // ... clone_from method ... } ``` -------------------------------- ### Plugin Initialization Function Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html?search=u32+-%3E+bool The `init` function creates and returns a `TauriPlugin` for the liquid-glass plugin. It registers commands and sets up necessary state management within the Tauri application. ```rust pub fn init() -> TauriPlugin { Builder::new("liquid-glass") .invoke_handler(tauri::generate_handler![ commands::is_glass_supported, commands::set_liquid_glass_effect, ]) .setup(|app, _api| { // Manage the LiquidGlass struct for the extension trait app.manage(LiquidGlass::new(app.clone())); #[cfg(target_os = "macos")] { app.manage(glass_effect::GlassViewRegistry::default()); } Ok(()) }) .build() } ``` -------------------------------- ### Initialize and Use Liquid Glass API in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/desktop.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Demonstrates how to access the LiquidGlass plugin via the LiquidGlassExt trait and apply effects to a Tauri window. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; // In a Tauri command or setup hook: fn example(app: tauri::AppHandle, window: tauri::WebviewWindow) { let supported = app.liquid_glass().is_supported(); app.liquid_glass().set_effect(&window, Default::default()).unwrap(); } ``` -------------------------------- ### Tauri Liquid Glass Plugin Initialization and Usage Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This section demonstrates how to initialize and use the tauri-plugin-liquid-glass within a Tauri application. It shows how to access the plugin's API and check for support. ```APIDOC ## Initialize and Use tauri-plugin-liquid-glass ### Description Initializes the liquid-glass plugin and demonstrates how to access its API to check for Liquid Glass support. ### Method `init()` function to initialize the plugin, and `LiquidGlassExt` trait for API access. ### Endpoint N/A (This is a Rust library integration, not a web endpoint) ### Parameters #### Query Parameters None #### Request Body None ### Request Example ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Access the plugin API via extension trait let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` ### Response #### Success Response (Setup) - `supported` (boolean) - Indicates if Liquid Glass effect is supported on the current macOS version. #### Response Example ``` Liquid Glass supported: true ``` ### Structs #### `LiquidGlass` - **Description**: Liquid Glass plugin API. #### `LiquidGlassConfig` - **Description**: Configuration for the liquid glass effect. ### Enums #### `Error` - **Description**: Error types for the liquid-glass plugin. #### `GlassMaterialVariant` - **Description**: Glass material variants for NSGlassEffectView. ### Traits #### `LiquidGlassExt` - **Description**: Extension trait for accessing the Liquid Glass plugin API. ### Functions #### `init()` - **Description**: Initialize the liquid-glass plugin. ### Type Aliases #### `Result` - **Description**: Result type for the liquid-glass plugin. ``` -------------------------------- ### Initialize Liquid Glass Plugin Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html?search= Provides the function to initialize the liquid-glass Tauri plugin. This function should be called when building the Tauri application. It sets up the plugin's invoke handler and manages necessary states. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Use the extension trait to access the API let supported = app.liquid_glass().is_supported(); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` -------------------------------- ### Hash for Result Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Implements the Hash trait for Result, provided that both T and E implement Hash. This allows Result values to be hashed, for example, when used in hash maps or sets. ```rust impl Hash for Result where T: Hash, E: Hash, { fn hash<__H>(&self, state: &mut __H) where __H: Hasher, { // ... implementation details ... } fn hash_slice(data: &[Self], state: &mut H) where H: Hasher, Self: Sized, { // ... implementation details ... } } ``` -------------------------------- ### into_ok() Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search= Returns the contained Ok value, but never panics. This is an experimental API. ```APIDOC ## GET /into_ok ### Description Returns the contained `Ok` value, but never panics. Unlike `unwrap`, this method is known to never panic on the result types it is implemented for. Therefore, it can be used instead of `unwrap` as a maintainability safeguard that will fail to compile if the error type of the `Result` is later changed to an error that can actually occur. This is a nightly-only experimental API. ### Method GET ### Endpoint /into_ok ### Parameters None ### Request Example ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` ### Response #### Success Response (200) - **value** (T) - The contained Ok value. #### Response Example ```json { "value": "this is fine" } ``` ``` -------------------------------- ### Check Platform Support for Liquid Glass Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/desktop.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to verify if the current environment supports the liquid glass effect, which is currently limited to macOS. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; fn check_support(app: tauri::AppHandle) { let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); } ``` -------------------------------- ### Plugin Initialization Function (Rust) Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html?search=std%3A%3Avec Provides the core function `init()` for initializing the tauri-plugin-liquid-glass. This function sets up the plugin's invoke handlers and manages necessary states for its operation. ```rust use tauri::{plugin::Builder, Manager, Runtime}; use tauri_plugin_liquid_glass::{LiquidGlass, commands}; pub fn init() -> TauriPlugin { Builder::new("liquid-glass") .invoke_handler(tauri::generate_handler![ commands::is_glass_supported, commands::set_liquid_glass_effect, ]) .setup(|app, _api| { // Manage the LiquidGlass struct for the extension trait app.manage(LiquidGlass::new(app.clone())); #[cfg(target_os = "macos")] { app.manage(glass_effect::GlassViewRegistry::default()); } Ok(()) }) .build() } ``` -------------------------------- ### Safely Get Err Value (Nightly Only) Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Presents `into_err`, a nightly-only experimental API that returns the contained `Err` value without panicking. Similar to `into_ok`, it serves as a compile-time safeguard for Results that cannot produce success values. ```rust fn only_bad_news() -> Result { Err("Oops, it failed".into()) } let error: String = only_bad_news().into_err(); println!("{error}"); ``` -------------------------------- ### Get references from Result with as_ref() (Rust) Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Shows the `as_ref` method for Rust's Result type. This method converts a reference to a Result (&Result) into a Result containing references to the inner values (Result<&T, &E>), leaving the original Result unchanged. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### Handling File Metadata with `Result` and `and_then` in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Illustrates obtaining file metadata and handling potential errors using `Result` and `and_then` in Rust. It shows how to access metadata for existing paths and how errors are returned for non-existent ones. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Tauri Liquid Glass Plugin Initialization Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search=std%3A%3Avec This section details how to initialize and use the Liquid Glass plugin within a Tauri application. ```APIDOC ## Initialize Liquid Glass Plugin ### Description Initializes the tauri-plugin-liquid-glass plugin for your Tauri application. This function should be called when building your Tauri application. ### Method `init()` ### Endpoint N/A (This is a Rust function call) ### Parameters None ### Request Example ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Access the plugin API via extension trait let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` ### Response N/A (This is a Rust function call that returns a `TauriPlugin`) #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### Get mutable references from Result with as_mut() (Rust) Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Illustrates the `as_mut` method for Rust's Result type. This method converts a mutable reference to a Result (&mut Result) into a Result containing mutable references to the inner values (Result<&mut T, &mut E>), allowing in-place modification. ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` -------------------------------- ### Tauri Liquid Glass Plugin Initialization Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search= This section details how to initialize and use the tauri-plugin-liquid-glass within a Tauri application. ```APIDOC ## Initialize tauri_plugin_liquid_glass ### Description Initializes the liquid-glass plugin for use in a Tauri application. ### Function `init()` ### Usage Example ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; tauri::Builder::default() .plugin(tauri_plugin_liquid_glass::init()) .setup(|app| { // Access the plugin API via extension trait let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); Ok(()) }) .run(tauri::generate_context!()) .expect("error while running tauri application"); ``` ### Return Type `tauri_plugin_liquid_glass::Result` ``` -------------------------------- ### Access Liquid Glass Plugin API with Extension Trait Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html Demonstrates how to use the `LiquidGlassExt` trait to access the Liquid Glass plugin's API within a Tauri application. This allows checking if the effect is supported and applying it to a window. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; fn example(app: tauri::AppHandle, window: tauri::WebviewWindow) { // Check if supported let supported = app.liquid_glass().is_supported(); // Apply effect app.liquid_glass().set_effect(&window, Default::default()).unwrap(); } ``` -------------------------------- ### Configuration and Types Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search=u32+-%3E+bool Overview of the structs and enums used to configure the Liquid Glass effect. ```APIDOC ## Structs ### LiquidGlass - **Description**: The primary interface for the Liquid Glass plugin API. ### LiquidGlassConfig - **Description**: Configuration object for defining the liquid glass effect parameters. ## Enums ### GlassMaterialVariant - **Description**: Defines the specific glass material variants available for the NSGlassEffectView. ### Error - **Description**: Represents the possible error types encountered by the plugin. ``` -------------------------------- ### Result Implementations Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Provides documentation for various implementations of the Result type, including methods for copying, cloning, transposing, flattening, and checking status. ```APIDOC ## Result Implementations ### `impl Result<&T, E>` #### `pub const fn copied(self) -> Result` Maps a `Result<&T, E>` to a `Result` by copying the contents of the `Ok` part. ##### Examples ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` #### `pub fn cloned(self) -> Result` Maps a `Result<&T, E>` to a `Result` by cloning the contents of the `Ok` part. ##### Examples ```rust let val = 12; let x: Result<&i32, i32> = Ok(&val); assert_eq!(x, Ok(&12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` ### `impl Result<&mut T, E>` #### `pub const fn copied(self) -> Result` Maps a `Result<&mut T, E>` to a `Result` by copying the contents of the `Ok` part. ##### Examples ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let copied = x.copied(); assert_eq!(copied, Ok(12)); ``` #### `pub fn cloned(self) -> Result` Maps a `Result<&mut T, E>` to a `Result` by cloning the contents of the `Ok` part. ##### Examples ```rust let mut val = 12; let x: Result<&mut i32, i32> = Ok(&mut val); assert_eq!(x, Ok(&mut 12)); let cloned = x.cloned(); assert_eq!(cloned, Ok(12)); ``` ### `impl Result, E>` #### `pub const fn transpose(self) -> Option>` Transposes a `Result` of an `Option` into an `Option` of a `Result`. `Ok(None)` will be mapped to `None`. `Ok(Some(_))` and `Err(_)` will be mapped to `Some(Ok(_))` and `Some(Err(_))`. ##### Examples ```rust #[derive(Debug, Eq, PartialEq)] struct SomeErr; let x: Result, SomeErr> = Ok(Some(5)); let y: Option> = Some(Ok(5)); assert_eq!(x.transpose(), y); ``` ### `impl Result, E>` #### `pub const fn flatten(self) -> Result` Converts from `Result, E>` to `Result`. ##### Examples ```rust let x: Result, u32> = Ok(Ok("hello")); assert_eq!(Ok("hello"), x.flatten()); let x: Result, u32> = Ok(Err(6)); assert_eq!(Err(6), x.flatten()); let x: Result, u32> = Err(6); assert_eq!(Err(6), x.flatten()); ``` Flattening only removes one level of nesting at a time: ```rust let x: Result, u32>, u32> = Ok(Ok(Ok("hello"))); assert_eq!(Ok(Ok("hello")), x.flatten()); assert_eq!(Ok("hello"), x.flatten().flatten()); ``` ### `impl Result` #### `pub const fn is_ok(&self) -> bool` Returns `true` if the result is `Ok`. ##### Examples ```rust let x: Result = Ok(-3); assert_eq!(x.is_ok(), true); let x: Result = Err("Some error message"); assert_eq!(x.is_ok(), false); ``` #### `pub fn is_ok_and(self, f: F) -> bool` where F: FnOnce(T) -> bool Returns `true` if the result is `Ok` and the value inside of it matches a predicate. ##### Examples ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` #### `pub const fn is_err(&self) -> bool` Returns `true` if the result is `Err`. ##### Examples ```rust let x: Result = Ok(-3); assert_eq!(x.is_err(), false); let x: Result = Err("Some error message"); assert_eq!(x.is_err(), true); ``` #### `pub fn is_err_and(self, f: F) -> bool` where F: FnOnce(E) -> bool Returns `true` if the result is `Err` and the value inside of it matches a predicate. ``` -------------------------------- ### Apply Liquid Glass Effects via Extension Trait Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/lib.rs.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Shows how to use the LiquidGlassExt trait to interact with the plugin from within application logic. It provides methods to check support and apply the glass effect to a specific WebviewWindow. ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; fn example(app: tauri::AppHandle, window: tauri::WebviewWindow) { let supported = app.liquid_glass().is_supported(); app.liquid_glass().set_effect(&window, Default::default()).unwrap(); } ``` -------------------------------- ### Implement Default for LiquidGlassConfig in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/struct.LiquidGlassConfig.html Provides a default implementation for the LiquidGlassConfig struct, allowing for the creation of a default configuration. This is useful for setting up initial states or when no specific configuration is provided. ```rust impl Default for LiquidGlassConfig { fn default() -> Self } ``` -------------------------------- ### Implement Default for LiquidGlassConfig in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/struct.LiquidGlassConfig.html?search=u32+-%3E+bool Provides a default implementation for the LiquidGlassConfig struct. This allows creating a LiquidGlassConfig instance with sensible default values, simplifying initialization when specific configurations are not required. ```rust impl Default for LiquidGlassConfig { fn default() -> Self { // ... implementation details ... } } ``` -------------------------------- ### FromGlib for Result, I> Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=std%3A%3Avec Converts a Glib type G into a Result, I>. ```APIDOC ## POST /api/users ### Description Converts a Glib type G into a Result, I>. ### Method POST ### Endpoint /api/users ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **field1** (type) - Required/Optional - Description ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Unwrap and Default Methods Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Methods for extracting values from Result types or providing fallbacks. ```APIDOC ## unwrap_or_default ### Description Returns the contained `Ok` value or a default value if the result is `Err`. ### Method N/A (Rust Method) ### Parameters - **self** (Result) - Required - The result instance. ### Response - **T** - The contained value or the default value for type T. ### Response Example ``` let good = "1909".parse().unwrap_or_default(); // 1909 let bad = "abc".parse().unwrap_or_default(); // 0 ``` ``` -------------------------------- ### LiquidGlassConfig Struct Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/index.html?search=std%3A%3Avec Configuration options for customizing the liquid glass effect. ```APIDOC ## LiquidGlassConfig Struct ### Description Defines the configuration parameters that can be used to customize the appearance and behavior of the liquid glass effect in your Tauri application. ### Method N/A (This is a struct, typically used to build configuration objects) ### Endpoint N/A ### Parameters This struct likely contains fields for various configuration options. Specific fields are not detailed in the provided text but would typically include properties like material variants, opacity, etc. ### Request Example ```rust // Example of creating a configuration object (syntax may vary) let config = LiquidGlassConfig { // ... configuration fields ... }; ``` ### Response N/A #### Success Response N/A #### Response Example N/A ``` -------------------------------- ### FromGlib for Result, I> Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search= Provides an implementation for converting a Glib type G into a Rust Result, I>. This is typically used when interfacing with Glib libraries, allowing Glib values to be mapped to Rust's Result and Option types, handling potential errors. ```rust impl FromGlib for Result, I> where G: Copy, I: Error, T: TryFromGlib>{ unsafe fn from_glib(val: G) -> Result, I>; } ``` -------------------------------- ### GlassMaterialVariant::equivalent Method Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/struct.LiquidGlassConfig.html?search=u32+-%3E+bool Documentation for the `equivalent` method within the `GlassMaterialVariant` enum. This method compares two instances of `GlassMaterialVariant` to determine if they are equivalent, with a specific constraint on the generic type `K`. ```APIDOC ## POST /websites/rs_tauri-plugin-liquid-glass/GlassMaterialVariant/equivalent ### Description Checks if two `GlassMaterialVariant` instances are equivalent. This method is generic over a type `K` which must be `u32`. ### Method `POST` (Implicitly, as it's a method call within a structure) ### Endpoint `/websites/rs_tauri-plugin-liquid-glass/GlassMaterialVariant/equivalent` ### Parameters #### Query Parameters - **K** (u32) - Required - The generic type parameter for comparison, must be `u32`. ### Request Body ```json { "instance1": "GlassMaterialVariant", "instance2": "GlassMaterialVariant" } ``` ### Response #### Success Response (200) - **bool** (boolean) - `true` if the variants are equivalent, `false` otherwise. #### Response Example ```json { "equivalent": true } ``` ``` -------------------------------- ### unwrap() Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search= Retrieves the contained Ok value or panics if the Result is Err. ```APIDOC ## GET /unwrap ### Description Retrieves the contained `Ok` value. If the `Result` is `Err`, this function will panic with the message provided by the `Err`'s value. ### Method GET ### Endpoint /unwrap ### Parameters None ### Request Example ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` ### Response #### Success Response (200) - **value** (T) - The contained Ok value. #### Response Example ```json { "value": 2 } ``` #### Error Response (Panic) Panics if the value is an `Err`. ```rust let x: Result = Err("emergency failure"); x.unwrap(); // panics with `emergency failure` ``` ``` -------------------------------- ### and() Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search= Returns the second Result if the first is Ok, otherwise returns the first Err. ```APIDOC ## GET /and ### Description Returns `res` if the result is `Ok`, otherwise returns the `Err` value of `self`. Arguments passed to `and` are eagerly evaluated. ### Method GET ### Endpoint /and ### Parameters #### Query Parameters - **res** (Result) - Required - The second Result to potentially return. ### Request Example ```rust let x: Result = Ok(2); let y: Result<&str, &str> = Err("late error"); assert_eq!(x.and(y), Err("late error")); let x: Result = Err("early error"); let y: Result<&str, &str> = Ok("foo"); assert_eq!(x.and(y), Err("early error")); let x: Result = Ok(2); let y: Result<&str, &str> = Ok("different result type"); assert_eq!(x.and(y), Ok("different result type")); ``` ### Response #### Success Response (200) - **result** (Result) - The second Result if the first was Ok, otherwise the first Err. #### Response Example ```json { "result": "late error" } ``` ```json { "result": "early error" } ``` ```json { "result": "different result type" } ``` ``` -------------------------------- ### Manage Liquid Glass Window Effects Source: https://docs.rs/tauri-plugin-liquid-glass/latest/src/tauri_plugin_liquid_glass/commands.rs.html Provides commands to check if the liquid glass effect is supported on the host platform and to apply or remove the effect from a specific Tauri window. These functions interface with the LiquidGlassExt trait to handle platform-specific window styling. ```rust use tauri::{command, AppHandle, Runtime, WebviewWindow}; use crate::error::Result; use crate::models::LiquidGlassConfig; use crate::LiquidGlassExt; #[command] pub fn is_glass_supported(app: AppHandle) -> bool { app.liquid_glass().is_supported() } #[command] pub fn set_liquid_glass_effect( app: AppHandle, window: WebviewWindow, config: LiquidGlassConfig, ) -> Result<()> { app.liquid_glass().set_effect(&window, config) } ``` -------------------------------- ### Unwrap values with defaults or closures Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=std%3A%3Avec Shows how to extract values from a Result using unwrap_or for static defaults or unwrap_or_else for computed values. ```rust let default = 2; let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); fn count(x: &str) -> usize { x.len() } assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` -------------------------------- ### Using `or` to Provide Alternative Results in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Demonstrates the `or` method on Rust's `Result` type. It returns the `Ok` value if the first `Result` is `Ok`, otherwise it returns the second `Result`. Note that arguments to `or` are eagerly evaluated. ```rust let x: Result = Ok(2); let y: Result = Err("late error"); assert_eq!(x.or(y), Ok(2)); let x: Result = Err("early error"); let y: Result = Ok(2); assert_eq!(x.or(y), Ok(2)); let x: Result = Err("not a 2"); let y: Result = Err("late error"); assert_eq!(x.or(y), Err("late error")); let x: Result = Ok(2); let y: Result = Ok(100); assert_eq!(x.or(y), Ok(2)); ``` -------------------------------- ### IntoGlib for Result Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=std%3A%3Avec Provides functionality to convert a Result into its corresponding Glib type. ```APIDOC ## POST /api/users ### Description Provides functionality to convert a Result into its corresponding Glib type. ### Method POST ### Endpoint /api/users ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **field1** (type) - Required/Optional - Description ### Request Example ```json { "example": "request body" } ``` ### Response #### Success Response (200) - **field1** (type) - Description #### Response Example ```json { "example": "response body" } ``` ``` -------------------------------- ### Reference and Mutate Result Contents Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=u32+-%3E+bool Demonstrates how to obtain references to the inner values of a Result using as_ref() and as_mut() for safe inspection or modification. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); ``` -------------------------------- ### LiquidGlassExt API Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/trait.LiquidGlassExt.html?search= The LiquidGlassExt trait provides methods to access the Liquid Glass plugin, check for platform support, and apply effects to specific windows. ```APIDOC ## [METHOD] liquid_glass() ### Description Returns a handle to the Liquid Glass plugin API, allowing access to plugin-specific functionality. ### Method Rust Trait Method ### Parameters #### Path Parameters - **&self** (Manager) - Required - The instance of the App, AppHandle, or WebviewWindow. ### Request Example ```rust let plugin = app.liquid_glass(); ``` ### Response #### Success Response - **LiquidGlass** (Object) - A handle to the plugin instance. --- ## [METHOD] is_supported() ### Description Checks if the current platform supports the Liquid Glass effect. ### Method Rust Method ### Response #### Success Response - **bool** (Boolean) - Returns true if the effect is supported on the current platform. --- ## [METHOD] set_effect(window, options) ### Description Applies the Liquid Glass effect to the specified Tauri window. ### Method Rust Method ### Parameters - **window** (WebviewWindow) - Required - The window to apply the effect to. - **options** (Default) - Required - Configuration options for the effect. ### Response #### Success Response - **Result<(), Error>** (Result) - Returns Ok(()) if the effect was applied successfully. ``` -------------------------------- ### LiquidGlass API Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/struct.LiquidGlass.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Provides methods to interact with the liquid glass effect, including checking platform support and applying configurations to windows. ```APIDOC ## LiquidGlass API Access the Liquid Glass plugin API through the `LiquidGlassExt` trait. ### Methods #### `is_supported()` **Description**: Checks if the liquid glass effect is supported on the current platform. **Method**: GET **Endpoint**: N/A (Instance method) **Parameters**: None **Response**: * **Success Response (200)**: - `supported` (boolean) - True if running on macOS 26+ with NSGlassEffectView available, false otherwise. **Example**: ```rust use tauri_plugin_liquid_glass::LiquidGlassExt; fn check_support(app: tauri::AppHandle) { let supported = app.liquid_glass().is_supported(); println!("Liquid Glass supported: {}", supported); } ``` #### `set_effect()` **Description**: Sets or removes the liquid glass effect on a specified window. **Method**: POST **Endpoint**: N/A (Instance method) **Parameters**: * **`window`** (`&WebviewWindow`) - Required - The window to apply the effect to. * **`config`** (`LiquidGlassConfig`) - Required - The configuration for the liquid glass effect. - `enabled` (boolean) - If true, creates or updates the glass effect. If false, removes the effect. - `corner_radius` (f64) - The radius of the window corners. - `tint_color` (Option) - The tint color for the glass effect (e.g., "#ffffff20"). - `variant` (GlassMaterialVariant) - The material variant for the glass effect (e.g., `Sidebar`). **Request Body Example**: ```json { "enabled": true, "corner_radius": 24.0, "tint_color": "#ffffff20", "variant": "Sidebar" } ``` **Response**: * **Success Response (200)**: - Indicates successful application or removal of the effect. **Example**: ```rust use tauri_plugin_liquid_glass::{LiquidGlassExt, LiquidGlassConfig, GlassMaterialVariant}; fn apply_glass(app: tauri::AppHandle, window: tauri::WebviewWindow) { // Enable with default settings app.liquid_glass().set_effect(&window, Default::default()).unwrap(); // Enable with custom settings app.liquid_glass().set_effect(&window, LiquidGlassConfig { corner_radius: 24.0, tint_color: Some("#ffffff20".into()), variant: GlassMaterialVariant::Sidebar, ..Default::default() }).unwrap(); // Disable app.liquid_glass().set_effect(&window, LiquidGlassConfig { enabled: false, ..Default::default() }).unwrap(); } ``` ``` -------------------------------- ### Providing Default Values with `unwrap_or` in Rust Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html Demonstrates `unwrap_or` on Rust's `Result`, which returns the contained `Ok` value or a provided default if the `Result` is an `Err`. Arguments are eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Chain fallible operations with and_then Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=std%3A%3Avec Demonstrates using and_then to chain operations that return a Result. It handles both successful transformations and error propagation. ```rust fn sq_then_to_string(x: u32) -> Result { x.checked_mul(x).map(|sq| sq.to_string()).ok_or("overflowed") } assert_eq!(Ok(2).and_then(sq_then_to_string), Ok(4.to_string())); assert_eq!(Ok(1_000_000).and_then(sq_then_to_string), Err("overflowed")); assert_eq!(Err("not a number").and_then(sq_then_to_string), Err("not a number")); use std::{io::ErrorKind, path::Path}; let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); ``` -------------------------------- ### UseCloned Implementation for Result Source: https://docs.rs/tauri-plugin-liquid-glass/latest/tauri_plugin_liquid_glass/type.Result.html?search=std%3A%3Avec Implements the `UseCloned` trait for `Result` where both `T` and `E` also implement `UseCloned`. ```APIDOC ## impl UseCloned for Result ### Description Implements the `UseCloned` trait for `Result`, provided that both `T` and `E` also implement `UseCloned`. ### Method N/A (Trait implementation) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response N/A ### Error Handling N/A ```