diff options
| author | Max Audron <audron@cocaine.farm> | 2020-01-21 16:12:13 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2020-01-21 16:12:13 +0100 |
| commit | b1bae553b620f0a1d71c6be7fa98c10978662907 (patch) | |
| tree | 05d33d9e14d2f960ce071938aa88408aa0e941fc /src/util.rs | |
| parent | update (diff) | |
le tokio
Diffstat (limited to 'src/util.rs')
| -rw-r--r-- | src/util.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/util.rs b/src/util.rs index 48ab55e..7c26ec5 100644 --- a/src/util.rs +++ b/src/util.rs @@ -24,6 +24,18 @@ macro_rules! match_variant { } } +use crate::protocol::primitive::{Variant, String}; +use crate::protocol::error::ProtocolError; +use failure::Error; + +pub fn get_msg_type(val: &Variant) -> Result<&str, Error> { + match val { + Variant::String(x) => return Ok(x), + Variant::StringUTF8(x) => return Ok(x), + _ => bail!(ProtocolError::WrongVariant) + }; +} + pub fn prepend_byte_len(buf: &mut Vec<u8>) { use std::convert::TryInto; let len: i32 = buf.len().try_into().unwrap(); |
