a4bb565

Branches > refactor/use-spec-1 > a4bb565 > files / LICENSE

MORE SPECS

Grahp, 2026-06-02

Commit: a4bb5650e45449c13fef89155fd94baabc727714
Parent: 82d578c

3 changed files:

src/net/bowmap/network/message/client.clj modified (view file)

@@ -266,3 +266,7 @@                              (varint-> (get! message->packet-ids {::msg/id (::msg/id msg) ::state/connection-state state}))                              (encode-body msg))))       (adorn "Error while encoding message into packet" {:msg msg :state state})))++(s/fdef message->packet+        :args (s/cat :msg ::msg/message :state ::state/connection-state)+        :ret ::pk/packet)

src/net/bowmap/network/message/server.clj modified (view file)

@@ -171,12 +171,16 @@     2. No schema exists for that packet id     3. 'buf' is not properly framed     4. The contents of 'buf' are not a valid packet"-  [packet-buf state]-  (-> (let [numeric-id (->varint packet-buf)+  [packet state]+  (-> (let [numeric-id (->varint packet)             packet-id (packet-ids {::state/connection-state state ::pk/id numeric-id})             reader (packets packet-id)]         (if reader-          (adorn (reader packet-buf)+          (adorn (reader packet)                  "Error while calling packet reader" {:numeric-id numeric-id :packet-id packet-id :reader reader})           (raise "Failed to read message, no such message with that id." {:id numeric-id :state state :packet-id packet-id})))-      (adorn "Error while turning serverbound packet into message" {:buf packet-buf :state state})))+      (adorn "Error while turning serverbound packet into message" {:buf packet :state state})))++(s/fdef packet->message+        :args (s/cat :packet ::pk/packet :state ::state/connection-state)+        :ret ::msg/message)

src/net/bowmap/network/packet.clj modified (view file)

@@ -1,5 +1,6 @@ (ns net.bowmap.network.packet   (:require+   [clojure.alpha.spec :as s]    [dev.grahp.spec :as S]))  ; The serialized form of a message, called a packet by everyone else :p@@ -9,3 +10,5 @@   "Protocol id of a packet, i.e. 0x00, 0x80, etc.    Numeric ids are NOT unique across connection states! See the wiki"   pos-int?)++(S/def ::packet (s/schema [::id]))