user_agent_parser/models/
os.rs1use std::borrow::Cow;
2
3#[derive(Debug, Clone, Default)]
4pub struct OS<'a> {
5 pub name: Option<Cow<'a, str>>,
6 pub major: Option<Cow<'a, str>>,
7 pub minor: Option<Cow<'a, str>>,
8 pub patch: Option<Cow<'a, str>>,
9 pub patch_minor: Option<Cow<'a, str>>,
10}
11
12impl<'a> OS<'a> {
13 #[inline]
15 pub fn into_owned(self) -> OS<'static> {
16 let os = self.name.map(|c| Cow::from(c.into_owned()));
17 let major = self.major.map(|c| Cow::from(c.into_owned()));
18 let minor = self.minor.map(|c| Cow::from(c.into_owned()));
19 let patch = self.patch.map(|c| Cow::from(c.into_owned()));
20 let patch_minor = self.patch_minor.map(|c| Cow::from(c.into_owned()));
21
22 OS {
23 name: os,
24 major,
25 minor,
26 patch,
27 patch_minor,
28 }
29 }
30}