kimchi_stubs/caml/
caml_bytes_string.rs1use ocaml::{FromValue, IntoValue, Runtime, Value};
2use ocaml_gen::{const_random, Env, OCamlDesc};
3
4pub struct CamlBytesString<'a>(pub &'a [u8]);
5
6unsafe impl<'a> IntoValue for CamlBytesString<'a> {
7 fn into_value(self, rt: &Runtime) -> Value {
8 self.0.into_value(rt)
9 }
10}
11
12unsafe impl<'a> FromValue<'a> for CamlBytesString<'a> {
13 fn from_value(v: Value) -> Self {
14 CamlBytesString(FromValue::from_value(v))
15 }
16}
17
18impl<'a> OCamlDesc for CamlBytesString<'a> {
19 fn ocaml_desc(_env: &Env, _generics: &[&str]) -> String {
20 "string".to_string()
21 }
22
23 fn unique_id() -> u128 {
24 const_random!(u128)
25 }
26}