Class: DBus::PacketUnmarshaller
- Inherits:
-
Object
- Object
- DBus::PacketUnmarshaller
- Defined in:
- lib/dbus/marshall.rb
Overview
D-Bus packet unmarshaller class
Class that handles the conversion (unmarshalling) of payload data to #Objects (in plain mode) or to Data::Base (in exact mode)
Spelling note: this codebase always uses a double L in the “marshall” word and its inflections.
Instance Method Summary collapse
-
#align_body ⇒ Object
after the headers, the body starts 8-aligned.
- #consumed_size ⇒ Integer
-
#initialize(buffer, endianness) ⇒ PacketUnmarshaller
constructor
Create a new unmarshaller for the given data buffer.
-
#unmarshall(signature, len = nil, mode: :plain) ⇒ Array<::Object,DBus::Data::Base>
Unmarshall the buffer for a given signature and length len.
Constructor Details
#initialize(buffer, endianness) ⇒ PacketUnmarshaller
Create a new unmarshaller for the given data buffer.
36 37 38 39 40 41 |
# File 'lib/dbus/marshall.rb', line 36 def initialize(buffer, endianness) # TODO: this dup can be avoided if we can prove # that an IncompleteBufferException leaves the original *buffer* intact buffer = buffer.dup @raw_msg = RawMessage.new(buffer, endianness) end |
Instance Method Details
#align_body ⇒ Object
after the headers, the body starts 8-aligned
66 67 68 |
# File 'lib/dbus/marshall.rb', line 66 def align_body @raw_msg.align(8) end |
#consumed_size ⇒ Integer
71 72 73 |
# File 'lib/dbus/marshall.rb', line 71 def consumed_size @raw_msg.pos end |
#unmarshall(signature, len = nil, mode: :plain) ⇒ Array<::Object,DBus::Data::Base>
Unmarshall the buffer for a given signature and length len. Return an array of unmarshalled objects.
54 55 56 57 58 59 60 61 62 63 |
# File 'lib/dbus/marshall.rb', line 54 def unmarshall(signature, len = nil, mode: :plain) @raw_msg.want!(len) if len sigtree = Type::Parser.new(signature).parse ret = [] sigtree.each do |elem| ret << do_parse(elem, mode: mode) end ret end |