[1] Disclaimer: //! we use “zero-copy” with quotes because it is an exaggeration. //! In typical usage there is at least one copy, //! for example from the kernel’s network stack to a newly allocated buffer. //! However, the library’s design is intended to minimize the number of copies needed after that. extern crate utf8; /// FIXME: remove this module and use std::ptr::Shared instead once it is stable. /// https://github.com/rust-lang/rust/issues/27730 mod shared_ptr; mod heap_data; mod bytesbuf; mod strbuf; mod utf8_decoder; pub use bytesbuf::BytesBuf; pub use strbuf::{StrBuf, FromUtf8Error}; pub use utf8_decoder::{LossyUtf8Decoder, StrictUtf8Decoder, Utf8DecoderError}; #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] fn u32_to_usize(x: u32) -> usize { x as usize // Valid because usize is at least as big as u32 } #[cfg(any(target_pointer_width = "32", target_pointer_width = "64"))] fn usize_to_u32(x: usize) -> u32 { const MAX: usize = ::std::u32::MAX as usize; // Valid because usize is at least as big as u32 assert!(x <= MAX, "overflow"); x as u32 }