Rename generic writer
This commit is contained in:
parent
6ca24956ad
commit
9933ed6b1f
@ -4,7 +4,7 @@ use sehn::*;
|
||||
|
||||
fn main() {
|
||||
let mut buf = [0u8; 2048];
|
||||
let mut w: GenericWriter<_> = SliceBuffer::new(&mut buf).into();
|
||||
let mut w: GenericBufferWriter<_> = SliceBuffer::new(&mut buf).into();
|
||||
let mut s = BaseSerializer::new(&mut w);
|
||||
|
||||
s.serialize_unit("hello", 1.0).unwrap();
|
||||
|
@ -85,6 +85,7 @@ impl<'a> GenericWriteBuffer for SliceBuffer<'a> {
|
||||
|
||||
#[cfg(any(feature = "std", feature = "alloc"))]
|
||||
impl GenericWriteBuffer for Vec<u8> {
|
||||
// TODO: Use never type
|
||||
type Error = ();
|
||||
|
||||
#[inline]
|
||||
|
@ -11,7 +11,7 @@ pub use self::buffer::*;
|
||||
pub fn to_string<T>(value: T) -> Result<String, SerializerError<()>>
|
||||
where T: Serialize
|
||||
{
|
||||
let mut w = GenericWriter::from(Vec::new());
|
||||
let mut w = GenericBufferWriter::from(Vec::new());
|
||||
let mut s = BaseSerializer::new(&mut w);
|
||||
value.serialize(&mut s)?;
|
||||
Ok(w.to_string())
|
||||
|
@ -1,21 +1,21 @@
|
||||
use crate::se::*;
|
||||
use super::{GenericWriteBuffer, GenericReadBuffer};
|
||||
|
||||
pub struct GenericWriter<T>
|
||||
where T: GenericWriteBuffer
|
||||
pub struct GenericBufferWriter<T>
|
||||
where T: GenericWriteBuffer + GenericReadBuffer
|
||||
{
|
||||
buf: T
|
||||
}
|
||||
|
||||
impl<T> From<T> for GenericWriter<T>
|
||||
where T: GenericWriteBuffer
|
||||
impl<T> From<T> for GenericBufferWriter<T>
|
||||
where T: GenericWriteBuffer + GenericReadBuffer
|
||||
{
|
||||
fn from(buf: T) -> Self {
|
||||
Self { buf }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> GenericWriter<T>
|
||||
impl<T> GenericBufferWriter<T>
|
||||
where T: GenericWriteBuffer + GenericReadBuffer
|
||||
{
|
||||
pub fn into_inner(self) -> T {
|
||||
@ -36,7 +36,7 @@ impl<T> GenericWriter<T>
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Write for &mut GenericWriter<T>
|
||||
impl<T> Write for &mut GenericBufferWriter<T>
|
||||
where
|
||||
T: GenericWriteBuffer + GenericReadBuffer,
|
||||
T::Error: WriteError
|
||||
|
Loading…
Reference in New Issue
Block a user