1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
//! RPC codec types.

mod errors;
mod list;
mod traits;
mod util;

pub use crate::errors::CodecError;
pub use crate::list::ListOf;
pub use crate::traits::RpcCodec;

#[cfg(feature = "as-borsh")]
mod borsh_wrap;

#[cfg(feature = "as-borsh")]
pub use crate::borsh_wrap::AsBorsh;

#[cfg(feature = "as-serde-cbor")]
mod serde_cbor_wrap;

#[cfg(feature = "as-serde-cbor")]
pub use serde_cbor_wrap::AsSerdeCbor;

#[cfg(feature = "as-serde-cbor")]
mod serde_json_wrap;

#[cfg(feature = "as-serde-cbor")]
pub use serde_json_wrap::AsSerdeJson;

/// Encodes the type into a vec.
pub fn encode_to_vec<T: RpcCodec>(v: &T) -> Result<Vec<u8>, CodecError> {
    let mut buf = Vec::new();
    v.fill_buf(&mut buf)?;
    Ok(buf)
}