Hi
I want to start by thanking the Rust community for being so helpful to beginners. I went through the book and I want to reinforce my learning by making something useful (at least to me).
Now the the issue at hand:
I need to parse a set of strings from a big string. What I am basically doing is, invoking an inxi command, get a big text input and parse it one by one. A sample argument is here.
Now I have a struct called System and it includes various components like struct Audio, CPU etc.
What I want to do is:
-
From the sample argument, first section out a specific part, say for example, while constructing
Audio, I want a slice of this part only:Audio: Device-1: AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]
vendor: Hightech Information System driver: snd_hda_intel v: kernel bus ID: 1c:00.1
chip ID: 1002:aaf0
Device-2: AMD Family 17h HD Audio vendor: Micro-Star MSI driver: snd_hda_intel v: kernel
bus ID: 1e:00.3 chip ID: 1022:1457
Sound Server: ALSA v: k4.19.66-1-MANJARO -
From the Audio slice, I want to construct this struct:
pub struct Device {
name, vendor, driver, version, bus_id, chip_id: String
}pub struct SoundServer {
name, version: String
}
pub struct System {
devices: Vec<device>,
sound_server: String
}
Is there any crate that would allow me to easily parse those inputs? For example, slice.find_between("Audio:", "vendor") == " AMD Ellesmere HDMI Audio [Radeon RX 470/480 / 570/580/590]" or something similar?