diff --git a/README.md b/README.md index 17c1e8e..4bac611 100755 --- a/README.md +++ b/README.md @@ -2,6 +2,17 @@ Mers is an experimental programming language inspired by high-level and scripting languages, but with error handling inspired by rust. +## WARNING + +If you use libraries, be aware that they run as a seperate process that might not exit with mers! +This means that, after running a script 40-50 times (which can happen more quickly than you might realize), +you might find 40-50 random processes just running and possibly maxing our your cpu. +So if you use libraries (recommendation: don't, the implementation is pretty bad anyway. just use any other language), make sure to kill those processes once you're done +until I figure out how to make that happen automatically. +(I believe the issue happens when closing the window from the GUI library, which crashes mers, leaving the http library process running) + +(other than that, the language is pretty usable, i promise...) + ## Features ### Multiple Types diff --git a/mers/src/libs/inlib.rs b/mers/src/libs/inlib.rs index 2b5d80a..e73aa84 100755 --- a/mers/src/libs/inlib.rs +++ b/mers/src/libs/inlib.rs @@ -5,10 +5,7 @@ use std::{ use crate::{ libs::DirectReader, - script::{ - val_data::{VData, VDataEnum}, - val_type::VType, - }, + script::{val_data::VData, val_type::VType}, }; use super::{data_from_bytes, data_to_bytes}; @@ -38,8 +35,8 @@ impl MyLib { MyLibTaskCompletion { _priv: () }, ) } - pub fn get_enum(&self, e: &str) -> usize { - *self.enum_variants.get(e).unwrap() + pub fn get_enum(&self, e: &str) -> Option { + self.enum_variants.get(e).map(|v| *v) } pub fn run( &mut self, @@ -84,19 +81,27 @@ impl MyLib { } 'I' => { let mut line = String::new(); - stdin.read_line(&mut line).unwrap(); - if let Some((task, args)) = line.split_once(' ') { - match task { - "set_enum_id" => { - let (enum_name, enum_id) = args.split_once(' ').unwrap(); - let name = enum_name.trim().to_string(); - let id = enum_id.trim().parse().unwrap(); - self.enum_variants.insert(name.clone(), id); + loop { + line.clear(); + stdin.read_line(&mut line).unwrap(); + if let Some((task, args)) = line.split_once(' ') { + match task { + "set_enum_id" => { + let (enum_name, enum_id) = args.split_once(' ').unwrap(); + let name = enum_name.trim().to_string(); + let id = enum_id.trim().parse().unwrap(); + self.enum_variants.insert(name.clone(), id); + } + _ => todo!(), + } + } else { + match line.trim_end() { + "init_finished" => break, + _ => unreachable!(), } - _ => todo!(), } } - None + Some(MyLibTask::FinishedInit(MyLibTaskCompletion { _priv: () })) } 'f' => { let fnid = stdin.one_byte().unwrap() as usize; @@ -119,6 +124,7 @@ impl MyLib { pub enum MyLibTask { None(MyLibTaskCompletion), + FinishedInit(MyLibTaskCompletion), RunFunction(MyLibTaskRunFunction), } pub struct MyLibTaskRunFunction { diff --git a/mers/src/libs/mod.rs b/mers/src/libs/mod.rs index 4a61942..2070b1e 100755 --- a/mers/src/libs/mod.rs +++ b/mers/src/libs/mod.rs @@ -32,7 +32,8 @@ the identifying ascii chars: f a function: followed by the function signature, i.e. "my_func(string int/float [string]) string/[float int]" x end: indicates that you are done registering things I init 2 - TODO! (currently nothing) + can send some tasks, + must end with a line saying 'init_finished'. reply should be a single line (only the newline char). If there is data before the newline char, it will be reported as an error and the script will not run. f call a function: followed by the function id byte (0 <= id < #funcs; function ids are assigned in ascending order as they were registered in the reply to "i" @@ -124,9 +125,11 @@ impl Lib { _ => todo!(), } } + write!(stdin, "I").unwrap(); for (enum_name, enum_id) in enum_variants.iter() { - writeln!(stdin, "Iset_enum_id {enum_name} {enum_id}").unwrap(); + writeln!(stdin, "set_enum_id {enum_name} {enum_id}").unwrap(); } + writeln!(stdin, "init_finished").unwrap(); Ok(Self { process: handle, stdin: Arc::new(Mutex::new(stdin)), diff --git a/mers/src/libs/path.rs b/mers/src/libs/path.rs index 9aed570..6dac339 100755 --- a/mers/src/libs/path.rs +++ b/mers/src/libs/path.rs @@ -10,7 +10,6 @@ pub fn path_from_string(path: &str, script_directory: &PathBuf) -> Option match chs.next() { + // backslash can escape these characters: + Some('\n') => data.push('\\'), + // backshash invalidates comments, so \// will just be //. + Some('/') => data.push('/'), + // backslash does nothing otherwise. + Some(ch) => { + data.push('\\'); + data.push(ch); + } + None => data.push('\\'), + }, Some('/') => match chs.next() { Some('/') => loop { match chs.next() { diff --git a/mers/src/script/builtins.rs b/mers/src/script/builtins.rs index 099829f..9cf5393 100755 --- a/mers/src/script/builtins.rs +++ b/mers/src/script/builtins.rs @@ -20,6 +20,7 @@ pub const EVS: [&'static str; 1] = ["Err"]; pub enum BuiltinFunction { // core Assume1, // assume []/[t] is [t], return t. Optionally provide a reason as to why (2nd arg) + AssumeNoEnum, // assume enum(*)/t is t. NoEnum, Matches, // print @@ -83,6 +84,7 @@ impl BuiltinFunction { pub fn get(s: &str) -> Option { Some(match s { "assume1" => Self::Assume1, + "assume_no_enum" => Self::AssumeNoEnum, "noenum" => Self::NoEnum, "matches" => Self::Matches, "print" => Self::Print, @@ -151,7 +153,7 @@ impl BuiltinFunction { } } if !len0 { - eprintln!("Warn: calling assume1 on a value of type {}, which will never be a length-0 tuple and therefore will not cannot fail.", input[0]); + eprintln!("Warn: calling assume1 on a value of type {}, which will never be a length-0 tuple and therefore cannot fail.", input[0]); } if !len1 { eprintln!("Warn: calling assume1 on a value of type {}, which will always be a length-0 tuple!", input[0]); @@ -169,6 +171,37 @@ impl BuiltinFunction { false } } + Self::AssumeNoEnum => { + if input.len() >= 1 { + let mut someenum = false; + let mut noenum = false; + for t in input[0].types.iter() { + match t { + VSingleType::EnumVariant(..) | VSingleType::EnumVariantS(..) => { + someenum = true + } + _ => noenum = true, + } + } + if !someenum { + eprintln!("Warn: calling assume_no_enum on a value of type {}, which will never be an enum and therefore cannot fail.", input[0]); + } + if !noenum { + eprintln!("Warn: calling assume_no_enum on a value of type {}, which will always be an enum!", input[0]); + } + if input.len() >= 2 { + if input.len() == 2 { + input[1].fits_in(&VSingleType::String.to()).is_empty() + } else { + false + } + } else { + true + } + } else { + false + } + } Self::NoEnum => input.len() == 1, Self::Matches => input.len() == 1, Self::Print | Self::Println => { @@ -341,6 +374,16 @@ impl BuiltinFunction { } out } + Self::AssumeNoEnum => { + let mut out = VType { types: vec![] }; + for t in &input[0].types { + match t { + VSingleType::EnumVariant(..) | VSingleType::EnumVariantS(..) => (), + t => out = out | t.clone().to(), + } + } + out + } Self::NoEnum => input[0].clone().noenum(), Self::Matches => input[0].matches().1, // [] @@ -557,12 +600,31 @@ impl BuiltinFunction { } } else { String::new() - } + }, ); } } v => v.to(), }, + Self::AssumeNoEnum => { + let data = args[0].run(vars, libs); + match data.data { + VDataEnum::EnumVariant(..) => panic!( + "ASSUMPTION FAILED: assume_no_enum :: found {} :: {}", + data, + if args.len() > 1 { + if let VDataEnum::String(v) = args[1].run(vars, libs).data { + v + } else { + String::new() + } + } else { + String::new() + } + ), + d => d.to(), + } + } Self::NoEnum => args[0].run(vars, libs).noenum(), Self::Matches => match args[0].run(vars, libs).data.matches() { Some(v) => VDataEnum::Tuple(vec![v]).to(), @@ -1232,25 +1294,32 @@ impl BuiltinFunction { } Self::Get => { if args.len() == 2 { - if let (VDataEnum::Reference(v), VDataEnum::Int(i)) = + if let (container, VDataEnum::Int(i)) = (args[0].run(vars, libs).data, args[1].run(vars, libs).data) { - if let VDataEnum::List(_, v) | VDataEnum::Tuple(v) = - &mut v.lock().unwrap().data - { - if i >= 0 { - match v.get(i as usize) { - Some(v) => VDataEnum::Tuple(vec![v.clone()]).to(), - None => VDataEnum::Tuple(vec![]).to(), + if i >= 0 { + match match container { + VDataEnum::Reference(v) => match &v.lock().unwrap().data { + VDataEnum::List(_, v) | VDataEnum::Tuple(v) => { + v.get(i as usize).map(|v| v.clone()) + } + _ => unreachable!( + "get: reference to something other than list/tuple" + ), + }, + VDataEnum::List(_, v) | VDataEnum::Tuple(v) => { + v.get(i as usize).map(|v| v.clone()) } - } else { - VDataEnum::Tuple(vec![]).to() + _ => unreachable!("get: not a reference/list/tuple"), + } { + Some(v) => VDataEnum::Tuple(vec![v]).to(), + None => VDataEnum::Tuple(vec![]).to(), } } else { - unreachable!("get: not a list/tuple") + VDataEnum::Tuple(vec![]).to() } } else { - unreachable!("get: not a reference and index") + unreachable!("get: not a list/tuple/reference and index") } } else { unreachable!("get: not 2 args") @@ -1347,12 +1416,21 @@ impl BuiltinFunction { }; let left = if left >= 0 { left as usize } else { 0 }; if let Some(len) = len { - let len = if len >= 0 { - len as usize + if len >= 0 { + VDataEnum::String( + a.chars() + .skip(left) + .take((len as usize).saturating_sub(left)) + .collect(), + ) + .to() } else { - todo!("negative len - shorthand for backwards? not sure yet...") - }; - VDataEnum::String(a.chars().skip(left).take(len).collect()).to() + // negative end index => max length + VDataEnum::String( + a.chars().skip(left).take(len.abs() as usize).collect(), + ) + .to() + } } else { VDataEnum::String(a.chars().skip(left).collect()).to() } diff --git a/mers_libs/gui_v1/src/main.rs b/mers_libs/gui_v1/src/main.rs index de295df..7dc4fb9 100755 --- a/mers_libs/gui_v1/src/main.rs +++ b/mers_libs/gui_v1/src/main.rs @@ -1,14 +1,12 @@ use std::{ - collections::HashMap, io::{self, Read}, - rc::Rc, - sync::{mpsc, Arc}, + sync::mpsc, time::Duration, }; use iced::{ executor, time, - widget::{self, button, column, row, text}, + widget::{button, column, row, text}, Application, Command, Element, Renderer, Settings, Subscription, Theme, }; use mers::{ @@ -94,7 +92,7 @@ fn main() { let mut layout = Layout::Row(vec![]); loop { run = match my_lib.run(run, &mut stdin, &mut stdout) { - MyLibTask::None(v) => v, + MyLibTask::None(v) | MyLibTask::FinishedInit(v) => v, MyLibTask::RunFunction(mut f) => { let return_value = match f.function { 0 => VDataEnum::List(VSingleType::Int.to(), vec![]).to(), @@ -104,7 +102,7 @@ fn main() { match recv { MessageAdv::ButtonPressed(path) => v.push( VDataEnum::EnumVariant( - my_lib.get_enum("ButtonPressed"), + my_lib.get_enum("ButtonPressed").unwrap(), Box::new( VDataEnum::List(VSingleType::Int.to(), path).to(), ), @@ -190,10 +188,10 @@ fn main() { } fn layout_from_vdata(my_lib: &MyLib, d: VDataEnum) -> Layout { - let row = my_lib.get_enum("Row"); - let col = my_lib.get_enum("Column"); - let text = my_lib.get_enum("Text"); - let button = my_lib.get_enum("Button"); + let row = my_lib.get_enum("Row").unwrap(); + let col = my_lib.get_enum("Column").unwrap(); + let text = my_lib.get_enum("Text").unwrap(); + let button = my_lib.get_enum("Button").unwrap(); if let VDataEnum::EnumVariant(variant, inner_data) = d { if variant == row { Layout::Row(vec![]) @@ -257,7 +255,7 @@ impl Application for App { recv: flags.0, sender: flags.1, buttons: vec![], - layout: Layout::Row(vec![]), + layout: Layout::Column(vec![]), }, Command::none(), ) @@ -361,6 +359,7 @@ impl App { } } fn calc_layout_stats(&mut self) { + self.buttons.clear(); Self::calc_layout_stats_rec(&self.layout, &mut vec![], &mut self.buttons) } fn calc_layout_stats_rec( diff --git a/mers_libs/http_requests b/mers_libs/http_requests new file mode 100755 index 0000000..d4f006a --- /dev/null +++ b/mers_libs/http_requests @@ -0,0 +1,3 @@ +#!/bin/bash +cd ./http_requests_v1 +cargo run --release diff --git a/mers_libs/http_requests/Cargo.lock b/mers_libs/http_requests/Cargo.lock deleted file mode 100644 index 14482d1..0000000 --- a/mers_libs/http_requests/Cargo.lock +++ /dev/null @@ -1,49 +0,0 @@ -# This file is automatically @generated by Cargo. -# It is not intended for manual editing. -version = 3 - -[[package]] -name = "aho-corasick" -version = "0.7.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" -dependencies = [ - "memchr", -] - -[[package]] -name = "http_requests" -version = "0.1.0" -dependencies = [ - "mers", -] - -[[package]] -name = "memchr" -version = "2.5.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" - -[[package]] -name = "mers" -version = "0.1.0" -dependencies = [ - "regex", -] - -[[package]] -name = "regex" -version = "1.7.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.6.29" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" diff --git a/mers_libs/http_requests/src/main.rs b/mers_libs/http_requests/src/main.rs deleted file mode 100755 index 375cdd1..0000000 --- a/mers_libs/http_requests/src/main.rs +++ /dev/null @@ -1,29 +0,0 @@ -fn main() { - let (mut my_lib, mut run) = MyLib::new( - "GUI-Iced".to_string(), - (0, 0), - "A basic GUI library for mers.".to_string(), - vec![( - "http_get".to_string(), - vec![VSingleType::String], - VType { - types: vec![VSingleType::Tuple(vec![]), VSingleType::String], - }, - )], - ); - let mut stdin = std::io::stdin().lock(); - let mut stdout = std::io::stdout().lock(); - let mut layout = Layout::Row(vec![]); - loop { - run = match my_lib.run(run, &mut stdin, &mut stdout) { - MyLibTask::None(v) => v, - MyLibTask::RunFunction(mut f) => { - let return_value = match f.function { - 0 => VDataEnum::List(VSingleType::Int.to(), vec![]).to(), - _ => unreachable!(), - }; - f.done(&mut stdout, return_value) - } - } - } -} diff --git a/mers_libs/http_requests_v1/Cargo.lock b/mers_libs/http_requests_v1/Cargo.lock new file mode 100644 index 0000000..49a7034 --- /dev/null +++ b/mers_libs/http_requests_v1/Cargo.lock @@ -0,0 +1,1138 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "aho-corasick" +version = "0.7.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc936419f96fa211c1b9166887b38e5e40b19958e5b895be7c1f93adec7071ac" +dependencies = [ + "memchr", +] + +[[package]] +name = "autocfg" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d468802bab17cbc0cc575e9b053f41e72aa36bfa6b7f55e3529ffa43161b97fa" + +[[package]] +name = "base64" +version = "0.21.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a4a4ddaa51a5bc52a6948f74c06d20aaaddb71924eab79b8c97a8c556e942d6a" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bumpalo" +version = "3.12.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" + +[[package]] +name = "bytes" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "89b2fd2a0dcf38d7971e2194b6b6eebab45ae01067456a7fd93d5547a61b70be" + +[[package]] +name = "cc" +version = "1.0.79" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50d30906286121d95be3d479533b458f87493b30a4b5f79a607db8f5d11aa91f" + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "core-foundation" +version = "0.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "194a7a9e6de53fa55116934067c844d9d749312f75c6f6d0980e8c252f8c2146" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e496a50fda8aacccc86d7529e2c1e0892dbd0f898a6b5645b5561b89c3210efa" + +[[package]] +name = "encoding_rs" +version = "0.8.32" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071a31f4ee85403370b58aca746f01041ede6f0da2730960ad001edc2b71b394" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "errno" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bcfec3a70f97c962c307b2d2c56e358cf1d00b558d74262b5f929ee8cc7e73a" +dependencies = [ + "errno-dragonfly", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "errno-dragonfly" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa68f1b12764fab894d2755d2518754e71b4fd80ecfb822714a1206c2aab39bf" +dependencies = [ + "cc", + "libc", +] + +[[package]] +name = "fastrand" +version = "1.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e51093e27b0797c359783294ca4f0a911c270184cb10f85783b118614a1501be" +dependencies = [ + "instant", +] + +[[package]] +name = "fnv" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1" + +[[package]] +name = "foreign-types" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f6f339eb8adc052cd2ca78910fda869aefa38d22d5cb648e6485e4d3fc06f3b1" +dependencies = [ + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-shared" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "00b0228411908ca8685dba7fc2cdd70ec9990a6e753e89b6ac91a84c40fbaf4b" + +[[package]] +name = "form_urlencoded" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9c384f161156f5260c24a097c56119f9be8c798586aecc13afbcbe7b7e26bf8" +dependencies = [ + "percent-encoding", +] + +[[package]] +name = "futures-channel" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "955518d47e09b25bbebc7a18df10b81f0c766eaf4c4f1cccef2fca5f2a4fb5f2" +dependencies = [ + "futures-core", +] + +[[package]] +name = "futures-core" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4bca583b7e26f571124fe5b7561d49cb2868d79116cfa0eefce955557c6fee8c" + +[[package]] +name = "futures-io" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4fff74096e71ed47f8e023204cfd0aa1289cd54ae5430a9523be060cdb849964" + +[[package]] +name = "futures-sink" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f43be4fe21a13b9781a69afa4985b0f6ee0e1afab2c6f454a8cf30e2b2237b6e" + +[[package]] +name = "futures-task" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "76d3d132be6c0e6aa1534069c705a74a5997a356c0dc2f86a47765e5617c5b65" + +[[package]] +name = "futures-util" +version = "0.3.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26b01e40b772d54cf6c6d721c1d1abd0647a0106a12ecaa1c186273392a69533" +dependencies = [ + "futures-core", + "futures-io", + "futures-task", + "memchr", + "pin-project-lite", + "pin-utils", + "slab", +] + +[[package]] +name = "h2" +version = "0.3.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5be7b54589b581f624f566bf5d8eb2bab1db736c51528720b6bd36b96b55924d" +dependencies = [ + "bytes", + "fnv", + "futures-core", + "futures-sink", + "futures-util", + "http", + "indexmap", + "slab", + "tokio", + "tokio-util", + "tracing", +] + +[[package]] +name = "hashbrown" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" + +[[package]] +name = "hermit-abi" +version = "0.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ee512640fe35acbfb4bb779db6f0d80704c2cacfa2e39b601ef3e3f47d1ae4c7" +dependencies = [ + "libc", +] + +[[package]] +name = "hermit-abi" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" + +[[package]] +name = "http" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd6effc99afb63425aff9b05836f029929e345a6148a14b7ecd5ab67af944482" +dependencies = [ + "bytes", + "fnv", + "itoa", +] + +[[package]] +name = "http-body" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d5f38f16d184e36f2408a55281cd658ecbd3ca05cce6d6510a176eca393e26d1" +dependencies = [ + "bytes", + "http", + "pin-project-lite", +] + +[[package]] +name = "http_requests_v1" +version = "0.1.0" +dependencies = [ + "mers", + "reqwest", +] + +[[package]] +name = "httparse" +version = "1.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d897f394bad6a705d5f4104762e116a75639e470d80901eed05a860a95cb1904" + +[[package]] +name = "httpdate" +version = "1.0.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4a1e36c821dbe04574f602848a19f742f4fb3c98d40449f11bcad18d6b17421" + +[[package]] +name = "hyper" +version = "0.14.25" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc5e554ff619822309ffd57d8734d77cd5ce6238bc956f037ea06c58238c9899" +dependencies = [ + "bytes", + "futures-channel", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "httparse", + "httpdate", + "itoa", + "pin-project-lite", + "socket2", + "tokio", + "tower-service", + "tracing", + "want", +] + +[[package]] +name = "hyper-tls" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d6183ddfa99b85da61a140bea0efc93fdf56ceaa041b37d553518030827f9905" +dependencies = [ + "bytes", + "hyper", + "native-tls", + "tokio", + "tokio-native-tls", +] + +[[package]] +name = "idna" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e14ddfc70884202db2244c223200c204c2bda1bc6e0998d11b5e024d657209e6" +dependencies = [ + "unicode-bidi", + "unicode-normalization", +] + +[[package]] +name = "indexmap" +version = "1.9.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd070e393353796e801d209ad339e89596eb4c8d430d18ede6a1cced8fafbd99" +dependencies = [ + "autocfg", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a5bbe824c507c5da5956355e86a746d82e0e1464f65d862cc5e71da70e94b2c" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "io-lifetimes" +version = "1.0.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c66c74d2ae7e79a5a8f7ac924adbe38ee42a859c6539ad869eb51f0b52dc220" +dependencies = [ + "hermit-abi 0.3.1", + "libc", + "windows-sys 0.48.0", +] + +[[package]] +name = "ipnet" +version = "2.7.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "12b6ee2129af8d4fb011108c73d99a1b83a85977f23b82460c0ae2e25bb4b57f" + +[[package]] +name = "itoa" +version = "1.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "453ad9f582a441959e5f0d088b02ce04cfe8d51a8eaf077f12ac6d3e94164ca6" + +[[package]] +name = "js-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "lazy_static" +version = "1.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" + +[[package]] +name = "libc" +version = "0.2.141" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" + +[[package]] +name = "linux-raw-sys" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" + +[[package]] +name = "log" +version = "0.4.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "memchr" +version = "2.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2dffe52ecf27772e601905b7522cb4ef790d2cc203488bbd0e2fe85fcb74566d" + +[[package]] +name = "mers" +version = "0.1.0" +dependencies = [ + "regex", +] + +[[package]] +name = "mime" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a" + +[[package]] +name = "mio" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5b9d9a46eff5b4ff64b45a9e316a6d1e0bc719ef429cbec4dc630684212bfdf9" +dependencies = [ + "libc", + "log", + "wasi", + "windows-sys 0.45.0", +] + +[[package]] +name = "native-tls" +version = "0.2.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07226173c32f2926027b63cce4bcd8076c3552846cbe7925f3aaffeac0a3b92e" +dependencies = [ + "lazy_static", + "libc", + "log", + "openssl", + "openssl-probe", + "openssl-sys", + "schannel", + "security-framework", + "security-framework-sys", + "tempfile", +] + +[[package]] +name = "num_cpus" +version = "1.15.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fac9e2da13b5eb447a6ce3d392f23a29d8694bff781bf03a16cd9ac8697593b" +dependencies = [ + "hermit-abi 0.2.6", + "libc", +] + +[[package]] +name = "once_cell" +version = "1.17.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b7e5500299e16ebb147ae15a00a942af264cf3688f47923b8fc2cd5858f23ad3" + +[[package]] +name = "openssl" +version = "0.10.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e30d8bc91859781f0a943411186324d580f2bbeb71b452fe91ae344806af3f1" +dependencies = [ + "bitflags", + "cfg-if", + "foreign-types", + "libc", + "once_cell", + "openssl-macros", + "openssl-sys", +] + +[[package]] +name = "openssl-macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a948666b637a0f465e8564c73e89d4dde00d72d4d473cc972f390fc3dcee7d9c" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.14", +] + +[[package]] +name = "openssl-probe" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ff011a302c396a5197692431fc1948019154afc178baf7d8e37367442a4601cf" + +[[package]] +name = "openssl-sys" +version = "0.9.85" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d3d193fb1488ad46ffe3aaabc912cc931d02ee8518fe2959aea8ef52718b0c0" +dependencies = [ + "cc", + "libc", + "pkg-config", + "vcpkg", +] + +[[package]] +name = "percent-encoding" +version = "2.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" + +[[package]] +name = "pin-project-lite" +version = "0.2.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0a7ae3ac2f1173085d398531c705756c94a4c56843785df85a60c1a0afac116" + +[[package]] +name = "pin-utils" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b870d8c151b6f2fb93e84a13146138f05d02ed11c7e7c54f8826aaaf7c9f184" + +[[package]] +name = "pkg-config" +version = "0.3.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" + +[[package]] +name = "proc-macro2" +version = "1.0.56" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "quote" +version = "1.0.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "redox_syscall" +version = "0.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "567664f262709473930a4bf9e51bf2ebf3348f2e748ccc50dea20646858f8f29" +dependencies = [ + "bitflags", +] + +[[package]] +name = "regex" +version = "1.7.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.6.29" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" + +[[package]] +name = "reqwest" +version = "0.11.16" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "27b71749df584b7f4cac2c426c127a7c785a5106cc98f7a8feb044115f0fa254" +dependencies = [ + "base64", + "bytes", + "encoding_rs", + "futures-core", + "futures-util", + "h2", + "http", + "http-body", + "hyper", + "hyper-tls", + "ipnet", + "js-sys", + "log", + "mime", + "native-tls", + "once_cell", + "percent-encoding", + "pin-project-lite", + "serde", + "serde_json", + "serde_urlencoded", + "tokio", + "tokio-native-tls", + "tower-service", + "url", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "winreg", +] + +[[package]] +name = "rustix" +version = "0.37.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" +dependencies = [ + "bitflags", + "errno", + "io-lifetimes", + "libc", + "linux-raw-sys", + "windows-sys 0.48.0", +] + +[[package]] +name = "ryu" +version = "1.0.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f91339c0467de62360649f8d3e185ca8de4224ff281f66000de5eb2a77a79041" + +[[package]] +name = "schannel" +version = "0.1.21" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "713cfb06c7059f3588fb8044c0fad1d09e3c01d225e25b9220dbfdcf16dbb1b3" +dependencies = [ + "windows-sys 0.42.0", +] + +[[package]] +name = "security-framework" +version = "2.8.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a332be01508d814fed64bf28f798a146d73792121129962fdf335bb3c49a4254" +dependencies = [ + "bitflags", + "core-foundation", + "core-foundation-sys", + "libc", + "security-framework-sys", +] + +[[package]] +name = "security-framework-sys" +version = "2.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31c9bb296072e961fcbd8853511dd39c2d8be2deb1e17c6860b1d30732b323b4" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "serde" +version = "1.0.160" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" + +[[package]] +name = "serde_json" +version = "1.0.95" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d721eca97ac802aa7777b701877c8004d950fc142651367300d21c1cc0194744" +dependencies = [ + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "serde_urlencoded" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d3491c14715ca2294c4d6a88f15e84739788c1d030eed8c110436aafdaa2f3fd" +dependencies = [ + "form_urlencoded", + "itoa", + "ryu", + "serde", +] + +[[package]] +name = "slab" +version = "0.4.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" +dependencies = [ + "autocfg", +] + +[[package]] +name = "socket2" +version = "0.4.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "64a4a911eed85daf18834cfaa86a79b7d266ff93ff5ba14005426219480ed662" +dependencies = [ + "libc", + "winapi", +] + +[[package]] +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "syn" +version = "2.0.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcf316d5356ed6847742d036f8a39c3b8435cac10bd528a4bd461928a6ab34d5" +dependencies = [ + "proc-macro2", + "quote", + "unicode-ident", +] + +[[package]] +name = "tempfile" +version = "3.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b9fbec84f381d5795b08656e4912bec604d162bff9291d6189a78f4c8ab87998" +dependencies = [ + "cfg-if", + "fastrand", + "redox_syscall", + "rustix", + "windows-sys 0.45.0", +] + +[[package]] +name = "tinyvec" +version = "1.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87cc5ceb3875bb20c2890005a4e226a4651264a5c75edb2421b52861a0a0cb50" +dependencies = [ + "tinyvec_macros", +] + +[[package]] +name = "tinyvec_macros" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20" + +[[package]] +name = "tokio" +version = "1.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d0de47a4eecbe11f498978a9b29d792f0d2692d1dd003650c24c76510e3bc001" +dependencies = [ + "autocfg", + "bytes", + "libc", + "mio", + "num_cpus", + "pin-project-lite", + "socket2", + "windows-sys 0.45.0", +] + +[[package]] +name = "tokio-native-tls" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbae76ab933c85776efabc971569dd6119c580d8f5d448769dec1764bf796ef2" +dependencies = [ + "native-tls", + "tokio", +] + +[[package]] +name = "tokio-util" +version = "0.7.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5427d89453009325de0d8f342c9490009f76e999cb7672d77e46267448f7e6b2" +dependencies = [ + "bytes", + "futures-core", + "futures-sink", + "pin-project-lite", + "tokio", + "tracing", +] + +[[package]] +name = "tower-service" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b6bc1c9ce2b5135ac7f93c72918fc37feb872bdc6a5533a8b85eb4b86bfdae52" + +[[package]] +name = "tracing" +version = "0.1.37" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8ce8c33a8d48bd45d624a6e523445fd21ec13d3653cd51f681abf67418f54eb8" +dependencies = [ + "cfg-if", + "pin-project-lite", + "tracing-core", +] + +[[package]] +name = "tracing-core" +version = "0.1.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "24eb03ba0eab1fd845050058ce5e616558e8f8d8fca633e6b163fe25c797213a" +dependencies = [ + "once_cell", +] + +[[package]] +name = "try-lock" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3528ecfd12c466c6f163363caf2d02a71161dd5e1cc6ae7b34207ea2d42d81ed" + +[[package]] +name = "unicode-bidi" +version = "0.3.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "92888ba5573ff080736b3648696b70cafad7d250551175acbaa4e0385b3e1460" + +[[package]] +name = "unicode-ident" +version = "1.0.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5464a87b239f13a63a501f2701565754bae92d243d4bb7eb12f6d57d2269bf4" + +[[package]] +name = "unicode-normalization" +version = "0.1.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c5713f0fc4b5db668a2ac63cdb7bb4469d8c9fed047b1d0292cc7b0ce2ba921" +dependencies = [ + "tinyvec", +] + +[[package]] +name = "url" +version = "2.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d68c799ae75762b8c3fe375feb6600ef5602c883c5d21eb51c09f22b83c4643" +dependencies = [ + "form_urlencoded", + "idna", + "percent-encoding", +] + +[[package]] +name = "vcpkg" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "accd4ea62f7bb7a82fe23066fb0957d48ef677f6eeb8215f372f52e48bb32426" + +[[package]] +name = "want" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8a968cb1cd110d136ff8b819a556d6fb6d919363c61534f6860c7eb172ba0" +dependencies = [ + "log", + "try-lock", +] + +[[package]] +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" + +[[package]] +name = "wasm-bindgen" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] + +[[package]] +name = "wasm-bindgen-backend" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-futures" +version = "0.4.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f219e0d211ba40266969f6dbdd90636da12f75bee4fc9d6c23d1260dadb51454" +dependencies = [ + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "wasm-bindgen-macro" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] + +[[package]] +name = "wasm-bindgen-macro-support" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", + "wasm-bindgen-backend", + "wasm-bindgen-shared", +] + +[[package]] +name = "wasm-bindgen-shared" +version = "0.2.84" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" + +[[package]] +name = "web-sys" +version = "0.3.61" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +dependencies = [ + "js-sys", + "wasm-bindgen", +] + +[[package]] +name = "winapi" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" +dependencies = [ + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", +] + +[[package]] +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" + +[[package]] +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" + +[[package]] +name = "windows-sys" +version = "0.42.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.45.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" +dependencies = [ + "windows-targets 0.42.2", +] + +[[package]] +name = "windows-sys" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "677d2418bec65e3338edb076e806bc1ec15693c5d0104683f2efe857f61056a9" +dependencies = [ + "windows-targets 0.48.0", +] + +[[package]] +name = "windows-targets" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8e5180c00cd44c9b1c88adb3693291f1cd93605ded80c250a75d472756b4d071" +dependencies = [ + "windows_aarch64_gnullvm 0.42.2", + "windows_aarch64_msvc 0.42.2", + "windows_i686_gnu 0.42.2", + "windows_i686_msvc 0.42.2", + "windows_x86_64_gnu 0.42.2", + "windows_x86_64_gnullvm 0.42.2", + "windows_x86_64_msvc 0.42.2", +] + +[[package]] +name = "windows-targets" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7b1eb6f0cd7c80c79759c929114ef071b87354ce476d9d94271031c0497adfd5" +dependencies = [ + "windows_aarch64_gnullvm 0.48.0", + "windows_aarch64_msvc 0.48.0", + "windows_i686_gnu 0.48.0", + "windows_i686_msvc 0.48.0", + "windows_x86_64_gnu 0.48.0", + "windows_x86_64_gnullvm 0.48.0", + "windows_x86_64_msvc 0.48.0", +] + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "597a5118570b68bc08d8d59125332c54f1ba9d9adeedeef5b99b02ba2b0698f8" + +[[package]] +name = "windows_aarch64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91ae572e1b79dba883e0d315474df7305d12f569b400fcf90581b06062f7e1bc" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e08e8864a60f06ef0d0ff4ba04124db8b0fb3be5776a5cd47641e942e58c4d43" + +[[package]] +name = "windows_aarch64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b2ef27e0d7bdfcfc7b868b317c1d32c641a6fe4629c171b8928c7b08d98d7cf3" + +[[package]] +name = "windows_i686_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c61d927d8da41da96a81f029489353e68739737d3beca43145c8afec9a31a84f" + +[[package]] +name = "windows_i686_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "622a1962a7db830d6fd0a69683c80a18fda201879f0f447f065a3b7467daa241" + +[[package]] +name = "windows_i686_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "44d840b6ec649f480a41c8d80f9c65108b92d89345dd94027bfe06ac444d1060" + +[[package]] +name = "windows_i686_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4542c6e364ce21bf45d69fdd2a8e455fa38d316158cfd43b3ac1c5b1b19f8e00" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8de912b8b8feb55c064867cf047dda097f92d51efad5b491dfb98f6bbb70cb36" + +[[package]] +name = "windows_x86_64_gnu" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca2b8a661f7628cbd23440e50b05d705db3686f894fc9580820623656af974b1" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "26d41b46a36d453748aedef1486d5c7a85db22e56aff34643984ea85514e94a3" + +[[package]] +name = "windows_x86_64_gnullvm" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7896dbc1f41e08872e9d5e8f8baa8fdd2677f29468c4e156210174edc7f7b953" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.42.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9aec5da331524158c6d1a4ac0ab1541149c0b9505fde06423b02f5ef0106b9f0" + +[[package]] +name = "windows_x86_64_msvc" +version = "0.48.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a515f5799fe4961cb532f983ce2b23082366b898e52ffbce459c86f67c8378a" + +[[package]] +name = "winreg" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "80d0f4e272c85def139476380b12f9ac60926689dd2e01d4923222f40580869d" +dependencies = [ + "winapi", +] diff --git a/mers_libs/http_requests/Cargo.toml b/mers_libs/http_requests_v1/Cargo.toml similarity index 69% rename from mers_libs/http_requests/Cargo.toml rename to mers_libs/http_requests_v1/Cargo.toml index 645f8a3..21be91b 100755 --- a/mers_libs/http_requests/Cargo.toml +++ b/mers_libs/http_requests_v1/Cargo.toml @@ -1,5 +1,5 @@ [package] -name = "http_requests" +name = "http_requests_v1" version = "0.1.0" edition = "2021" @@ -7,3 +7,4 @@ edition = "2021" [dependencies] mers = { path = "../../mers/" } +reqwest = { version = "0.11.16", features = ["blocking"] } diff --git a/mers_libs/http_requests_v1/src/main.rs b/mers_libs/http_requests_v1/src/main.rs new file mode 100755 index 0000000..8f2f7a3 --- /dev/null +++ b/mers_libs/http_requests_v1/src/main.rs @@ -0,0 +1,95 @@ +use mers::{ + libs::inlib::{MyLib, MyLibTask}, + script::{ + val_data::VDataEnum, + val_type::{VSingleType, VType}, + }, +}; + +fn main() { + let (mut my_lib, mut run) = MyLib::new( + "HTTP requests for MERS".to_string(), + (0, 0), + "basic HTTP functionality for mers. warning: this is fully single-threaded.".to_string(), + vec![( + "http_get".to_string(), + vec![VSingleType::String.to()], + VType { + types: vec![ + VSingleType::String, + VSingleType::EnumVariantS( + format!("Err"), + VType { + types: vec![ + VSingleType::EnumVariantS( + format!("ErrBuildingRequest"), + VSingleType::String.to(), + ), + VSingleType::EnumVariantS( + format!("ErrGettingResponseText"), + VSingleType::String.to(), + ), + ], + }, + ), + ], + }, + )], + ); + let mut stdin = std::io::stdin().lock(); + let mut stdout = std::io::stdout().lock(); + let mut err_general = 0; + let mut err_building_request = 0; + let mut err_getting_response_text = 0; + loop { + run = match my_lib.run(run, &mut stdin, &mut stdout) { + MyLibTask::None(v) => v, + MyLibTask::FinishedInit(v) => { + err_general = my_lib.get_enum("Err").unwrap(); + err_building_request = my_lib.get_enum("ErrBuildingRequest").unwrap(); + err_getting_response_text = my_lib.get_enum("ErrGettingResponseText").unwrap(); + v + } + MyLibTask::RunFunction(f) => { + let return_value = match f.function { + 0 => { + // http_get + if let VDataEnum::String(url) = &f.args[0].data { + match reqwest::blocking::get(url) { + Ok(response) => match response.text() { + Ok(text) => VDataEnum::String(text).to(), + Err(e) => VDataEnum::EnumVariant( + err_general, + Box::new( + VDataEnum::EnumVariant( + err_getting_response_text, + Box::new(VDataEnum::String(e.to_string()).to()), + ) + .to(), + ), + ) + .to(), + }, + Err(e) => VDataEnum::EnumVariant( + err_general, + Box::new( + VDataEnum::EnumVariant( + err_building_request, + Box::new(VDataEnum::String(e.to_string()).to()), + ) + .to(), + ), + ) + .to(), + } + } else { + unreachable!() + } + } + _ => unreachable!(), + }; + f.done(&mut stdout, return_value) + } + } + } +} diff --git a/musicdb_remote.txt b/musicdb_remote.txt new file mode 100755 index 0000000..52e6034 --- /dev/null +++ b/musicdb_remote.txt @@ -0,0 +1,205 @@ +lib mers_libs/http_requests +lib mers_libs/gui + +// MusicDB is a private project of mine. +// Basically, a SBC is hooked up to some speakers. +// It has a database of my songs and can play them. +// It can be controlled through HTTP requests, such as +// p- to stop +// p+ to play +// qi to get the queue index / playback position +// l to list all the songs +// ql or qL to list the queue +// ... +// this mers program should work as a very simple gui to remotely control +// the playback of songs. It should be able to add/remove songs to/from the queue, +// to start/stop playback, and to display some information about the current song. + +// the url used to connect to the SBC and use the HTTP api +api_url = "http:\//192.168.2.103:26315/api/raw?" + +// start the GUI +base = gui_init() +set_title("Mers MusicDB Remote") + +playback_controls = base.gui_add(Row: []) +play_button = playback_controls.gui_add(Button: "Play") +stop_button = playback_controls.gui_add(Button: "Stop") + +// these functions abstract away the api interactions +// because they aren't pretty. +// feel free to skip past this section and look at the gui code instead +fn make_api_request(to_api string) { + http_get(api_url.add(to_api)) +} +fn get_queue_index() { + r = make_api_request("qi") + switch! r { + string { + r.regex("[0-9]").assume_no_enum().get(0).assume1().parse_int().assume1() + } + // return the error + Err(ErrBuildingRequest(string)/ErrGettingResponseText(string)) r + } +} +fn get_db_contents() { + // list only 7 = 1 (title) + 2 (artist) + 4 (album) + r = make_api_request("lo7,") + switch! r { + string { + entries = r.regex("#.*:\n.*\n.*\n.*").assume_no_enum() + // initialize the list with a default value + // because mers doesnt know the inner type without it. + db = [[0 "title" "artist" "album"] ...] + &db.remove(0) + for entry entries { + lines = entry.regex(".*") + switch! lines { + [string] { + index_line = &lines.get(0).assume1() + index = index_line.substring(1 index_line.len().sub(1)).parse_int().assume1() + title = &lines.get(1).assume1().substring(1) + artist = &lines.get(2).assume1().substring(1) + album = &lines.get(3).assume1().substring(1) + &db.push([index title artist album]) + } + Err(string) { + println("invalid response from server; 3u123128731289") + exit(1) + } + } + } + db + } + Err(ErrBuildingRequest(string)/ErrGettingResponseText(string)) { + println("couldn't request db from server:") + print(" ") + println(r.to_string()) + exit(1) + } + } +} +fn get_queue() { + r = make_api_request("ql") + switch! r { + string { + queue = [0 ...] + &queue.remove(0) + for index r.regex("[0-9]+[ \n]").assume_no_enum() { + &queue.push(index.substring(0 index.len().sub(1)).parse_int().assume1()) + } + queue + } + Err(ErrBuildingRequest(string)/ErrGettingResponseText(string)) { + println("couldn't request queue from server:") + print(" ") + println(r.to_string()) + exit(1) + } + } +} +fn play() { + r = make_api_request("p+") + switch! r { + // success! but nothing to return. + string [] + // return the error + Err(ErrBuildingRequest(string)/ErrGettingResponseText(string)) r + } +} +fn stop() { + r = make_api_request("p-") + switch! r { + // success! but nothing to return. + string [] + // return the error + Err(ErrBuildingRequest(string)/ErrGettingResponseText(string)) r + } +} +fn queue_song(song_id int) { + make_api_request("q+{0}".format(song_id)) +} + +// fetch the database contents (a list of songs) +database = get_db_contents() + +// this is where all the songs will be displayed. +songs_gui = base.gui_add(Row: []) +queue_list = songs_gui.gui_add(Column: []) +library = songs_gui.gui_add(Column: []) + +limit = 0 // set to 0 to disable library length limit +for entry database { + // by on + song = library.gui_add(Row: []) + song.gui_add(Button: entry.1) + song.gui_add(Text: "by {0} on {1}".format(entry.2 entry.3)) + limit = limit.sub(1) + if limit.eq(0) [[]] else [] +} + +// regularly update the queue +thread(() { + queue_index = get_queue_index().assume_no_enum("if the server isn't reachable, it's ok to crash") + queue_list_inner = queue_list.gui_add(Column: []) + prev_artist = "" + prev_album = "" + for song_id get_queue() { + this_is_playing = if queue_index.eq(0) { queue_index = -1 true } else if queue_index.gt(0) { queue_index = queue_index.sub(1) false } else { false } + song = &database.get(song_id).assume1() + row = queue_list_inner.gui_add(Row: []) + text = if this_is_playing ">> " else "" + text = text.add(song.1) + if prev_artist.eq(song.2) { + if prev_album.eq(song.3) { + } else { + text = text.add("(on {0})".format(song.3)) + } + } else { + text = text.add("(by {0} on {1})".format(song.2 song.3)) + } + row.gui_add(Text: text) + [] + } + sleep(10) + queue_list_inner.gui_remove() +}) + +while { + for event gui_updates() { + switch! event { + ButtonPressed([int]) { + e = event.noenum() + println("Pressed button {0}".format(e.to_string())) + match e { + &e.eq(&play_button) { + println("pressed play.") + play() + } + &e.eq(&stop_button) { + println("pressed stop.") + stop() + } + { + // the button is in a row that is in the library, + // so pop()ing twice gets the library path. + // THIS WILL BREAK IF THE GUI LIBRARY SWITCHES TO IDs INSTEAD OF PATHS! + last = &e.pop().assume1() + slast = &e.pop().assume1() + matches = &e.eq(&library) + &e.push(slast) + &e.push(last) + if matches e else [] + } { + // the second to last part of the path is the row within library, which is also the index in the db + song = &database.get(&e.get(e.len().sub(2)).assume1()).assume1() + println("Added song \"{0}\" to queue.".format(song.1)) + queue_song(song.0) + } + true println("A different button was pressed (unreachable)") + } + } + } + } + [] +} diff --git a/script.txt b/script.txt deleted file mode 100755 index 9efdf91..0000000 --- a/script.txt +++ /dev/null @@ -1,51 +0,0 @@ -lib mers_libs/gui - -base = gui_init() -column = base.gui_add(Column: []) - -text = column.gui_add(Text: "Welcome to MERS GUI!") - -button = column.gui_add(Button: "This is a button.") -second_button = column.gui_add(Button: "This is a second button.") - -text_state = -2 -second_text = column.gui_add(Text: "press the button above to remove this text!") - -while { - for event gui_updates() { - switch! event { - ButtonPressed([int]) { - e = event.noenum() - match e { - &e.eq(&button) println("First button pressed") - &e.eq(&second_button) { - // don't match on text_state because we need to change the original from inside the match statement - state = text_state - match state { - // the first, third, fifth, ... time the button is pressed: remove the text - text_state.mod(2).eq(0) { - if text_state.eq(-2) { - // the first time the button is pressed - text_state = 0 - set_title("keep pressing the button!") - } - second_text.gui_remove() - } - // the 2nd, 4th, 6th, ... time the button is pressed: add the text back - text_state.eq(1) second_text = column.gui_add(Text: "i'm back!") - text_state.eq(3) second_text = column.gui_add(Text: "you can't fully get rid of me!") - true { - second_text = column.gui_add(Text: "i always come back") - // restart (set text_state to 0) - text_state = -1 - } - } - text_state = text_state.add(1) - } - true println("A different button was pressed (unreachable)") - } - } - } - } - [] -}