summaryrefslogtreecommitdiff
path: root/README.md
blob: 50a1419309efde05a8e6d7a699ec8a32e1e29b59 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
NineKt: Teaching Kotlin to speak 9P
===================================

NineKt (I don't really care about pronunciation, "nine-kay-tee" or "nine-Kate" or whatever you want) is a library
written in Kotlin (and primarily targeting the JVM) that eases the process of implementing the [9P protocol](https://en.wikipedia.org/wiki/9P_(protocol))
into any JVM application, including those for Android.

Rationale
---------

There are a bunch of reasons why NineKt was born:

1. [All other JVM implementations](http://9p.cat-v.org/implementations) look dead.
2. There is no Kotlin implementation yet.
3. There seems to be no such thing for Android, but Android apps can create custom file systems in a bunch of ways. See
   the section named "A word on Android" below.
4. I thought it would be fun to make.

Usage
-----

The most important class is `NinePConnection`. This class translates file system operations (reading, writing, etc.)
into 9P network messages and vice versa. It needs basic information about: the connection details (remote host's
address, port, etc.), the file system handlers (functions for reading, writing, etc.), and network handlers (functions
for sending and receiving data in the networking scope). Connection details are provided directly to the class, while
handlers must be provided by implementing the `FileSystemManager` and `NetworkManager` interfaces.

Avoiding using file system and networking primitives directly vastly improves independence from them (and therefore
portability), in addition to letting NineKt's codebase focus solely on the 9P protocol itself and the translation of one
set of operations into the other.

Once everything is properly configured, the 9P connection can be started using the `connect` method.

A word on Android
-----------------

Android 11 introduces ([back](https://source.android.com/docs/core/storage/scoped#fuse-performance-tuning)) the support
for [FUSE](https://en.wikipedia.org/wiki/Filesystem_in_Userspace) ([source](https://source.android.com/docs/core/storage/scoped#using-scoped-storage-with-fuse)),
but this limits compatibility with certain versions of Android, and consequently certain devices.

Android has also been supporting the [Storage Access Framework](https://developer.android.com/guide/topics/providers/document-provider)
since version 4.4. [TODO]


Notes
-----

- Source files live in `src/main/kotlin`.
- All manual page references (e.g. `dial(2)`) refer to [9front's manual](https://man.9front.org/).

License
-------

The [Unlicense](https://unlicense.org/).