mirror of
https://github.com/kata-containers/kata-containers.git
synced 2025-08-16 07:05:14 +00:00
agent: rename SerializeError as Error
Rename SerializeError as Error and export it as the Error codes for the OCI crate. Signed-off-by: Liu Jiang <gerry@linux.alibaba.com>
This commit is contained in:
parent
c34bdd06db
commit
a47a94218f
@ -12,7 +12,7 @@ use libc::mode_t;
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
mod serialize;
|
mod serialize;
|
||||||
pub use serialize::{to_string, to_writer, Result, SerializeError};
|
pub use serialize::{to_string, to_writer, Error, Result};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn is_false(b: bool) -> bool {
|
fn is_false(b: bool) -> bool {
|
||||||
|
@ -6,53 +6,53 @@
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use serde_json;
|
use serde_json;
|
||||||
|
|
||||||
use std::error::Error;
|
use std::error;
|
||||||
use std::fmt::{Display, Formatter, Result as FmtResult};
|
use std::fmt::{Display, Formatter, Result as FmtResult};
|
||||||
use std::fs::File;
|
use std::fs::File;
|
||||||
use std::io;
|
use std::io;
|
||||||
|
|
||||||
pub type Result<T> = std::result::Result<T, SerializeError>;
|
pub type Result<T> = std::result::Result<T, Error>;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum SerializeError {
|
pub enum Error {
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
Json(serde_json::Error),
|
Json(serde_json::Error),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Display for SerializeError {
|
impl Display for Error {
|
||||||
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
fn fmt(&self, f: &mut Formatter) -> FmtResult {
|
||||||
match *self {
|
match *self {
|
||||||
SerializeError::Io(ref e) => e.fmt(f),
|
Error::Io(ref e) => e.fmt(f),
|
||||||
SerializeError::Json(ref e) => e.fmt(f),
|
Error::Json(ref e) => e.fmt(f),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Error for SerializeError {
|
impl error::Error for Error {
|
||||||
fn description(&self) -> &str {
|
fn description(&self) -> &str {
|
||||||
match *self {
|
match *self {
|
||||||
SerializeError::Io(ref e) => e.description(),
|
Error::Io(ref e) => e.description(),
|
||||||
SerializeError::Json(ref e) => e.description(),
|
Error::Json(ref e) => e.description(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn cause(&self) -> Option<&dyn Error> {
|
fn cause(&self) -> Option<&dyn error::Error> {
|
||||||
match *self {
|
match *self {
|
||||||
SerializeError::Io(ref e) => Some(e),
|
Error::Io(ref e) => Some(e),
|
||||||
SerializeError::Json(ref e) => Some(e),
|
Error::Json(ref e) => Some(e),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<io::Error> for SerializeError {
|
impl From<io::Error> for Error {
|
||||||
fn from(e: io::Error) -> SerializeError {
|
fn from(e: io::Error) -> Error {
|
||||||
SerializeError::Io(e)
|
Error::Io(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<serde_json::Error> for SerializeError {
|
impl From<serde_json::Error> for Error {
|
||||||
fn from(e: serde_json::Error) -> SerializeError {
|
fn from(e: serde_json::Error) -> Error {
|
||||||
SerializeError::Json(e)
|
Error::Json(e)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user