pub async fn write_manager_state<H: Handle>(
        &mut self,
        raw_state: &crate::state::State<H>,
    ) -> Result<()> {
        if self.listener.is_some() {
            let state: ManagerState = raw_state.into();
            let mut json = serde_json::to_string(&state)?;
            json.push('\n');
            let mut state = self.state.lock().await;

            let state_changed = json != state.last_state;
            if state_changed {
                state.peers.retain(std::option::Option::is_some);
                for peer in &mut state.peers {
                    if peer
                        .as_mut()
                        .ok_or(LeftError::StreamError)?
                        .write_all(json.as_bytes())
                        .await
                        .is_err()
                    {
                        peer.take();
                    }
                }
                state.last_state = json;
            }
        }
        Ok(())
    }
# Errors
Will return Err if a mut ref to the peer is unavailable.
Will return error if state cannot be serialized
leftwm-core/src/utils/state_socket.rs