Class: Rumai::IXP::Fcall

Inherits:
Object show all
Includes:
Struct
Defined in:
lib/rumai/ixp/message.rb,
lib/rumai/ixp/message.rb

Overview

A remote function call (fcall).

Direct Known Subclasses

Rattach, Rauth, Rclunk, Rcreate, Rerror, Rflush, Ropen, Rread, Rremove, Rstat, Rversion, Rwalk, Rwrite, Rwstat, Tattach, Tauth, Tclunk, Tcreate, Terror, Tflush, Topen, Tread, Tremove, Tstat, Tversion, Twalk, Twrite, Twstat

Constant Summary

NOTAG =
BYTE2_MASK
NOFID =

(ushort) (uint32)

BYTE4_MASK
CLASS_TO_TYPE =
{
  Tversion => 100,
  Rversion => 101,
  Tauth    => 102,
  Rauth    => 103,
  Tattach  => 104,
  Rattach  => 105,
  Terror   => 106,
  Rerror   => 107,
  Tflush   => 108,
  Rflush   => 109,
  Twalk    => 110,
  Rwalk    => 111,
  Topen    => 112,
  Ropen    => 113,
  Tcreate  => 114,
  Rcreate  => 115,
  Tread    => 116,
  Rread    => 117,
  Twrite   => 118,
  Rwrite   => 119,
  Tclunk   => 120,
  Rclunk   => 121,
  Tremove  => 122,
  Rremove  => 123,
  Tstat    => 124,
  Rstat    => 125,
  Twstat   => 126,
  Rwstat   => 127,
}.freeze
TYPE_TO_CLASS =
CLASS_TO_TYPE.invert.freeze

Instance Attribute Summary

Attributes included from Struct

fields

Class Method Summary (collapse)

Instance Method Summary (collapse)

Methods included from Struct

included, #initialize, #load_9p

Constructor Details

This class inherits a constructor from Rumai::IXP::Struct

Class Method Details

+ (Object) __from_9p__



409
# File 'lib/rumai/ixp/message.rb', line 409

alias __from_9p__ from_9p

+ (Object) from_9p(stream)

Creates a new instance of this class from the given 9P2000 byte stream and returns the instance.



416
417
418
419
420
421
422
423
424
425
# File 'lib/rumai/ixp/message.rb', line 416

def from_9p stream
  size = stream.read_9p(4)
  type = stream.read_9p(1)

  unless fcall = TYPE_TO_CLASS[type]
    raise Error, "illegal fcall type: #{type}"
  end

  __from_9p__ stream, fcall
end

+ (Object) type

Returns the value of the 'type' field for this fcall.



657
658
659
# File 'lib/rumai/ixp/message.rb', line 657

def self.type
  CLASS_TO_TYPE[self]
end

Instance Method Details

- (Object) to_9p

Transforms this object into a string of 9P2000 bytes.



402
403
404
405
406
# File 'lib/rumai/ixp/message.rb', line 402

def to_9p
  data = type.to_9p(1) << super
  size = (data.bytesize + 4).to_9p(4)
  size << data
end

- (Object) type

Returns the value of the 'type' field for this fcall.



664
665
666
# File 'lib/rumai/ixp/message.rb', line 664

def type
  self.class.type
end