[−][src]Function typescript_definitions::as_byte_string
pub fn as_byte_string<S>(bytes: &[u8], serializer: S) -> Result<S::Ok, S::Error> where
S: Serializer,
String serializer for u8
byte buffers.
Use #[serde(serialize_with="typescript_definitions::as_byte_string")]
on a [u8]
or Vec<u8>
object to make the output type a string
(instead of a number[]
).
The encoding is a simple \xdd
format.
Or provide your own serializer:
typescript-definitions
only checks the final name "as_byte_string" of the path.
e.g.
use serde::Serialize; use typescript_definitions::{TypeScriptify, TypeScriptifyTrait}; #[derive(Serialize, TypeScriptify)] struct S { #[serde(serialize_with="typescript_definitions::as_byte_string")] image : Vec<u8>, buffer: &'static [u8], } println!("{}", S::type_script_ify());
prints export type S = { image: string, buffer: number[] };
.