use gtk4 as gtk; use bitvec::{order::Lsb0, view::AsBits}; use gtk::{prelude::*, *}; use std::ops::Deref; const ASCII_ZERO_CHAR_POSITION: u8 = 48; pub fn processing_input(input: impl Into) -> String { input .into() .split_ascii_whitespace() .filter(|&x| !x.is_empty()) .fold(String::new(), |c: String, n: &str| c + n) } pub fn from_vec_bits_to_string(raw_data: &[u8]) -> String { raw_data .iter() .map(|bit| -> char { (bit + ASCII_ZERO_CHAR_POSITION).into() }) .collect() } pub fn from_string_to_vec_bits(raw_data: impl Into) -> Vec { raw_data .into() .as_bits::() .iter() .step_by(8) .map(|x| *x.deref() as u8) .collect() } pub fn clearing(output: &TextView, input: &TextView) { input.buffer().set_text(""); output.buffer().set_text(""); }