Skip to main content

Api

Struct Api 

Source
pub struct Api<'rofi> { /* private fields */ }
Expand description

The Rofi API, controlled by a lifetime to be only accessible while Rofi is running.

Implementations§

Source§

impl Api<'_>

Source

pub fn display_name(&self) -> Option<&str>

Get the display name of the current mode (the text displayed before the colon).

Returns None if there isn’t one, in which case Rofi shows the mode name instead.

Source

pub fn take_display_name(&mut self) -> Option<String>

Take the current display name, leaving None in its place and returning the previous display name. This will cause Rofi to display the mode name instead.

Returns None if there was no previous display name.

Source

pub fn replace_display_name(&mut self, display_name: String) -> Option<String>

Replace the current display name, returning the previous one.

Returns None if there was no previous display name.

Source

pub fn set_display_name<T: Display>(&mut self, display_name: T)

Set the display name of the current mode.

§Panics

Panics if the given string contains any interior nul bytes.

Source

pub fn supports_image<P: AsRef<Path>>(&self, path: P) -> bool

Check whether the given file path is an image in one of Rofi’s supported formats, by looking at its file extension.

Source

pub fn query_icon(&mut self, name: &str, size: u32) -> IconRequest

Query the icon theme for an icon with a specific name and size.

name can also be a full path.

§Panics

Panics if name contains interior nul bytes.

Source

pub fn query_icon_cstr(&mut self, name: &CStr, size: u32) -> IconRequest

Query the icon theme for an icon with a specific name and size.

name can also be a full path.

Source

pub fn query_icon_wh( &mut self, name: &str, width: u32, height: u32, ) -> IconRequest

Query the icon theme for an icon with a specific name and size.

name can also be a full path.

§Panics

Panics if name contains interior nul bytes.

Source

pub fn query_icon_wh_cstr( &mut self, name: &CStr, width: u32, height: u32, ) -> IconRequest

Query the icon theme for an icon with a specific name and size.

name can also be a full path.

Source

pub fn retrieve_icon( &mut self, request: IconRequest, ) -> Result<Surface, IconError>

Finalize an icon request and retrieve the inner icon.

The returned icon will be the best match for the requested size, but you may need to resize it to desired size.

It may be ergonomically preferable to use IconRequest::wait instead of this function.

§Errors

Errors if the icon was not found, or an error occurred inside the returned Cairo surface.

Source

pub fn hide(&mut self)

Hides the view.

Be warned that this is a private API, so while we expose it for some use-cases, using it is technically unreliable.

Trait Implementations§

Source§

impl<'rofi> Debug for Api<'rofi>

Source§

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

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

impl Send for Api<'_>

Source§

impl Sync for Api<'_>

Auto Trait Implementations§

§

impl<'rofi> Freeze for Api<'rofi>

§

impl<'rofi> RefUnwindSafe for Api<'rofi>

§

impl<'rofi> Unpin for Api<'rofi>

§

impl<'rofi> UnsafeUnpin for Api<'rofi>

§

impl<'rofi> UnwindSafe for Api<'rofi>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.