i5-add-tests #6

Merged
kemitix merged 14 commits from i5-add-tests into main 2023-07-25 16:59:24 +01:00
2 changed files with 47 additions and 46 deletions
Showing only changes of commit ec20864dac - Show all commits

44
src/errors.rs Normal file
View file

@ -0,0 +1,44 @@
use std::{fmt::Display, string::FromUtf8Error};
#[derive(Debug)]
pub struct Error {
details: String,
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.details.to_string().as_str())
}
}
impl From<FromUtf8Error> for Error {
fn from(value: FromUtf8Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<String> for Error {
fn from(details: String) -> Self {
Self { details }
}
}
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<atom_syndication::Error> for Error {
fn from(value: atom_syndication::Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<reqwest::Error> for Error {
fn from(value: reqwest::Error) -> Self {
Self {
details: value.to_string(),
}
}
}

View file

@ -1,54 +1,11 @@
// https://www.phind.com/agent?cache=clke9xk39001cmj085upzho1t // https://www.phind.com/agent?cache=clke9xk39001cmj085upzho1t
use std::{fmt::Display, fs::File, string::FromUtf8Error}; use std::fs::File;
use atom_syndication::{Entry, Feed, Link}; use atom_syndication::{Entry, Feed, Link};
// mod errors;
// ERRORS use errors::Error;
//
#[derive(Debug)]
pub struct Error {
details: String,
}
impl Display for Error {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
f.write_str(self.details.to_string().as_str())
}
}
impl From<FromUtf8Error> for Error {
fn from(value: FromUtf8Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<String> for Error {
fn from(details: String) -> Self {
Self { details }
}
}
impl From<std::io::Error> for Error {
fn from(value: std::io::Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<atom_syndication::Error> for Error {
fn from(value: atom_syndication::Error) -> Self {
Self {
details: value.to_string(),
}
}
}
impl From<reqwest::Error> for Error {
fn from(value: reqwest::Error) -> Self {
Self {
details: value.to_string(),
}
}
}
// //
// RESULTS // RESULTS