Skip to content

Commit

Permalink
trans utf8 binary to string
Browse files Browse the repository at this point in the history
  • Loading branch information
wangjingjing authored and jtong11 committed Oct 9, 2020
1 parent c2ee77c commit cee9ad5
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/core/util/variant_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,22 @@ impl VariantValue {
}
}

pub fn get_utf8_string(&self) -> Option<String> {
match self {
VariantValue::VString(s) => Some(s.clone()),
VariantValue::Binary(b) => {
if let Ok(s) = String::from_utf8(b.clone()) {
Some(s)
} else {
None
}
}
_ => {
None
}
}
}

// used for index sort check
pub fn is_zero(&self) -> bool {
match self {
Expand Down

0 comments on commit cee9ad5

Please sign in to comment.