refactor: os::io was split

This commit is contained in:
Mark Poliakov 2024-01-05 00:22:42 +02:00
parent 1337bf10db
commit d346ef4b24
13 changed files with 30 additions and 15 deletions

View File

@ -1,6 +1,9 @@
use std::{ use std::{
fs::OpenOptions, fs::OpenOptions,
os::yggdrasil::io::{DeviceRequest, FdDeviceRequest, FileMapping}, os::yggdrasil::io::{
device::{DeviceRequest, FdDeviceRequest},
mapping::FileMapping,
},
}; };
use crate::error::Error; use crate::error::Error;

View File

@ -6,7 +6,7 @@ use std::{
collections::BTreeMap, collections::BTreeMap,
os::{ os::{
fd::{AsRawFd, RawFd}, fd::{AsRawFd, RawFd},
yggdrasil::io::{FileMapping, PollChannel, SharedMemory}, yggdrasil::io::{mapping::FileMapping, poll::PollChannel, shared_memory::SharedMemory},
}, },
process::{Command, ExitCode}, process::{Command, ExitCode},
}; };

View File

@ -4,7 +4,7 @@ use std::{
fmt, fmt,
fs::File, fs::File,
io::{self, BufRead, BufReader}, io::{self, BufRead, BufReader},
os::yggdrasil::io::{MessageChannel, MessageReceiver}, os::yggdrasil::io::message_channel::{MessageChannel, MessageReceiver},
path::Path, path::Path,
process::{Command, ExitCode, Stdio}, process::{Command, ExitCode, Stdio},
str::FromStr, str::FromStr,

View File

@ -2,7 +2,7 @@ use std::{
collections::VecDeque, collections::VecDeque,
os::{ os::{
fd::{AsRawFd, FromRawFd, OwnedFd, RawFd}, fd::{AsRawFd, FromRawFd, OwnedFd, RawFd},
yggdrasil::io::PollChannel, yggdrasil::io::poll::PollChannel,
}, },
time::Duration, time::Duration,
}; };

View File

@ -1,5 +1,5 @@
use std::{ use std::{
os::yggdrasil::io::FileMapping, os::yggdrasil::io::mapping::FileMapping,
sync::{Arc, Mutex}, sync::{Arc, Mutex},
}; };

View File

@ -5,7 +5,7 @@ use std::{
marker::PhantomData, marker::PhantomData,
os::{ os::{
fd::{AsRawFd, RawFd}, fd::{AsRawFd, RawFd},
yggdrasil::io::{ yggdrasil::io::message_channel::{
MessageChannel, MessageChannelReceiver, MessageChannelSender, MessageDestination, MessageChannel, MessageChannelReceiver, MessageChannelSender, MessageDestination,
MessageReceiver, MessageSender, ReceivedMessageMetadata, MessageReceiver, MessageSender, ReceivedMessageMetadata,
}, },

View File

@ -1,7 +1,10 @@
use std::{ use std::{
io::{self, Stdin, Stdout}, io::{self, Stdin, Stdout},
mem::MaybeUninit, mem::MaybeUninit,
os::yggdrasil::io::{update_terminal_options, DeviceRequest, FdDeviceRequest, TerminalOptions}, os::yggdrasil::io::{
device::{DeviceRequest, FdDeviceRequest},
terminal::{update_terminal_options, TerminalOptions},
},
}; };
pub struct RawMode(TerminalOptions); pub struct RawMode(TerminalOptions);

View File

@ -50,7 +50,7 @@ pub mod unix {
pub struct Syslog { pub struct Syslog {
#[cfg(target_os = "yggdrasil")] #[cfg(target_os = "yggdrasil")]
channel: std::os::yggdrasil::io::MessageChannel, channel: std::os::yggdrasil::io::message_channel::MessageChannel,
} }
// TODO replace this // TODO replace this
@ -61,7 +61,7 @@ pub trait ToExitCode {
#[cfg(target_os = "yggdrasil")] #[cfg(target_os = "yggdrasil")]
impl Syslog { impl Syslog {
pub fn open() -> io::Result<Self> { pub fn open() -> io::Result<Self> {
use std::os::yggdrasil::io::MessageChannel; use std::os::yggdrasil::io::message_channel::MessageChannel;
let channel = MessageChannel::open("log", false)?; let channel = MessageChannel::open("log", false)?;
@ -69,7 +69,7 @@ impl Syslog {
} }
pub fn send_str(&mut self, msg: &str) -> io::Result<()> { pub fn send_str(&mut self, msg: &str) -> io::Result<()> {
use std::os::yggdrasil::io::{MessageDestination, MessageSender}; use std::os::yggdrasil::io::message_channel::{MessageDestination, MessageSender};
self.channel self.channel
.send_message(msg.as_bytes(), MessageDestination::Specific(0)) .send_message(msg.as_bytes(), MessageDestination::Specific(0))

View File

@ -1,6 +1,6 @@
#![feature(yggdrasil_os)] #![feature(yggdrasil_os)]
use std::os::yggdrasil::io::{MessageChannel, MessageReceiver}; use std::os::yggdrasil::io::message_channel::{MessageChannel, MessageReceiver};
fn main() { fn main() {
let channel = MessageChannel::open("log", true).unwrap(); let channel = MessageChannel::open("log", true).unwrap();

View File

@ -5,7 +5,10 @@ use std::{
io::{self, stdin, stdout, BufRead, Write}, io::{self, stdin, stdout, BufRead, Write},
os::{ os::{
fd::AsRawFd, fd::AsRawFd,
yggdrasil::io::{start_terminal_session, DeviceRequest, FdDeviceRequest}, yggdrasil::io::{
device::{DeviceRequest, FdDeviceRequest},
terminal::start_terminal_session,
},
}, },
process::{self, Command, ExitCode}, process::{self, Command, ExitCode},
}; };

View File

@ -1,5 +1,8 @@
#![feature(rustc_private, yggdrasil_os)] #![feature(rustc_private, yggdrasil_os)]
use std::{process::ExitCode, os::yggdrasil::io::{MountOptions, mount_raw}}; use std::{
os::yggdrasil::io::device::{mount_raw, MountOptions},
process::ExitCode,
};
use clap::Parser; use clap::Parser;

View File

@ -2,7 +2,7 @@
use std::{ use std::{
io, io,
os::yggdrasil::io::{MessageChannel, MessageDestination, MessageSender}, os::yggdrasil::io::message_channel::{MessageChannel, MessageDestination, MessageSender},
process::ExitCode, process::ExitCode,
}; };

View File

@ -5,7 +5,10 @@ use std::{
io::{Read, Write}, io::{Read, Write},
os::{ os::{
fd::{AsRawFd, FromRawFd, RawFd}, fd::{AsRawFd, FromRawFd, RawFd},
yggdrasil::io::{create_pty, PollChannel, TerminalOptions, TerminalSize}, yggdrasil::io::{
poll::PollChannel,
terminal::{create_pty, TerminalOptions, TerminalSize},
},
}, },
process::{Child, Command, ExitCode, Stdio}, process::{Child, Command, ExitCode, Stdio},
sync::{ sync::{