This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[macro_export] | |
| macro_rules! filter ( | |
| ($i:expr, $c: expr) => ( | |
| { | |
| if $i.is_empty() { | |
| nom::IResult::Incomplete(nom::Needed::Size(1)) | |
| } else { | |
| if $c($i[0]) { | |
| nom::IResult::Done(&$i[1..], &$i[0..1]) | |
| } else { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn among(characters:&[u8]) -> Box<Fn(u8) -> bool> { | |
| Box::new(move |chr| { | |
| characters.iter().any(chr) | |
| }) | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[macro_export] | |
| macro_rules! optional ( | |
| ($i:expr, $submac:ident!( $($args:tt)* )) => ( | |
| { | |
| opt!($i, complete!($i, $submac!($i, $($args)*))) | |
| } | |
| ); | |
| ($i:expr, $f:expr) => ( | |
| optional!($i, call!($f)); | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| pub fn message_body<'a>(slice: &'a [u8], headers:&Vec<(&str, String)>) -> IResult<&'a [u8], MessageBody<'a>> { | |
| IResult::Done(slice, MessageBody::None) | |
| } | |
| apply!(message_body, &headers) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| fn get<'a>(headers: &'a Vec<(&str, String)>, name:&str) -> Option<&'a str> { | |
| headers.into_iter().find(|&&(key,_)| name.eq_ignore_ascii_case(key)).map(|&(_,&value)|value) | |
| } // ^^^^^^ expected struct `std::string::String`, found reference |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #[derive(PartialEq, Debug)] | |
| pub enum StartLine<'a> { | |
| RequestLine (RequestLine<'a>), | |
| StatusLine (StatusLine<'a>), | |
| } | |
| impl <'a> fmt::Display for StartLine<'a> { | |
| fn fmt(&self, format: &mut fmt::Formatter) -> fmt::Result { | |
| match self { | |
| StartLine::RequestLine(rl) => rl.fmt(format), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package fun; | |
| import com.googlecode.totallylazy.Streams; | |
| import com.googlecode.totallylazy.io.Uri; | |
| import com.googlecode.utterlyidle.HttpHandler; | |
| import com.googlecode.utterlyidle.Request; | |
| import com.googlecode.utterlyidle.Response; | |
| import com.googlecode.utterlyidle.handlers.ClientHttpHandler; | |
| import com.googlecode.utterlyidle.html.RelativeUrlHandler; | |
| import jodd.lagarto.dom.*; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <div class="application root"> | |
| <style src="../generated/bundle.css"></style> | |
| <include src="../generated/bundle.svg" selector="svg"></include> | |
| <decorator src="../header/header.html" selector=".header" content=".controls"> | |
| <svg class="close-logo"> | |
| <use xlink:href="#close-logo"></use> | |
| </svg> | |
| </decorator> | |
| <include src="../popup/popup.html" selector=".popup"></include> | |
| <decorator src="../footer/footer.html" selector=".footer"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| * Usage: | |
| * const message: IncomingMessage = ... | |
| * const iterator = new AsyncIteratorHandler<string>(); | |
| * message.on("data", chunk => { | |
| * iterator.handle({value: chunk.toString(), done: false}); | |
| * }); | |
| * this.message.on("end", () => { | |
| * iterator.handle({value: null as any, done: true}) | |
| * }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| interface Constructor<T = object> { | |
| new(...args: any[]): T; | |
| } | |
| interface Disposable { | |
| dispose(): void; | |
| } | |
| function Disposable<T extends Constructor>(Base: T): T & Constructor<Disposable> { | |
| return class extends Base implements Disposable { |
OlderNewer