Resources are opened schemes. You can think of them like an established connection between the scheme provider and the client.
Resources are closely connected to schemes and are sometimes intertwined with schemes. The difference between schemes and resources is subtle but important.
A resource can be defined as a data type with the following methods defined on it:
read- read N bytes to a buffer provided as argument. Defaults to
write- write a buffer to the resource. Defaults to
seek- seek the resource. That is, move the "cursor" without writing. Many resources do not support this operation. Defaults to
close- close the resource, potentially releasing a lock. Defaults to
TODO add F-operations.
There are two types of resources:
- File-like resources. These behave a lot like files. They act in a blocking manner; reads and writes are "buffer-like".
- Socket-like resources. These behave like sockets. They act in a non-blocking manner; reads and writes are more "stream-like".
TODO Expand on this.