Skip to content

Commit 33b00fa

Browse files
committed
Make http types cloneable
1 parent ce0930c commit 33b00fa

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/std_lib/http.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,10 @@ impl<'vm, 'value> Getable<'vm, 'value> for Headers {
108108

109109
// By implementing `Userdata` on `Body` it can be automatically pushed and retrieved from gluon
110110
// threads
111-
#[derive(Userdata, Trace, VmType)]
111+
#[derive(Userdata, Trace, VmType, Clone)]
112112
#[gluon(vm_type = "std.http.types.Body")]
113113
#[gluon(crate_name = "::vm")]
114+
#[gluon_userdata(clone)]
114115
#[gluon_trace(skip)]
115116
// Representation of a http body that is in the prograss of being read
116117
pub struct Body(
@@ -146,9 +147,10 @@ fn read_chunk(body: &Body) -> impl Future<Output = IO<Option<PushAsRef<Bytes, [u
146147
}
147148

148149
// A http body that is being written
149-
#[derive(Userdata, Trace, VmType)]
150+
#[derive(Userdata, Trace, VmType, Clone)]
150151
#[gluon(vm_type = "std.http.types.ResponseBody")]
151152
#[gluon(crate_name = "::vm")]
153+
#[gluon_userdata(clone)]
152154
#[gluon_trace(skip)]
153155
pub struct ResponseBody(Arc<Mutex<Option<hyper::body::Sender>>>);
154156

@@ -194,10 +196,11 @@ fn write_response(response: &ResponseBody, bytes: &[u8]) -> impl Future<Output =
194196
})
195197
}
196198

197-
#[derive(Debug, Userdata, Trace, VmType)]
199+
#[derive(Debug, Userdata, Trace, VmType, Clone)]
198200
#[gluon(vm_type = "std.http.types.Uri")]
199201
#[gluon(crate_name = "::vm")]
200202
#[gluon_trace(skip)]
203+
#[gluon_userdata(clone)]
201204
struct Uri(http::Uri);
202205

203206
// Next we define some record types which are marshalled to and from gluon. These have equivalent

0 commit comments

Comments
 (0)