From 7d6d40a78580c70037249619d45a5d167092ca5b Mon Sep 17 00:00:00 2001 From: Simon Renblad Date: Mon, 16 Dec 2024 17:49:54 +0800 Subject: [PATCH] replace deprecated NoneError use --- src/satman/src/main.rs | 2 +- src/satman/src/subkernel.rs | 16 +++++----------- 2 files changed, 6 insertions(+), 12 deletions(-) diff --git a/src/satman/src/main.rs b/src/satman/src/main.rs index afff3fda..1d908e54 100644 --- a/src/satman/src/main.rs +++ b/src/satman/src/main.rs @@ -1,6 +1,6 @@ #![no_std] #![no_main] -#![feature(alloc_error_handler, try_trait, never_type, panic_info_message)] +#![feature(alloc_error_handler, never_type, panic_info_message)] #[macro_use] extern crate log; diff --git a/src/satman/src/subkernel.rs b/src/satman/src/subkernel.rs index a49e29a4..a02fe7d0 100644 --- a/src/satman/src/subkernel.rs +++ b/src/satman/src/subkernel.rs @@ -2,7 +2,7 @@ use alloc::{collections::BTreeMap, format, string::{String, ToString}, vec::Vec}; -use core::{option::NoneError, slice, str}; +use core::{slice, str}; use core_io::{Error as IoError, Write}; use cslice::AsCSlice; @@ -65,12 +65,6 @@ pub enum Error { DmaError(DmaError), } -impl From for Error { - fn from(_: NoneError) -> Error { - Error::KernelNotFound - } -} - impl From for Error { fn from(_value: IoError) -> Error { Error::SubkernelIoError @@ -316,7 +310,7 @@ impl<'a> Manager<'_> { complete: false, }, ); - self.kernels.get_mut(&id)? + self.kernels.get_mut(&id).ok_or_else(|| Error::KernelNotFound)? } else { kernel } @@ -329,7 +323,7 @@ impl<'a> Manager<'_> { complete: false, }, ); - self.kernels.get_mut(&id)? + self.kernels.get_mut(&id).ok_or_else(|| Error::KernelNotFound)? } }; kernel.library.extend(&data[0..data_len]); @@ -396,7 +390,7 @@ impl<'a> Manager<'_> { if self.session.id == id && self.session.kernel_state == KernelState::Loaded { return Ok(()); } - if !self.kernels.get(&id)?.complete { + if !self.kernels.get(&id).ok_or_else(|| Error::KernelNotFound)?.complete { return Err(Error::KernelNotFound); } self.session = Session::new(id); @@ -404,7 +398,7 @@ impl<'a> Manager<'_> { self.control .tx - .send(kernel::Message::LoadRequest(self.kernels.get(&id)?.library.clone())); + .send(kernel::Message::LoadRequest(self.kernels.get(&id).ok_or_else(|| Error::KernelNotFound)?.library.clone())); let reply = self.control.rx.recv(); match reply { kernel::Message::LoadCompleted => Ok(()),