mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-02-16 20:13:23 +00:00
Changes include: - Removing all submodules from vendor folder. - Updating sds.nimble with required depndencies. - Generating a nimble.lock file using Nimble. - Updated Nim code to reference depndencies correctly. - Added nix/deps.nix fixed output derivation that calls Nimble. - Updated nixpkgs to use 25.11 commit which provides Nimbe 0.20.1. - Disabled Nix Android builds on MacOS due to Nimble segfault. Signed-off-by: Jakub Sokołowski <jakub@status.im>
33 lines
938 B
Nim
33 lines
938 B
Nim
# adapted from https://github.com/waku-org/nwaku/blob/master/waku/common/protobuf.nim
|
|
|
|
{.push raises: [].}
|
|
|
|
import libp2p/protobuf/minprotobuf
|
|
import libp2p/varint
|
|
|
|
export minprotobuf, varint
|
|
|
|
type
|
|
ProtobufErrorKind* {.pure.} = enum
|
|
DecodeFailure
|
|
MissingRequiredField
|
|
|
|
ProtobufError* = object
|
|
case kind*: ProtobufErrorKind
|
|
of DecodeFailure:
|
|
error*: minprotobuf.ProtoError
|
|
of MissingRequiredField:
|
|
field*: string
|
|
|
|
ProtobufResult*[T] = Result[T, ProtobufError]
|
|
|
|
converter toProtobufError*(err: minprotobuf.ProtoError): ProtobufError =
|
|
case err
|
|
of minprotobuf.ProtoError.RequiredFieldMissing:
|
|
ProtobufError(kind: ProtobufErrorKind.MissingRequiredField, field: "unknown")
|
|
else:
|
|
ProtobufError(kind: ProtobufErrorKind.DecodeFailure, error: err)
|
|
|
|
proc missingRequiredField*(T: type ProtobufError, field: string): T =
|
|
ProtobufError(kind: ProtobufErrorKind.MissingRequiredField, field: field)
|