disconnect

suspend fun disconnect()(source)

Gracefully disconnect from the device.

Stops the engine, closes the transport, and releases storage. Never throws; idempotent. In-flight MessageHandles that have not reached terminal state will be failed with SendFailure.Disconnected.

Suspend semantics: suspends until the engine has drained pending failures, the transport is fully disconnected, and storage is closed. Returns when connection settles on ConnectionState.Disconnected.

Cancellation: the disconnect path runs under kotlinx.coroutines.NonCancellable internally for resource release — cancelling the caller's coroutine will not leave the transport or storage half-open. Cancellation may still be observed before any teardown work begins.