use std::fmt; use std::io::IoSlice; use bytes::buf::{Chain, Take}; use bytes::Buf; use super::io::WriteBuf; type StaticBuf = &'static [u8]; #[derive(Debug, Clone, PartialEq)] pub(crate) struct Encoder { kind: Kind, is_last: bool, } #[derive(Debug)] pub(crate) struct EncodedBuf { kind: BufKind, } #[derive(Debug)] pub(crate) struct NotEof(u64); #[derive(Debug, PartialEq, Clone)] enum Kind { Chunked, Length(u64), #[cfg(feature = "server")] CloseDelimited, } #[derive(Debug)] enum BufKind { Exact(B), Limited(Take), Chunked(Chain, StaticBuf>), ChunkedEnd(StaticBuf), } impl Encoder { fn new(kind: Kind) -> Encoder { loop {} } pub(crate) fn chunked() -> Encoder { loop {} } pub(crate) fn length(len: u64) -> Encoder { loop {} } #[cfg(feature = "server")] pub(crate) fn close_delimited() -> Encoder { loop {} } pub(crate) fn is_eof(&self) -> bool { loop {} } #[cfg(feature = "server")] pub(crate) fn set_last(mut self, is_last: bool) -> Self { loop {} } pub(crate) fn is_last(&self) -> bool { loop {} } pub(crate) fn is_close_delimited(&self) -> bool { loop {} } pub(crate) fn end(&self) -> Result>, NotEof> { loop {} } pub(crate) fn encode(&mut self, msg: B) -> EncodedBuf where B: Buf, { loop {} } pub(super) fn encode_and_end( &self, msg: B, dst: &mut WriteBuf>, ) -> bool where B: Buf, { loop {} } pub(super) fn danger_full_buf(self, msg: B, dst: &mut WriteBuf>) where B: Buf, { loop {} } } impl Buf for EncodedBuf where B: Buf, { #[inline] fn remaining(&self) -> usize { loop {} } #[inline] fn chunk(&self) -> &[u8] { loop {} } #[inline] fn advance(&mut self, cnt: usize) { loop {} } #[inline] fn chunks_vectored<'t>(&'t self, dst: &mut [IoSlice<'t>]) -> usize { loop {} } } #[cfg(target_pointer_width = "32")] const USIZE_BYTES: usize = 4; #[cfg(target_pointer_width = "64")] const USIZE_BYTES: usize = 8; const CHUNK_SIZE_MAX_BYTES: usize = USIZE_BYTES * 2; #[derive(Clone, Copy)] struct ChunkSize { bytes: [u8; CHUNK_SIZE_MAX_BYTES + 2], pos: u8, len: u8, } impl ChunkSize { fn new(len: usize) -> ChunkSize { loop {} } } impl Buf for ChunkSize { #[inline] fn remaining(&self) -> usize { loop {} } #[inline] fn chunk(&self) -> &[u8] { loop {} } #[inline] fn advance(&mut self, cnt: usize) { loop {} } } impl fmt::Debug for ChunkSize { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { loop {} } } impl fmt::Write for ChunkSize { fn write_str(&mut self, num: &str) -> fmt::Result { loop {} } } impl From for EncodedBuf { fn from(buf: B) -> Self { loop {} } } impl From> for EncodedBuf { fn from(buf: Take) -> Self { loop {} } } impl From, StaticBuf>> for EncodedBuf { fn from(buf: Chain, StaticBuf>) -> Self { loop {} } } impl fmt::Display for NotEof { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { loop {} } } impl std::error::Error for NotEof {} #[cfg(test)] mod tests { use bytes::BufMut; use super::super::io::Cursor; use super::Encoder; #[test] fn chunked() { loop {} } #[test] fn length() { loop {} } #[test] fn eof() { loop {} } }