diff --git a/core/conversations/src/api.rs b/core/conversations/src/api.rs index a189627..be0618a 100644 --- a/core/conversations/src/api.rs +++ b/core/conversations/src/api.rs @@ -52,8 +52,8 @@ pub struct ContextHandle(pub(crate) Context); /// so the caller always gets a deterministic name reflecting their input. #[ffi_export] pub fn create_context(name: c_slice::Ref<'_, u8>) -> repr_c::Box { - let name_str = std::string::String::from_utf8_lossy(name.as_slice()); - Box::new(ContextHandle(Context::new_with_name(&name_str))).into() + let name_str = std::string::String::from_utf8_lossy(name.as_slice()).into_owned(); + Box::new(ContextHandle(Context::new_with_name(name_str))).into() } /// Returns the friendly name of the contexts installation. diff --git a/nim-bindings/src/libchat.nim b/nim-bindings/src/libchat.nim index 90960c1..7368c73 100644 --- a/nim-bindings/src/libchat.nim +++ b/nim-bindings/src/libchat.nim @@ -15,7 +15,7 @@ type ## Create a new conversations context proc newConversationsContext*(name: string): LibChat = - result.handle = create_context(name.toReprCString) + result.handle = create_context(name.toSlice) result.buffer_size = 256 if result.handle.isNil: raise newException(IOError, "Failed to create context") @@ -95,7 +95,7 @@ proc sendContent*(ctx: LibChat, convoId: string, content: seq[byte]): Result[seq if content.len == 0: return err("content is zero length") - let res = bindings.send_content(ctx.handle, convoId.toReprCString, content.toSlice()) + let res = bindings.send_content(ctx.handle, convoId.toSlice, content.toSlice()) defer: destroy_send_content_result(res) if res.error_code != 0: