Skip to main content

Client

Struct Client 

Source
pub struct Client {
    pub api: u32,
    pub server: String,
    /* private fields */
}
Expand description

A connection to smed, after the handshake.

Fields§

§api: u32

The API version both sides agreed on.

§server: String

smed’s name and version from its hello.

Implementations§

Source§

impl Client

Source

pub fn connect(client: &str) -> Result<Self>

Connects to smed at default_socket_path and introduces itself as client.

Source

pub fn connect_to(path: &Path, client: &str) -> Result<Self>

Connects to smed at path and introduces itself as client.

Source

pub fn send(&mut self, message: &ClientMessage) -> Result<()>

Sends one message.

Source

pub fn set_lock(&mut self, on: bool) -> Result<()>

Asks smed to switch the rotation lock on or off.

Source

pub fn get_state(&mut self) -> Result<()>

Asks smed for a state message.

Source

pub fn focus(&mut self, on: bool) -> Result<()>

Tells smed whether this client’s window has the input focus (API 2): the focused client has the LCD.

Source

pub fn set_icon_svg(&mut self, id: &str, svg: &str) -> Result<()>

Sends an SVG icon under id (API 2), for set_commands. currentColor takes the LCD’s text colour.

Source

pub fn set_icon_png(&mut self, id: &str, png: &[u8]) -> Result<()>

Sends a PNG icon (the file’s bytes) under id (API 2), for set_commands.

Source

pub fn set_commands(&mut self, app: &App, commands: &[Command]) -> Result<()>

Sends the application and its command catalogue (API 2); replaces the previous one.

Source

pub fn set_environments(&mut self, environments: &[Environment]) -> Result<()>

Sends the environments with their key assignments (API 2); replaces the previous ones.

Source

pub fn set_unavailable<S: AsRef<str>>(&mut self, commands: &[S]) -> Result<()>

Tells smed which commands (ids from set_commands) cannot run now (API 2, since 0.2.1): their tiles are drawn greyed out. Replaces the previous list; send an empty one when every command can run again. smed still sends command for them.

Source

pub fn set_environment(&mut self, id: &str) -> Result<()>

Shows environment id (from set_environments) on the keys and the LCD (API 2).

Source

pub fn set_lcd( &mut self, brightness: Option<u8>, text_size: Option<TextSize>, theme: Option<Theme>, ) -> Result<()>

Changes the LCD settings for every client until smed restarts (API 2); None keeps a setting. smed answers with lcd.

Source

pub fn get_screen(&mut self) -> Result<()>

Asks for the current LCD page (API 2); smed answers with screen, see ServerMessage::screen_png.

Source

pub fn next_message(&mut self) -> Result<Option<ServerMessage>>

The next message, blocking; None once smed closed the connection. Unknown message types are skipped. A LineError comes as InvalidData with the LineError inside (get_ref() and downcast_ref): after Invalid the next call reads on, after Overlong close the connection. With a read timeout on Client::stream, a timeout is returned as the error it is (WouldBlock or TimedOut) and a line it split is kept: the next call goes on with it.

Source

pub fn stream(&self) -> &UnixStream ⓘ

The underlying stream, e.g. to set a read timeout or shut it down from another thread.

Auto Trait Implementations§

§

impl Forget for Client

§

impl Freeze for Client
where *const u8 is !null: Freeze, PhantomData<u8>: Freeze, I32NotAllOnes: Freeze,

§

impl Move for Client

§

impl RefUnwindSafe for Client
where I32NotAllOnes: RefUnwindSafe,

§

impl Send for Client
where RawVecInner: Send, I32NotAllOnes: Send,

§

impl Sync for Client
where RawVecInner: Sync, I32NotAllOnes: Sync,

§

impl Unpin for Client
where *const u8 is !null: Unpin, I32NotAllOnes: Unpin,

§

impl UnsafeUnpin for Client
where *const u8 is !null: UnsafeUnpin, PhantomData<u8>: UnsafeUnpin, I32NotAllOnes: UnsafeUnpin,

§

impl UnwindSafe for Client
where RawVecInner: UnwindSafe, I32NotAllOnes: UnwindSafe,

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.