mirror of
https://github.com/rutgersc/m3u8-rs.git
synced 2025-01-10 22:55:25 +00:00
Add some convenience API to QuotedOrUnquoted
This commit is contained in:
parent
b692ac0808
commit
0789098d7d
1 changed files with 23 additions and 0 deletions
|
@ -628,6 +628,29 @@ impl Default for QuotedOrUnquoted {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl QuotedOrUnquoted {
|
||||||
|
pub fn as_str(&self) -> &str {
|
||||||
|
match self {
|
||||||
|
QuotedOrUnquoted::Quoted(s) => s.as_str(),
|
||||||
|
QuotedOrUnquoted::Unquoted(s) => s.as_str(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_unquoted(&self) -> Option<&str> {
|
||||||
|
match self {
|
||||||
|
QuotedOrUnquoted::Unquoted(s) => Some(s.as_str()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn as_quoted(&self) -> Option<&str> {
|
||||||
|
match self {
|
||||||
|
QuotedOrUnquoted::Quoted(s) => Some(s.as_str()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl From<&str> for QuotedOrUnquoted {
|
impl From<&str> for QuotedOrUnquoted {
|
||||||
fn from(s: &str) -> Self {
|
fn from(s: &str) -> Self {
|
||||||
if s.starts_with('"') && s.ends_with('"') {
|
if s.starts_with('"') && s.ends_with('"') {
|
||||||
|
|
Loading…
Reference in a new issue