tailhook / netbuf Goto Github PK
View Code? Open in Web Editor NEWNetwork buffers for rust
Home Page: http://tailhook.github.com/netbuf/
License: Apache License 2.0
Network buffers for rust
Home Page: http://tailhook.github.com/netbuf/
License: Apache License 2.0
struct HelloWorld;
impl<C:Counter> rotor_http::http1::Handler<C> for HelloWorld {
fn request(req: rotor_http::http1::Request,
res: &mut rotor_http::http1::ResponseBuilder,
ctx: &mut C)
{
println!("request");
ctx.increment();
match req.uri {
hyper::uri::RequestUri::AbsolutePath(ref p) if &p[..] == "/" => {
thread::spawn(move || {
res.set_status(hyper::status::StatusCode::Ok);
let five_seconds = time::Duration::new(5, 0);
thread::sleep(five_seconds);
res.put_body("Hello World!");
});
}
hyper::uri::RequestUri::AbsolutePath(ref p) if &p[..] == "/num"
=> {
res.set_status(hyper::status::StatusCode::Ok);
res.put_body(format!("This host visited {} times",
ctx.get()));
}
hyper::uri::RequestUri::AbsolutePath(p) => {
res.set_status(hyper::status::StatusCode::Ok);
res.put_body(format!("Hello {}!", &p[1..]));
}
_ => {} // Do nothing: not found or bad request
}
}
}
Is it possible to delay sending a response?
This could be useful if waiting for a response from the database.
Currently I getting errors :
examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41 thread::spawn(move || {
^~~~~~~~~~~~~
note: type must outlive the static lifetime
examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41 thread::spawn(move || {
^~~~~~~~~~~~~
note: type must outlive the static lifetime
examples/threaded.rs:41:5: 41:18 error: the type `[closure@examples/threaded.rs:41:19: 48:8 res:&mut rotor_http::http1::ResponseBuilder<'_, '_>]` does not fulfill the required lifetime [E0477]
examples/threaded.rs:41 thread::spawn(move || {
^~~~~~~~~~~~~
note: type must outlive the static lifetime
error: aborting due to 3 previous errors
Could not compile `rotor-http`.
Buf::is_empty
assumes that an empty buffer will never have allocated space, but this assumption is broken by Buf::read_from
when attempting the read returns an error.
I'm currently working on a AMQP client, the maximum theoretical size for a frame is 2^32-- slightly over what netbuf allows.
I was thinking of writing a fix, but am wondering on what would be the most acceptable solution.
Thoughts?
I want to be able to get specifc bytes from the buffer, not only ranges of bytes.
The standard library uses always is_empty()
to check if a collection is empty. It would be great if netbuf followed this naming convention. I would also create a PR.
I try run "rotor-http" example file.
When compiling get an error :
grzegorz@grzegorz:~/Pulpit/rotor-http$ cargo run --example threaded --verbose
Updating registry `https://github.com/rust-lang/crates.io-index`
Updating git repository `git://github.com/tailhook/rotor`
Fresh unicase v1.0.1
Fresh slab v0.1.2
Fresh httparse v1.0.0
Fresh bytes v0.2.11
Fresh gcc v0.3.19
Fresh libc v0.1.12
Fresh traitobject v0.0.1
Fresh language-tags v0.0.7
Fresh log v0.3.3
Fresh mime v0.1.0
Fresh hpack v0.2.0
Fresh solicit v0.4.4
Fresh winapi v0.2.5
Fresh bitflags v0.3.3
Fresh matches v0.1.2
Fresh libc v0.2.2
Fresh memchr v0.1.7
Fresh winapi v0.1.23
Fresh bitflags v0.1.1
Compiling nix v0.3.9
Running `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/nix-0.3.9/src/lib.rs --crate-name nix --crate-type lib -g -C metadata=1295479b75f240b4 -C extra-filename=-1295479b75f240b4 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --extern bitflags=/home/grzegorz/Pulpit/rotor-http/target/debug/deps/libbitflags-83dc6fc5ecc9dd71.rlib --extern libc=/home/grzegorz/Pulpit/rotor-http/target/debug/deps/liblibc-6bc3b8388045ae15.rlib --cap-lints allow`
Fresh lazy_static v0.1.15
Compiling netbuf v0.2.0
Running `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/lib.rs --crate-name netbuf --crate-type lib -g -C metadata=f13fe0a853c39504 -C extra-filename=-f13fe0a853c39504 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --cap-lints allow`
/home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/buf.rs:13:34: 13:41 error: attempted left shift with overflow
/home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/buf.rs:13 pub const MAX_BUF_SIZE: usize = (1 << 32) - 2;
^~~~~~~
error: aborting due to previous error
Could not compile `netbuf`.
Caused by:
Process didn't exit successfully: `rustc /home/grzegorz/.cargo/registry/src/github.com-121aea75f9ef2ce2/netbuf-0.2.0/src/lib.rs --crate-name netbuf --crate-type lib -g -C metadata=f13fe0a853c39504 -C extra-filename=-f13fe0a853c39504 --out-dir /home/grzegorz/Pulpit/rotor-http/target/debug/deps --emit=dep-info,link -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps -L dependency=/home/grzegorz/Pulpit/rotor-http/target/debug/deps --cap-lints allow` (exit code: 101)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.