Skip to content

Commit

Permalink
chore: expose set_data() and get_data() in uniffi bindings
Browse files Browse the repository at this point in the history
And in JVM wrapper.
Part of WPB-10919.
  • Loading branch information
SimonThormeyer committed Nov 12, 2024
1 parent 5fa65b8 commit 45fb16a
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,23 @@ class CoreCryptoContext(private val cc: CoreCryptoContext) {
)
}

/**
* Set arbitrary data to be retrieved by [getData].
* This is meant to be used as a check point at the end of a transaction.
* The data should be limited to a reasonable size.
*/
suspend fun setData(data: ByteArray) {
cc.setData(data)
}

/**
* Get the data that has previously been set by [setData], or null if no data has been set.
* This is meant to be used as a check point at the end of a transaction.
*/
suspend fun getData(): ByteArray? {
return cc.getData()
}

/**
* This is your entrypoint to initialize [com.wire.crypto.client.MLSClient] with a Basic Credential
*/
Expand Down
10 changes: 10 additions & 0 deletions crypto-ffi/src/generic/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,16 @@ impl CoreCrypto {

#[uniffi::export]
impl CoreCryptoContext {
/// See [core_crypto::context::CentralContext::set_data].
pub async fn set_data(&self, data: Vec<u8>) -> CoreCryptoResult<()> {
self.context.set_data(data).await.map_err(Into::into)
}

/// See [core_crypto::context::CentralContext::get_data].
pub async fn get_data(&self) -> CoreCryptoResult<Option<Vec<u8>>> {
self.context.get_data().await.map_err(Into::into)
}

/// See [core_crypto::context::CentralContext::mls_init]
pub async fn mls_init(
&self,
Expand Down

0 comments on commit 45fb16a

Please sign in to comment.