protocol-zmtp 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6eac99ed3115e12e24bfc7545fd235cbeddecf9acbf6e80363247f6d85c1ed37
4
- data.tar.gz: 58f81f079d7b5785baf7fa8b15f00224ac93c9505ed2f0b00d9f6bcc12147f55
3
+ metadata.gz: 041cc13ea6667319835f40ea09fae02b68cc34f988d986548691e29d48fee7ba
4
+ data.tar.gz: 2d396b42d33c473c0f45a0752da9ab8c292d5541464ea1cb2c667a3508297fc6
5
5
  SHA512:
6
- metadata.gz: ff813236409d769b319b712c120995ed1bbf5e0c51dcb772a9a3e86f3130a379a1aac64843425e67a76277f91e4c74b44450b4fbe60e5a8f1173bdefa051d50c
7
- data.tar.gz: 208791933fd0006915a7155ba0a18c32ec81f84854df0d77f39314e598fcc4fad3b1eb69cc341365685a3eae55928c662d767bce4331d5958c2e8d8039e84fc5
6
+ metadata.gz: 2d71dd3c5f2ad463b72c6160d8a70691a60baefe469503d59f9a2d8a80294554afaa4fdcc0a9a3ea1db19f5dcca9fda3df599ca14b6b8f9866ab90c07069294d
7
+ data.tar.gz: 9b5b1a1d7966fc893e08c840a2ec929eacc32f874fe5f42e8b2064fbde6be1d2b01eebfde4a4ec78ea086884ddb5363dcd5c21e0c719186a65bee475bf19d3b0
@@ -52,6 +52,21 @@ module Protocol
52
52
  end
53
53
  end
54
54
 
55
+ # Encodes a multi-part message into a single wire-format string.
56
+ # The result can be written to multiple connections without
57
+ # re-encoding each time (useful for fan-out patterns like PUB).
58
+ #
59
+ # @param parts [Array<String>] message frames
60
+ # @return [String] frozen binary wire representation
61
+ #
62
+ def self.encode_message(parts)
63
+ buf = +""
64
+ parts.each_with_index do |part, i|
65
+ buf << new(part, more: i < parts.size - 1).to_wire
66
+ end
67
+ buf.freeze
68
+ end
69
+
55
70
  # Reads one frame from an IO-like object.
56
71
  #
57
72
  # @param io [#read_exactly] must support read_exactly(n)
@@ -91,6 +91,26 @@ module Protocol
91
91
  end
92
92
  end
93
93
 
94
+ # Writes pre-encoded wire bytes to the buffer without flushing.
95
+ # Used for fan-out: encode once, write to many connections.
96
+ #
97
+ # @param wire_bytes [String] ZMTP wire-format bytes
98
+ # @return [void]
99
+ def write_wire(wire_bytes)
100
+ @mutex.synchronize do
101
+ @io.write(wire_bytes)
102
+ end
103
+ end
104
+
105
+ # Returns true if the ZMTP mechanism encrypts at the frame level
106
+ # (e.g. CURVE). TLS encryption is below ZMTP and does not affect
107
+ # wire-format bytes.
108
+ #
109
+ # @return [Boolean]
110
+ def curve?
111
+ @mechanism.encrypted?
112
+ end
113
+
94
114
  # Flushes the write buffer to the underlying IO.
95
115
  def flush
96
116
  @mutex.synchronize do
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Protocol
4
4
  module ZMTP
5
- VERSION = "0.1.0"
5
+ VERSION = "0.1.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: protocol-zmtp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Patrik Wenger