cradle-shared 0.1.1

Shared utilities in use by the Cradle agent and cli
Documentation
//! # `cradle-shared`
//! A library used by the `cradle` toolkit and its plugins that contains shared utilities and definitions
#![warn(missing_docs)]

/// Contains definitions for cradle checks
pub mod checks;
/// Constants shared by the agent and CLI
pub mod consts;
/// Errors shared by the cradle workspace
pub mod errors;
/// Small wrapper around an `Arc<Mutex<T>>` to make the code slightly cleaner
pub mod mutex;
#[cfg(feature = "tls")]
/// Contains the code to allow the agent and cli to communicate over TLS.
pub mod tls;

pub use checks::*;
pub use consts::*;
pub use errors::*;
pub use mutex::*;

/// Small helper to convert a `&[u8]` to `Vec<u16>`
pub fn bytes2wide(buf: &[u8]) -> Vec<u16> {
    buf.chunks_exact(2)
        .map(|c| u16::from_le_bytes([c[0], c[1]]))
        .take_while(|&c| c != 0)
        .collect()
}