Skip to content

Commit

Permalink
allow returning bytevectors via ffi (#255)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwparas authored Aug 2, 2024
1 parent 1eb4d9b commit 03649c1
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion crates/steel-core/src/steel_vm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use crate::{
rerrs::ErrorKind,
rvals::{
as_underlying_type_mut, Custom, CustomType, FutureResult, IntoSteelVal, Result,
SteelHashMap, SteelVal,
SteelByteVector, SteelHashMap, SteelVal,
},
values::functions::{BoxedDynFunction, StaticOrRcStr},
SteelErr,
Expand Down Expand Up @@ -1006,6 +1006,7 @@ pub enum FFIValue {
#[sabi(unsafe_opaque_field)]
fut: FfiFuture<RResult<FFIValue, RBoxError>>,
},
ByteVector(RVec<u8>),
}

impl FFIValue {
Expand Down Expand Up @@ -1063,6 +1064,7 @@ impl std::fmt::Debug for FFIValue {
FFIValue::Vector(v) => write!(f, "{:?}", v),
FFIValue::HashMap(h) => write!(f, "{:?}", h),
FFIValue::Future { .. } => write!(f, "#<future>"),
FFIValue::ByteVector(b) => write!(f, "{:?}", b),
}
}
}
Expand Down Expand Up @@ -1188,6 +1190,8 @@ impl IntoSteelVal for FFIValue {
.await
}),
)))),

Self::ByteVector(b) => Ok(SteelVal::ByteVector(SteelByteVector::new(b.into()))),
}
}
}
Expand Down

0 comments on commit 03649c1

Please sign in to comment.