Skip to content

Commit

Permalink
stream all messages in libxmtp
Browse files Browse the repository at this point in the history
  • Loading branch information
nplasterer committed Feb 21, 2024
1 parent e56f527 commit 867d1dc
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions library/src/main/java/xmtpv3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,8 @@ internal interface _UniFFILib : Library {
): Pointer
fun uniffi_xmtpv3_fn_method_fficonversations_stream(`ptr`: Pointer,`callback`: Long,
): Pointer
fun uniffi_xmtpv3_fn_method_fficonversations_stream_all_messages(`ptr`: Pointer,`messageCallback`: Long,
): Pointer
fun uniffi_xmtpv3_fn_method_fficonversations_sync(`ptr`: Pointer,
): Pointer
fun uniffi_xmtpv3_fn_free_ffigroup(`ptr`: Pointer,_uniffi_out_err: RustCallStatus,
Expand Down Expand Up @@ -657,6 +659,8 @@ internal interface _UniFFILib : Library {
): Short
fun uniffi_xmtpv3_checksum_method_fficonversations_stream(
): Short
fun uniffi_xmtpv3_checksum_method_fficonversations_stream_all_messages(
): Short
fun uniffi_xmtpv3_checksum_method_fficonversations_sync(
): Short
fun uniffi_xmtpv3_checksum_method_ffigroup_add_members(
Expand Down Expand Up @@ -795,6 +799,9 @@ private fun uniffiCheckApiChecksums(lib: _UniFFILib) {
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_stream() != 60583.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_stream_all_messages() != 65211.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
if (lib.uniffi_xmtpv3_checksum_method_fficonversations_sync() != 62598.toShort()) {
throw RuntimeException("UniFFI API checksum mismatch: try cleaning and rebuilding your project")
}
Expand Down Expand Up @@ -1289,6 +1296,7 @@ public interface FfiConversationsInterface {
suspend fun `createGroup`(`accountAddresses`: List<String>, `permissions`: GroupPermissions?): FfiGroup@Throws(GenericException::class)
suspend fun `list`(`opts`: FfiListConversationsOptions): List<FfiGroup>@Throws(GenericException::class)
suspend fun `stream`(`callback`: FfiConversationCallback): FfiStreamCloser@Throws(GenericException::class)
suspend fun `streamAllMessages`(`messageCallback`: FfiMessageCallback): FfiStreamCloser@Throws(GenericException::class)
suspend fun `sync`()
companion object
}
Expand Down Expand Up @@ -1372,6 +1380,26 @@ class FfiConversations(
)
}

@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `streamAllMessages`(`messageCallback`: FfiMessageCallback) : FfiStreamCloser {
return uniffiRustCallAsync(
callWithPointer { thisPtr ->
_UniFFILib.INSTANCE.uniffi_xmtpv3_fn_method_fficonversations_stream_all_messages(
thisPtr,
FfiConverterTypeFfiMessageCallback.lower(`messageCallback`),
)
},
{ future, continuation -> _UniFFILib.INSTANCE.ffi_xmtpv3_rust_future_poll_pointer(future, continuation) },
{ future, continuation -> _UniFFILib.INSTANCE.ffi_xmtpv3_rust_future_complete_pointer(future, continuation) },
{ future -> _UniFFILib.INSTANCE.ffi_xmtpv3_rust_future_free_pointer(future) },
// lift function
{ FfiConverterTypeFfiStreamCloser.lift(it) },
// Error FFI converter
GenericException.ErrorHandler,
)
}

@Throws(GenericException::class)
@Suppress("ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE")
override suspend fun `sync`() {
Expand Down

0 comments on commit 867d1dc

Please sign in to comment.