diff options
author | Edoardo La Greca | 2025-08-01 19:19:15 +0200 |
---|---|---|
committer | Edoardo La Greca | 2025-08-01 19:20:25 +0200 |
commit | eec68974cabb51e1a8136772e0cad38eaa7d3620 (patch) | |
tree | 73e1e2d0e1df015e36aa0e9211c10541ccb074d1 /src/main/kotlin/ProtocolTranslator.kt | |
parent | 756db579d92270ca7cce13f3eda8e4b17ac0039f (diff) |
change class names and do some refactoring
Diffstat (limited to 'src/main/kotlin/ProtocolTranslator.kt')
-rw-r--r-- | src/main/kotlin/ProtocolTranslator.kt | 88 |
1 files changed, 88 insertions, 0 deletions
diff --git a/src/main/kotlin/ProtocolTranslator.kt b/src/main/kotlin/ProtocolTranslator.kt new file mode 100644 index 0000000..bc64002 --- /dev/null +++ b/src/main/kotlin/ProtocolTranslator.kt @@ -0,0 +1,88 @@ +/* +TODO: + - add arguments to methods +*/ + +/** + * The [ProtocolTranslator] interface provides methods that coincide 1:1 with each request type in the 9P protocol. Every + * method that can fail, that is, every request that can receive a response with `Rerror` type instead of the same type + * as itself, returns a non-null `String` that contains the error message received in the response. + * + * Tags are supposed to be managed internally by the class that provides the implementation. + * + * Trivia: comments for each method are taken from each message type's manual page in section 5. + */ +interface ProtocolTranslator { + /** + * Negotiate protocol version. + * + * This must be the first message sent on the 9P connection and no other requests can be issued until a response has + * been received. + * + * @param msize The maximum length, in bytes, that the client will ever generate or expect to receive in a single + * 9P message. + * @param version Should be "9P2000", which is the only defined value. + * @return a possible error. + */ + fun version(msize: UInt, version: String): String? + + /** + * Perform authentication. + */ + fun auth(afid: UInt, uname: String, aname: String) + + /** + * Abort a message. + */ + fun flush() + + /** + * Establish a connection. + */ + fun attach() + + /** + * Descend a directory hierarchy. + */ + fun walk(path: String) + + /** + * Prepare an FID for I/O on an existing file. + */ + fun open(path: String) + + /** + * Prepare an FID for I/O on a new file. + */ + fun create(path: String) + + /** + * Transfer data from file. + */ + fun read(fid: UInt, offset: ULong, count: UInt): String? + + /** + * Transfer data to file. + */ + fun write(fid: UInt, offset: ULong, count: UInt, data: Iterable<UByte>): String? + + /** + * Forget about an FID. + */ + fun clunk(path: String) + + /** + * Remove a file from a server. + */ + fun remove(path: String) + + /** + * Inquire file attributes. + */ + fun stat(path: String) + + /** + * Change file attributes. + */ + fun wstat(path: String) +}
\ No newline at end of file |