#reverse #stream #url #parser

rfind_url

Parser to search strings for URLs in reverse order

9 unstable releases (3 breaking)

✓ Uses Rust 2018 edition

new 0.4.4 Oct 7, 2019
0.4.3 Oct 7, 2019
0.4.2 Aug 26, 2019
0.4.1 Jul 30, 2019
0.1.0 Mar 16, 2019

#53 in Parser tooling

Download history 5/week @ 2019-06-24 10/week @ 2019-07-01 7/week @ 2019-07-08 55/week @ 2019-07-15 110/week @ 2019-07-22 703/week @ 2019-07-29 1120/week @ 2019-08-05 898/week @ 2019-08-12 677/week @ 2019-08-19 999/week @ 2019-08-26 770/week @ 2019-09-02 934/week @ 2019-09-09 973/week @ 2019-09-16 1030/week @ 2019-09-23 900/week @ 2019-09-30

3,074 downloads per month

MIT/Apache

20KB
396 lines

Reverse Find URL

Build Status crates.io

This crate provides a parser to search a string for URLs in reverse order.

All functionality is handled by the Parser struct which takes chars as input.

Examples

Text can be fed into the parser in reverse order:

use rfind_url::{Parser, ParserState};

let mut parser = Parser::new();

for c in "There_is_no_URL_here".chars().rev() {
    assert_eq!(parser.advance(c), ParserState::MaybeUrl);
}

The parser returns the length of the URL as soon as the last character of the URL is pushed into it. Otherwise it will return None:

use rfind_url::{Parser, ParserState};

let mut parser = Parser::new();

// Parser guarantees there's currently no active URL
assert_eq!(parser.advance(' '), ParserState::NoUrl);

// URLs are only returned once they are complete
for c in "ttps://example.org".chars().rev() {
    assert_eq!(parser.advance(c), ParserState::MaybeUrl);
}

// Parser has detected a URL spanning the last 19 characters
assert_eq!(parser.advance('h'), ParserState::Url(19));

No runtime deps