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