Use Errno as RPC error type
This commit is contained in:
parent
75b12fdac4
commit
aedc6f5cb4
41
Cargo.lock
generated
41
Cargo.lock
generated
@ -31,9 +31,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "autocfg"
|
name = "autocfg"
|
||||||
version = "1.3.0"
|
version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0"
|
checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bga"
|
name = "bga"
|
||||||
@ -191,9 +191,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.158"
|
version = "0.2.159"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d8adc4bb1803a324070e64a98ae98f38934d91957a99cfb3a43dcbc01bc56439"
|
checksum = "561d97a539a36e26a9a5fad1ea11a3039a67714694aaa379433e580854bc3dc5"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "lock_api"
|
name = "lock_api"
|
||||||
@ -207,9 +207,12 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.19.0"
|
version = "1.20.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92"
|
checksum = "82881c4be219ab5faaf2ad5e5e5ecdff8c66bd7402ca3160975c93b24961afd1"
|
||||||
|
dependencies = [
|
||||||
|
"portable-atomic",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "parking_lot"
|
name = "parking_lot"
|
||||||
@ -242,6 +245,12 @@ dependencies = [
|
|||||||
"postcard",
|
"postcard",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "1.9.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cc9c68a3f6da06753e9335d63e27f6b9754dd1920d941135b7ea8224f141adb2"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "postcard"
|
name = "postcard"
|
||||||
version = "1.0.10"
|
version = "1.0.10"
|
||||||
@ -287,9 +296,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "redox_syscall"
|
name = "redox_syscall"
|
||||||
version = "0.5.3"
|
version = "0.5.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4"
|
checksum = "9b6dfecf2c74bce2466cabf93f6664d6998a69eb21e39f4207930065b27b771f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bitflags",
|
"bitflags",
|
||||||
]
|
]
|
||||||
@ -330,8 +339,6 @@ checksum = "61697e0a1c7e512e84a621326239844a24d8207b4669b41bc18b32ea5cbf988b"
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.210"
|
version = "1.0.210"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "c8e3592472072e6e22e0a54d5904d9febf8508f65fb8552499a1abc7d1078c3a"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
@ -339,12 +346,10 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.210"
|
version = "1.0.210"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "243902eda00fad750862fc144cea25caca5e20d615af0a81bee94ca738f1df1f"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -381,9 +386,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "syn"
|
name = "syn"
|
||||||
version = "2.0.77"
|
version = "2.0.79"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9f35bcdf61fd8e7be6caf75f429fdca8beb3ed76584befb503b1569faee373ed"
|
checksum = "89132cd0bf050864e1d38dc3bbc07a0eb8e7530af26344d3d2bbbef83499f590"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@ -414,9 +419,9 @@ checksum = "2c591d83f69777866b9126b24c6dd9a18351f177e49d625920d19f989fd31cf8"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "unicode-ident"
|
name = "unicode-ident"
|
||||||
version = "1.0.12"
|
version = "1.0.13"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b"
|
checksum = "e91b56cd4cadaeb79bbf1a5645f6b4f8dc5bde8834ad5894a8db35fda9efa1fe"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "version_check"
|
name = "version_check"
|
||||||
@ -529,5 +534,5 @@ checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
"syn 2.0.77",
|
"syn 2.0.79",
|
||||||
]
|
]
|
||||||
|
@ -15,3 +15,7 @@ rhexdump = "0.2.0"
|
|||||||
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
syslog_rpc = { version = "0.1.0", path = "../syslog/syslog_rpc" }
|
||||||
volatile = { version = "0.6.1", features = ["unstable"] }
|
volatile = { version = "0.6.1", features = ["unstable"] }
|
||||||
x86_64 = "0.15.1"
|
x86_64 = "0.15.1"
|
||||||
|
|
||||||
|
[patch.crates-io]
|
||||||
|
serde = { path = "../serde/serde" }
|
||||||
|
serde_derive = { path = "../serde/serde_derive" }
|
||||||
|
24
src/main.rs
24
src/main.rs
@ -24,7 +24,7 @@ use std::{
|
|||||||
borrow::Cow,
|
borrow::Cow,
|
||||||
collections::{HashMap, VecDeque},
|
collections::{HashMap, VecDeque},
|
||||||
fmt::{self, Write},
|
fmt::{self, Write},
|
||||||
os::mikros::{address_space::ACTIVE_SPACE, ipc, syscalls},
|
os::mikros::{address_space::ACTIVE_SPACE, ipc, syscalls, Errno},
|
||||||
};
|
};
|
||||||
|
|
||||||
use fontdue::{
|
use fontdue::{
|
||||||
@ -336,7 +336,7 @@ impl fmt::Write for FramebufferWriter {
|
|||||||
struct DevServ;
|
struct DevServ;
|
||||||
|
|
||||||
impl dev_driver_rpc::Server for DevServ {
|
impl dev_driver_rpc::Server for DevServ {
|
||||||
fn open(&self, _path: &std::path::Path) -> Result<u64, ()> {
|
fn open(&self, _path: &std::path::Path) -> Result<u64, Errno> {
|
||||||
Ok(0)
|
Ok(0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -351,13 +351,13 @@ impl file_rpc::Server for FileServ {
|
|||||||
&self,
|
&self,
|
||||||
_fd: u64,
|
_fd: u64,
|
||||||
_len: usize,
|
_len: usize,
|
||||||
) -> std::result::Result<std::borrow::Cow<'_, [u8]>, ()> {
|
) -> std::result::Result<std::borrow::Cow<'_, [u8]>, Errno> {
|
||||||
Err(())
|
Err(Errno::ENOSYS)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(clippy::significant_drop_tightening)]
|
#[allow(clippy::significant_drop_tightening)]
|
||||||
fn write(&self, _fd: u64, data: &[u8]) -> Result<(), ()> {
|
fn write(&self, _fd: u64, data: &[u8]) -> Result<(), Errno> {
|
||||||
let string = str::from_utf8(data).map_err(|_| ())?;
|
let string = str::from_utf8(data).map_err(|_| Errno::EINVALDAT)?;
|
||||||
let mut fbwriter = self.fbwriter.lock();
|
let mut fbwriter = self.fbwriter.lock();
|
||||||
let mut fbuffer = self.fbuffer.lock();
|
let mut fbuffer = self.fbuffer.lock();
|
||||||
let _ = fbwriter.write_str(string); // never errors
|
let _ = fbwriter.write_str(string); // never errors
|
||||||
@ -365,17 +365,17 @@ impl file_rpc::Server for FileServ {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn close(&self, _fd: u64) {}
|
fn close(&self, _fd: u64) -> Result<(), Errno> { Ok(()) }
|
||||||
|
|
||||||
fn size(&self, _fd: u64) -> Option<u64> {
|
fn size(&self, _fd: u64) -> Result<u64, Errno> {
|
||||||
None
|
Err(Errno::ENOSYS)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn dup(&self, fd: u64) -> Option<u64> {
|
fn dup(&self, fd: u64) -> Result<u64, Errno> {
|
||||||
Some(fd)
|
Ok(fd)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn seek(&self, _fd: u64, _pos: file_rpc::SeekFrom) -> u64 { 0 }
|
fn seek(&self, _fd: u64, _pos: file_rpc::SeekFrom) -> Result<u64, Errno> { Err(Errno::ESPIPE) }
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
|
Loading…
Reference in New Issue
Block a user