Sha256: 1ee18732a49218c1cec62a26c4d3ab24643e98b54b65bc28d1fd2fad16272b05

Contents?: true

Size: 1.76 KB

Versions: 37

Compression:

Stored size: 1.76 KB

Contents

# encoding: ascii-8bit

# Copyright 2014 Ball Aerospace & Technologies Corp.
# All Rights Reserved.
#
# This program is free software; you can modify and/or redistribute it
# under the terms of the GNU General Public License
# as published by the Free Software Foundation; version 3 with
# attribution addendums as found in the LICENSE.txt

module Cosmos
  # Class that implments the following methods: read, write(data),
  # connect, connected? and disconnect. Streams are simply data sources which
  # {Protocol} classes read and write to. This separation of concerns
  # allows Streams to simply focus on getting and sending raw data while the
  # higher level processing occurs in {Protocol}.
  class Stream
    # Expected to return any amount of data on success, or a blank string on
    # closed/EOF, and may raise Timeout::Error, or other errors
    def read
      raise "read not defined by Stream"
    end

    # Expected to always return immediately with data if available or an empty string.
    # Should not raise errors
    def read_nonblock
      raise "read_nonblock not defined by Stream"
    end

    # Expected to write complete set of data.  May raise Timeout::Error
    # or other errors.
    #
    # @param data [String] Binary data to write to the stream
    def write(data)
      raise "write not defined by Stream"
    end

    # Connects the stream
    def connect
      raise "connect not defined by Stream"
    end

    # @return [Boolean] true if connected or false otherwise
    def connected?
      raise "connected? not defined by Stream"
    end

    # Disconnects the stream
    # Note that streams are not designed to be reconnected and must be recreated
    def disconnect
      raise "disconnect not defined by Stream"
    end
  end # class Stream
end # module Cosmos

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
cosmos-4.5.2-java lib/cosmos/streams/stream.rb
cosmos-4.5.2 lib/cosmos/streams/stream.rb
cosmos-4.5.1-java lib/cosmos/streams/stream.rb
cosmos-4.5.1 lib/cosmos/streams/stream.rb
cosmos-4.5.0-java lib/cosmos/streams/stream.rb
cosmos-4.5.0 lib/cosmos/streams/stream.rb
cosmos-4.4.2-java lib/cosmos/streams/stream.rb
cosmos-4.4.2 lib/cosmos/streams/stream.rb
cosmos-4.4.1-java lib/cosmos/streams/stream.rb
cosmos-4.4.1 lib/cosmos/streams/stream.rb
cosmos-4.4.0-java lib/cosmos/streams/stream.rb
cosmos-4.4.0 lib/cosmos/streams/stream.rb
cosmos-4.3.0-java lib/cosmos/streams/stream.rb
cosmos-4.3.0 lib/cosmos/streams/stream.rb
cosmos-4.2.4-java lib/cosmos/streams/stream.rb
cosmos-4.2.4 lib/cosmos/streams/stream.rb
cosmos-4.2.3-java lib/cosmos/streams/stream.rb
cosmos-4.2.3 lib/cosmos/streams/stream.rb
cosmos-4.2.2-java lib/cosmos/streams/stream.rb
cosmos-4.2.2 lib/cosmos/streams/stream.rb