use bstr::{BStr, ByteSlice};
#[derive(Debug, PartialEq, Ord, PartialOrd, Eq, Hash, Clone, Copy)]
pub struct Key<'a> {
pub section_name: &'a str,
pub subsection_name: Option<&'a BStr>,
}
impl<'a> Key<'a> {
pub fn parse(input: impl Into<&'a BStr>) -> Option<Self> {
let input = input.into();
let mut tokens = input.splitn(2, |b| *b == b'.');
Some(Key {
section_name: tokens.next()?.to_str().ok()?,
subsection_name: tokens.next().map(Into::into),
})
}
}