![]() |
IOLink Python 1.11.0
|
Public Member Functions | |
| __init__ (self, *args, **kwargs) | |
| get_capabilities (self) | |
| support (self, flags) | |
| get_good (self) | |
| get_eof (self) | |
| get_fail (self) | |
| to_string (self) | |
| peek (self) | |
| flush (self) | |
| tell (self) | |
| seek (self, offset, origin) | |
| write (self, src) | |
| read (self, dst) | |
| __repr__ (self) | |
| to_raw_io (self) | |
Public Member Functions inherited from iolink.iolink.DataAccess | |
| get_storage (self) | |
| get_resource_id (self) | |
Properties | |
| thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") | |
| capabilities = property(get_capabilities, doc=get_capabilities.__doc__) | |
| is_good = property(get_good, doc=get_good.__doc__) | |
| is_eof = property(get_eof, doc=get_eof.__doc__) | |
| is_fail = property(get_fail, doc=get_fail.__doc__) | |
Properties inherited from iolink.iolink.DataAccess | |
| thisown = property(lambda x: x.this.own(), lambda x, v: x.this.own(v), doc="The membership flag") | |
| storage = property(get_storage, doc=get_storage.__doc__) | |
| resource_id = property(get_resource_id, doc=get_resource_id.__doc__) | |
Mother interface for all stream-like data accessors. This interface capabilities are indicated by the StreamAccessCapabilitySet returned by the method StreamAccess::capabilities. Each capability enables the use of a specific set of methods. When one of those methods is called, if its corresponding capability is not supported, a NotImplemented exception will be thrown. See also: StreamAccessCapability for capabilities managed by this object
| iolink.iolink.StreamAccess.__init__ | ( | self, | |
| * | args, | ||
| ** | kwargs | ||
| ) |
Reimplemented from iolink.iolink.DataAccess.
| iolink.iolink.StreamAccess.__repr__ | ( | self | ) |
Reimplemented from iolink.iolink.DataAccess.
| iolink.iolink.StreamAccess.flush | ( | self | ) |
Assure that all data is written to the endpoint.
Available when the StreamAccess has the WRITE capability.
| iolink.iolink.StreamAccess.get_capabilities | ( | self | ) |
:rtype: :py:class:`StreamAccessCapabilitySet`
:return: capabilities for current stream
| iolink.iolink.StreamAccess.get_eof | ( | self | ) |
Checks if the cursor is at the end of the stream for reading
For writing, this status is not relevant.
:rtype: boolean
:return: true if the end of stream is reached. No more byte can be read.
| iolink.iolink.StreamAccess.get_good | ( | self | ) |
Checks if the stream is currently valid for reading (only)
Default implementation returns true if nor 'end of file'
or 'fail' status are raised
:rtype: boolean
:return: true if the stream can be read
| iolink.iolink.StreamAccess.peek | ( | self | ) |
Return the current byte without moving the cursor.
Available when the StreamAccess has the READ capability.
:raises: Error if cursor is at EOF.
| iolink.iolink.StreamAccess.read | ( | self, | |
| dst | |||
| ) |
Read data from the stream.
Stream must have the READ capability to use this method.
Args:
dst (bytearray or int): The buffer where data should be read, or
when using the self-allocating mode, the numbers of bytes to read.
Returns:
When using classic mode, returns the number of bytes read.
When using self-allocating mode, return a bytes instance containing the
read data, its size should match the size given with argument dst.
Raises:
iolink.NotImplemented: if the stream does not have the READ capability.
| iolink.iolink.StreamAccess.seek | ( | self, | |
| offset, | |||
| origin | |||
| ) |
Move the cursor to the desired position.
Available when the StreamAccess has the SEEK capability.
Cursor position must be set as following:
new position = current position + offset
If new computed position is less than 0, previous current position is kept.
:type offset: int
:param offset: Offset used to move the cursor according to the origin.
:type origin: int
:param origin: The origin from which to move the cursor. Can be the start
of the stream, the current position of the cursor, or the end of the stream.
Positive offsets always make the cursor move forward in the stream, whatever the origin.
Negative offsets always make the cursor move backward.
:raises: Error if trying to set cursor before BEGIN position (negative value)
| iolink.iolink.StreamAccess.support | ( | self, | |
| flags | |||
| ) |
Checks if the StreamAccess supports the given capabilities.
| iolink.iolink.StreamAccess.tell | ( | self | ) |
Returns the current position of the cursor.
Available when the StreamAccess has the SEEK capability.
| iolink.iolink.StreamAccess.to_raw_io | ( | self | ) |
Method which returns a version of current stream compatible with I/O streams.
| iolink.iolink.StreamAccess.to_string | ( | self | ) |
Return a string representation
| iolink.iolink.StreamAccess.write | ( | self, | |
| src | |||
| ) |
Write content of src buffer into StreamAccess.
Stream cursor is incremented by written byte count.
Available when the StreamAccess has the WRITE capability.
:type src: uint8_t
:param src: Source buffer. This buffer should have a size of "size"
:rtype: int
:return: Count of actually written bytes. It may not be considered as an error
that return value is different from size (ie. an exception may not be thrown).
It is up to the user to decide how to handle this case.