mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-04-10 05:23:08 +00:00
fix: build
This commit is contained in:
parent
14a403399e
commit
cdd58ec7f4
@ -52,8 +52,8 @@ pub struct ContextHandle(pub(crate) Context);
|
|||||||
/// so the caller always gets a deterministic name reflecting their input.
|
/// so the caller always gets a deterministic name reflecting their input.
|
||||||
#[ffi_export]
|
#[ffi_export]
|
||||||
pub fn create_context(name: c_slice::Ref<'_, u8>) -> repr_c::Box<ContextHandle> {
|
pub fn create_context(name: c_slice::Ref<'_, u8>) -> repr_c::Box<ContextHandle> {
|
||||||
let name_str = std::string::String::from_utf8_lossy(name.as_slice());
|
let name_str = std::string::String::from_utf8_lossy(name.as_slice()).into_owned();
|
||||||
Box::new(ContextHandle(Context::new_with_name(&name_str))).into()
|
Box::new(ContextHandle(Context::new_with_name(name_str))).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the friendly name of the contexts installation.
|
/// Returns the friendly name of the contexts installation.
|
||||||
|
|||||||
@ -15,7 +15,7 @@ type
|
|||||||
## Create a new conversations context
|
## Create a new conversations context
|
||||||
proc newConversationsContext*(name: string): LibChat =
|
proc newConversationsContext*(name: string): LibChat =
|
||||||
|
|
||||||
result.handle = create_context(name.toReprCString)
|
result.handle = create_context(name.toSlice)
|
||||||
result.buffer_size = 256
|
result.buffer_size = 256
|
||||||
if result.handle.isNil:
|
if result.handle.isNil:
|
||||||
raise newException(IOError, "Failed to create context")
|
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:
|
if content.len == 0:
|
||||||
return err("content is zero length")
|
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)
|
defer: destroy_send_content_result(res)
|
||||||
|
|
||||||
if res.error_code != 0:
|
if res.error_code != 0:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user