config: add get_connector_by_name
This commit is contained in:
parent
52b91654ca
commit
cf36da4077
4 changed files with 31 additions and 0 deletions
|
|
@ -560,6 +560,12 @@ impl ConfigClient {
|
|||
connector
|
||||
}
|
||||
|
||||
pub fn get_connector_by_name(&self, name: &str) -> Connector {
|
||||
let res = self.send_with_response(&ClientMessage::GetConnectorByName { name });
|
||||
get_response!(res, Connector(0), GetConnector { connector });
|
||||
connector
|
||||
}
|
||||
|
||||
pub fn get_seat_cursor_workspace(&self, seat: Seat) -> Workspace {
|
||||
let res = self.send_with_response(&ClientMessage::GetSeatCursorWorkspace { seat });
|
||||
get_response!(res, Workspace(0), GetSeatCursorWorkspace { workspace });
|
||||
|
|
|
|||
|
|
@ -849,6 +849,9 @@ pub enum ClientMessage<'a> {
|
|||
ConnectorSupportsArbitraryModes {
|
||||
connector: Connector,
|
||||
},
|
||||
GetConnectorByName {
|
||||
name: &'a str,
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug)]
|
||||
|
|
|
|||
|
|
@ -454,6 +454,14 @@ pub fn get_connector(id: impl ToConnectorId) -> Connector {
|
|||
get!(Connector(0)).get_connector(ty, idx)
|
||||
}
|
||||
|
||||
/// Returns the connector with the given name.
|
||||
///
|
||||
/// Unlike [`get_connector`], this function can also be used for connectors whose names
|
||||
/// don't follow the `<type>-<id>` pattern.
|
||||
pub fn get_connector_by_name(name: &str) -> Connector {
|
||||
get!(Connector(0)).get_connector_by_name(name)
|
||||
}
|
||||
|
||||
/// A type that can be converted to a `(ConnectorType, idx)` tuple.
|
||||
pub trait ToConnectorId {
|
||||
fn to_connector_id(&self) -> Result<(ConnectorType, u32), String>;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue