diff --git a/shard.yml b/shard.yml index 9a0c29e..193da67 100644 --- a/shard.yml +++ b/shard.yml @@ -1,5 +1,5 @@ name: bacnet -version: 0.9.0 +version: 0.9.1 dependencies: bindata: diff --git a/src/bacnet/ip4_message.cr b/src/bacnet/ip4_message.cr index 6c8ff96..8b0965e 100644 --- a/src/bacnet/ip4_message.cr +++ b/src/bacnet/ip4_message.cr @@ -73,17 +73,17 @@ module BACnet end end - def to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : IO + def to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : Int64 format = IO::ByteFormat::BigEndian - io.write_bytes(@data_link, format) + wrote = io.write_bytes(@data_link, format) if net = @network - io.write_bytes(net, format) + wrote += io.write_bytes(net, format) if app = @application - io.write_bytes(app, format) - objects.each { |object| io.write_bytes(object, format) } + wrote += io.write_bytes(app, format) + objects.each { |object| wrote += io.write_bytes(object, format) } end end - io + wrote end def to_slice diff --git a/src/bacnet/secure_message.cr b/src/bacnet/secure_message.cr index ed97be8..822f5ea 100644 --- a/src/bacnet/secure_message.cr +++ b/src/bacnet/secure_message.cr @@ -57,17 +57,17 @@ module BACnet end end - def to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : IO + def to_io(io : IO, format : IO::ByteFormat = IO::ByteFormat::BigEndian) : Int64 format = IO::ByteFormat::BigEndian - io.write_bytes(@data_link, format) + wrote = io.write_bytes(@data_link, format) if network = @network - io.write_bytes(network, format) + wrote += io.write_bytes(network, format) if app = @application - io.write_bytes(app, format) - objects.each { |object| io.write_bytes(object, format) } + wrote += io.write_bytes(app, format) + objects.each { |object| wrote += io.write_bytes(object, format) } end end - io + wrote end def to_slice