extern crate xml; #[allow(unused)] // use dotenv::dotenv; use env_logger::{ Env, Target }; #[allow(unused)] use log::{debug, info, log_enabled, warn, error}; use reqwest; #[allow(unused)] use std::io::{self, Write}; #[allow(unused)] use xml::reader::{EventReader, XmlEvent}; #[allow(unused)] fn publicise() { } #[allow(unused)] async fn get_folder_contents(password: String, url_tail: &str) -> Result> { debug!("Entering: get_folder_contents()"); let root_url = "https://theadamcooper.com"; let method = reqwest::Method::from_bytes(b"PROPFIND").unwrap(); let client = reqwest::Client::new(); let url = format!("{}{}", root_url, url_tail); debug!("url: {}", url); let body = String::from(r#" "#); let response = client.request(method, url) .basic_auth("adam", Some(password)) .body(body) .send() .await?; debug!("{:?}", response); Ok(response) } fn get_password() -> Result { print!("Nextcloud password: "); io::stdout().flush().unwrap(); let mut buffer = String::new(); let stdin = io::stdin(); match stdin.read_line(&mut buffer) { Ok(_) => Ok(buffer), Err(error) => Err(error), } } #[tokio::main] async fn main() -> Result<(), Box> { env_logger::Builder::from_env(Env::default().default_filter_or("trace")).target(Target::Stdout).init(); println!("Publicise it!"); let password = get_password().unwrap(); debug!("Received password: {}", password); let folder_contents = get_folder_contents(password, "/nextcloud/remote.php/dav/files/adam/public").await?; debug!("{:?}", folder_contents); Ok(()) }