size_t idx; string buf = "foo\nbar"; auto ret = parseToken!("\0\037\177\377", "\r\n")(buf, idx); assert(ret == 0); // no error assert(idx == 3); // index of newline character idx = 0; ret = parseToken!("\0\037\177\377", "\r\n")(buf[0..3], idx); assert(ret == -1); // not enough data to find next character assert(idx == 3); idx = 0; buf = "foo\t\nbar"; ret = parseToken!("\0\037\177\377", "\r\n")(buf, idx); assert(ret == -2); // invalid character '\t' found in token assert(idx == 3); // invalid character on index 3