user-agent-parser 0.3.4

A parser to get the product, OS, device, cpu, and engine information from a user agent, inspired by https://github.com/faisalman/ua-parser-js and https://github.com/ua-parser/uap-core
Documentation
use std::borrow::Cow;

#[derive(Debug, Clone, Default)]
pub struct UserAgent<'a> {
    pub user_agent: Option<Cow<'a, str>>,
}

impl<'a> UserAgent<'a> {
    /// Extracts the owned data.
    #[inline]
    pub fn into_owned(self) -> UserAgent<'static> {
        let user_agent = self.user_agent.map(|c| Cow::from(c.into_owned()));

        UserAgent {
            user_agent,
        }
    }
}