Browse Source

util module

pbs
Jake Probst 5 years ago
parent
commit
fff61e0adb
  1. 2
      src/common/mod.rs
  2. 11
      src/common/util.rs
  3. 5
      src/lib.rs

2
src/common/mod.rs

@ -5,4 +5,4 @@ pub mod cipherkeys;
pub mod network;
pub mod serverstate;
pub mod client;
pub mod util;

11
src/common/util.rs

@ -0,0 +1,11 @@
pub fn array_to_utf8<const X: usize>(array: [u8; X]) -> Result<String, std::string::FromUtf8Error> {
String::from_utf8(array.to_vec())
.map(|mut s| {
if let Some(index) = s.find("\u{0}") {
s.truncate(index);
}
s
})
}

5
src/lib.rs

@ -1,4 +1,7 @@
#![feature(async_await)]
#![feature(const_generics)]
#[macro_use]
extern crate diesel;
pub mod common;
pub mod schema;
Loading…
Cancel
Save