Skip to content

Commit 556b71a

Browse files
committed
add derived trait implementations for stuff
1 parent 77ffb44 commit 556b71a

File tree

16 files changed

+36
-15
lines changed

16 files changed

+36
-15
lines changed

src/async.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub using @coroutine {pause}
4949
pub using @coroutine {is_being_cancelled}
5050

5151
///|
52-
pub suberror TimeoutError derive(Show)
52+
pub suberror TimeoutError derive(Show, ToJson)
5353

5454
///|
5555
/// `with_timeout(timeout, f)` run the async function `f`.

src/http/client.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ struct Client {
2929

3030
///|
3131
/// Error raised when the proxy responded with a non-2XX response code
32-
pub suberror ProxyError Response derive(Show)
32+
pub suberror ProxyError Response derive(Show, ToJson)
3333

3434
///|
3535
/// Create a new HTTP client by connecting to a remote host.

src/http/parser.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ pub suberror HttpProtocolError {
4040
BadRequest
4141
HttpVersionNotSupported(String)
4242
NotImplemented
43-
} derive(Show)
43+
} derive(Show, ToJson)
4444

4545
///|
4646
/// Read from the body of the HTTP request/response

src/http/pkg.generated.mbti

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,18 @@ pub suberror HttpProtocolError {
2929
NotImplemented
3030
}
3131
impl Show for HttpProtocolError
32+
impl ToJson for HttpProtocolError
3233

3334
pub suberror ProxyError Response
3435
impl Show for ProxyError
36+
impl ToJson for ProxyError
3537

3638
pub suberror URIParseError {
3739
InvalidFormat
3840
UnsupportedProtocol(String)
3941
}
4042
impl Show for URIParseError
43+
impl ToJson for URIParseError
4144

4245
// Types and methods
4346
type Client
@@ -59,13 +62,19 @@ pub(all) enum Protocol {
5962
Https
6063
}
6164
fn Protocol::default_port(Self) -> Int
65+
impl Compare for Protocol
66+
impl Eq for Protocol
67+
impl Hash for Protocol
68+
impl Show for Protocol
69+
impl ToJson for Protocol
6270

6371
pub(all) struct Request {
6472
meth : RequestMethod
6573
path : String
6674
headers : Map[String, String]
6775
}
6876
impl Show for Request
77+
impl ToJson for Request
6978

7079
pub(all) enum RequestMethod {
7180
Get
@@ -78,15 +87,19 @@ pub(all) enum RequestMethod {
7887
Trace
7988
Patch
8089
}
90+
impl Compare for RequestMethod
8191
impl Eq for RequestMethod
92+
impl Hash for RequestMethod
8293
impl Show for RequestMethod
94+
impl ToJson for RequestMethod
8395

8496
pub(all) struct Response {
8597
code : Int
8698
reason : String
8799
headers : Map[String, String]
88100
}
89101
impl Show for Response
102+
impl ToJson for Response
90103

91104
type Server
92105
async fn Server::accept(Self) -> (ServerConnection, @socket.Addr)

src/http/request.mbt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
pub(all) enum Protocol {
1717
Http
1818
Https
19-
}
19+
} derive(Show, Eq, Compare, Hash, ToJson)
2020

2121
///|
2222
pub fn Protocol::default_port(p : Protocol) -> Int {
@@ -30,7 +30,7 @@ pub fn Protocol::default_port(p : Protocol) -> Int {
3030
pub suberror URIParseError {
3131
InvalidFormat
3232
UnsupportedProtocol(String)
33-
} derive(Show)
33+
} derive(Show, ToJson)
3434

3535
///|
3636
fn resolve_url(

src/http/types.mbt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,18 @@ pub(all) enum RequestMethod {
2323
Options
2424
Trace
2525
Patch
26-
} derive(Show, Eq)
26+
} derive(Show, Eq, Compare, Hash, ToJson)
2727

2828
///|
2929
pub(all) struct Request {
3030
meth : RequestMethod
3131
path : String
3232
headers : Map[String, String]
33-
} derive(Show)
33+
} derive(Show, ToJson)
3434

3535
///|
3636
pub(all) struct Response {
3737
code : Int
3838
reason : String
3939
headers : Map[String, String]
40-
} derive(Show)
40+
} derive(Show, ToJson)

src/io/pipe.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ pub impl Reader for PipeRead with _get_internal_buffer(self) {
125125
///|
126126
/// This error will be raised when
127127
/// writing to a pipe whose read end is already closed.
128-
pub suberror PipeClosed derive(Show)
128+
pub suberror PipeClosed derive(Show, ToJson)
129129

130130
///|
131131
/// Write data to a pipe. The data can be read from the read end of the pipe.

src/io/pkg.generated.mbti

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ fn pipe() -> (PipeRead, PipeWrite)
77
// Errors
88
pub suberror PipeClosed
99
impl Show for PipeClosed
10+
impl ToJson for PipeClosed
1011

1112
pub(all) suberror ReaderClosed
1213
impl Show for ReaderClosed
14+
impl ToJson for ReaderClosed
1315

1416
// Types and methods
1517
#deprecated

src/io/reader.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ pub(open) trait Reader {
2828
}
2929

3030
///|
31-
pub(all) suberror ReaderClosed derive(Show)
31+
pub(all) suberror ReaderClosed derive(Show, ToJson)
3232

3333
///|
3434
/// `reader.read(dst, offset~, max_len~)` read at most `max_len` bytes from the reader,

src/os_error/error.mbt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extern "C" fn strerror(errno : Int) -> @c_buffer.Buffer = "moonbitlang_async_err
4141
///|
4242
pub(all) suberror OSError {
4343
OSError(Int, context~ : String)
44-
}
44+
} derive(ToJson)
4545

4646
///|
4747
pub impl Show for OSError with output(self, logger) -> Unit {

0 commit comments

Comments
 (0)