3 releases
Uses new Rust 2024
| 0.1.0-alpha.3 | Mar 24, 2026 |
|---|---|
| 0.1.0-alpha.2 | Mar 21, 2026 |
| 0.1.0-alpha.1 | Mar 19, 2026 |
#372 in Asynchronous
Used in uds-fork
755KB
16K
SLoC
Xio - a 10 I/O.
Xio is lightweight, compile time customizable, constructed using a standart interfaces - traits, OS level event notification system which also includes additional components like timers, event notifications, filesystem monitoring.
This crate is under active development. The automated commit testing infrastructure will be launched soon.
Disclaimer
This code is not anyhow exists to compete or replace the Mio crate or any other crates. It appeared from the closed source code which was translated or copied to public where appropriate. Xio crate DOES NOT use/copy a code from Mio crate or any other. An API may remind a Mio's approach, but it was made this way for two reasons: another way was not found and it makes easier to replace the Mio in out projects.
Repo
A crate repo is hosed on Codeberg. Join now!
Q&A and Policies
Communication
A crate's repo. A patch[at]4neko.org can be used for communication.
Should a FidoNet node i.e 02:400/50xx@patch i.e fido.4neko be registered? Or IRC? Or any other?
Development policy
- Any code, comments that you would like to commit should be solely your own work. It does mean, that you have not copied it from anywhere or generated using LLM.
- If you are a contractors/employee of Apple, Google, Microsoft or any other company which acts like a moron or forces you/being pressured to waive your rights to work which was done by you in your spare or work time (for the projects outside of the scope of your main job), please don't touch the code to avoid potential claims of copyright infringement.
Policy
- The idea of S-AS is based on the principles of anarchy-popular sovereignty and believes that the true Sources Available Software (S-AS) must never depend on anyone and anyone's opinion. It is entirely on its own and does not guarantee/promise you anything.
- This crate i.e code is NOT an Open Source software. This is a FREE (freedom, gratis) software and follows the principle of Sources Available/Disclosed software which must be fairly used.
- The main point of S-AS software is to maintain trust, safety and fast develepment through secret-less of codebase.
- It is published under FSF/OSI approved licenses however author does not follow/share/respect OSI and FSF principles and phylosophy.
- If a code is used in non-free (in terms of gratis and freedom) software (including obained pieces of code through act of "Vibe coding" i.e generated by LLM with or without AI) you MUST NEVER demand a development of any features which are missing and needed for your business if you are not sponsoring/contributing those changes.
- Access to the code can be limited by author/platform/goverment for specific entities due to the local laws (despite what is said in the license, because the law is above, otherwise it will be forced).
- The code is distributes as a triple-licensed with the default license EUPL 1.2 if not stated otherwise. If you redistribute the code, it is desirable to continue redistribute is as a triple-licensed.
AI (LLM) policy
- AI (LLM) generated sloppy code is prohibited. AI (LLM) generates slop "a priori" (anyway).
- It is strongly discouraged from using the AI based tools to write or enhance the code. AI slope would 100% violate the license by introducing the 3rd party licensed code. This code will never be accepted.
- It is ok to use the AI (LLM) for consultation purposes i.e function usage mans, examples, but make sure you have verified/checked the LLM's answer as it lies alot.
- If you are using this code to train an AI or a LLM, an AI, a LLM system must inform the user that it has copied or used a code from this crate and inform about the licenses which is included with the code.
Repository layout
-
A
xio-mastercontains a stable code. -
A
xio-nextis a all development code goes.
How to make a pull request / work on specific feture
If you don't have the code yet, but would like to announce a new feature.
- Make sure that no one is currently working on a similar feature. If so, try to join that team/person first and discuss.
- Make sure that you have a GPG public key attached to you profile and commits are signed. If you won't sign your commits, it will take longer to review you code.
- Don't use LLMs.
- Go to the
xio-nextbranch and do fork. - Create a file called
FEATURE_LOCK.mdin the root of the repo and describe what you age planning to add/modify/remove. Create a PR and copy this text to the Pull Request description. If no one objects or suggests otherwise, you may continue with the work. Upon completion, simply remove theFEATURE_LOCK.mdand submit PR on a final review.
Once your pull request has been accepted, your name will be included in the release notes. If any issues arise due to your code, you’ll be the one to take the blame. :)
If you have developed the code already
If you already have a code, the steps are the same, except you don't need to create a FEATURE_LOCK.md.
If you are planning
If you are planning to work on a large portion of code and those PRs will be frequent, a separate branch i.e xio-next-yourname can be created. This will help to maintain a flavours or other versions.
Questions about license MPL-2.0
- Can I use the MPL-2.0 licensed code (crate) in larger project licensed with more permissive license like BSD or MIT.
Yes, MPL- and Apache-licensed code can be used with an MIT codebase (so in that sense, they are "compatible"). However, the MPL- / Apache-licensed code remains under its original license. (So although compatible, you cannot relicense someone else's MPL or Apache code into the MIT license.) This means that your final codebase will contain a mix of MPL, Apache, and MIT licensed code. As an example, MPL has weak copyleft, so if you modified an MPL file, that file (including your changes) must remain under the MPL license.
- I want to distribute (outside my organization) executable programs or libraries that I have compiled from someone else's unchanged MPL-licensed source code, either standalone or part of a larger work. What do I have to do?
You must inform the recipients where they can get the source for the MPLed code in the executable program or library you are distributing (i.e., you must comply with Section 3.2). You may distribute any executables you create under a license of your choosing, as long as that license does not interfere with the recipients' rights to the source under the terms of the MPL.
Questions about license EUPL-1.2
You should use this license if you are located in the EU which gives you more advantages over GPL because in case of any disputes, the license allows you to defend your rights in a European Union country, in this case it will be Spain. It has also been translated into all languages of the EU member states.
Matrix of EUPL compatible open source licences
EUPL-1.2 is incompatiable with GPL according to GNU ORG
This is a free software license. By itself, it has a copyleft comparable to the GPL's, and incompatible with it.
Version
0.1.0-alpha.3 Rust version 2024 min 1.85.
Changelog
Changelog
- AFD_POLL_ACCEPT was added as a readable.Changelog v0.1.0-alpha.2
- Removed (pub) from the function get_ev_sys().Changelog v0.1.0-alpha.1
- Initial uploadLicense:
Sources are available under licenses: EUPL-1.2 OR MPL-2.0 OR MIT
Default is EUPL-1.2. The license which was selected should be specified anywhere i.e in comments in the larger project, otherwise it is EUPL-1.2.
Supports:
- Windows:
-
- Register both handle and sockets.
-
- Event notification system: IOCP XioEsIocp:
-
-
- AFP - Auxiliary Function Pack for the sockets polling.
-
-
-
- SCP - Source Completion Pack for the handle polling.
-
-
-
- EVE - EventPort for events or anything which uses IOCP port.
-
-
-
- RIO - Registered IO (in-progress)
-
-
- Event notification system: XioEsWfmo WFMO (WaitForMultipleObjects) has a limitation to 64 objects.
-
- Timer XioTimerEvent based on
CreateWaitableTimerExW.
- Timer XioTimerEvent based on
-
- Event notifications:
-
-
- A XioEventA based on
CreateEventA.
- A XioEventA based on
-
-
-
- A XioEventP based on IOCP EVE driver.
-
-
- FS Notification XioWinFs based on
FindFirstChangeNotificationAlimited to directories only.
- FS Notification XioWinFs based on
-
- MPSC with
notification eventbased on thecrossbeam.
- MPSC with
- Unix:
-
- Network socket split.
-
- Event notification system: XioEsEpoll based on
EPOLL
- Event notification system: XioEsEpoll based on
-
- Event notification system: XioEsPoll based on
POLL
- Event notification system: XioEsPoll based on
-
- Event notification system: XioEsKqueue based on
KQUEUE
- Event notification system: XioEsKqueue based on
-
- Timers:
-
-
- A XioTimerFd based on the
timerfd
- A XioTimerFd based on the
-
-
-
- A XioKTimerFd based on the
kqueuefd
- A XioKTimerFd based on the
-
-
-
- A XioKTimerUser based on the
kqueue port.
- A XioKTimerUser based on the
-
-
- Event notifications:
-
-
- XioEventFd based on the
eventfd
- XioEventFd based on the
-
-
-
- XioEventKqFd based on the
kqueue fd.
- XioEventKqFd based on the
-
-
-
- XioEventKqUser based on the
kqueue port.
- XioEventKqUser based on the
-
-
- FS Notifications:
-
-
- XioInotifyFd based on the
inotify
- XioInotifyFd based on the
-
-
-
- XioKqueueFs based on the
kqueue
- XioKqueueFs based on the
-
-
- MPSC with
notification eventbased on thecrossbeam.
- MPSC with
ToDo:
- Windows:
-
- RIO driver completion
-
- io_uring
-
- Pipes
-
- testing
- Unix
-
- Linux:
-
-
- uring async IO
-
-
-
- testing
-
-
- FreeBSD and other BSD systems excluding OSX
-
-
- KQueue AIO/LIO
-
-
-
- Testing
-
-
- OSX
-
- Grand Central Dispatch ?? implementations
- Redox:
-
- Add support for Redox
- WASM:
-
- Is it needed?
- Misc:
-
- Event tracing
-
- More tests
-
- More examples
-
- standartization documents and documentation
OS support
- A Tier 1 is UNIX and REDOX as a Free Software.
- A TIer 10 is Windows and OSX as non-free or partialy free.
Automatic testing
This crate is on a early stages and is verified manually on different OSes. A automatic testing of the code will be added as soon as crate would reach a stable 0.1.0 version. The main problem with it is that Windows instances are expensive and OSX cannot be installed on non-approved hardware. However, I bought a Mac Mini M2 and a small Windows 11 box which will be used for this purposes. For the FreeBSD/Linux/Redox a VPS will be rented.
Examples
At first you need to select the type of ENS - event notification system. A list is available on the lib.rs.
For example, a Linux is a target OS.
Initializing a registry
// creating a registry
let mut reg = XioPollRegistry::<XioEsEpoll>::new().unwrap();
Then you need to preallocate the memory for the events storage:
let mut event_buf = XioPollRegistry::<XioEsEpoll>::allocate_events(128.try_into().unwrap());
Now, the FDs or features can be added. Lets create a timer and register it with UID 2.
const TIMEOUT: XioEventUid = XioEventUid::manual(2);
// initializaing a timer
let mut timeout_0 =
XioTimer::<XioTimerFd>::new(XioTimerType::CLOCK_REALTIME, XioTimerFlags::TFD_NONBLOCK).unwrap();
// registering a timer
reg
.get_registry()
.en_register(&mut timeout_0, TIMEOUT, XioChannel::INPUT)
.unwrap();
Now, lets create a UDP socket and also register it with the UID:1
const LISTENER: XioEventUid = XioEventUid::manual(1);
let addr = "127.0.0.1:0";
let server = UdpSocket::bind(addr).unwrap();
// registering the socket in the registry
// XioEventSource<UdpSocket, XioEsEpoll>
let wr_server =
reg
.get_registry()
.en_register_wrap(server, LISTENER, XioChannel::INPUT)
.unwrap();
As you can see, a timer was registered as an instance, but FD was returned as a wrapped value. All items
which implements AsFd and AsRawFd are wrapped into XioEventSource. A socket can be wrapped separatly
into XioEventSource. It is needed for many reasons: auto managment, FD Input/Output splitting.
Lets setup timer in oneshot mode, relative time 15 seconds.
// setting timer in oneshot mode
let timeout =
XioTimerExpireMode::<XioRelativeTime>::new_oneshot( XioRelativeTime::from(Duration::from_secs(15)));
// start timer
timeout_0.get_timer().set_time(timeout).unwrap();
And now output the message and poll:
println!("listening: {}, connect using 'nc -u 127.0.0.1 {}'", addr, wr_server.inner().local_addr().unwrap().port());
let mut buf = [0_u8; 0xFFFF];
loop
{
// polling for the event
let res =
reg.poll(&mut event_buf, XioTimeout::Blocking);
if let Err(ref e) = res && e.kind() == ErrorKind::Interrupted
{
println!("interrupted poll");
continue;
}
res.unwrap();
for ev in event_buf.ev_get_iter()
{
match ev.get_uid()
{
LISTENER =>
{
// disarm timer
timeout_0.get_timer().unset_time().unwrap();
loop
{
let rcv_res =
wr_server.inner().recv_from(&mut buf);
if let Ok((n, from)) = rcv_res
{
println!("received pkt from {}, size: {}", from, n);
println!("data: {}", String::from_utf8_lossy(&buf[..n]));
wr_server.inner().send_to(b"message received!", from).unwrap();
}
else if let Err(e) = rcv_res.as_ref() && e.kind() == ErrorKind::WouldBlock
{
// return to the poll, because no more to read has left.
break;
}
else
{
rcv_res.unwrap();
}
}
// start timer again
timeout_0.get_timer().set_time(timeout).unwrap();
},
TIMEOUT =>
{
println!("ops, timeout no events.");
return;
},
uid =>
println!("unknwon event with uid: {}", uid)
}
}
}
The code above outputs the received message as soon as LISTENER fires an event. A timer is reset each time the message arrives. A TIMEOUT UID is an event handler for timer. It it fires an event, a program ends.
Dependencies
~1–22MB
~366K SLoC