From 163d2cfc0b51e953c0cea9b09897a6e6bb0f151c Mon Sep 17 00:00:00 2001 From: Darius Maitia Date: Thu, 19 Sep 2024 11:18:44 -0300 Subject: [PATCH] ZenohId: renaming from ZenohID to ZenohId --- zenoh-jni/src/zenoh_id.rs | 2 +- .../src/commonMain/kotlin/io/zenoh/Config.kt | 1 - .../src/commonMain/kotlin/io/zenoh/Session.kt | 8 ++++---- .../commonMain/kotlin/io/zenoh/SessionInfo.kt | 14 +++++++------- .../commonMain/kotlin/io/zenoh/jni/JNIScout.kt | 4 ++-- .../kotlin/io/zenoh/jni/JNISession.kt | 18 +++++++++--------- .../zenoh/jni/{JNIZenohID.kt => JNIZenohId.kt} | 2 +- .../zenoh/protocol/{ZenohID.kt => ZenohId.kt} | 8 ++++---- .../commonMain/kotlin/io/zenoh/query/Reply.kt | 4 ++-- .../kotlin/io/zenoh/scouting/Hello.kt | 6 +++--- 10 files changed, 33 insertions(+), 34 deletions(-) rename zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/{JNIZenohID.kt => JNIZenohId.kt} (95%) rename zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/{ZenohID.kt => ZenohId.kt} (83%) diff --git a/zenoh-jni/src/zenoh_id.rs b/zenoh-jni/src/zenoh_id.rs index fc0dbf1c2..9f0eb1831 100644 --- a/zenoh-jni/src/zenoh_id.rs +++ b/zenoh-jni/src/zenoh_id.rs @@ -23,7 +23,7 @@ use zenoh::session::ZenohId; /// Returns the string representation of a ZenohID. #[no_mangle] #[allow(non_snake_case)] -pub extern "C" fn Java_io_zenoh_jni_JNIZenohID_toStringViaJNI( +pub extern "C" fn Java_io_zenoh_jni_JNIZenohId_toStringViaJNI( mut env: JNIEnv, _class: JClass, zenoh_id: JByteArray, diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Config.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Config.kt index 9271fedd2..3dc392600 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Config.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Config.kt @@ -15,7 +15,6 @@ package io.zenoh import io.zenoh.jni.JNIConfig -import io.zenoh.protocol.ZenohID import java.io.File import java.nio.file.Path import kotlinx.serialization.json.JsonElement diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt index dc69eb350..e4b78a8c8 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/Session.kt @@ -24,7 +24,7 @@ import io.zenoh.prelude.Encoding import io.zenoh.prelude.QoS import io.zenoh.protocol.IntoZBytes import io.zenoh.protocol.ZBytes -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId import io.zenoh.publication.Delete import io.zenoh.publication.Publisher import io.zenoh.publication.Put @@ -872,15 +872,15 @@ class Session private constructor(private val config: Config) : AutoCloseable { jniSession?.run { performDelete(keyExpr, delete) } } - internal fun zid(): Result { + internal fun zid(): Result { return jniSession?.zid() ?: Result.failure(sessionClosedException) } - internal fun getPeersId(): Result> { + internal fun getPeersId(): Result> { return jniSession?.peersZid() ?: Result.failure(sessionClosedException) } - internal fun getRoutersId(): Result> { + internal fun getRoutersId(): Result> { return jniSession?.routersZid() ?: Result.failure(sessionClosedException) } diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/SessionInfo.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/SessionInfo.kt index 468a43792..5849e87c8 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/SessionInfo.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/SessionInfo.kt @@ -14,7 +14,7 @@ package io.zenoh -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId /** * Class allowing to obtain the information of a [Session]. @@ -22,23 +22,23 @@ import io.zenoh.protocol.ZenohID class SessionInfo(private val session: Session) { /** - * Return the [ZenohID] of the current Zenoh [Session] + * Return the [ZenohId] of the current Zenoh [Session] */ - fun zid(): Result { + fun zid(): Result { return session.zid() } /** - * Return the [ZenohID] of the zenoh peers the session is currently connected to. + * Return the [ZenohId] of the zenoh peers the session is currently connected to. */ - fun peersZid(): Result> { + fun peersZid(): Result> { return session.getPeersId() } /** - * Return the [ZenohID] of the zenoh routers the session is currently connected to. + * Return the [ZenohId] of the zenoh routers the session is currently connected to. */ - fun routersZid(): Result> { + fun routersZid(): Result> { return session.getRoutersId() } } diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt index f697c9c8a..08b393cbf 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIScout.kt @@ -17,7 +17,7 @@ package io.zenoh.jni import io.zenoh.Config import io.zenoh.handlers.Callback import io.zenoh.jni.callbacks.JNIScoutCallback -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId import io.zenoh.scouting.Hello import io.zenoh.scouting.Scout import io.zenoh.scouting.WhatAmI @@ -37,7 +37,7 @@ internal class JNIScout(private val ptr: Long) { receiver: R ): Result> = runCatching { val scoutCallback = JNIScoutCallback { whatAmI2: Int, id: ByteArray, locators: List -> - callback.run(Hello(WhatAmI.fromInt(whatAmI2), ZenohID(id), locators)) + callback.run(Hello(WhatAmI.fromInt(whatAmI2), ZenohId(id), locators)) } val binaryWhatAmI: Int = whatAmI.map { it.value }.reduce { acc, it -> acc or it } val ptr = scoutViaJNI(binaryWhatAmI, scoutCallback, config?.jniConfig?.ptr) diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNISession.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNISession.kt index f212b013b..129faf0c7 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNISession.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNISession.kt @@ -25,7 +25,7 @@ import io.zenoh.jni.callbacks.JNISubscriberCallback import io.zenoh.keyexpr.KeyExpr import io.zenoh.prelude.* import io.zenoh.protocol.IntoZBytes -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId import io.zenoh.protocol.into import io.zenoh.publication.Delete import io.zenoh.publication.Publisher @@ -170,10 +170,10 @@ internal class JNISession { QoS(CongestionControl.fromInt(congestionControl), Priority.fromInt(priority), express), attachmentBytes?.into() ) - reply = Reply(replierId?.let { ZenohID(it) }, Result.success(sample)) + reply = Reply(replierId?.let { ZenohId(it) }, Result.success(sample)) } else { reply = Reply( - replierId?.let { ZenohID(it) }, Result.failure( + replierId?.let { ZenohId(it) }, Result.failure( ReplyError( payload.into(), Encoding(encodingId, schema = encodingSchema) @@ -251,16 +251,16 @@ internal class JNISession { ) } - fun zid(): Result = runCatching { - ZenohID(getZidViaJNI(sessionPtr.get())) + fun zid(): Result = runCatching { + ZenohId(getZidViaJNI(sessionPtr.get())) } - fun peersZid(): Result> = runCatching { - getPeersZidViaJNI(sessionPtr.get()).map { ZenohID(it) } + fun peersZid(): Result> = runCatching { + getPeersZidViaJNI(sessionPtr.get()).map { ZenohId(it) } } - fun routersZid(): Result> = runCatching { - getRoutersZidViaJNI(sessionPtr.get()).map { ZenohID(it) } + fun routersZid(): Result> = runCatching { + getRoutersZidViaJNI(sessionPtr.get()).map { ZenohId(it) } } @Throws(Exception::class) diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohID.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohId.kt similarity index 95% rename from zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohID.kt rename to zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohId.kt index 318924afe..53ecb5dc7 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohID.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/jni/JNIZenohId.kt @@ -16,7 +16,7 @@ package io.zenoh.jni import io.zenoh.ZenohLoad -internal object JNIZenohID { +internal object JNIZenohId { init { ZenohLoad diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohID.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohId.kt similarity index 83% rename from zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohID.kt rename to zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohId.kt index 341a798b8..dd57b6244 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohID.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/protocol/ZenohId.kt @@ -14,22 +14,22 @@ package io.zenoh.protocol -import io.zenoh.jni.JNIZenohID +import io.zenoh.jni.JNIZenohId /** * The global unique id of a Zenoh peer. */ -data class ZenohID internal constructor(internal val bytes: ByteArray) { +data class ZenohId internal constructor(internal val bytes: ByteArray) { override fun toString(): String { - return JNIZenohID.toStringViaJNI(bytes) + return JNIZenohId.toStringViaJNI(bytes) } override fun equals(other: Any?): Boolean { if (this === other) return true if (javaClass != other?.javaClass) return false - other as ZenohID + other as ZenohId return bytes.contentEquals(other.bytes) } diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/query/Reply.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/query/Reply.kt index 48897c8d3..f5a0d5306 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/query/Reply.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/query/Reply.kt @@ -16,7 +16,7 @@ package io.zenoh.query import io.zenoh.ZenohType import io.zenoh.sample.Sample -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId import io.zenoh.queryable.Query /** @@ -44,4 +44,4 @@ import io.zenoh.queryable.Query * @property replierId: unique ID identifying the replier, may be null in case the network cannot provide it * (@see https://github.com/eclipse-zenoh/zenoh/issues/709#issuecomment-2202763630). */ -data class Reply(val replierId: ZenohID?, val result: Result) : ZenohType +data class Reply(val replierId: ZenohId?, val result: Result) : ZenohType diff --git a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/scouting/Hello.kt b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/scouting/Hello.kt index c3cbe20b8..13e270f6d 100644 --- a/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/scouting/Hello.kt +++ b/zenoh-kotlin/src/commonMain/kotlin/io/zenoh/scouting/Hello.kt @@ -15,14 +15,14 @@ package io.zenoh.scouting import io.zenoh.ZenohType -import io.zenoh.protocol.ZenohID +import io.zenoh.protocol.ZenohId /** * Hello message received while scouting. * * @property whatAmI [WhatAmI] configuration: it indicates the role of the zenoh node sending the HELLO message. - * @property zid [ZenohID] of the node sending the hello message. + * @property zid [ZenohId] of the node sending the hello message. * @property locators The locators of this hello message. * @see Scout */ -data class Hello(val whatAmI: WhatAmI, val zid: ZenohID, val locators: List): ZenohType +data class Hello(val whatAmI: WhatAmI, val zid: ZenohId, val locators: List): ZenohType