mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-22 01:40:07 +01:00
Merge various proto utils together in core-util-jvm.
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright 2024 Signal Messenger, LLC
|
||||
* SPDX-License-Identifier: AGPL-3.0-only
|
||||
*/
|
||||
|
||||
package org.thoughtcrime.securesms.util
|
||||
|
||||
import com.google.protobuf.InvalidProtocolBufferException
|
||||
import com.squareup.wire.ProtoAdapter
|
||||
|
||||
/**
|
||||
* Performs the common pattern of attempting to decode a serialized proto and returning null if it fails to decode.
|
||||
*/
|
||||
fun <E> ProtoAdapter<E>.decodeOrNull(serialized: ByteArray): E? {
|
||||
return try {
|
||||
this.decode(serialized)
|
||||
} catch (e: InvalidProtocolBufferException) {
|
||||
null
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user