pub struct Client {
pub api: u32,
pub server: String,
/* private fields */
}Expand description
A connection to smed, after the handshake.
Fields§
§api: u32The API version both sides agreed on.
server: Stringsmed’s name and version from its hello.
Implementations§
Source§impl Client
impl Client
Sourcepub fn connect(client: &str) -> Result<Self>
pub fn connect(client: &str) -> Result<Self>
Connects to smed at default_socket_path and introduces itself as client.
Sourcepub fn connect_to(path: &Path, client: &str) -> Result<Self>
pub fn connect_to(path: &Path, client: &str) -> Result<Self>
Connects to smed at path and introduces itself as client.
Sourcepub fn send(&mut self, message: &ClientMessage) -> Result<()>
pub fn send(&mut self, message: &ClientMessage) -> Result<()>
Sends one message.
Sourcepub fn set_lock(&mut self, on: bool) -> Result<()>
pub fn set_lock(&mut self, on: bool) -> Result<()>
Asks smed to switch the rotation lock on or off.
Sourcepub fn focus(&mut self, on: bool) -> Result<()>
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.
Sourcepub fn set_icon_svg(&mut self, id: &str, svg: &str) -> Result<()>
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.
Sourcepub fn set_icon_png(&mut self, id: &str, png: &[u8]) -> Result<()>
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.
Sourcepub fn set_commands(&mut self, app: &App, commands: &[Command]) -> Result<()>
pub fn set_commands(&mut self, app: &App, commands: &[Command]) -> Result<()>
Sends the application and its command catalogue (API 2); replaces the previous one.
Sourcepub fn set_environments(&mut self, environments: &[Environment]) -> Result<()>
pub fn set_environments(&mut self, environments: &[Environment]) -> Result<()>
Sends the environments with their key assignments (API 2); replaces the previous ones.
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.
Sourcepub fn set_environment(&mut self, id: &str) -> Result<()>
pub fn set_environment(&mut self, id: &str) -> Result<()>
Shows environment id (from set_environments) on the keys and the LCD (API 2).
Sourcepub fn set_lcd(
&mut self,
brightness: Option<u8>,
text_size: Option<TextSize>,
theme: Option<Theme>,
) -> Result<()>
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.
Sourcepub fn get_screen(&mut self) -> Result<()>
pub fn get_screen(&mut self) -> Result<()>
Asks for the current LCD page (API 2); smed answers with screen, see
ServerMessage::screen_png.
Sourcepub fn next_message(&mut self) -> Result<Option<ServerMessage>>
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.
Sourcepub fn stream(&self) -> &UnixStream ⓘ
pub fn stream(&self) -> &UnixStream ⓘ
The underlying stream, e.g. to set a read timeout or shut it down from another thread.