futures::sync::mpsc::channel(8)
copypaste? I hate that magic number
fn key( path: &str ) -> Vec< String >
{
let mut components: Vec< String > = path.split( '/' ).map( |s| s.to_string() ).collect();
// If present, remove the trailing empty string (which represents a trailing slash).
// If it isn't removed a path without a trailing space will never match the same path with trailing space
// Can't find a way to write this without the boolean without upsetting the borrow checker.
//
let mut trailing = false;
{
if let Some( s ) = components.last() {
if s.is_empty()
{
trailing = true;
}}
}
if trailing { components.pop(); }
components
}
The borrow checker won't let me pop without creating a bool in a separate scope
if match components.last() {
Some(s) => s.is_empty(),
_ => false,
} {
components.pop();
}
str::from_utf8
corrupts data
extern crate curl;
extern crate json;
use curl::easy::Easy;
use std::str;
use json::*;
fn main() {
let query = build_qery();
let mut easy = Easy::new();
easy.url(query.as_str()).expect("Query error");
let mut transfer = easy.transfer();
let result = transfer.write_function(|data| {
println!("{}", str::from_utf8(data).unwrap());
//let temp_s = str::from_utf8(data).unwrap();
// let parsed = json::parse(temp_s.expect("FFFFUCK");
Ok(data.len())
});
result.expect("Transfer error");
transfer.perform().expect("Transfer error")
}
fn build_qery() -> String {
"https://api.darksky.net/forecast/6143f6925645b592e2ca57829537a30a/37.8267,-122.4233?units=si".to_owned()
}
from_utf8
curl
might corrupt data or str::from_utf8
or I might be just an idiot
write_function
can be called multiple times with parts of the reply.
UnexpectedEndOfJson
. Thank you