From b65303ede0750e9d83df4d2c5df67f143c9171c4 Mon Sep 17 00:00:00 2001 From: Irene Knapp Date: Wed, 25 Nov 2026 03:40:14 -0700 Subject: i3 mode module fully works now; some API changes most notably, modules now have a way to request immediate redrawing Change-Id: Id060c88d3ab484addfd8ca574fbc4e2ffdbb5c8f Force-Push: yes --- src/facility/i3.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/facility') diff --git a/src/facility/i3.rs b/src/facility/i3.rs index d914548..53258f8 100644 --- a/src/facility/i3.rs +++ b/src/facility/i3.rs @@ -530,3 +530,27 @@ fn parse_success_object(json: &[u8]) -> Result { } } + +pub fn parse_change_string(json: &[u8]) -> Result { + let mut parser = SliceJsonParser::new(json); + + if let JsonEvent::StartObject = parser.parse_next()? { } else { + return Err(Error::custom("Reading i3 JSON, expected object start.")); + } + + if let JsonEvent::ObjectKey(key) = parser.parse_next()? { + if key == "change" { + if let JsonEvent::String(result) = parser.parse_next()? { + /* That's our answer; exit early. */ + return Ok(result.into_owned()); + } else { + return Err(Error::custom("Reading i3 JSON, expected string.")); + } + } else { + return Err(Error::custom("Reading i3 JSON, expected \"change\" key.")); + } + } else { + return Err(Error::custom("Reading i3 JSON, expected object key.")); + } +} + -- cgit 1.4.1