### Example Search Query: Option, (T -> U) -> Option Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.ColumnDisplay.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E This is an example search query, not a code snippet. It illustrates a pattern for transforming Option types. ```text Option, (T -> U) -> Option ``` -------------------------------- ### Layer Search Examples Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Layer.html?search= Provides examples of how to perform searches related to the Layer enum, demonstrating common search patterns. ```APIDOC ## Layer Search Examples ### Description This section provides example searches for the Layer enum, illustrating how to query for specific types and transformations. ### Example Searches * `std::vec` * `u32 -> bool` * `Option, (T -> U) -> Option` ``` -------------------------------- ### Request::PickWindow Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html Requests picking a window and getting its information. ```APIDOC ## Request::PickWindow ### Description Request picking a window and get its information. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ``` -------------------------------- ### PickWindow Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Request picking a window and get its information. ```APIDOC ## PickWindow ### Description Request picking a window and get its information. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "PickWindow" } ``` ### Response #### Success Response (200) - **picked_window** (object) - Information about the picked window. #### Response Example ```json { "reply": "Ok", "response": { "PickWindow": { "id": "12345", "workspace_id": "1", "output_id": "DP-1", "title": "Browser Tab", "class": "Firefox", "pid": 1234 } } } ``` ``` -------------------------------- ### Example: Reading Events from Niri IPC Socket Source: https://docs.rs/niri-ipc/latest/niri_ipc/socket/struct.Socket.html Demonstrates connecting to the niri IPC socket, requesting an event stream, and then continuously reading and printing incoming events. ```rust use niri_ipc::{Request, Response}; use niri_ipc::socket::Socket; fn main() -> std::io::Result<()> { let mut socket = Socket::connect()?; let reply = socket.send(Request::EventStream)?; if matches!(reply, Ok(Response::Handled)) { let mut read_event = socket.read_events(); while let Ok(event) = read_event() { println!("Received event: {event:?}"); } } Ok(()) } ``` -------------------------------- ### LayoutSwitchTarget::Prev Variant Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.LayoutSwitchTarget.html Represents switching to the previous configured layout in the sequence. ```rust LayoutSwitchTarget::Prev ``` -------------------------------- ### LayoutSwitchTarget::Next Variant Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.LayoutSwitchTarget.html Represents switching to the next configured layout in the sequence. ```rust LayoutSwitchTarget::Next ``` -------------------------------- ### Product of Results Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Demonstrates how to calculate the product of elements in an iterator where each element is a Result. If any element fails parsing, the entire operation returns an Err. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### Result::is_ok Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Demonstrates how to check if a `Result` is the `Ok` variant. This is useful for conditional logic based on the success or failure of an operation. ```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); ``` -------------------------------- ### unwrap_or_else Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Demonstrates the use of unwrap_or_else with a closure to provide a default value when the Result is an Err. ```Rust assert_eq!(Ok(2).unwrap_or_else(count), 2); assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` -------------------------------- ### LayoutSwitchTarget::Index Variant Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.LayoutSwitchTarget.html Illustrates switching to a specific layout by its index. Requires the layout index to be a u8. ```rust LayoutSwitchTarget::Index(0) ``` -------------------------------- ### FocusColumnLeftOrLast Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Focus the next column to the left, looping to the last column if at the start. ```APIDOC ## FocusColumnLeftOrLast ### Description Focus the next column to the left, looping if at start. ``` -------------------------------- ### Result::ok Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Converts a `Result` into an `Option`, discarding the error value. Useful when you only care about the success value. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### Result::as_ref Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Creates a `Result` containing references to the contained values, without consuming the original `Result`. Useful for inspecting values without taking ownership. ```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")); ``` -------------------------------- ### Spawn Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Spawn a command with a list of string arguments. ```APIDOC ## Spawn ### Description Spawn a command. ### Fields - **command** (Vec) - Required - Command to spawn. ``` -------------------------------- ### Get Ok value or default with `unwrap_or` Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Shows how to use `unwrap_or` to get the contained Ok value or a provided default. The default value is 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); ``` -------------------------------- ### Get Ok value or compute default with `unwrap_or_else` Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Demonstrates using `unwrap_or_else` to get the contained Ok value or compute a default value using a closure. The closure is lazily evaluated only when the Result is Err. ```Rust fn count(x: &str) -> usize { x.len() } ``` -------------------------------- ### ShowHotkeyOverlay Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Displays an overlay showing available hotkeys. ```APIDOC ## ShowHotkeyOverlay ### Description Displays an overlay showing available hotkeys. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### EventStream Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Start continuously receiving events from the compositor. ```APIDOC ## EventStream ### Description Start continuously receiving events from the compositor. The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send `Event`s, one per line. The event stream will always give you the full current state up-front. For example, the first workspace-related event you will receive will be `Event::WorkspacesChanged` containing the full current workspaces state. You _do not_ need to separately send `Request::Workspaces` when using the event stream. Where reasonable, event stream state updates are atomic, though this is not always the case. For example, a window may end up with a workspace id for a workspace that had already been removed. This can happen if the corresponding `Event::WorkspacesChanged` arrives before the corresponding `Event::WindowOpenedOrChanged`. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "EventStream" } ``` ### Response #### Success Response (200) - **handled** (boolean) - Indicates if the event stream was successfully started. #### Response Example ```json { "reply": "Ok", "response": { "EventStream": { "handled": true } } } ``` ### Events Events are sent continuously after the `EventStream` request is handled. Example event: ```json { "event": "WorkspacesChanged", "data": [ { "id": "1", "name": "web", "outputs": ["DP-1"] } ] } ``` ``` -------------------------------- ### OpenOverview Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Opens the overview mode. ```APIDOC ## OpenOverview ### Description Opens the overview mode. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### Clone Implementation for Overview Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.Overview.html?search= Provides methods for cloning Overview instances. ```rust fn clone(&self) -> Overview ``` ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Request::EventStream Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=std%3A%3Avec Start continuously receiving events from the compositor. ```APIDOC ## Request::EventStream ### Description Start continuously receiving events from the compositor. The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send `Event`s, one per line. The event stream will always give you the full current state up-front. For example, the first workspace-related event you will receive will be `Event::WorkspacesChanged` containing the full current workspaces state. You _do not_ need to separately send `Request::Workspaces` when using the event stream. Where reasonable, event stream state updates are atomic, though this is not always the case. For example, a window may end up with a workspace id for a workspace that had already been removed. This can happen if the corresponding `Event::WorkspacesChanged` arrives before the corresponding `Event::WindowOpenedOrChanged`. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example None ### Response #### Success Response - **reply** (string) - Should be `Ok(Handled)` initially, followed by continuous `Event`s. #### Response Example ```json { "reply": "Ok(Handled)" } ``` ```json { "event": "WorkspacesChanged", "data": [ { "id": "1", "name": "Web", "output": "DP-1" } ] } ``` ``` -------------------------------- ### type_id Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.WindowLayout.html?search= Gets the `TypeId` of `self`. This method is part of the `Any` trait implementation. ```APIDOC ## fn type_id(&self) -> TypeId ### Description Gets the `TypeId` of `self`. ### Method N/A (Method within a trait implementation) ### Endpoint N/A ### Parameters N/A ### Request Example N/A ### Response #### Success Response - **TypeId**: The unique identifier for the type of `self`. ``` -------------------------------- ### OverviewState Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Request information about the overview. ```APIDOC ## OverviewState ### Description Request information about the overview. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "OverviewState" } ``` ### Response #### Success Response (200) - **overview_state** (object) - Information about the overview state. #### Response Example ```json { "reply": "Ok", "response": { "OverviewState": { "visible": true, "workspaces": ["1", "2"] } } } ``` ``` -------------------------------- ### MoveWindowToTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Move the focused window to the tiling layout. ```APIDOC ## MoveWindowToTiling ### Description Move the focused window to the tiling layout. ### Method (Not specified, likely an internal command) ### Endpoint (Not specified) ### Parameters #### Path Parameters - **id** (Option) - Optional - Id of the window to move. If `None`, uses the focused window. ### Request Example (None specified) ### Response (None specified) ``` -------------------------------- ### MoveWindowToTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Moves the focused window to the tiling layout. ```APIDOC ## MoveWindowToTiling ### Description Move the focused window to the tiling layout. ### Fields - `id` (Option) - Optional - Id of the window to move. If `None`, uses the focused window. ### Method N/A (IPC Action) ### Endpoint N/A (IPC Action) ``` -------------------------------- ### Result::is_err Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Demonstrates how to check if a `Result` is the `Err` variant. This is fundamental for error handling in Rust. ```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); ``` -------------------------------- ### ScreenshotWindow Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Screenshot a specific window, with options to specify the window ID, write to disk, show the pointer, and specify a save path. ```APIDOC ## ScreenshotWindow ### Description Screenshot a window. ### Fields - **id** (Option) - Optional - Id of the window to screenshot. If `None`, uses the focused window. - **write_to_disk** (bool) - Optional - Write the screenshot to disk in addition to putting it in your clipboard. The screenshot is saved according to the `screenshot-path` config setting. - **show_pointer** (bool) - Optional - Whether to include the mouse pointer in the screenshot. The pointer will be included only if the window is currently receiving pointer input (usually this means the pointer is on top of the window). - **path** (Option) - Optional - Path to save the screenshot to. The path must be absolute, otherwise an error is returned. If `None`, the screenshot is saved according to the `screenshot-path` config setting. ``` -------------------------------- ### FocusTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Focuses a window in the tiling layer. ```APIDOC ## FocusTiling ### Description Focuses a window in the tiling layer. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### report function for Termination Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Called to get the representation of the value as a status code, which is then returned to the operating system. ```rust fn report(self) -> ExitCode ``` -------------------------------- ### LoadConfigFile Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Loads a configuration file. ```APIDOC ## LoadConfigFile ### Description Loads a configuration file. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Request Body - **path** (Option) - Optional - The path to the configuration file to load. If `None`, the default configuration file is loaded. ``` -------------------------------- ### Rust TypeId Trait Implementation Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.WindowLayout.html?search= Demonstrates how to get the TypeId of a trait object. This is part of the blanket implementations for Any. ```rust impl Any for T where T: 'static + ?Sized, fn type_id(&self) -> TypeId ``` -------------------------------- ### FocusTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Focuses the most recently used tiling window. ```APIDOC ## FocusTiling ### Description Sets the keyboard focus to the most recently used tiling window. ### Method N/A (IPC Action) ### Endpoint N/A (IPC Action) ### Parameters None ### Request Example ```json { "action": "FocusTiling" } ``` ### Response #### Success Response (200) Indicates the action was processed successfully. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Socket::read_events Source: https://docs.rs/niri-ipc/latest/niri_ipc/socket/struct.Socket.html Starts reading an event stream from the socket. The returned function blocks until the next event arrives. ```APIDOC ## Socket::read_events ### Description Starts reading an event stream from the socket. The returned closure will block until the next `Event` arrives and then return it. This should only be used after requesting an `EventStream`. ### Method `read_events(self) -> impl FnMut() -> Result` ### Returns - `impl FnMut() -> Result`: A closure that, when called, returns the next `Event` from the stream or an error if communication fails. ``` -------------------------------- ### Spawn Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Spawns a command. ```APIDOC ## Spawn ### Description Spawns a command. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Request Body - **command** (Vec) - Required - The command to spawn, including its arguments. ``` -------------------------------- ### Collecting Results into a Result with checked_sub (success) Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html?search=std%3A%3Avec Shows collecting Results where `checked_sub` is used. This example succeeds as no underflow occurs. ```rust let v = vec![1, 2]; let res: Result, &'static str> = v.iter().map(|x: &u32| x.checked_sub(1).ok_or("Underflow!") ).collect(); assert_eq!(res, Ok(vec![0, 1])); ``` -------------------------------- ### MoveWindowToTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Moves a window to the tiling layer. ```APIDOC ## MoveWindowToTiling ### Description Moves a window to the tiling layer. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Request Body - **id** (Option) - Optional - The ID of the window to move. If `None`, the focused window is used. ``` -------------------------------- ### Result::err Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Converts a `Result` into an `Option`, discarding the success value. Useful when you only care about the error value. ```rust let x: Result = Ok(2); assert_eq!(x.err(), None); let x: Result = Err("Nothing here"); assert_eq!(x.err(), Some("Nothing here")); ``` -------------------------------- ### Version Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Request the version string for the running niri instance. ```APIDOC ## Version ### Description Request the version string for the running niri instance. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "Version" } ``` ### Response #### Success Response (200) - **version** (string) - The version string of the niri instance. #### Response Example ```json { "reply": "Ok", "response": { "Version": "niri-ipc-26.4.0" } } ``` ``` -------------------------------- ### unsafe unwrap_err_unchecked on Err Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Shows how to use unwrap_err_unchecked to get the Err value without a check. Calling on Ok is undefined behavior. ```Rust let x: Result = Err("emergency failure"); assert_eq!(unsafe { x.unwrap_err_unchecked() }, "emergency failure"); ``` -------------------------------- ### SwitchPresetWindowHeightBack Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Switch between preset window heights backwards. The focused window is used if no ID is provided. ```APIDOC ## SwitchPresetWindowHeightBack ### Description Switch between preset window heights backwards. ### Fields - **id** (Option) - Optional - Id of the window whose height to switch. If `None`, uses the focused window. ``` -------------------------------- ### unsafe unwrap_unchecked on Ok Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Shows how to use unwrap_unchecked to get the Ok value without a check. Calling on Err is undefined behavior. ```Rust let x: Result = Ok(2); assert_eq!(unsafe { x.unwrap_unchecked() }, 2); ``` -------------------------------- ### PartialEq Implementation for KeyboardLayouts Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.KeyboardLayouts.html Enables comparison of two KeyboardLayouts instances for equality. ```rust fn eq(&self, other: &KeyboardLayouts) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ``` -------------------------------- ### Result::is_ok_and Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Checks if a `Result` is `Ok` and its contained value satisfies a given predicate function. Useful for validating success conditions. ```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); ``` -------------------------------- ### Quit Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Exit niri. Optionally skip the confirmation prompt. ```APIDOC ## Quit ### Description Exit niri. ### Fields - **skip_confirmation** (bool) - Optional - Skip the “Press Enter to confirm” prompt. ``` -------------------------------- ### Termination for Result Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html?search= Implementation of the Termination trait for Result. This is used to get the representation of the value as a status code returned to the operating system. ```rust impl Termination for Result where T: Termination, E: Debug, ``` -------------------------------- ### Screenshot Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Open the screenshot UI, with options to show the pointer and specify a save path. ```APIDOC ## Screenshot ### Description Open the screenshot UI. ### Fields - **show_pointer** (bool) - Optional - Whether to show the mouse pointer by default in the screenshot UI. - **path** (Option) - Optional - Path to save the screenshot to. The path must be absolute, otherwise an error is returned. If `None`, the screenshot is saved according to the `screenshot-path` config setting. ``` -------------------------------- ### Result::as_mut Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Creates a `Result` containing mutable references to the contained values, allowing in-place modification. Useful for updating values within a `Result`. ```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); ``` -------------------------------- ### SwitchPresetWindowWidthBack Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Switch between preset window widths backwards. The focused window is used if no ID is provided. ```APIDOC ## SwitchPresetWindowWidthBack ### Description Switch between preset window widths backwards. ### Fields - **id** (Option) - Optional - Id of the window whose width to switch. If `None`, uses the focused window. ``` -------------------------------- ### ScreenshotWindow Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search= Screenshots a specific window, with options to write to disk, include the pointer, and specify a save path. ```APIDOC ## ScreenshotWindow ### Description Screenshots a specific window, with options to write to disk, include the pointer, and specify a save path. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ### Parameters #### Request Body - **id** (Option) - Optional - The ID of the window to screenshot. If `None`, uses the focused window. - **write_to_disk** (bool) - Optional - Whether to write the screenshot to disk. - **show_pointer** (bool) - Optional - Whether to include the mouse pointer in the screenshot. - **path** (Option) - Optional - The absolute path to save the screenshot. If `None`, uses the `screenshot-path` config setting. ``` -------------------------------- ### Result::is_err_and Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Checks if a `Result` is `Err` and its contained error value satisfies a given predicate function. Useful for specific error condition checks. ```rust use std::io::{Error, ErrorKind}; let x: Result = Err(Error::new(ErrorKind::NotFound, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), true); let x: Result = Err(Error::new(ErrorKind::PermissionDenied, "!")); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Ok(123); assert_eq!(x.is_err_and(|x| x.kind() == ErrorKind::NotFound), false); let x: Result = Err("ownership".to_string()); assert_eq!(x.as_ref().is_err_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` -------------------------------- ### Request::OverviewState Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html Requests information about the overview. ```APIDOC ## Request::OverviewState ### Description Request information about the overview. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ``` -------------------------------- ### Mutably iterating over Result values Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html?search= Use `iter_mut` to get a mutable iterator for modifying the contained value if `Ok`. This allows in-place updates to the `Ok` variant. ```rust let mut x: Result = Ok(7); match x.iter_mut().next() { Some(v) => *v = 40, None => {}, } assert_eq!(x, Ok(40)); let mut x: Result = Err("nothing!"); assert_eq!(x.iter_mut().next(), None); ``` -------------------------------- ### Sum of Results Example Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html Illustrates summing elements from an iterator where each element is a Result. The summation stops and returns an Err if any element is negative or fails the provided mapping function. ```rust let f = |&x: &i32| if x < 0 { Err("Negative element found") } else { Ok(x) }; let v = vec![1, 2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Ok(3)); let v = vec![1, -2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Err("Negative element found")); ``` -------------------------------- ### Request::Windows Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html Requests information about open windows. ```APIDOC ## Request::Windows ### Description Request information about open windows. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ``` -------------------------------- ### Screenshot Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Opens the screenshot UI with configurable options. ```APIDOC ## Screenshot ### Description Opens the screenshot user interface. Allows configuration for showing the pointer and specifying a save path. ### Method N/A (IPC Action) ### Endpoint N/A (IPC Action) ### Parameters #### Request Body - **show_pointer** (bool) - Optional - Whether to show the mouse pointer by default in the screenshot UI. Defaults to false. - **path** (Option) - Optional - The absolute path to save the screenshot. If `None`, the `screenshot-path` config setting is used. ### Request Example ```json { "action": "Screenshot", "show_pointer": true, "path": "/home/user/screenshots/my_screenshot.png" } ``` ### Response #### Success Response (200) Indicates the action was processed successfully. #### Response Example ```json { "status": "success" } ``` ``` -------------------------------- ### Implement Debug for KeyboardLayoutsState Source: https://docs.rs/niri-ipc/latest/niri_ipc/state/struct.KeyboardLayoutsState.html?search=std%3A%3Avec Provides a way to format the KeyboardLayoutsState for debugging purposes. ```rust impl Debug for KeyboardLayoutsState Source§ #### fn fmt(&self, f: &mut Formatter<'_>) -> Result Formats the value using the given formatter. Read more Source ``` -------------------------------- ### Iterating over Result values Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html?search= Use `iter` to get an iterator that yields the value if `Ok`, or nothing if `Err`. This is useful for processing the contained value without explicit matching. ```rust let x: Result = Ok(7); assert_eq!(x.iter().next(), Some(&7)); let x: Result = Err("nothing!"); assert_eq!(x.iter().next(), None); ``` -------------------------------- ### FocusMonitorUp Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Focus the monitor above. ```APIDOC ## FocusMonitorUp ### Description Focus the monitor above. ``` -------------------------------- ### Windows Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Request information about open windows. ```APIDOC ## Windows ### Description Request information about open windows. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "Windows" } ``` ### Response #### Success Response (200) - **windows** (array) - An array of window information objects. #### Response Example ```json { "reply": "Ok", "response": { "Windows": [ { "id": "12345", "workspace_id": "1", "output_id": "DP-1", "title": "Browser Tab", "class": "Firefox", "pid": 1234 } ] } } ``` ``` -------------------------------- ### Read Event Stream from Socket Source: https://docs.rs/niri-ipc/latest/niri_ipc/socket/struct.Socket.html Starts reading a stream of events from the niri IPC socket. The returned function blocks until the next event is available. Ensure an EventStream is requested before using this. ```rust pub fn read_events(self) -> impl FnMut() -> Result ``` -------------------------------- ### KeyboardLayouts Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Request information about the configured keyboard layouts. ```APIDOC ## KeyboardLayouts ### Description Request information about the configured keyboard layouts. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Request Example ```json { "request": "KeyboardLayouts" } ``` ### Response #### Success Response (200) - **keyboard_layouts** (array) - An array of keyboard layout strings. #### Response Example ```json { "reply": "Ok", "response": { "KeyboardLayouts": [ "us", "de" ] } } ``` ``` -------------------------------- ### Request::EventStream Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html Starts continuously receiving events from the compositor. The compositor will reply with `Reply::Ok(Response::Handled)` and then continuously send `Event`s. The event stream provides the full current state upfront, so separate requests for state (like `Request::Workspaces`) are not needed when using the event stream. ```APIDOC ## Request::EventStream ### Description Start continuously receiving events from the compositor. The compositor should reply with `Reply::Ok(Response::Handled)`, then continuously send `Event`s, one per line. The event stream will always give you the full current state up-front. For example, the first workspace-related event you will receive will be `Event::WorkspacesChanged` containing the full current workspaces state. You _do not_ need to separately send `Request::Workspaces` when using the event stream. Where reasonable, event stream state updates are atomic, though this is not always the case. For example, a window may end up with a workspace id for a workspace that had already been removed. This can happen if the corresponding `Event::WorkspacesChanged` arrives before the corresponding `Event::WindowOpenedOrChanged`. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ``` -------------------------------- ### MoveWindowToFloating Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Move the focused window to the floating layout. ```APIDOC ## MoveWindowToFloating ### Description Move the focused window to the floating layout. ### Method (Not specified, likely an internal command) ### Endpoint (Not specified) ### Parameters #### Path Parameters - **id** (Option) - Optional - Id of the window to move. If `None`, uses the focused window. ### Request Example (None specified) ### Response (None specified) ``` -------------------------------- ### MoveWindowToTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search= Moves the focused window to the tiling layout. Optionally specify a window ID. ```APIDOC ## MoveWindowToTiling ### Description Moves the focused window to the tiling layout. Optionally specify a window ID. ### Method POST ### Endpoint /actions/move_window_to_tiling ### Parameters #### Request Body - **id** (Option) - Optional - Id of the window to move. If None, uses the focused window. ``` -------------------------------- ### SwitchPresetWindowWidth Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Switch between preset window widths. The focused window is used if no ID is provided. ```APIDOC ## SwitchPresetWindowWidth ### Description Switch between preset window widths. ### Fields - **id** (Option) - Optional - Id of the window whose width to switch. If `None`, uses the focused window. ``` -------------------------------- ### Action Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Perform an action. ```APIDOC ## Action ### Description Perform an action. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters #### Request Body - **action** (Action) - The action to perform. See `Action` enum for details. ### Request Example ```json { "request": { "Action": { "type": "MoveWindow", "window_id": "12345", "x": 100, "y": 100 } } } ``` ### Response #### Success Response (200) - **handled** (boolean) - Indicates if the action was handled. #### Response Example ```json { "reply": "Ok", "response": { "Action": { "handled": true } } } ``` ``` -------------------------------- ### Request::KeyboardLayouts Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html Requests information about the configured keyboard layouts. ```APIDOC ## Request::KeyboardLayouts ### Description Request information about the configured keyboard layouts. ### Method N/A (Enum variant) ### Endpoint N/A (Enum variant) ``` -------------------------------- ### Default WindowsState Implementation Source: https://docs.rs/niri-ipc/latest/niri_ipc/state/struct.WindowsState.html Provides the default value for WindowsState, typically an empty state. ```rust fn default() -> WindowsState ``` -------------------------------- ### FocusMonitorPrevious Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Focus the previous monitor. ```APIDOC ## FocusMonitorPrevious ### Description Focus the previous monitor. ``` -------------------------------- ### SpawnSh Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Spawn a command through the shell. ```APIDOC ## SpawnSh ### Description Spawn a command through the shell. ### Fields - **command** (String) - Required - Command to run. ``` -------------------------------- ### StructuralPartialEq Implementation for VrrToSet Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.VrrToSet.html Provides structural equality comparison for VrrToSet. ```rust impl StructuralPartialEq for VrrToSet Source ``` -------------------------------- ### MoveWindowToMonitorUp Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Move the focused window to the monitor above. ```APIDOC ## MoveWindowToMonitorUp ### Description Move the focused window to the monitor above. ``` -------------------------------- ### FullscreenWindow Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Toggle fullscreen on a window, optionally by ID. ```APIDOC ## FullscreenWindow ### Description Toggle fullscreen on a window. ### Fields - **id** (Option) - Optional - Id of the window to toggle fullscreen of. If `None`, uses the focused window. ``` -------------------------------- ### Request::OverviewState Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=u32+-%3E+bool Requests information about the current overview state. ```APIDOC ## Request::OverviewState ### Description Request information about the overview. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters None ### Response Success Response (200) - **overview_state** (object) - Information about the overview. ### Response Example ```json { "overview_state": { "visible": true, "windows": [] } } ``` ``` -------------------------------- ### ToggleOverview Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Toggles the overview mode. ```APIDOC ## ToggleOverview ### Description Toggles the overview mode. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters None ### Request Example None ### Response None ``` -------------------------------- ### FocusMonitorNext Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Focus the next monitor. ```APIDOC ## FocusMonitorNext ### Description Focus the next monitor. ``` -------------------------------- ### SwitchLayout Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Switches between available keyboard layouts. ```APIDOC ## SwitchLayout ### Description Switch between keyboard layouts. ### Method (Not specified, likely an IPC call) ### Endpoint (Not specified, likely an IPC call) ### Parameters #### Path Parameters - **layout** (LayoutSwitchTarget) - Required - Layout to switch to. ``` -------------------------------- ### Output Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Request.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Change output configuration temporarily. ```APIDOC ## Output ### Description Change output configuration temporarily. The configuration is changed temporarily and not saved into the config file. If the output configuration subsequently changes in the config file, these temporary changes will be forgotten. ### Method N/A (Enum Variant) ### Endpoint N/A (Enum Variant) ### Parameters #### Request Body - **output** (String) - Output name. - **action** (OutputAction) - Configuration to apply. See `OutputAction` enum for details. ### Request Example ```json { "request": { "Output": { "output": "DP-1", "action": { "type": "SetMode", "width": 1920, "height": 1080, "refresh_rate": 60 } } } } ``` ### Response #### Success Response (200) - **handled** (boolean) - Indicates if the output configuration change was handled. #### Response Example ```json { "reply": "Ok", "response": { "Output": { "handled": true } } } ``` ``` -------------------------------- ### into_ok Source: https://docs.rs/niri-ipc/latest/niri_ipc/type.Reply.html?search=std%3A%3Avec Returns the contained `Ok` value, but never panics. This is an experimental API. ```APIDOC ## into_ok ### Description Returns the contained `Ok` value, but never panics. This is a nightly-only experimental API. Unlike `unwrap`, this method is known to never panic on the result types it is implemented for, serving as a maintainability safeguard. ### Method `into_ok` ### Parameters None ### Response The contained `Ok` value. ### Examples ```rust // Example usage for into_ok would go here, assuming it's available. ``` ``` -------------------------------- ### SwitchPresetWindowHeight Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Switch between preset window heights. The focused window is used if no ID is provided. ```APIDOC ## SwitchPresetWindowHeight ### Description Switch between preset window heights. ### Fields - **id** (Option) - Optional - Id of the window whose height to switch. If `None`, uses the focused window. ``` -------------------------------- ### MoveWindowToTiling Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Moves the focused window to the tiling layout. Optionally targets a specific window by ID. ```APIDOC ## MoveWindowToTiling ### Description Move the focused window to the tiling layout. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Query Parameters - **id** (Option) - Optional - Id of the window to move. If `None`, uses the focused window. ``` -------------------------------- ### FocusWindowPrevious Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html Focus the previously focused window. ```APIDOC ## FocusWindowPrevious ### Description Focus the previously focused window. ``` -------------------------------- ### FocusWindowUp Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=u32+-%3E+bool Focuses the window directly above the current one. ```APIDOC ## FocusWindowUp ### Description Focuses the window above. ### Method N/A (SDK Method) ### Endpoint N/A (SDK Method) ``` -------------------------------- ### MoveWindowToFloating Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=Option%3CT%3E%2C+%28T+-%3E+U%29+-%3E+Option%3CU%3E Moves the focused window to the floating layout. ```APIDOC ## MoveWindowToFloating ### Description Move the focused window to the floating layout. ### Fields - `id` (Option) - Optional - Id of the window to move. If `None`, uses the focused window. ### Method N/A (IPC Action) ### Endpoint N/A (IPC Action) ``` -------------------------------- ### MoveWindowToFloating Source: https://docs.rs/niri-ipc/latest/niri_ipc/enum.Action.html?search=std%3A%3Avec Moves a window to the floating layer. ```APIDOC ## MoveWindowToFloating ### Description Moves a window to the floating layer. ### Method N/A (This is an action, not an HTTP endpoint) ### Endpoint N/A ### Parameters #### Request Body - **id** (Option) - Optional - The ID of the window to move. If `None`, the focused window is used. ``` -------------------------------- ### PartialEq Implementation for VrrToSet Source: https://docs.rs/niri-ipc/latest/niri_ipc/struct.VrrToSet.html Enables equality comparison for VrrToSet instances. The `eq` method tests for equality, and `ne` tests for inequality. ```rust impl PartialEq for VrrToSet Source ``` ```rust fn eq(&self, other: &VrrToSet) -> bool ``` ```rust fn ne(&self, other: &Rhs) -> bool ```