Metadata-Version: 2.4
Name: netaio
Version: 0.0.1
Summary: Simple asyncio TCP client and server library inspired by fastapi
Project-URL: Homepage, https://github.com/k98kurz/netaio
Project-URL: Bug Tracker, https://github.com/k98kurz/netaio/issues
Author-email: k98kurz <k98kurz@gmail.com>
Classifier: Development Status :: 2 - Pre-Alpha
Classifier: License :: OSI Approved :: ISC License (ISCL)
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Topic :: Internet
Classifier: Topic :: Software Development :: Libraries :: Application Frameworks
Requires-Python: >=3.10
Description-Content-Type: text/markdown

# netaio

This is designed to be a simple and easy to use asyncio-based TCP client and
server implementation inspired by fastapi but for non-HTTP use cases.

## Status

This is currently a work-in-progress. Remaining work before the v0.1.0 release:

- [ ] Add authorization plugin
- [ ] Add encryption plugin
- [ ] Add optional authorization plugin using tapescript
- [ ] Add optional encryption plugin using simple symmetric stream cipher
- [ ] More thorough test suite
- [ ] Better usage examples/documentation

After that, issues will be tracked [here](https://github.com/k98kurz/netaio/issues).

## Usage

For more documentation, see the
[dox.md](https://github.com/k98kurz/netaio/blob/v0.0.1/dox.md) file generated by
[autodox](https://pypi.org/project/autodox/).

### Server

```python
from netaio import TCPServer, Body, Message, MessageType
import asyncio


server = TCPServer("0.0.0.0", 8888)

@server.on((MessageType.REQUEST_URI, b'something'))
async def something(msg: Message):
    body = Body.prepare(b'This is it.', uri=b'something')
    return Message.prepare(body, MessageType.RESPOND_URI)

asyncio.run(server.start())
```

### Client

```python
from netaio import TCPClient, Body, Message, MessageType
import asyncio


client = TCPClient("127.0.0.1", 8888)
received_resources = {}

@client.on(MessageType.RESPOND_URI)
def echo(msg: Message):
    received_resources[msg.body.uri] = msg.body.content

async def run_client():
    request_body = Body.prepare(b'pls gibs me dat', uri=b'something')
    request_message = Message.prepare(request_body, MessageType.REQUEST_URI)
    await client.connect()
    await client.send(request_message)
    await client.receive_once()

asyncio.run(run_client())

print(received_resources)
```

## License

Copyright (c) 2025 Jonathan Voss (k98kurz)

Permission to use, copy, modify, and/or distribute this software
for any purpose with or without fee is hereby granted, provided
that the above copyleft notice and this permission notice appear in
all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
