itsi-server 0.1.7 → 0.1.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of itsi-server might be problematic. Click here for more details.

data/Cargo.toml ADDED
@@ -0,0 +1,7 @@
1
+ # This Cargo.toml is here to let externals tools (IDEs, etc.) know that this is
2
+ # a Rust project. Your extensions dependencies should be added to the Cargo.toml
3
+ # in the ext/ directory.
4
+
5
+ [workspace]
6
+ members = ["./ext/itsi_server"]
7
+ resolver = "2"
@@ -1,5 +1,12 @@
1
+ use magnus::{
2
+ Error,
3
+ error::ErrorType,
4
+ exception::{self, arg_error, exception},
5
+ };
6
+ use nix::errno::Errno;
7
+
1
8
  use crate::ItsiError;
2
- use std::ffi::NulError;
9
+ use std::{ffi::NulError, io};
3
10
 
4
11
  pub static CLIENT_CONNECTION_CLOSED: &str = "Client disconnected";
5
12
 
@@ -9,14 +16,14 @@ impl From<httparse::Error> for ItsiError {
9
16
  }
10
17
  }
11
18
 
12
- impl From<nix::errno::Errno> for ItsiError {
13
- fn from(err: nix::errno::Errno) -> Self {
19
+ impl From<Errno> for ItsiError {
20
+ fn from(err: Errno) -> Self {
14
21
  ItsiError::ArgumentError(err.to_string())
15
22
  }
16
23
  }
17
24
 
18
- impl From<std::io::Error> for ItsiError {
19
- fn from(err: std::io::Error) -> Self {
25
+ impl From<io::Error> for ItsiError {
26
+ fn from(err: io::Error) -> Self {
20
27
  ItsiError::ArgumentError(err.to_string())
21
28
  }
22
29
  }
@@ -33,39 +40,29 @@ impl From<NulError> for ItsiError {
33
40
  }
34
41
  }
35
42
 
36
- impl From<magnus::Error> for ItsiError {
37
- fn from(err: magnus::Error) -> Self {
43
+ impl From<Error> for ItsiError {
44
+ fn from(err: Error) -> Self {
38
45
  match err.error_type() {
39
- magnus::error::ErrorType::Jump(tag) => ItsiError::Jump(tag.to_string()),
40
- magnus::error::ErrorType::Error(_exception_class, cow) => {
41
- ItsiError::ArgumentError(cow.to_string())
42
- }
43
- magnus::error::ErrorType::Exception(exception) => {
44
- ItsiError::ArgumentError(exception.to_string())
45
- }
46
+ ErrorType::Jump(tag) => ItsiError::Jump(tag.to_string()),
47
+ ErrorType::Error(_exception_class, cow) => ItsiError::ArgumentError(cow.to_string()),
48
+ ErrorType::Exception(exception) => ItsiError::ArgumentError(exception.to_string()),
46
49
  }
47
50
  }
48
51
  }
49
52
 
50
- impl From<ItsiError> for magnus::Error {
53
+ impl From<ItsiError> for Error {
51
54
  fn from(err: ItsiError) -> Self {
52
55
  match err {
53
- ItsiError::InvalidInput(msg) => magnus::Error::new(magnus::exception::arg_error(), msg),
54
- ItsiError::InternalServerError(msg) => {
55
- magnus::Error::new(magnus::exception::exception(), msg)
56
- }
57
- ItsiError::UnsupportedProtocol(msg) => {
58
- magnus::Error::new(magnus::exception::arg_error(), msg)
59
- }
60
- ItsiError::ArgumentError(msg) => {
61
- magnus::Error::new(magnus::exception::arg_error(), msg)
62
- }
63
- ItsiError::Jump(msg) => magnus::Error::new(magnus::exception::local_jump_error(), msg),
64
- ItsiError::Break() => magnus::Error::new(magnus::exception::interrupt(), "Break"),
56
+ ItsiError::InvalidInput(msg) => Error::new(arg_error(), msg),
57
+ ItsiError::InternalServerError(msg) => Error::new(exception(), msg),
58
+ ItsiError::UnsupportedProtocol(msg) => Error::new(arg_error(), msg),
59
+ ItsiError::ArgumentError(msg) => Error::new(arg_error(), msg),
60
+ ItsiError::Jump(msg) => Error::new(exception::local_jump_error(), msg),
61
+ ItsiError::Break() => Error::new(exception::interrupt(), "Break"),
65
62
  ItsiError::ClientConnectionClosed => {
66
- magnus::Error::new(magnus::exception::eof_error(), CLIENT_CONNECTION_CLOSED)
63
+ Error::new(exception::eof_error(), CLIENT_CONNECTION_CLOSED)
67
64
  }
68
- ItsiError::Pass() => magnus::Error::new(magnus::exception::interrupt(), "Pass"),
65
+ ItsiError::Pass() => Error::new(exception::interrupt(), "Pass"),
69
66
  }
70
67
  }
71
68
  }