From fff61e0adb4764bdb04864d05bdcfa897ad6dcab Mon Sep 17 00:00:00 2001 From: Jake Probst Date: Tue, 20 Aug 2019 18:00:14 -0700 Subject: [PATCH] util module --- src/common/mod.rs | 2 +- src/common/util.rs | 11 +++++++++++ src/lib.rs | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) create mode 100644 src/common/util.rs diff --git a/src/common/mod.rs b/src/common/mod.rs index 781e7a0..5af6caf 100644 --- a/src/common/mod.rs +++ b/src/common/mod.rs @@ -5,4 +5,4 @@ pub mod cipherkeys; pub mod network; pub mod serverstate; pub mod client; - +pub mod util; diff --git a/src/common/util.rs b/src/common/util.rs new file mode 100644 index 0000000..ec13e9c --- /dev/null +++ b/src/common/util.rs @@ -0,0 +1,11 @@ + +pub fn array_to_utf8(array: [u8; X]) -> Result { + String::from_utf8(array.to_vec()) + .map(|mut s| { + if let Some(index) = s.find("\u{0}") { + s.truncate(index); + } + s + }) + +} diff --git a/src/lib.rs b/src/lib.rs index 7917840..b0ec1cd 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,4 +1,7 @@ -#![feature(async_await)] +#![feature(const_generics)] +#[macro_use] +extern crate diesel; pub mod common; +pub mod schema;