OX2J5WFE6GRVIE7P7EY75ZRXQHEX64JKK63QUJF26BWD5PU3F3OQC
ui.set_channel_list(SharedString::from(&channel_list));
let channel_strs = channel_list
.entries
.into_iter()
.map(SharedString::from)
.collect::<Vec<_>>();
ui.set_channels((&channel_strs[..]).into());
ui.set_active_channel(i32::try_from(channel_list.active).unwrap_or(-1));
Ok(String::from_utf8(output.stdout)?)
parse_channel_output(output.stdout)
}
fn parse_channel_output(output: Vec<u8>) -> Result<ChannelsList, Error> {
let channels_str = String::from_utf8(output)?;
let channels_list = channels_str.split('\n').map(|substr| substr.trim()).fold(
ChannelsList::new(),
|mut channels_list, ch_str| {
if ch_str.starts_with("* ") {
channels_list.active = channels_list.entries.len();
channels_list.entries.push(ch_str[2..].to_string());
} else {
channels_list.entries.push(ch_str.to_string());
}
channels_list
},
);
Ok(channels_list)