mirror of
https://github.com/logos-messaging/libchat.git
synced 2026-04-02 01:23:11 +00:00
Add name retrieval to bindings
This commit is contained in:
parent
459ce2802c
commit
a97ddfdbd0
@ -53,6 +53,12 @@ pub fn create_context(name: String) -> repr_c::Box<ContextHandle> {
|
|||||||
Box::new(ContextHandle(Context::new_with_name(name))).into()
|
Box::new(ContextHandle(Context::new_with_name(name))).into()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns the friendly name of the context's identity
|
||||||
|
#[ffi_export]
|
||||||
|
pub fn get_friendly_name(ctx: &ContextHandle) -> repr_c::String {
|
||||||
|
ctx.0.get_friendly_name().to_string().into()
|
||||||
|
}
|
||||||
|
|
||||||
/// Destroys a conversation store and frees its memory
|
/// Destroys a conversation store and frees its memory
|
||||||
///
|
///
|
||||||
/// # Safety
|
/// # Safety
|
||||||
|
|||||||
@ -99,6 +99,10 @@ type
|
|||||||
## Returns: Opaque handle to the context. Must be freed with destroy_context()
|
## Returns: Opaque handle to the context. Must be freed with destroy_context()
|
||||||
proc create_context*(name: ReprCString): ContextHandle {.importc, dynlib: CONVERSATIONS_LIB.}
|
proc create_context*(name: ReprCString): ContextHandle {.importc, dynlib: CONVERSATIONS_LIB.}
|
||||||
|
|
||||||
|
## Returns the friendly name of the context's identity
|
||||||
|
## The result must be freed by the caller (repr_c::String ownership transfers)
|
||||||
|
proc get_friendly_name*(ctx: ContextHandle): ReprCString {.importc, dynlib: CONVERSATIONS_LIB.}
|
||||||
|
|
||||||
## Destroys a context and frees its memory
|
## Destroys a context and frees its memory
|
||||||
## - handle must be a valid pointer from create_context()
|
## - handle must be a valid pointer from create_context()
|
||||||
## - handle must not be used after this call
|
## - handle must not be used after this call
|
||||||
|
|||||||
@ -20,6 +20,13 @@ proc newConversationsContext*(name: string): LibChat =
|
|||||||
if result.handle.isNil:
|
if result.handle.isNil:
|
||||||
raise newException(IOError, "Failed to create context")
|
raise newException(IOError, "Failed to create context")
|
||||||
|
|
||||||
|
## Get the friendly name of this context's installation
|
||||||
|
proc getInstallationName*(ctx: LibChat): string =
|
||||||
|
if ctx.handle == nil:
|
||||||
|
return ""
|
||||||
|
let name = get_friendly_name(ctx.handle)
|
||||||
|
result = $name
|
||||||
|
|
||||||
## Destroy the context and free resources
|
## Destroy the context and free resources
|
||||||
proc destroy*(ctx: var LibChat) =
|
proc destroy*(ctx: var LibChat) =
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user