hex-view-0.1.3/.gitignore010064400007650000024000000000371316352445300134640ustar0000000000000000/target/ **/*.rs.bk Cargo.lock hex-view-0.1.3/Cargo.toml.orig010064400007650000024000000004551351122350200143530ustar0000000000000000[package] name = "hex-view" version = "0.1.3" description = "Easily format a &[u8] as hex." readme = "README.md" authors = ["Paul Kernfeld "] license = "MIT/Apache-2.0" documentation = "https://crates.io/crates/hex-view" repository = "https://github.com/paulkernfeld/hex-view" hex-view-0.1.3/Cargo.toml0000644000000014720000000000000106320ustar00# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO # # When uploading crates to the registry Cargo will automatically # "normalize" Cargo.toml files for maximal compatibility # with all versions of Cargo and also rewrite `path` dependencies # to registry (e.g., crates.io) dependencies # # If you believe there's an error in this file please file an # issue against the rust-lang/cargo repository. If you're # editing this file be aware that the upstream Cargo.toml # will likely look very different (and much more reasonable) [package] name = "hex-view" version = "0.1.3" authors = ["Paul Kernfeld "] description = "Easily format a &[u8] as hex." documentation = "https://crates.io/crates/hex-view" readme = "README.md" license = "MIT/Apache-2.0" repository = "https://github.com/paulkernfeld/hex-view" hex-view-0.1.3/README.md010064400007650000024000000011031351122340600127350ustar0000000000000000# hex-view *NOTE:* As of Rust 1.26.0, this crate is no longer necessary because an `&[u8]` can be formatted as hex using the `:x?` and `:X?` formatters. Easily format a `&[u8]` as hex. ```rust use hex_view::HexView; let ff00_slice: &[u8] = &[255, 0]; assert_eq!(format!("{:x}", HexView::from(&ff00_slice)), "ff00") ``` `HexView::from` also works on anything that implements `AsRef<[u8]>`, such as a `&Vec`: ```rust use hex_view::HexView; let ff00_vec: Vec = vec![255, 0]; assert_eq!(format!("{:X}", HexView::from(&ff00_vec)), "FF00") ``` License: MIT/Apache-2.0 hex-view-0.1.3/src/lib.rs010064400007650000024000000027131351122335300133720ustar0000000000000000//! *NOTE:* As of Rust 1.26.0, this crate is no longer necessary because an `&[u8]` can be //! formatted as hex using the `:x?` and `:X?` formatters. //! //! Easily format a `&[u8]` as hex. //! //! ```rust //! use hex_view::HexView; //! //! let ff00_slice: &[u8] = &[255, 0]; //! assert_eq!(format!("{:x}", HexView::from(&ff00_slice)), "ff00") //! //! ``` //! //! `HexView::from` also works on anything that implements `AsRef<[u8]>`, such as a `&Vec`: //! //! ```rust //! use hex_view::HexView; //! //! let ff00_vec: Vec = vec![255, 0]; //! assert_eq!(format!("{:X}", HexView::from(&ff00_vec)), "FF00") //! ``` #![no_std] #![deny(missing_docs)] #![deny(warnings)] use core::fmt; use core::fmt::{Formatter, LowerHex, UpperHex}; /// This struct can be formatted with the `core::fmt::LowerHex` and `core::fmt::UpperHex` formatting /// traits. pub struct HexView<'a> { bytes: &'a [u8], } impl<'a> LowerHex for HexView<'a> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { for b in self.bytes { write!(f, "{:02x}", b)?; } Ok(()) } } impl<'a> UpperHex for HexView<'a> { fn fmt(&self, f: &mut Formatter) -> fmt::Result { for b in self.bytes { write!(f, "{:02X}", b)?; } Ok(()) } } impl<'a, T> From<&'a T> for HexView<'a> where T: ?Sized, T: AsRef<[u8]>, T: 'a, { fn from(bytes: &'a T) -> Self { HexView { bytes: bytes.as_ref(), } } } hex-view-0.1.3/test010075500007650000024000000001301351122337600123700ustar0000000000000000#!/usr/bin/env bash set -e cargo test cargo clippy cargo fmt cargo readme -o README.md hex-view-0.1.3/watch010075500007650000024000000002601316352744100125260ustar0000000000000000#!/usr/bin/env bash set -e cargo watch -w src \ -x test \ -x clippy \ -x "fmt -- --write-mode=diff" \ -x "readme -o README.md" hex-view-0.1.3/.cargo_vcs_info.json0000644000000001120000000000000126220ustar00{ "git": { "sha1": "b85c555344b55ea79aca8189fac3303da1c6952a" } }