Client

Struct Client 

Source
pub struct Client(/* private fields */);
Expand description

A connection to the Sawfish window manager.

Implementations§

Source§

impl Client

Source

pub fn open(display: Option<&str>) -> Result<Self, ConnError>

Opens a connection to the Sawfish server.

The display argument specifies an optional display string, (such as ":0"). If not provided, the DISPLAY environment variable is used.

Tries to connect to the Unix socket of the Sawfish server. If that fails and the experimental-xcb Cargo feature is enabled, tries using X11 protocol to communicate with Sawfish.

Source

pub fn eval( &mut self, form: impl AsRef<[u8]>, ) -> Result<EvalResponse, EvalError>

Sends a Lisp form to the Sawfish server for evaluation and waits for a reply.

  • If there’s an error sending the form to the server (e.g. an I/O error), returns an Err(error) value.
  • Otherwise, if the form has been successfully sent to the server but evaluation failed, returns Ok(Err(data)) value.
  • Otherwise, if the form has been successfully executed by the server, returns Ok(Ok(data)) value.
§Example
let mut client = sawfish_client::Client::open(None).unwrap();
match client.eval("(system-name)") {
    Ok(Ok(data)) => {
        println!("Form evaluated to: {}",
                 String::from_utf8_lossy(&data))
    }
    Ok(Err(data)) => {
        println!("Error evaluating form: {}",
                 String::from_utf8_lossy(&data))
    }
    Err(err) => println!("Communication error: {err}")
}
Source

pub fn send(&mut self, form: impl AsRef<[u8]>) -> Result<(), EvalError>

Sends a Lisp form to the Sawfish server for evaluation but does not wait for a reply.

If there’s an error sending the form to the server (e.g. an I/O error), returns an Err(error) value. Otherwise, so long as the form was successfully sent, returns Ok(()) even if evaluation on the server side has changed (e.g. due to syntax error). Use Self::eval instead to check whether evaluation succeeded.

§Example
let mut client = sawfish_client::Client::open(None).unwrap();
match client.send("(set-screen-viewport 0 0)") {
    Ok(()) => println!("Form successfully sent"),
    Err(err) => println!("Communication error: {err}")
}

Auto Trait Implementations§

§

impl Freeze for Client

§

impl RefUnwindSafe for Client

§

impl Send for Client

§

impl Sync for Client

§

impl Unpin for Client

§

impl UnwindSafe for Client

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.