Obsolete
/
libipc-old
Archived
3
0
Fork 0

Crystal bindings: removing a useless CBOR function.

master
Philippe Pittoli 2023-02-03 05:36:04 +01:00
parent 1c850be4cf
commit 6a912202e4
1 changed files with 1 additions and 13 deletions

View File

@ -1,4 +1,5 @@
require "cbor" require "cbor"
require "./main.cr"
# IPC::CBOR is the root class for all exchanged messages (using CBOR). # IPC::CBOR is the root class for all exchanged messages (using CBOR).
# IPC::CBOR inherited classes have a common 'type' class attribute, # IPC::CBOR inherited classes have a common 'type' class attribute,
@ -42,19 +43,6 @@ class IPC
end end
end end
# CAUTION: Only use this method on an Array(IPC::CBOR.class)
class Array(T)
def parse_ipc_cbor(message : IPC::Message) : IPC::CBOR?
message_type = find &.type.==(message.utype)
if message_type.nil?
raise "invalid message type (#{message.utype})"
end
message_type.from_cbor message.payload
end
end
# CAUTION: only use this method on an Array(IPC::CBOR.class). # CAUTION: only use this method on an Array(IPC::CBOR.class).
class Array(T) class Array(T)
def parse_ipc_cbor(message : IPCMessage::TypedMessage) : IPC::CBOR? def parse_ipc_cbor(message : IPCMessage::TypedMessage) : IPC::CBOR?