diff --git a/Cargo.lock b/Cargo.lock index 807c0ec..9f22535 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "aho-corasick" version = "0.7.15" @@ -94,6 +96,19 @@ version = "0.1.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" +[[package]] +name = "chrono" +version = "0.4.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "670ad68c9088c2a963aaa298cb369688cf3f9465ce5e2d4ca10e6e0098a1ce73" +dependencies = [ + "libc", + "num-integer", + "num-traits", + "time 0.1.44", + "winapi", +] + [[package]] name = "clap" version = "2.33.3" @@ -215,7 +230,7 @@ checksum = "fc587bc0ec293155d5bfa6b9891ec18a1e330c234f896ea47fbada4cadbe47e6" dependencies = [ "cfg-if", "libc", - "wasi", + "wasi 0.9.0+wasi-snapshot-preview1", ] [[package]] @@ -227,6 +242,17 @@ dependencies = [ "libc", ] +[[package]] +name = "hostname" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3c731c3e10504cc8ed35cfe2f1db4c9274c3d35fa486e3b31df46f068ef3e867" +dependencies = [ + "libc", + "match_cfg", + "winapi", +] + [[package]] name = "itoa" version = "0.4.6" @@ -254,12 +280,37 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "match_cfg" +version = "0.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ffbee8634e0d45d258acb448e7eaab3fce7a0a467395d4d9f228e3c1f01fb2e4" + [[package]] name = "memchr" version = "2.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ee1c47aaa256ecabcaea351eae4a9b01ef39ed810004e298d2511ed284b1525" +[[package]] +name = "num-integer" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2cc698a63b549a70bc047073d2949cce27cd1c7b0a4a862d08a8031bc2801db" +dependencies = [ + "autocfg", + "num-traits", +] + +[[package]] +name = "num-traits" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9a64b1ec5cda2586e284722486d802acf1f7dbdc623e2bfc57e65ca1cd099290" +dependencies = [ + "autocfg", +] + [[package]] name = "numtoa" version = "0.1.0" @@ -289,9 +340,9 @@ dependencies = [ [[package]] name = "protobuf" -version = "1.7.5" +version = "2.25.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e14ccd6b79ec748412d4f2dfde1a80fa363a67def4062969f8aed3d790a30f28" +checksum = "23129d50f2c9355ced935fce8a08bd706ee2e7ce2b3b33bf61dace0e379ac63a" [[package]] name = "quickcheck" @@ -591,6 +642,17 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "time" +version = "0.1.44" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" +dependencies = [ + "libc", + "wasi 0.10.0+wasi-snapshot-preview1", + "winapi", +] + [[package]] name = "time" version = "0.2.22" @@ -663,11 +725,13 @@ checksum = "b5a972e5669d67ba988ce3dc826706fb0a8b01471c088cb0b6110b805cc36aed" name = "voidmap" version = "1.1.5" dependencies = [ + "chrono", "clap", "clippy", "dirs 3.0.1", "fs2", "getopts", + "hostname", "lazy_static", "libc", "log", @@ -676,7 +740,7 @@ dependencies = [ "rand", "regex", "termion", - "time", + "time 0.2.22", "unicode-segmentation", ] @@ -686,6 +750,12 @@ version = "0.9.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cccddf32554fecc6acb585f82a32a72e28b48f8c4c1883ddfeeeaa96f7d8e519" +[[package]] +name = "wasi" +version = "0.10.0+wasi-snapshot-preview1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a143597ca7c7793eff794def352d41792a93c481eb1042423ff7ff72ba2c31f" + [[package]] name = "wasm-bindgen" version = "0.2.68" diff --git a/Cargo.toml b/Cargo.toml index 6248b4c..9aea4bf 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,13 +24,15 @@ log = "0.4.11" lazy_static = "1.4.0" time = "0.2.22" getopts = "0.2.21" -protobuf = "1" +protobuf = "2" rand = "0.7.3" libc = "0.2.80" regex = "1.4.2" unicode-segmentation = "1.6.0" clippy = { version = "0.0.302", optional = true } fs2 = "0.4.3" +chrono = "0.4" +hostname = "0.3.1" [dev-dependencies] quickcheck = "0.9.2" diff --git a/include/data_model.proto b/include/data_model.proto index 043d5b6..75287f3 100644 --- a/include/data_model.proto +++ b/include/data_model.proto @@ -8,8 +8,14 @@ message Tag { } message Gps { - required float lat = 1; - required float lon = 2; + optional float lat = 1; + optional float lon = 2; +} + +message Date { + required uint32 day = 1; + required uint32 month = 2; + required uint32 year = 3; } message Meta { @@ -18,7 +24,8 @@ message Meta { optional uint64 finish_time = 5; required Gps gps = 3; repeated Tag tags = 4; - optional uint64 due = 6; + optional uint64 OLD_due = 6; + optional Date due_date = 7; } message Node { @@ -31,10 +38,11 @@ message Node { required bool hide_stricken = 7; required uint32 x = 8; required uint32 y = 9; - required bool selected = 10; + optional bool selected = 10; required uint64 parent_id = 11; optional string free_text = 12; required bool auto_arrange = 13; + optional string url = 14; } message Arrow { diff --git a/src/bin/void/main.rs b/src/bin/void/main.rs index c61346a..9ba983b 100644 --- a/src/bin/void/main.rs +++ b/src/bin/void/main.rs @@ -1,9 +1,21 @@ -use fs2::FileExt; -use std::{ffi::OsString, fs::OpenOptions, io::Read}; -use voidmap::{deserialize_screen, init_screen_log, Config, Screen}; +use std::{ + ffi::OsString, + fs::OpenOptions, + io::{Read, Write}, + path::PathBuf, +}; +use voidmap::{deserialize_screen, init_screen_log, Config}; mod cli; +struct DeleteOnDrop(PathBuf); + +impl Drop for DeleteOnDrop { + fn drop(&mut self) { + std::fs::remove_file(&self.0).expect("failed to kill lockfile") + } +} + fn main() { // Initialise the CLI parser let app = cli::create(); @@ -16,15 +28,39 @@ fn main() { .value_of("PATH") .map(OsString::from) .or_else(|| { - dirs::home_dir().and_then(|mut h| { + dirs::home_dir().map(|mut h| { h.push(".void.db"); - Some(h.into_os_string()) + h.into_os_string() }) }) .unwrap(); // load from file if present let mut data = vec![]; + let mut lock_path = PathBuf::new(); + lock_path.push(&path); + let mut file_name = lock_path + .file_name() + .expect("a filename for the db is needed") + .to_owned(); + file_name.push(".lock"); + lock_path.set_file_name(file_name); + + let mut lock_file = OpenOptions::new() + .write(true) + .create_new(true) + .open(&lock_path) + .expect("failed to lock db - is another process using it?"); + write!( + lock_file, + "{}::{}", + hostname::get().unwrap().to_string_lossy(), + std::process::id() + ) + .unwrap(); + lock_file.sync_all().unwrap(); + let guard = DeleteOnDrop(lock_path); + let mut f = OpenOptions::new() .write(true) .read(true) @@ -32,15 +68,11 @@ fn main() { .open(&path) .unwrap(); - // exclusively lock the file - f.try_lock_exclusive() - .unwrap_or_else(|_| panic!("Another `void` process is using this path already!")); - f.read_to_end(&mut data).unwrap(); - let saved_screen = deserialize_screen(data).ok(); + let saved_screen = deserialize_screen(data).expect("invalid screen"); // Initialise the main working screen - let mut screen = saved_screen.unwrap_or_else(Screen::default); + let mut screen = saved_screen/*.unwrap_or_else(Screen::default)*/; screen.work_path = matches .value_of("PATH") @@ -58,4 +90,5 @@ fn main() { screen.config = config; screen.run(); + drop(guard); } diff --git a/src/colors.rs b/src/colors.rs index a238b00..ec0c410 100644 --- a/src/colors.rs +++ b/src/colors.rs @@ -4,14 +4,23 @@ pub fn random_fg_color() -> String { use termion::color::*; let colors: Vec = vec![ format!("{}", Fg(LightGreen)), - // format!("{}", Fg(LightBlack)), + format!("{}", Fg(LightBlack)), format!("{}", Fg(LightRed)), format!("{}", Fg(LightGreen)), - format!("{}", Fg(LightYellow)), - // format!("{}", Fg(LightBlue)), + //format!("{}", Fg(LightYellow)), + format!("{}", Fg(LightBlue)), format!("{}", Fg(LightMagenta)), format!("{}", Fg(LightCyan)), - format!("{}", Fg(LightWhite)), + //format!("{}", Fg(LightWhite)), + format!("{}", Fg(Green)), + format!("{}", Fg(Black)), + format!("{}", Fg(Red)), + format!("{}", Fg(Green)), + format!("{}", Fg(Yellow)), + format!("{}", Fg(Blue)), + format!("{}", Fg(Magenta)), + format!("{}", Fg(Cyan)), + //format!("{}", Fg(White)), ]; colors.choose(&mut rand::thread_rng()).unwrap().clone() } diff --git a/src/config.rs b/src/config.rs index a3adbc5..741ad6d 100644 --- a/src/config.rs +++ b/src/config.rs @@ -39,15 +39,69 @@ pub enum Action { ToggleShowLogs, EnterCmd, FindTask, + MovePasteNode, YankPasteNode, RaiseSelected, LowerSelected, Search, - UndoDelete, + Undo, Help, SelectParent, SelectNextSibling, SelectPrevSibling, + SelectFirstSibling, + SelectLastSibling, + Insert, +} + +impl fmt::Display for Action { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match self { + Action::LeftClick(..) | Action::RightClick(..) | Action::Release(..) => { + write!(f, "Other action") + }, + Action::Arrow => write!(f, "Start or end arrow"), + Action::AutoArrange => write!(f, "Toggle automatic arrangement"), + Action::Char(c) => write!(f, "Input character {}", c), + Action::CreateChild => write!(f, "Create new child node"), + Action::CreateFreeNode => write!(f, "Create new free node"), + Action::CreateSibling => write!(f, "Create new sibling node"), + Action::DeleteSelected => write!(f, "Delete selected node"), + Action::DrillDown => write!(f, "Move down in hierarchy"), + Action::EnterCmd => write!(f, "Enter command"), + Action::EraseChar => write!(f, "Erase character"), + Action::ExecSelected => write!(f, "Execute node content"), + Action::FindTask => write!(f, "Autoassign task"), + Action::Help => write!(f, "Display help"), + Action::Insert => write!(f, "Enter insert mode"), + Action::LowerSelected => write!(f, "Move selected node down"), + Action::MovePasteNode => write!(f, "Move node"), + Action::PopUp => write!(f, "Move up in hierarchy"), + Action::PrefixJump => write!(f, "Select by prefix"), + Action::Quit => write!(f, "Quit void"), + Action::RaiseSelected => write!(f, "Move selected node up"), + Action::Save => write!(f, "Save"), + Action::ScrollDown => write!(f, "Scroll view down"), + Action::ScrollUp => write!(f, "Scroll view up"), + Action::Search => write!(f, "Search for node"), + Action::SelectDown => write!(f, "Select next node down"), + Action::SelectFirstSibling => write!(f, "Select first sibling"), + Action::SelectLastSibling => write!(f, "Select last sibling"), + Action::SelectLeft => write!(f, "Select next node left"), + Action::SelectNextSibling => write!(f, "Select next sibling"), + Action::SelectParent => write!(f, "Select parent node"), + Action::SelectPrevSibling => write!(f, "Select previous sibling"), + Action::SelectRight => write!(f, "Select next node right"), + Action::SelectUp => write!(f, "Select next node up"), + Action::ToggleCollapsed => write!(f, "Toggle collapsing of children"), + Action::ToggleCompleted => write!(f, "Toggle completed"), + Action::ToggleHideCompleted => write!(f, "Toggle hiding of completed tasks"), + Action::ToggleShowLogs => write!(f, "Toggle log"), + Action::Undo => write!(f, "Undo deletion/toggling completed"), + Action::UnselectRet => write!(f, "Unselect node / leave insert mode"), + Action::YankPasteNode => write!(f, "Yank node"), + } + } } fn to_action(input: String) -> Option { @@ -79,14 +133,18 @@ fn to_action(input: String) -> Option { "enter_command" => Some(Action::EnterCmd), "find_task" => Some(Action::FindTask), "yank_paste_node" => Some(Action::YankPasteNode), + "move_paste_node" => Some(Action::MovePasteNode), "raise_selected" => Some(Action::RaiseSelected), "lower_selected" => Some(Action::LowerSelected), "search" => Some(Action::Search), - "undo_delete" => Some(Action::UndoDelete), + "undo" => Some(Action::Undo), "help" => Some(Action::Help), "select_parent" => Some(Action::SelectParent), "select_next_sibling" => Some(Action::SelectNextSibling), "select_prev_sibling" => Some(Action::SelectPrevSibling), + "select_first_sibling" => Some(Action::SelectFirstSibling), + "select_last_sibling" => Some(Action::SelectLastSibling), + "insert" => Some(Action::Insert), _ => None, } } @@ -126,6 +184,12 @@ fn to_key(raw_key: String) -> Option { #[derive(Debug, Clone)] pub struct Config { config: HashMap, + pub modal: bool, + pub stricken: String, + pub collapsed: String, + pub hide_stricken: String, + pub free_text: String, + pub url: String, } impl Default for Config { @@ -164,24 +228,62 @@ impl Default for Config { (Ctrl('g'), Action::RaiseSelected), (Ctrl('d'), Action::LowerSelected), (Ctrl('u'), Action::Search), - (Ctrl('z'), Action::UndoDelete), + (Ctrl('z'), Action::Undo), (Ctrl('?'), Action::Help), (Alt('P'), Action::SelectParent), + (Alt('y'), Action::MovePasteNode), (Alt('n'), Action::SelectNextSibling), (Alt('p'), Action::SelectPrevSibling), + (Alt('k'), Action::SelectFirstSibling), + (Alt('j'), Action::SelectLastSibling), ] .into_iter() .collect(), + modal: false, + stricken: "☠".to_owned(), + collapsed: "⊞".to_owned(), + hide_stricken: "⚔".to_owned(), + free_text: "✏".to_owned(), + url: "".to_owned(), + } + } +} + +struct FmtKey(Key); + +impl fmt::Display for FmtKey { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + match &self.0 { + Key::PageDown => write!(f, "PgDn"), + Key::PageUp => write!(f, "PgUp"), + Key::Delete => write!(f, "Del"), + Key::Alt(c) => write!(f, "A-{}", FmtKey(Key::Char(*c))), + Key::Ctrl(c) => write!(f, "C-{}", FmtKey(Key::Char(*c))), + Key::Char(' ') => write!(f, "Space"), + Key::Char('\n') => write!(f, "Enter"), + Key::Char('\t') => write!(f, "Tab"), + Key::Char(c) => write!(f, "{}", c), + other => fmt::Debug::fmt(other, f), } } } impl fmt::Display for Config { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - writeln!(f, "Configured Hotkeys:").unwrap(); - for (key, action) in &self.config { - writeln!(f, " {:?}: {:?}", action, key).unwrap(); + if self.modal { + writeln!(f, "Modal mode enabled.").unwrap(); } + writeln!(f, "Configured Hotkeys:").unwrap(); + let mut hotkeys = self + .config + .iter() + .map(|(key, action)| format!(" {}: {}", action, FmtKey(*key))) + .collect::>(); + hotkeys.sort(); + hotkeys + .into_iter() + .map(|string| writeln!(f, "{}", string)) + .collect::, _>>()?; Ok(()) } } @@ -201,7 +303,15 @@ impl Config { f.read_to_string(&mut buf)?; let mut config = Config::default(); for (mut line_num, line) in buf.lines().enumerate() { - if line == "" || line.starts_with('#') { + if line.is_empty() || line.starts_with('#') { + continue; + } + if line == "modal" { + config.modal = true; + continue; + } + if line == "no_defaults" { + config.config = HashMap::new(); continue; } @@ -215,21 +325,39 @@ impl Config { return Err(Error::new(ErrorKind::Other, e)); } - let (raw_action, raw_key) = (parts[0], parts[1]); + let (option, param) = (parts[0], parts[1]); + match (option, param) { + ("stricken", p) => { + config.stricken = p.to_owned(); + }, + ("collapsed", p) => { + config.collapsed = p.to_owned(); + }, + ("hide_stricken", p) => { + config.hide_stricken = p.to_owned(); + }, + ("free_text", p) => { + config.free_text = p.to_owned(); + }, + ("url", p) => { + config.url = p.to_owned(); + }, + (raw_action, raw_key) => { + let key_opt = to_key(raw_key.to_owned()); + let action_opt = to_action(raw_action.to_owned()); - let key_opt = to_key(raw_key.to_owned()); - let action_opt = to_action(raw_action.to_owned()); + if key_opt.is_none() || action_opt.is_none() { + let e = format!("invalid config at line {}: {}", line_num, line); + error!("{}", e); + return Err(Error::new(ErrorKind::Other, e)); + } - if key_opt.is_none() || action_opt.is_none() { - let e = format!("invalid config at line {}: {}", line_num, line); - error!("{}", e); - return Err(Error::new(ErrorKind::Other, e)); - } + let key = key_opt.unwrap(); + let action = action_opt.unwrap(); - let key = key_opt.unwrap(); - let action = action_opt.unwrap(); - - config.config.insert(key, action); + config.config.insert(key, action); + }, + } } Ok(config) @@ -244,10 +372,10 @@ impl Config { } else { Some(Action::Char(c)) } - } + }, Event::Mouse(MouseEvent::Press(MouseButton::Right, x, y)) => { Some(Action::RightClick(x, y)) - } + }, Event::Mouse(MouseEvent::Press(_, x, y)) => Some(Action::LeftClick(x, y)), Event::Mouse(MouseEvent::Release(x, y)) => Some(Action::Release(x, y)), Event::Mouse(MouseEvent::Hold(..)) => None, @@ -257,11 +385,11 @@ impl Config { warn!("Weird event {:?}", other); } lookup - } + }, other => { warn!("Unknown event received: {:?}", other); None - } + }, } } } diff --git a/src/meta.rs b/src/meta.rs index 37799ec..56dd548 100644 --- a/src/meta.rs +++ b/src/meta.rs @@ -1,13 +1,14 @@ use std::collections::HashMap; use crate::now; +use chrono::{Date, Local}; #[derive(Debug, Clone)] pub struct Meta { pub ctime: u64, pub mtime: u64, pub finish_time: Option, - pub due: Option, + pub due_date: Option>, pub tags: HashMap, } @@ -18,7 +19,7 @@ impl Default for Meta { ctime: now, mtime: now, finish_time: None, - due: None, + due_date: None, tags: HashMap::new(), } } diff --git a/src/node.rs b/src/node.rs index f8c45a4..50a3946 100644 --- a/src/node.rs +++ b/src/node.rs @@ -15,6 +15,7 @@ pub struct Node { pub free_text: Option, pub color: String, pub auto_arrange: bool, + pub url: Option, } impl Default for Node { @@ -31,6 +32,7 @@ impl Default for Node { hide_stricken: false, meta: Meta::default(), free_text: None, + url: None, color: random_fg_color(), auto_arrange: true, } @@ -38,7 +40,9 @@ impl Default for Node { } impl Node { - pub fn toggle_collapsed(&mut self) { self.collapsed = !self.collapsed; } + pub fn toggle_collapsed(&mut self) { + self.collapsed = !self.collapsed; + } pub fn toggle_stricken(&mut self) { if self.stricken { @@ -49,5 +53,17 @@ impl Node { self.stricken = !self.stricken; } - pub fn toggle_hide_stricken(&mut self) { self.hide_stricken = !self.hide_stricken; } + pub fn toggle_hide_stricken(&mut self) { + self.hide_stricken = !self.hide_stricken; + } + + pub fn new_from(other: &Self) -> Self { + Node { + color: random_fg_color(), + id: 0, + parent_id: 0, + selected: false, + ..other.clone() + } + } } diff --git a/src/pack.rs b/src/pack.rs index 32fc0e0..13bd790 100644 --- a/src/pack.rs +++ b/src/pack.rs @@ -80,7 +80,9 @@ impl Pack { ) } - fn is_leaf(&self) -> bool { self.children.is_none() } + fn is_leaf(&self) -> bool { + self.children.is_none() + } fn can_accomodate(&self, dim: Coords) -> bool { let capacity = self.dim(); diff --git a/src/pb/data_model.rs b/src/pb/data_model.rs index c50060e..d343ad2 100644 --- a/src/pb/data_model.rs +++ b/src/pb/data_model.rs @@ -1,25 +1,27 @@ -// This file is generated. Do not edit +// This file is generated by rust-protobuf 2.25.1. Do not edit // @generated -// https://github.com/Manishearth/rust-clippy/issues/702 +// https://github.com/rust-lang/rust-clippy/issues/702 #![allow(unknown_lints)] -#![allow(bare_trait_objects)] #![allow(clippy::all)] -#![cfg_attr(rustfmt, rustfmt_skip)] +#![allow(unused_attributes)] +#![cfg_attr(rustfmt, rustfmt::skip)] #![allow(box_pointers)] #![allow(dead_code)] +#![allow(missing_docs)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] #![allow(non_upper_case_globals)] #![allow(trivial_casts)] -#![allow(unsafe_code)] #![allow(unused_imports)] #![allow(unused_results)] +//! Generated file from `include/data_model.proto` -use protobuf::Message as Message_imported_for_functions; -use protobuf::ProtobufEnum as ProtobufEnum_imported_for_functions; +/// Generated files are compatible only with the same version +/// of protobuf runtime. +// const _PROTOBUF_VERSION_CHECK: () = ::protobuf::VERSION_2_25_1; #[derive(PartialEq,Clone,Default)] pub struct Tag { @@ -27,30 +29,30 @@ pub struct Tag { key: ::protobuf::SingularField<::std::string::String>, value: ::protobuf::SingularField<::std::string::String>, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Tag {} +impl<'a> ::std::default::Default for &'a Tag { + fn default() -> &'a Tag { + ::default_instance() + } +} impl Tag { pub fn new() -> Tag { ::std::default::Default::default() } - pub fn default_instance() -> &'static Tag { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Tag, - }; - unsafe { - instance.get(Tag::new) - } - } - // required string key = 1; + + pub fn get_key(&self) -> &str { + match self.key.as_ref() { + Some(v) => &v, + None => "", + } + } pub fn clear_key(&mut self) { self.key.clear(); } @@ -69,7 +71,7 @@ impl Tag { pub fn mut_key(&mut self) -> &mut ::std::string::String { if self.key.is_none() { self.key.set_default(); - }; + } self.key.as_mut().unwrap() } @@ -78,23 +80,15 @@ impl Tag { self.key.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_key(&self) -> &str { - match self.key.as_ref() { + // required string value = 2; + + + pub fn get_value(&self) -> &str { + match self.value.as_ref() { Some(v) => &v, None => "", } } - - fn get_key_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { - &self.key - } - - fn mut_key_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { - &mut self.key - } - - // required string value = 2; - pub fn clear_value(&mut self) { self.value.clear(); } @@ -113,7 +107,7 @@ impl Tag { pub fn mut_value(&mut self) -> &mut ::std::string::String { if self.value.is_none() { self.value.set_default(); - }; + } self.value.as_mut().unwrap() } @@ -121,35 +115,20 @@ impl Tag { pub fn take_value(&mut self) -> ::std::string::String { self.value.take().unwrap_or_else(|| ::std::string::String::new()) } - - pub fn get_value(&self) -> &str { - match self.value.as_ref() { - Some(v) => &v, - None => "", - } - } - - fn get_value_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { - &self.value - } - - fn mut_value_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { - &mut self.value - } } impl ::protobuf::Message for Tag { fn is_initialized(&self) -> bool { if self.key.is_none() { return false; - }; + } if self.value.is_none() { return false; - }; + } true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -171,24 +150,24 @@ impl ::protobuf::Message for Tag { #[allow(unused_variables)] fn compute_size(&self) -> u32 { let mut my_size = 0; - if let Some(v) = self.key.as_ref() { + if let Some(ref v) = self.key.as_ref() { my_size += ::protobuf::rt::string_size(1, &v); - }; - if let Some(v) = self.value.as_ref() { + } + if let Some(ref v) = self.value.as_ref() { my_size += ::protobuf::rt::string_size(2, &v); - }; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { - if let Some(v) = self.key.as_ref() { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let Some(ref v) = self.key.as_ref() { os.write_string(1, &v)?; - }; - if let Some(v) = self.value.as_ref() { + } + if let Some(ref v) = self.value.as_ref() { os.write_string(2, &v)?; - }; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -205,65 +184,69 @@ impl ::protobuf::Message for Tag { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Tag { fn new() -> Tag { Tag::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "key", - Tag::get_key_for_reflect, - Tag::mut_key_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "value", - Tag::get_value_for_reflect, - Tag::mut_value_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Tag", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "key", + |m: &Tag| { &m.key }, + |m: &mut Tag| { &mut m.key }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "value", + |m: &Tag| { &m.value }, + |m: &mut Tag| { &mut m.value }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Tag", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Tag { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Tag::new) } } impl ::protobuf::Clear for Tag { fn clear(&mut self) { - self.clear_key(); - self.clear_value(); + self.key.clear(); + self.value.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Tag { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Tag { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -273,30 +256,27 @@ pub struct Gps { lat: ::std::option::Option, lon: ::std::option::Option, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Gps {} +impl<'a> ::std::default::Default for &'a Gps { + fn default() -> &'a Gps { + ::default_instance() + } +} impl Gps { pub fn new() -> Gps { ::std::default::Default::default() } - pub fn default_instance() -> &'static Gps { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Gps, - }; - unsafe { - instance.get(Gps::new) - } - } + // optional float lat = 1; - // required float lat = 1; + pub fn get_lat(&self) -> f32 { + self.lat.unwrap_or(0.) + } pub fn clear_lat(&mut self) { self.lat = ::std::option::Option::None; } @@ -310,20 +290,12 @@ impl Gps { self.lat = ::std::option::Option::Some(v); } - pub fn get_lat(&self) -> f32 { - self.lat.unwrap_or(0.) - } + // optional float lon = 2; - fn get_lat_for_reflect(&self) -> &::std::option::Option { - &self.lat - } - fn mut_lat_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.lat + pub fn get_lon(&self) -> f32 { + self.lon.unwrap_or(0.) } - - // required float lon = 2; - pub fn clear_lon(&mut self) { self.lon = ::std::option::Option::None; } @@ -336,46 +308,28 @@ impl Gps { pub fn set_lon(&mut self, v: f32) { self.lon = ::std::option::Option::Some(v); } - - pub fn get_lon(&self) -> f32 { - self.lon.unwrap_or(0.) - } - - fn get_lon_for_reflect(&self) -> &::std::option::Option { - &self.lon - } - - fn mut_lon_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.lon - } } impl ::protobuf::Message for Gps { fn is_initialized(&self) -> bool { - if self.lat.is_none() { - return false; - }; - if self.lon.is_none() { - return false; - }; true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { if wire_type != ::protobuf::wire_format::WireTypeFixed32 { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_float()?; self.lat = ::std::option::Option::Some(tmp); }, 2 => { if wire_type != ::protobuf::wire_format::WireTypeFixed32 { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_float()?; self.lon = ::std::option::Option::Some(tmp); }, @@ -393,22 +347,22 @@ impl ::protobuf::Message for Gps { let mut my_size = 0; if let Some(v) = self.lat { my_size += 5; - }; + } if let Some(v) = self.lon { my_size += 5; - }; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(v) = self.lat { os.write_float(1, v)?; - }; + } if let Some(v) = self.lon { os.write_float(2, v)?; - }; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -425,65 +379,312 @@ impl ::protobuf::Message for Gps { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Gps { fn new() -> Gps { Gps::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( - "lat", - Gps::get_lat_for_reflect, - Gps::mut_lat_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( - "lon", - Gps::get_lon_for_reflect, - Gps::mut_lon_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Gps", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( + "lat", + |m: &Gps| { &m.lat }, + |m: &mut Gps| { &mut m.lat }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeFloat>( + "lon", + |m: &Gps| { &m.lon }, + |m: &mut Gps| { &mut m.lon }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Gps", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Gps { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Gps::new) } } impl ::protobuf::Clear for Gps { fn clear(&mut self) { - self.clear_lat(); - self.clear_lon(); + self.lat = ::std::option::Option::None; + self.lon = ::std::option::Option::None; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Gps { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Gps { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) + } +} + +#[derive(PartialEq,Clone,Default)] +pub struct Date { + // message fields + day: ::std::option::Option, + month: ::std::option::Option, + year: ::std::option::Option, + // special fields + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, +} + +impl<'a> ::std::default::Default for &'a Date { + fn default() -> &'a Date { + ::default_instance() + } +} + +impl Date { + pub fn new() -> Date { + ::std::default::Default::default() + } + + // required uint32 day = 1; + + + pub fn get_day(&self) -> u32 { + self.day.unwrap_or(0) + } + pub fn clear_day(&mut self) { + self.day = ::std::option::Option::None; + } + + pub fn has_day(&self) -> bool { + self.day.is_some() + } + + // Param is passed by value, moved + pub fn set_day(&mut self, v: u32) { + self.day = ::std::option::Option::Some(v); + } + + // required uint32 month = 2; + + + pub fn get_month(&self) -> u32 { + self.month.unwrap_or(0) + } + pub fn clear_month(&mut self) { + self.month = ::std::option::Option::None; + } + + pub fn has_month(&self) -> bool { + self.month.is_some() + } + + // Param is passed by value, moved + pub fn set_month(&mut self, v: u32) { + self.month = ::std::option::Option::Some(v); + } + + // required uint32 year = 3; + + + pub fn get_year(&self) -> u32 { + self.year.unwrap_or(0) + } + pub fn clear_year(&mut self) { + self.year = ::std::option::Option::None; + } + + pub fn has_year(&self) -> bool { + self.year.is_some() + } + + // Param is passed by value, moved + pub fn set_year(&mut self, v: u32) { + self.year = ::std::option::Option::Some(v); + } +} + +impl ::protobuf::Message for Date { + fn is_initialized(&self) -> bool { + if self.day.is_none() { + return false; + } + if self.month.is_none() { + return false; + } + if self.year.is_none() { + return false; + } + true + } + + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { + while !is.eof()? { + let (field_number, wire_type) = is.read_tag_unpack()?; + match field_number { + 1 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.day = ::std::option::Option::Some(tmp); + }, + 2 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.month = ::std::option::Option::Some(tmp); + }, + 3 => { + if wire_type != ::protobuf::wire_format::WireTypeVarint { + return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); + } + let tmp = is.read_uint32()?; + self.year = ::std::option::Option::Some(tmp); + }, + _ => { + ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; + }, + }; + } + ::std::result::Result::Ok(()) + } + + // Compute sizes of nested messages + #[allow(unused_variables)] + fn compute_size(&self) -> u32 { + let mut my_size = 0; + if let Some(v) = self.day { + my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.month { + my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); + } + if let Some(v) = self.year { + my_size += ::protobuf::rt::value_size(3, v, ::protobuf::wire_format::WireTypeVarint); + } + my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); + self.cached_size.set(my_size); + my_size + } + + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { + if let Some(v) = self.day { + os.write_uint32(1, v)?; + } + if let Some(v) = self.month { + os.write_uint32(2, v)?; + } + if let Some(v) = self.year { + os.write_uint32(3, v)?; + } + os.write_unknown_fields(self.get_unknown_fields())?; + ::std::result::Result::Ok(()) + } + + fn get_cached_size(&self) -> u32 { + self.cached_size.get() + } + + fn get_unknown_fields(&self) -> &::protobuf::UnknownFields { + &self.unknown_fields + } + + fn mut_unknown_fields(&mut self) -> &mut ::protobuf::UnknownFields { + &mut self.unknown_fields + } + + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self + } + + fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { + Self::descriptor_static() + } + + fn new() -> Date { + Date::new() + } + + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "day", + |m: &Date| { &m.day }, + |m: &mut Date| { &mut m.day }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "month", + |m: &Date| { &m.month }, + |m: &mut Date| { &mut m.month }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "year", + |m: &Date| { &m.year }, + |m: &mut Date| { &mut m.year }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Date", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Date { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Date::new) + } +} + +impl ::protobuf::Clear for Date { + fn clear(&mut self) { + self.day = ::std::option::Option::None; + self.month = ::std::option::Option::None; + self.year = ::std::option::Option::None; + self.unknown_fields.clear(); + } +} + +impl ::std::fmt::Debug for Date { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { + ::protobuf::text_format::fmt(self, f) + } +} + +impl ::protobuf::reflect::ProtobufValue for Date { + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -493,34 +694,32 @@ pub struct Meta { ctime: ::std::option::Option, mtime: ::std::option::Option, finish_time: ::std::option::Option, - gps: ::protobuf::SingularPtrField, - tags: ::protobuf::RepeatedField, - due: ::std::option::Option, + pub gps: ::protobuf::SingularPtrField, + pub tags: ::protobuf::RepeatedField, + OLD_due: ::std::option::Option, + pub due_date: ::protobuf::SingularPtrField, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Meta {} +impl<'a> ::std::default::Default for &'a Meta { + fn default() -> &'a Meta { + ::default_instance() + } +} impl Meta { pub fn new() -> Meta { ::std::default::Default::default() } - pub fn default_instance() -> &'static Meta { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Meta, - }; - unsafe { - instance.get(Meta::new) - } - } - // required uint64 ctime = 1; + + pub fn get_ctime(&self) -> u64 { + self.ctime.unwrap_or(0) + } pub fn clear_ctime(&mut self) { self.ctime = ::std::option::Option::None; } @@ -534,20 +733,12 @@ impl Meta { self.ctime = ::std::option::Option::Some(v); } - pub fn get_ctime(&self) -> u64 { - self.ctime.unwrap_or(0) - } + // required uint64 mtime = 2; - fn get_ctime_for_reflect(&self) -> &::std::option::Option { - &self.ctime - } - fn mut_ctime_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.ctime + pub fn get_mtime(&self) -> u64 { + self.mtime.unwrap_or(0) } - - // required uint64 mtime = 2; - pub fn clear_mtime(&mut self) { self.mtime = ::std::option::Option::None; } @@ -561,20 +752,12 @@ impl Meta { self.mtime = ::std::option::Option::Some(v); } - pub fn get_mtime(&self) -> u64 { - self.mtime.unwrap_or(0) - } + // optional uint64 finish_time = 5; - fn get_mtime_for_reflect(&self) -> &::std::option::Option { - &self.mtime - } - fn mut_mtime_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.mtime + pub fn get_finish_time(&self) -> u64 { + self.finish_time.unwrap_or(0) } - - // optional uint64 finish_time = 5; - pub fn clear_finish_time(&mut self) { self.finish_time = ::std::option::Option::None; } @@ -588,20 +771,12 @@ impl Meta { self.finish_time = ::std::option::Option::Some(v); } - pub fn get_finish_time(&self) -> u64 { - self.finish_time.unwrap_or(0) - } + // required .void.Gps gps = 3; - fn get_finish_time_for_reflect(&self) -> &::std::option::Option { - &self.finish_time - } - fn mut_finish_time_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.finish_time + pub fn get_gps(&self) -> &Gps { + self.gps.as_ref().unwrap_or_else(|| ::default_instance()) } - - // required .void.Gps gps = 3; - pub fn clear_gps(&mut self) { self.gps.clear(); } @@ -620,7 +795,7 @@ impl Meta { pub fn mut_gps(&mut self) -> &mut Gps { if self.gps.is_none() { self.gps.set_default(); - }; + } self.gps.as_mut().unwrap() } @@ -629,20 +804,12 @@ impl Meta { self.gps.take().unwrap_or_else(|| Gps::new()) } - pub fn get_gps(&self) -> &Gps { - self.gps.as_ref().unwrap_or_else(|| Gps::default_instance()) - } + // repeated .void.Tag tags = 4; - fn get_gps_for_reflect(&self) -> &::protobuf::SingularPtrField { - &self.gps - } - fn mut_gps_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { - &mut self.gps + pub fn get_tags(&self) -> &[Tag] { + &self.tags } - - // repeated .void.Tag tags = 4; - pub fn clear_tags(&mut self) { self.tags.clear(); } @@ -662,43 +829,56 @@ impl Meta { ::std::mem::replace(&mut self.tags, ::protobuf::RepeatedField::new()) } - pub fn get_tags(&self) -> &[Tag] { - &self.tags + // optional uint64 OLD_due = 6; + + + pub fn get_OLD_due(&self) -> u64 { + self.OLD_due.unwrap_or(0) + } + pub fn clear_OLD_due(&mut self) { + self.OLD_due = ::std::option::Option::None; } - fn get_tags_for_reflect(&self) -> &::protobuf::RepeatedField { - &self.tags + pub fn has_OLD_due(&self) -> bool { + self.OLD_due.is_some() } - fn mut_tags_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.tags + // Param is passed by value, moved + pub fn set_OLD_due(&mut self, v: u64) { + self.OLD_due = ::std::option::Option::Some(v); } - // optional uint64 due = 6; + // optional .void.Date due_date = 7; - pub fn clear_due(&mut self) { - self.due = ::std::option::Option::None; - } - pub fn has_due(&self) -> bool { - self.due.is_some() + pub fn get_due_date(&self) -> &Date { + self.due_date.as_ref().unwrap_or_else(|| ::default_instance()) + } + pub fn clear_due_date(&mut self) { + self.due_date.clear(); } - // Param is passed by value, moved - pub fn set_due(&mut self, v: u64) { - self.due = ::std::option::Option::Some(v); + pub fn has_due_date(&self) -> bool { + self.due_date.is_some() } - pub fn get_due(&self) -> u64 { - self.due.unwrap_or(0) + // Param is passed by value, moved + pub fn set_due_date(&mut self, v: Date) { + self.due_date = ::protobuf::SingularPtrField::some(v); } - fn get_due_for_reflect(&self) -> &::std::option::Option { - &self.due + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_due_date(&mut self) -> &mut Date { + if self.due_date.is_none() { + self.due_date.set_default(); + } + self.due_date.as_mut().unwrap() } - fn mut_due_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.due + // Take field + pub fn take_due_date(&mut self) -> Date { + self.due_date.take().unwrap_or_else(|| Date::new()) } } @@ -706,38 +886,53 @@ impl ::protobuf::Message for Meta { fn is_initialized(&self) -> bool { if self.ctime.is_none() { return false; - }; + } if self.mtime.is_none() { return false; - }; + } if self.gps.is_none() { return false; + } + for v in &self.gps { + if !v.is_initialized() { + return false; + } + }; + for v in &self.tags { + if !v.is_initialized() { + return false; + } + }; + for v in &self.due_date { + if !v.is_initialized() { + return false; + } }; true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.ctime = ::std::option::Option::Some(tmp); }, 2 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.mtime = ::std::option::Option::Some(tmp); }, 5 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.finish_time = ::std::option::Option::Some(tmp); }, @@ -750,9 +945,12 @@ impl ::protobuf::Message for Meta { 6 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; - self.due = ::std::option::Option::Some(tmp); + self.OLD_due = ::std::option::Option::Some(tmp); + }, + 7 => { + ::protobuf::rt::read_singular_message_into(wire_type, is, &mut self.due_date)?; }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; @@ -768,52 +966,61 @@ impl ::protobuf::Message for Meta { let mut my_size = 0; if let Some(v) = self.ctime { my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - }; + } if let Some(v) = self.mtime { my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); - }; + } if let Some(v) = self.finish_time { my_size += ::protobuf::rt::value_size(5, v, ::protobuf::wire_format::WireTypeVarint); - }; - if let Some(v) = self.gps.as_ref() { + } + if let Some(ref v) = self.gps.as_ref() { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; + } for value in &self.tags { let len = value.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; }; - if let Some(v) = self.due { + if let Some(v) = self.OLD_due { my_size += ::protobuf::rt::value_size(6, v, ::protobuf::wire_format::WireTypeVarint); - }; + } + if let Some(ref v) = self.due_date.as_ref() { + let len = v.compute_size(); + my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(v) = self.ctime { os.write_uint64(1, v)?; - }; + } if let Some(v) = self.mtime { os.write_uint64(2, v)?; - }; + } if let Some(v) = self.finish_time { os.write_uint64(5, v)?; - }; - if let Some(v) = self.gps.as_ref() { + } + if let Some(ref v) = self.gps.as_ref() { os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; - }; + } for v in &self.tags { os.write_tag(4, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; }; - if let Some(v) = self.due { + if let Some(v) = self.OLD_due { os.write_uint64(6, v)?; - }; + } + if let Some(ref v) = self.due_date.as_ref() { + os.write_tag(7, ::protobuf::wire_format::WireTypeLengthDelimited)?; + os.write_raw_varint32(v.get_cached_size())?; + v.write_to_with_cached_sizes(os)?; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -830,89 +1037,99 @@ impl ::protobuf::Message for Meta { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Meta { fn new() -> Meta { Meta::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "ctime", - Meta::get_ctime_for_reflect, - Meta::mut_ctime_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "mtime", - Meta::get_mtime_for_reflect, - Meta::mut_mtime_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "finish_time", - Meta::get_finish_time_for_reflect, - Meta::mut_finish_time_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "gps", - Meta::get_gps_for_reflect, - Meta::mut_gps_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "tags", - Meta::get_tags_for_reflect, - Meta::mut_tags_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "due", - Meta::get_due_for_reflect, - Meta::mut_due_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Meta", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "ctime", + |m: &Meta| { &m.ctime }, + |m: &mut Meta| { &mut m.ctime }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "mtime", + |m: &Meta| { &m.mtime }, + |m: &mut Meta| { &mut m.mtime }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "finish_time", + |m: &Meta| { &m.finish_time }, + |m: &mut Meta| { &mut m.finish_time }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "gps", + |m: &Meta| { &m.gps }, + |m: &mut Meta| { &mut m.gps }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "tags", + |m: &Meta| { &m.tags }, + |m: &mut Meta| { &mut m.tags }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "OLD_due", + |m: &Meta| { &m.OLD_due }, + |m: &mut Meta| { &mut m.OLD_due }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "due_date", + |m: &Meta| { &m.due_date }, + |m: &mut Meta| { &mut m.due_date }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Meta", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Meta { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Meta::new) } } impl ::protobuf::Clear for Meta { fn clear(&mut self) { - self.clear_ctime(); - self.clear_mtime(); - self.clear_finish_time(); - self.clear_gps(); - self.clear_tags(); - self.clear_due(); + self.ctime = ::std::option::Option::None; + self.mtime = ::std::option::Option::None; + self.finish_time = ::std::option::Option::None; + self.gps.clear(); + self.tags.clear(); + self.OLD_due = ::std::option::Option::None; + self.due_date.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Meta { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Meta { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -920,9 +1137,9 @@ impl ::protobuf::reflect::ProtobufValue for Meta { pub struct Node { // message fields id: ::std::option::Option, - meta: ::protobuf::SingularPtrField, + pub meta: ::protobuf::SingularPtrField, text: ::protobuf::SingularField<::std::string::String>, - children: ::std::vec::Vec, + pub children: ::std::vec::Vec, collapsed: ::std::option::Option, stricken: ::std::option::Option, hide_stricken: ::std::option::Option, @@ -932,31 +1149,29 @@ pub struct Node { parent_id: ::std::option::Option, free_text: ::protobuf::SingularField<::std::string::String>, auto_arrange: ::std::option::Option, + url: ::protobuf::SingularField<::std::string::String>, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Node {} +impl<'a> ::std::default::Default for &'a Node { + fn default() -> &'a Node { + ::default_instance() + } +} impl Node { pub fn new() -> Node { ::std::default::Default::default() } - pub fn default_instance() -> &'static Node { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Node, - }; - unsafe { - instance.get(Node::new) - } - } - // required uint64 id = 1; + + pub fn get_id(&self) -> u64 { + self.id.unwrap_or(0) + } pub fn clear_id(&mut self) { self.id = ::std::option::Option::None; } @@ -970,20 +1185,12 @@ impl Node { self.id = ::std::option::Option::Some(v); } - pub fn get_id(&self) -> u64 { - self.id.unwrap_or(0) - } + // required .void.Meta meta = 2; - fn get_id_for_reflect(&self) -> &::std::option::Option { - &self.id - } - fn mut_id_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.id + pub fn get_meta(&self) -> &Meta { + self.meta.as_ref().unwrap_or_else(|| ::default_instance()) } - - // required .void.Meta meta = 2; - pub fn clear_meta(&mut self) { self.meta.clear(); } @@ -1002,7 +1209,7 @@ impl Node { pub fn mut_meta(&mut self) -> &mut Meta { if self.meta.is_none() { self.meta.set_default(); - }; + } self.meta.as_mut().unwrap() } @@ -1011,20 +1218,15 @@ impl Node { self.meta.take().unwrap_or_else(|| Meta::new()) } - pub fn get_meta(&self) -> &Meta { - self.meta.as_ref().unwrap_or_else(|| Meta::default_instance()) - } + // required string text = 3; - fn get_meta_for_reflect(&self) -> &::protobuf::SingularPtrField { - &self.meta - } - fn mut_meta_for_reflect(&mut self) -> &mut ::protobuf::SingularPtrField { - &mut self.meta + pub fn get_text(&self) -> &str { + match self.text.as_ref() { + Some(v) => &v, + None => "", + } } - - // required string text = 3; - pub fn clear_text(&mut self) { self.text.clear(); } @@ -1043,7 +1245,7 @@ impl Node { pub fn mut_text(&mut self) -> &mut ::std::string::String { if self.text.is_none() { self.text.set_default(); - }; + } self.text.as_mut().unwrap() } @@ -1052,23 +1254,12 @@ impl Node { self.text.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_text(&self) -> &str { - match self.text.as_ref() { - Some(v) => &v, - None => "", - } - } + // repeated uint64 children = 4; - fn get_text_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { - &self.text - } - fn mut_text_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { - &mut self.text + pub fn get_children(&self) -> &[u64] { + &self.children } - - // repeated uint64 children = 4; - pub fn clear_children(&mut self) { self.children.clear(); } @@ -1088,20 +1279,12 @@ impl Node { ::std::mem::replace(&mut self.children, ::std::vec::Vec::new()) } - pub fn get_children(&self) -> &[u64] { - &self.children - } + // required bool collapsed = 5; - fn get_children_for_reflect(&self) -> &::std::vec::Vec { - &self.children - } - fn mut_children_for_reflect(&mut self) -> &mut ::std::vec::Vec { - &mut self.children + pub fn get_collapsed(&self) -> bool { + self.collapsed.unwrap_or(false) } - - // required bool collapsed = 5; - pub fn clear_collapsed(&mut self) { self.collapsed = ::std::option::Option::None; } @@ -1115,20 +1298,12 @@ impl Node { self.collapsed = ::std::option::Option::Some(v); } - pub fn get_collapsed(&self) -> bool { - self.collapsed.unwrap_or(false) - } + // required bool stricken = 6; - fn get_collapsed_for_reflect(&self) -> &::std::option::Option { - &self.collapsed - } - fn mut_collapsed_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.collapsed + pub fn get_stricken(&self) -> bool { + self.stricken.unwrap_or(false) } - - // required bool stricken = 6; - pub fn clear_stricken(&mut self) { self.stricken = ::std::option::Option::None; } @@ -1142,20 +1317,12 @@ impl Node { self.stricken = ::std::option::Option::Some(v); } - pub fn get_stricken(&self) -> bool { - self.stricken.unwrap_or(false) - } + // required bool hide_stricken = 7; - fn get_stricken_for_reflect(&self) -> &::std::option::Option { - &self.stricken - } - fn mut_stricken_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.stricken + pub fn get_hide_stricken(&self) -> bool { + self.hide_stricken.unwrap_or(false) } - - // required bool hide_stricken = 7; - pub fn clear_hide_stricken(&mut self) { self.hide_stricken = ::std::option::Option::None; } @@ -1169,20 +1336,12 @@ impl Node { self.hide_stricken = ::std::option::Option::Some(v); } - pub fn get_hide_stricken(&self) -> bool { - self.hide_stricken.unwrap_or(false) - } + // required uint32 x = 8; - fn get_hide_stricken_for_reflect(&self) -> &::std::option::Option { - &self.hide_stricken - } - fn mut_hide_stricken_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.hide_stricken + pub fn get_x(&self) -> u32 { + self.x.unwrap_or(0) } - - // required uint32 x = 8; - pub fn clear_x(&mut self) { self.x = ::std::option::Option::None; } @@ -1196,20 +1355,12 @@ impl Node { self.x = ::std::option::Option::Some(v); } - pub fn get_x(&self) -> u32 { - self.x.unwrap_or(0) - } + // required uint32 y = 9; - fn get_x_for_reflect(&self) -> &::std::option::Option { - &self.x - } - fn mut_x_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.x + pub fn get_y(&self) -> u32 { + self.y.unwrap_or(0) } - - // required uint32 y = 9; - pub fn clear_y(&mut self) { self.y = ::std::option::Option::None; } @@ -1223,20 +1374,12 @@ impl Node { self.y = ::std::option::Option::Some(v); } - pub fn get_y(&self) -> u32 { - self.y.unwrap_or(0) - } + // optional bool selected = 10; - fn get_y_for_reflect(&self) -> &::std::option::Option { - &self.y - } - fn mut_y_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.y + pub fn get_selected(&self) -> bool { + self.selected.unwrap_or(false) } - - // required bool selected = 10; - pub fn clear_selected(&mut self) { self.selected = ::std::option::Option::None; } @@ -1247,23 +1390,15 @@ impl Node { // Param is passed by value, moved pub fn set_selected(&mut self, v: bool) { - self.selected = ::std::option::Option::Some(v); - } - - pub fn get_selected(&self) -> bool { - self.selected.unwrap_or(false) - } - - fn get_selected_for_reflect(&self) -> &::std::option::Option { - &self.selected - } - - fn mut_selected_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.selected + self.selected = ::std::option::Option::Some(v); } // required uint64 parent_id = 11; + + pub fn get_parent_id(&self) -> u64 { + self.parent_id.unwrap_or(0) + } pub fn clear_parent_id(&mut self) { self.parent_id = ::std::option::Option::None; } @@ -1277,20 +1412,15 @@ impl Node { self.parent_id = ::std::option::Option::Some(v); } - pub fn get_parent_id(&self) -> u64 { - self.parent_id.unwrap_or(0) - } + // optional string free_text = 12; - fn get_parent_id_for_reflect(&self) -> &::std::option::Option { - &self.parent_id - } - fn mut_parent_id_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.parent_id + pub fn get_free_text(&self) -> &str { + match self.free_text.as_ref() { + Some(v) => &v, + None => "", + } } - - // optional string free_text = 12; - pub fn clear_free_text(&mut self) { self.free_text.clear(); } @@ -1309,7 +1439,7 @@ impl Node { pub fn mut_free_text(&mut self) -> &mut ::std::string::String { if self.free_text.is_none() { self.free_text.set_default(); - }; + } self.free_text.as_mut().unwrap() } @@ -1318,23 +1448,12 @@ impl Node { self.free_text.take().unwrap_or_else(|| ::std::string::String::new()) } - pub fn get_free_text(&self) -> &str { - match self.free_text.as_ref() { - Some(v) => &v, - None => "", - } - } + // required bool auto_arrange = 13; - fn get_free_text_for_reflect(&self) -> &::protobuf::SingularField<::std::string::String> { - &self.free_text - } - fn mut_free_text_for_reflect(&mut self) -> &mut ::protobuf::SingularField<::std::string::String> { - &mut self.free_text + pub fn get_auto_arrange(&self) -> bool { + self.auto_arrange.unwrap_or(false) } - - // required bool auto_arrange = 13; - pub fn clear_auto_arrange(&mut self) { self.auto_arrange = ::std::option::Option::None; } @@ -1348,16 +1467,40 @@ impl Node { self.auto_arrange = ::std::option::Option::Some(v); } - pub fn get_auto_arrange(&self) -> bool { - self.auto_arrange.unwrap_or(false) + // optional string url = 14; + + + pub fn get_url(&self) -> &str { + match self.url.as_ref() { + Some(v) => &v, + None => "", + } + } + pub fn clear_url(&mut self) { + self.url.clear(); + } + + pub fn has_url(&self) -> bool { + self.url.is_some() + } + + // Param is passed by value, moved + pub fn set_url(&mut self, v: ::std::string::String) { + self.url = ::protobuf::SingularField::some(v); } - fn get_auto_arrange_for_reflect(&self) -> &::std::option::Option { - &self.auto_arrange + // Mutable pointer to the field. + // If field is not initialized, it is initialized with default value first. + pub fn mut_url(&mut self) -> &mut ::std::string::String { + if self.url.is_none() { + self.url.set_default(); + } + self.url.as_mut().unwrap() } - fn mut_auto_arrange_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.auto_arrange + // Take field + pub fn take_url(&mut self) -> ::std::string::String { + self.url.take().unwrap_or_else(|| ::std::string::String::new()) } } @@ -1365,48 +1508,50 @@ impl ::protobuf::Message for Node { fn is_initialized(&self) -> bool { if self.id.is_none() { return false; - }; + } if self.meta.is_none() { return false; - }; + } if self.text.is_none() { return false; - }; + } if self.collapsed.is_none() { return false; - }; + } if self.stricken.is_none() { return false; - }; + } if self.hide_stricken.is_none() { return false; - }; + } if self.x.is_none() { return false; - }; + } if self.y.is_none() { return false; - }; - if self.selected.is_none() { - return false; - }; + } if self.parent_id.is_none() { return false; - }; + } if self.auto_arrange.is_none() { return false; + } + for v in &self.meta { + if !v.is_initialized() { + return false; + } }; true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.id = ::std::option::Option::Some(tmp); }, @@ -1422,49 +1567,49 @@ impl ::protobuf::Message for Node { 5 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_bool()?; self.collapsed = ::std::option::Option::Some(tmp); }, 6 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_bool()?; self.stricken = ::std::option::Option::Some(tmp); }, 7 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_bool()?; self.hide_stricken = ::std::option::Option::Some(tmp); }, 8 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint32()?; self.x = ::std::option::Option::Some(tmp); }, 9 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint32()?; self.y = ::std::option::Option::Some(tmp); }, 10 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_bool()?; self.selected = ::std::option::Option::Some(tmp); }, 11 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.parent_id = ::std::option::Option::Some(tmp); }, @@ -1474,10 +1619,13 @@ impl ::protobuf::Message for Node { 13 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_bool()?; self.auto_arrange = ::std::option::Option::Some(tmp); }, + 14 => { + ::protobuf::rt::read_singular_string_into(wire_type, is, &mut self.url)?; + }, _ => { ::protobuf::rt::read_unknown_or_skip_group(field_number, wire_type, is, self.mut_unknown_fields())?; }, @@ -1492,91 +1640,97 @@ impl ::protobuf::Message for Node { let mut my_size = 0; if let Some(v) = self.id { my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - }; - if let Some(v) = self.meta.as_ref() { + } + if let Some(ref v) = self.meta.as_ref() { let len = v.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; - }; - if let Some(v) = self.text.as_ref() { + } + if let Some(ref v) = self.text.as_ref() { my_size += ::protobuf::rt::string_size(3, &v); - }; + } for value in &self.children { my_size += ::protobuf::rt::value_size(4, *value, ::protobuf::wire_format::WireTypeVarint); }; if let Some(v) = self.collapsed { my_size += 2; - }; + } if let Some(v) = self.stricken { my_size += 2; - }; + } if let Some(v) = self.hide_stricken { my_size += 2; - }; + } if let Some(v) = self.x { my_size += ::protobuf::rt::value_size(8, v, ::protobuf::wire_format::WireTypeVarint); - }; + } if let Some(v) = self.y { my_size += ::protobuf::rt::value_size(9, v, ::protobuf::wire_format::WireTypeVarint); - }; + } if let Some(v) = self.selected { my_size += 2; - }; + } if let Some(v) = self.parent_id { my_size += ::protobuf::rt::value_size(11, v, ::protobuf::wire_format::WireTypeVarint); - }; - if let Some(v) = self.free_text.as_ref() { + } + if let Some(ref v) = self.free_text.as_ref() { my_size += ::protobuf::rt::string_size(12, &v); - }; + } if let Some(v) = self.auto_arrange { my_size += 2; - }; + } + if let Some(ref v) = self.url.as_ref() { + my_size += ::protobuf::rt::string_size(14, &v); + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(v) = self.id { os.write_uint64(1, v)?; - }; - if let Some(v) = self.meta.as_ref() { + } + if let Some(ref v) = self.meta.as_ref() { os.write_tag(2, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; v.write_to_with_cached_sizes(os)?; - }; - if let Some(v) = self.text.as_ref() { + } + if let Some(ref v) = self.text.as_ref() { os.write_string(3, &v)?; - }; + } for v in &self.children { os.write_uint64(4, *v)?; }; if let Some(v) = self.collapsed { os.write_bool(5, v)?; - }; + } if let Some(v) = self.stricken { os.write_bool(6, v)?; - }; + } if let Some(v) = self.hide_stricken { os.write_bool(7, v)?; - }; + } if let Some(v) = self.x { os.write_uint32(8, v)?; - }; + } if let Some(v) = self.y { os.write_uint32(9, v)?; - }; + } if let Some(v) = self.selected { os.write_bool(10, v)?; - }; + } if let Some(v) = self.parent_id { os.write_uint64(11, v)?; - }; - if let Some(v) = self.free_text.as_ref() { + } + if let Some(ref v) = self.free_text.as_ref() { os.write_string(12, &v)?; - }; + } if let Some(v) = self.auto_arrange { os.write_bool(13, v)?; - }; + } + if let Some(ref v) = self.url.as_ref() { + os.write_string(14, &v)?; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -1593,131 +1747,141 @@ impl ::protobuf::Message for Node { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Node { fn new() -> Node { Node::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "id", - Node::get_id_for_reflect, - Node::mut_id_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "meta", - Node::get_meta_for_reflect, - Node::mut_meta_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "text", - Node::get_text_for_reflect, - Node::mut_text_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "children", - Node::get_children_for_reflect, - Node::mut_children_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "collapsed", - Node::get_collapsed_for_reflect, - Node::mut_collapsed_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "stricken", - Node::get_stricken_for_reflect, - Node::mut_stricken_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "hide_stricken", - Node::get_hide_stricken_for_reflect, - Node::mut_hide_stricken_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "x", - Node::get_x_for_reflect, - Node::mut_x_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( - "y", - Node::get_y_for_reflect, - Node::mut_y_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "selected", - Node::get_selected_for_reflect, - Node::mut_selected_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "parent_id", - Node::get_parent_id_for_reflect, - Node::mut_parent_id_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( - "free_text", - Node::get_free_text_for_reflect, - Node::mut_free_text_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( - "auto_arrange", - Node::get_auto_arrange_for_reflect, - Node::mut_auto_arrange_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Node", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "id", + |m: &Node| { &m.id }, + |m: &mut Node| { &mut m.id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_ptr_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "meta", + |m: &Node| { &m.meta }, + |m: &mut Node| { &mut m.meta }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "text", + |m: &Node| { &m.text }, + |m: &mut Node| { &mut m.text }, + )); + fields.push(::protobuf::reflect::accessor::make_vec_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "children", + |m: &Node| { &m.children }, + |m: &mut Node| { &mut m.children }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "collapsed", + |m: &Node| { &m.collapsed }, + |m: &mut Node| { &mut m.collapsed }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "stricken", + |m: &Node| { &m.stricken }, + |m: &mut Node| { &mut m.stricken }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "hide_stricken", + |m: &Node| { &m.hide_stricken }, + |m: &mut Node| { &mut m.hide_stricken }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "x", + |m: &Node| { &m.x }, + |m: &mut Node| { &mut m.x }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint32>( + "y", + |m: &Node| { &m.y }, + |m: &mut Node| { &mut m.y }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "selected", + |m: &Node| { &m.selected }, + |m: &mut Node| { &mut m.selected }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "parent_id", + |m: &Node| { &m.parent_id }, + |m: &mut Node| { &mut m.parent_id }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "free_text", + |m: &Node| { &m.free_text }, + |m: &mut Node| { &mut m.free_text }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeBool>( + "auto_arrange", + |m: &Node| { &m.auto_arrange }, + |m: &mut Node| { &mut m.auto_arrange }, + )); + fields.push(::protobuf::reflect::accessor::make_singular_field_accessor::<_, ::protobuf::types::ProtobufTypeString>( + "url", + |m: &Node| { &m.url }, + |m: &mut Node| { &mut m.url }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Node", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Node { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Node::new) } } impl ::protobuf::Clear for Node { fn clear(&mut self) { - self.clear_id(); - self.clear_meta(); - self.clear_text(); - self.clear_children(); - self.clear_collapsed(); - self.clear_stricken(); - self.clear_hide_stricken(); - self.clear_x(); - self.clear_y(); - self.clear_selected(); - self.clear_parent_id(); - self.clear_free_text(); - self.clear_auto_arrange(); + self.id = ::std::option::Option::None; + self.meta.clear(); + self.text.clear(); + self.children.clear(); + self.collapsed = ::std::option::Option::None; + self.stricken = ::std::option::Option::None; + self.hide_stricken = ::std::option::Option::None; + self.x = ::std::option::Option::None; + self.y = ::std::option::Option::None; + self.selected = ::std::option::Option::None; + self.parent_id = ::std::option::Option::None; + self.free_text.clear(); + self.auto_arrange = ::std::option::Option::None; + self.url.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Node { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Node { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } @@ -1727,30 +1891,27 @@ pub struct Arrow { from_node: ::std::option::Option, to_node: ::std::option::Option, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Arrow {} +impl<'a> ::std::default::Default for &'a Arrow { + fn default() -> &'a Arrow { + ::default_instance() + } +} impl Arrow { pub fn new() -> Arrow { ::std::default::Default::default() } - pub fn default_instance() -> &'static Arrow { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Arrow, - }; - unsafe { - instance.get(Arrow::new) - } - } - // required uint64 from_node = 1; + + pub fn get_from_node(&self) -> u64 { + self.from_node.unwrap_or(0) + } pub fn clear_from_node(&mut self) { self.from_node = ::std::option::Option::None; } @@ -1764,20 +1925,12 @@ impl Arrow { self.from_node = ::std::option::Option::Some(v); } - pub fn get_from_node(&self) -> u64 { - self.from_node.unwrap_or(0) - } + // required uint64 to_node = 2; - fn get_from_node_for_reflect(&self) -> &::std::option::Option { - &self.from_node - } - fn mut_from_node_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.from_node + pub fn get_to_node(&self) -> u64 { + self.to_node.unwrap_or(0) } - - // required uint64 to_node = 2; - pub fn clear_to_node(&mut self) { self.to_node = ::std::option::Option::None; } @@ -1790,46 +1943,34 @@ impl Arrow { pub fn set_to_node(&mut self, v: u64) { self.to_node = ::std::option::Option::Some(v); } - - pub fn get_to_node(&self) -> u64 { - self.to_node.unwrap_or(0) - } - - fn get_to_node_for_reflect(&self) -> &::std::option::Option { - &self.to_node - } - - fn mut_to_node_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.to_node - } } impl ::protobuf::Message for Arrow { fn is_initialized(&self) -> bool { if self.from_node.is_none() { return false; - }; + } if self.to_node.is_none() { return false; - }; + } true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { 1 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.from_node = ::std::option::Option::Some(tmp); }, 2 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.to_node = ::std::option::Option::Some(tmp); }, @@ -1847,22 +1988,22 @@ impl ::protobuf::Message for Arrow { let mut my_size = 0; if let Some(v) = self.from_node { my_size += ::protobuf::rt::value_size(1, v, ::protobuf::wire_format::WireTypeVarint); - }; + } if let Some(v) = self.to_node { my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); - }; + } my_size += ::protobuf::rt::unknown_fields_size(self.get_unknown_fields()); self.cached_size.set(my_size); my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { if let Some(v) = self.from_node { os.write_uint64(1, v)?; - }; + } if let Some(v) = self.to_node { os.write_uint64(2, v)?; - }; + } os.write_unknown_fields(self.get_unknown_fields())?; ::std::result::Result::Ok(()) } @@ -1879,99 +2020,100 @@ impl ::protobuf::Message for Arrow { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Arrow { fn new() -> Arrow { Arrow::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "from_node", - Arrow::get_from_node_for_reflect, - Arrow::mut_from_node_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "to_node", - Arrow::get_to_node_for_reflect, - Arrow::mut_to_node_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Arrow", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "from_node", + |m: &Arrow| { &m.from_node }, + |m: &mut Arrow| { &mut m.from_node }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "to_node", + |m: &Arrow| { &m.to_node }, + |m: &mut Arrow| { &mut m.to_node }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Arrow", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Arrow { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Arrow::new) } } impl ::protobuf::Clear for Arrow { fn clear(&mut self) { - self.clear_from_node(); - self.clear_to_node(); + self.from_node = ::std::option::Option::None; + self.to_node = ::std::option::Option::None; self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Arrow { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Arrow { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } #[derive(PartialEq,Clone,Default)] pub struct Screen { // message fields - nodes: ::protobuf::RepeatedField, + pub nodes: ::protobuf::RepeatedField, max_id: ::std::option::Option, - arrows: ::protobuf::RepeatedField, + pub arrows: ::protobuf::RepeatedField, // special fields - unknown_fields: ::protobuf::UnknownFields, - cached_size: ::protobuf::CachedSize, + pub unknown_fields: ::protobuf::UnknownFields, + pub cached_size: ::protobuf::CachedSize, } -// see codegen.rs for the explanation why impl Sync explicitly -unsafe impl ::std::marker::Sync for Screen {} +impl<'a> ::std::default::Default for &'a Screen { + fn default() -> &'a Screen { + ::default_instance() + } +} impl Screen { pub fn new() -> Screen { ::std::default::Default::default() } - pub fn default_instance() -> &'static Screen { - static mut instance: ::protobuf::lazy::Lazy = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const Screen, - }; - unsafe { - instance.get(Screen::new) - } - } - // repeated .void.Node nodes = 1; + + pub fn get_nodes(&self) -> &[Node] { + &self.nodes + } pub fn clear_nodes(&mut self) { self.nodes.clear(); } @@ -1991,20 +2133,12 @@ impl Screen { ::std::mem::replace(&mut self.nodes, ::protobuf::RepeatedField::new()) } - pub fn get_nodes(&self) -> &[Node] { - &self.nodes - } + // required uint64 max_id = 2; - fn get_nodes_for_reflect(&self) -> &::protobuf::RepeatedField { - &self.nodes - } - fn mut_nodes_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.nodes + pub fn get_max_id(&self) -> u64 { + self.max_id.unwrap_or(0) } - - // required uint64 max_id = 2; - pub fn clear_max_id(&mut self) { self.max_id = ::std::option::Option::None; } @@ -2018,20 +2152,12 @@ impl Screen { self.max_id = ::std::option::Option::Some(v); } - pub fn get_max_id(&self) -> u64 { - self.max_id.unwrap_or(0) - } + // repeated .void.Arrow arrows = 3; - fn get_max_id_for_reflect(&self) -> &::std::option::Option { - &self.max_id - } - fn mut_max_id_for_reflect(&mut self) -> &mut ::std::option::Option { - &mut self.max_id + pub fn get_arrows(&self) -> &[Arrow] { + &self.arrows } - - // repeated .void.Arrow arrows = 3; - pub fn clear_arrows(&mut self) { self.arrows.clear(); } @@ -2050,29 +2176,27 @@ impl Screen { pub fn take_arrows(&mut self) -> ::protobuf::RepeatedField { ::std::mem::replace(&mut self.arrows, ::protobuf::RepeatedField::new()) } - - pub fn get_arrows(&self) -> &[Arrow] { - &self.arrows - } - - fn get_arrows_for_reflect(&self) -> &::protobuf::RepeatedField { - &self.arrows - } - - fn mut_arrows_for_reflect(&mut self) -> &mut ::protobuf::RepeatedField { - &mut self.arrows - } } impl ::protobuf::Message for Screen { fn is_initialized(&self) -> bool { if self.max_id.is_none() { return false; + } + for v in &self.nodes { + if !v.is_initialized() { + return false; + } + }; + for v in &self.arrows { + if !v.is_initialized() { + return false; + } }; true } - fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream) -> ::protobuf::ProtobufResult<()> { + fn merge_from(&mut self, is: &mut ::protobuf::CodedInputStream<'_>) -> ::protobuf::ProtobufResult<()> { while !is.eof()? { let (field_number, wire_type) = is.read_tag_unpack()?; match field_number { @@ -2082,7 +2206,7 @@ impl ::protobuf::Message for Screen { 2 => { if wire_type != ::protobuf::wire_format::WireTypeVarint { return ::std::result::Result::Err(::protobuf::rt::unexpected_wire_type(wire_type)); - }; + } let tmp = is.read_uint64()?; self.max_id = ::std::option::Option::Some(tmp); }, @@ -2107,7 +2231,7 @@ impl ::protobuf::Message for Screen { }; if let Some(v) = self.max_id { my_size += ::protobuf::rt::value_size(2, v, ::protobuf::wire_format::WireTypeVarint); - }; + } for value in &self.arrows { let len = value.compute_size(); my_size += 1 + ::protobuf::rt::compute_raw_varint32_size(len) + len; @@ -2117,7 +2241,7 @@ impl ::protobuf::Message for Screen { my_size } - fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream) -> ::protobuf::ProtobufResult<()> { + fn write_to_with_cached_sizes(&self, os: &mut ::protobuf::CodedOutputStream<'_>) -> ::protobuf::ProtobufResult<()> { for v in &self.nodes { os.write_tag(1, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; @@ -2125,7 +2249,7 @@ impl ::protobuf::Message for Screen { }; if let Some(v) = self.max_id { os.write_uint64(2, v)?; - }; + } for v in &self.arrows { os.write_tag(3, ::protobuf::wire_format::WireTypeLengthDelimited)?; os.write_raw_varint32(v.get_cached_size())?; @@ -2147,272 +2271,237 @@ impl ::protobuf::Message for Screen { &mut self.unknown_fields } - fn as_any(&self) -> &::std::any::Any { - self as &::std::any::Any + fn as_any(&self) -> &dyn (::std::any::Any) { + self as &dyn (::std::any::Any) + } + fn as_any_mut(&mut self) -> &mut dyn (::std::any::Any) { + self as &mut dyn (::std::any::Any) + } + fn into_any(self: ::std::boxed::Box) -> ::std::boxed::Box { + self } fn descriptor(&self) -> &'static ::protobuf::reflect::MessageDescriptor { - ::protobuf::MessageStatic::descriptor_static(None::) + Self::descriptor_static() } -} -impl ::protobuf::MessageStatic for Screen { fn new() -> Screen { Screen::new() } - fn descriptor_static(_: ::std::option::Option) -> &'static ::protobuf::reflect::MessageDescriptor { - static mut descriptor: ::protobuf::lazy::Lazy<::protobuf::reflect::MessageDescriptor> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::reflect::MessageDescriptor, - }; - unsafe { - descriptor.get(|| { - let mut fields = ::std::vec::Vec::new(); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "nodes", - Screen::get_nodes_for_reflect, - Screen::mut_nodes_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( - "max_id", - Screen::get_max_id_for_reflect, - Screen::mut_max_id_for_reflect, - )); - fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( - "arrows", - Screen::get_arrows_for_reflect, - Screen::mut_arrows_for_reflect, - )); - ::protobuf::reflect::MessageDescriptor::new::( - "Screen", - fields, - file_descriptor_proto() - ) - }) - } + fn descriptor_static() -> &'static ::protobuf::reflect::MessageDescriptor { + static descriptor: ::protobuf::rt::LazyV2<::protobuf::reflect::MessageDescriptor> = ::protobuf::rt::LazyV2::INIT; + descriptor.get(|| { + let mut fields = ::std::vec::Vec::new(); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "nodes", + |m: &Screen| { &m.nodes }, + |m: &mut Screen| { &mut m.nodes }, + )); + fields.push(::protobuf::reflect::accessor::make_option_accessor::<_, ::protobuf::types::ProtobufTypeUint64>( + "max_id", + |m: &Screen| { &m.max_id }, + |m: &mut Screen| { &mut m.max_id }, + )); + fields.push(::protobuf::reflect::accessor::make_repeated_field_accessor::<_, ::protobuf::types::ProtobufTypeMessage>( + "arrows", + |m: &Screen| { &m.arrows }, + |m: &mut Screen| { &mut m.arrows }, + )); + ::protobuf::reflect::MessageDescriptor::new_pb_name::( + "Screen", + fields, + file_descriptor_proto() + ) + }) + } + + fn default_instance() -> &'static Screen { + static instance: ::protobuf::rt::LazyV2 = ::protobuf::rt::LazyV2::INIT; + instance.get(Screen::new) } } impl ::protobuf::Clear for Screen { fn clear(&mut self) { - self.clear_nodes(); - self.clear_max_id(); - self.clear_arrows(); + self.nodes.clear(); + self.max_id = ::std::option::Option::None; + self.arrows.clear(); self.unknown_fields.clear(); } } impl ::std::fmt::Debug for Screen { - fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result { + fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result { ::protobuf::text_format::fmt(self, f) } } impl ::protobuf::reflect::ProtobufValue for Screen { - fn as_ref(&self) -> ::protobuf::reflect::ProtobufValueRef { - ::protobuf::reflect::ProtobufValueRef::Message(self) + fn as_ref(&self) -> ::protobuf::reflect::ReflectValueRef { + ::protobuf::reflect::ReflectValueRef::Message(self) } } -static file_descriptor_proto_data: &'static [u8] = &[ - 0x0a, 0x18, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x2f, 0x64, 0x61, 0x74, 0x61, 0x5f, 0x6d, - 0x6f, 0x64, 0x65, 0x6c, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x76, 0x6f, 0x69, 0x64, - 0x22, 0x2d, 0x0a, 0x03, 0x54, 0x61, 0x67, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, - 0x20, 0x02, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, - 0x75, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x22, - 0x29, 0x0a, 0x03, 0x47, 0x70, 0x73, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x61, 0x74, 0x18, 0x01, 0x20, - 0x02, 0x28, 0x02, 0x52, 0x03, 0x6c, 0x61, 0x74, 0x12, 0x10, 0x0a, 0x03, 0x6c, 0x6f, 0x6e, 0x18, - 0x02, 0x20, 0x02, 0x28, 0x02, 0x52, 0x03, 0x6c, 0x6f, 0x6e, 0x22, 0xa1, 0x01, 0x0a, 0x04, 0x4d, - 0x65, 0x74, 0x61, 0x12, 0x14, 0x0a, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x02, - 0x28, 0x04, 0x52, 0x05, 0x63, 0x74, 0x69, 0x6d, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x6d, 0x74, 0x69, - 0x6d, 0x65, 0x18, 0x02, 0x20, 0x02, 0x28, 0x04, 0x52, 0x05, 0x6d, 0x74, 0x69, 0x6d, 0x65, 0x12, - 0x1f, 0x0a, 0x0b, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x5f, 0x74, 0x69, 0x6d, 0x65, 0x18, 0x05, - 0x20, 0x01, 0x28, 0x04, 0x52, 0x0a, 0x66, 0x69, 0x6e, 0x69, 0x73, 0x68, 0x54, 0x69, 0x6d, 0x65, - 0x12, 0x1b, 0x0a, 0x03, 0x67, 0x70, 0x73, 0x18, 0x03, 0x20, 0x02, 0x28, 0x0b, 0x32, 0x09, 0x2e, - 0x76, 0x6f, 0x69, 0x64, 0x2e, 0x47, 0x70, 0x73, 0x52, 0x03, 0x67, 0x70, 0x73, 0x12, 0x1d, 0x0a, - 0x04, 0x74, 0x61, 0x67, 0x73, 0x18, 0x04, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x09, 0x2e, 0x76, 0x6f, - 0x69, 0x64, 0x2e, 0x54, 0x61, 0x67, 0x52, 0x04, 0x74, 0x61, 0x67, 0x73, 0x12, 0x10, 0x0a, 0x03, - 0x64, 0x75, 0x65, 0x18, 0x06, 0x20, 0x01, 0x28, 0x04, 0x52, 0x03, 0x64, 0x75, 0x65, 0x22, 0xda, - 0x02, 0x0a, 0x04, 0x4e, 0x6f, 0x64, 0x65, 0x12, 0x0e, 0x0a, 0x02, 0x69, 0x64, 0x18, 0x01, 0x20, - 0x02, 0x28, 0x04, 0x52, 0x02, 0x69, 0x64, 0x12, 0x1e, 0x0a, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x18, - 0x02, 0x20, 0x02, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x76, 0x6f, 0x69, 0x64, 0x2e, 0x4d, 0x65, 0x74, - 0x61, 0x52, 0x04, 0x6d, 0x65, 0x74, 0x61, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18, - 0x03, 0x20, 0x02, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x12, 0x1a, 0x0a, 0x08, 0x63, - 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x18, 0x04, 0x20, 0x03, 0x28, 0x04, 0x52, 0x08, 0x63, - 0x68, 0x69, 0x6c, 0x64, 0x72, 0x65, 0x6e, 0x12, 0x1c, 0x0a, 0x09, 0x63, 0x6f, 0x6c, 0x6c, 0x61, - 0x70, 0x73, 0x65, 0x64, 0x18, 0x05, 0x20, 0x02, 0x28, 0x08, 0x52, 0x09, 0x63, 0x6f, 0x6c, 0x6c, - 0x61, 0x70, 0x73, 0x65, 0x64, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x65, - 0x6e, 0x18, 0x06, 0x20, 0x02, 0x28, 0x08, 0x52, 0x08, 0x73, 0x74, 0x72, 0x69, 0x63, 0x6b, 0x65, - 0x6e, 0x12, 0x23, 0x0a, 0x0d, 0x68, 0x69, 0x64, 0x65, 0x5f, 0x73, 0x74, 0x72, 0x69, 0x63, 0x6b, - 0x65, 0x6e, 0x18, 0x07, 0x20, 0x02, 0x28, 0x08, 0x52, 0x0c, 0x68, 0x69, 0x64, 0x65, 0x53, 0x74, - 0x72, 0x69, 0x63, 0x6b, 0x65, 0x6e, 0x12, 0x0c, 0x0a, 0x01, 0x78, 0x18, 0x08, 0x20, 0x02, 0x28, - 0x0d, 0x52, 0x01, 0x78, 0x12, 0x0c, 0x0a, 0x01, 0x79, 0x18, 0x09, 0x20, 0x02, 0x28, 0x0d, 0x52, - 0x01, 0x79, 0x12, 0x1a, 0x0a, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x18, 0x0a, - 0x20, 0x02, 0x28, 0x08, 0x52, 0x08, 0x73, 0x65, 0x6c, 0x65, 0x63, 0x74, 0x65, 0x64, 0x12, 0x1b, - 0x0a, 0x09, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x0b, 0x20, 0x02, 0x28, - 0x04, 0x52, 0x08, 0x70, 0x61, 0x72, 0x65, 0x6e, 0x74, 0x49, 0x64, 0x12, 0x1b, 0x0a, 0x09, 0x66, - 0x72, 0x65, 0x65, 0x5f, 0x74, 0x65, 0x78, 0x74, 0x18, 0x0c, 0x20, 0x01, 0x28, 0x09, 0x52, 0x08, - 0x66, 0x72, 0x65, 0x65, 0x54, 0x65, 0x78, 0x74, 0x12, 0x21, 0x0a, 0x0c, 0x61, 0x75, 0x74, 0x6f, - 0x5f, 0x61, 0x72, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x18, 0x0d, 0x20, 0x02, 0x28, 0x08, 0x52, 0x0b, - 0x61, 0x75, 0x74, 0x6f, 0x41, 0x72, 0x72, 0x61, 0x6e, 0x67, 0x65, 0x22, 0x3d, 0x0a, 0x05, 0x41, - 0x72, 0x72, 0x6f, 0x77, 0x12, 0x1b, 0x0a, 0x09, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x6e, 0x6f, 0x64, - 0x65, 0x18, 0x01, 0x20, 0x02, 0x28, 0x04, 0x52, 0x08, 0x66, 0x72, 0x6f, 0x6d, 0x4e, 0x6f, 0x64, - 0x65, 0x12, 0x17, 0x0a, 0x07, 0x74, 0x6f, 0x5f, 0x6e, 0x6f, 0x64, 0x65, 0x18, 0x02, 0x20, 0x02, - 0x28, 0x04, 0x52, 0x06, 0x74, 0x6f, 0x4e, 0x6f, 0x64, 0x65, 0x22, 0x66, 0x0a, 0x06, 0x53, 0x63, - 0x72, 0x65, 0x65, 0x6e, 0x12, 0x20, 0x0a, 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x18, 0x01, 0x20, - 0x03, 0x28, 0x0b, 0x32, 0x0a, 0x2e, 0x76, 0x6f, 0x69, 0x64, 0x2e, 0x4e, 0x6f, 0x64, 0x65, 0x52, - 0x05, 0x6e, 0x6f, 0x64, 0x65, 0x73, 0x12, 0x15, 0x0a, 0x06, 0x6d, 0x61, 0x78, 0x5f, 0x69, 0x64, - 0x18, 0x02, 0x20, 0x02, 0x28, 0x04, 0x52, 0x05, 0x6d, 0x61, 0x78, 0x49, 0x64, 0x12, 0x23, 0x0a, - 0x06, 0x61, 0x72, 0x72, 0x6f, 0x77, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0b, 0x2e, - 0x76, 0x6f, 0x69, 0x64, 0x2e, 0x41, 0x72, 0x72, 0x6f, 0x77, 0x52, 0x06, 0x61, 0x72, 0x72, 0x6f, - 0x77, 0x73, 0x4a, 0xb8, 0x10, 0x0a, 0x06, 0x12, 0x04, 0x00, 0x00, 0x30, 0x01, 0x0a, 0x08, 0x0a, - 0x01, 0x0c, 0x12, 0x03, 0x00, 0x00, 0x12, 0x0a, 0x08, 0x0a, 0x01, 0x02, 0x12, 0x03, 0x02, 0x08, - 0x0c, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x00, 0x12, 0x04, 0x04, 0x00, 0x07, 0x01, 0x0a, 0x0a, 0x0a, - 0x03, 0x04, 0x00, 0x01, 0x12, 0x03, 0x04, 0x08, 0x0b, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x00, 0x02, - 0x00, 0x12, 0x03, 0x05, 0x02, 0x1a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x04, 0x12, - 0x03, 0x05, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x05, 0x12, 0x03, 0x05, - 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x01, 0x12, 0x03, 0x05, 0x12, 0x15, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x00, 0x03, 0x12, 0x03, 0x05, 0x18, 0x19, 0x0a, 0x0b, - 0x0a, 0x04, 0x04, 0x00, 0x02, 0x01, 0x12, 0x03, 0x06, 0x02, 0x1c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x00, 0x02, 0x01, 0x04, 0x12, 0x03, 0x06, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, - 0x01, 0x05, 0x12, 0x03, 0x06, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x01, - 0x12, 0x03, 0x06, 0x12, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x00, 0x02, 0x01, 0x03, 0x12, 0x03, - 0x06, 0x1a, 0x1b, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x01, 0x12, 0x04, 0x09, 0x00, 0x0c, 0x01, 0x0a, - 0x0a, 0x0a, 0x03, 0x04, 0x01, 0x01, 0x12, 0x03, 0x09, 0x08, 0x0b, 0x0a, 0x0b, 0x0a, 0x04, 0x04, - 0x01, 0x02, 0x00, 0x12, 0x03, 0x0a, 0x02, 0x19, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, - 0x04, 0x12, 0x03, 0x0a, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x05, 0x12, - 0x03, 0x0a, 0x0b, 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x01, 0x12, 0x03, 0x0a, - 0x11, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0a, 0x17, 0x18, - 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x01, 0x02, 0x01, 0x12, 0x03, 0x0b, 0x02, 0x19, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x01, 0x02, 0x01, 0x04, 0x12, 0x03, 0x0b, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x01, 0x02, 0x01, 0x05, 0x12, 0x03, 0x0b, 0x0b, 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, - 0x01, 0x01, 0x12, 0x03, 0x0b, 0x11, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x01, 0x02, 0x01, 0x03, - 0x12, 0x03, 0x0b, 0x17, 0x18, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x02, 0x12, 0x04, 0x0e, 0x00, 0x15, - 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x02, 0x01, 0x12, 0x03, 0x0e, 0x08, 0x0c, 0x0a, 0x0b, 0x0a, - 0x04, 0x04, 0x02, 0x02, 0x00, 0x12, 0x03, 0x0f, 0x02, 0x1c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, - 0x02, 0x00, 0x04, 0x12, 0x03, 0x0f, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, - 0x05, 0x12, 0x03, 0x0f, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x01, 0x12, - 0x03, 0x0f, 0x12, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x00, 0x03, 0x12, 0x03, 0x0f, - 0x1a, 0x1b, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x01, 0x12, 0x03, 0x10, 0x02, 0x1c, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x01, 0x04, 0x12, 0x03, 0x10, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x02, 0x02, 0x01, 0x05, 0x12, 0x03, 0x10, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x02, 0x02, 0x01, 0x01, 0x12, 0x03, 0x10, 0x12, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, - 0x01, 0x03, 0x12, 0x03, 0x10, 0x1a, 0x1b, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x02, 0x12, - 0x03, 0x11, 0x02, 0x22, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x02, 0x04, 0x12, 0x03, 0x11, - 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x02, 0x05, 0x12, 0x03, 0x11, 0x0b, 0x11, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x02, 0x01, 0x12, 0x03, 0x11, 0x12, 0x1d, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x02, 0x02, 0x02, 0x03, 0x12, 0x03, 0x11, 0x20, 0x21, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x02, 0x02, 0x03, 0x12, 0x03, 0x12, 0x02, 0x17, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, - 0x03, 0x04, 0x12, 0x03, 0x12, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x03, 0x06, - 0x12, 0x03, 0x12, 0x0b, 0x0e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x03, 0x01, 0x12, 0x03, - 0x12, 0x0f, 0x12, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x03, 0x03, 0x12, 0x03, 0x12, 0x15, - 0x16, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x04, 0x12, 0x03, 0x13, 0x02, 0x18, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x02, 0x02, 0x04, 0x04, 0x12, 0x03, 0x13, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x02, 0x02, 0x04, 0x06, 0x12, 0x03, 0x13, 0x0b, 0x0e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, - 0x02, 0x04, 0x01, 0x12, 0x03, 0x13, 0x0f, 0x13, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x04, - 0x03, 0x12, 0x03, 0x13, 0x16, 0x17, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x02, 0x02, 0x05, 0x12, 0x03, - 0x14, 0x02, 0x1a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x05, 0x04, 0x12, 0x03, 0x14, 0x02, - 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x05, 0x05, 0x12, 0x03, 0x14, 0x0b, 0x11, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x02, 0x02, 0x05, 0x01, 0x12, 0x03, 0x14, 0x12, 0x15, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x02, 0x02, 0x05, 0x03, 0x12, 0x03, 0x14, 0x18, 0x19, 0x0a, 0x0a, 0x0a, 0x02, 0x04, - 0x03, 0x12, 0x04, 0x17, 0x00, 0x25, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x03, 0x01, 0x12, 0x03, - 0x17, 0x08, 0x0c, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x00, 0x12, 0x03, 0x18, 0x02, 0x19, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x04, 0x12, 0x03, 0x18, 0x02, 0x0a, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x03, 0x02, 0x00, 0x05, 0x12, 0x03, 0x18, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x03, 0x02, 0x00, 0x01, 0x12, 0x03, 0x18, 0x12, 0x14, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, - 0x02, 0x00, 0x03, 0x12, 0x03, 0x18, 0x17, 0x18, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x01, - 0x12, 0x03, 0x19, 0x02, 0x19, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x04, 0x12, 0x03, - 0x19, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x06, 0x12, 0x03, 0x19, 0x0b, - 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x01, 0x12, 0x03, 0x19, 0x10, 0x14, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x01, 0x03, 0x12, 0x03, 0x19, 0x17, 0x18, 0x0a, 0x0b, 0x0a, - 0x04, 0x04, 0x03, 0x02, 0x02, 0x12, 0x03, 0x1a, 0x02, 0x1b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, - 0x02, 0x02, 0x04, 0x12, 0x03, 0x1a, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x02, - 0x05, 0x12, 0x03, 0x1a, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x02, 0x01, 0x12, - 0x03, 0x1a, 0x12, 0x16, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x02, 0x03, 0x12, 0x03, 0x1a, - 0x19, 0x1a, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x03, 0x12, 0x03, 0x1b, 0x02, 0x1f, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x03, 0x04, 0x12, 0x03, 0x1b, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x03, 0x02, 0x03, 0x05, 0x12, 0x03, 0x1b, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x03, 0x02, 0x03, 0x01, 0x12, 0x03, 0x1b, 0x12, 0x1a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, - 0x03, 0x03, 0x12, 0x03, 0x1b, 0x1d, 0x1e, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x04, 0x12, - 0x03, 0x1c, 0x02, 0x1e, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x04, 0x04, 0x12, 0x03, 0x1c, - 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x04, 0x05, 0x12, 0x03, 0x1c, 0x0b, 0x0f, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x04, 0x01, 0x12, 0x03, 0x1c, 0x10, 0x19, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x03, 0x02, 0x04, 0x03, 0x12, 0x03, 0x1c, 0x1c, 0x1d, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x03, 0x02, 0x05, 0x12, 0x03, 0x1d, 0x02, 0x1d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, - 0x05, 0x04, 0x12, 0x03, 0x1d, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x05, 0x05, - 0x12, 0x03, 0x1d, 0x0b, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x05, 0x01, 0x12, 0x03, - 0x1d, 0x10, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x05, 0x03, 0x12, 0x03, 0x1d, 0x1b, - 0x1c, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x06, 0x12, 0x03, 0x1e, 0x02, 0x22, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x03, 0x02, 0x06, 0x04, 0x12, 0x03, 0x1e, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x03, 0x02, 0x06, 0x05, 0x12, 0x03, 0x1e, 0x0b, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, - 0x02, 0x06, 0x01, 0x12, 0x03, 0x1e, 0x10, 0x1d, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x06, - 0x03, 0x12, 0x03, 0x1e, 0x20, 0x21, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x07, 0x12, 0x03, - 0x1f, 0x02, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x07, 0x04, 0x12, 0x03, 0x1f, 0x02, - 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x07, 0x05, 0x12, 0x03, 0x1f, 0x0b, 0x11, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x07, 0x01, 0x12, 0x03, 0x1f, 0x12, 0x13, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x03, 0x02, 0x07, 0x03, 0x12, 0x03, 0x1f, 0x16, 0x17, 0x0a, 0x0b, 0x0a, 0x04, 0x04, - 0x03, 0x02, 0x08, 0x12, 0x03, 0x20, 0x02, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x08, - 0x04, 0x12, 0x03, 0x20, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x08, 0x05, 0x12, - 0x03, 0x20, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x08, 0x01, 0x12, 0x03, 0x20, - 0x12, 0x13, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x08, 0x03, 0x12, 0x03, 0x20, 0x16, 0x17, - 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x09, 0x12, 0x03, 0x21, 0x02, 0x1e, 0x0a, 0x0c, 0x0a, - 0x05, 0x04, 0x03, 0x02, 0x09, 0x04, 0x12, 0x03, 0x21, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x03, 0x02, 0x09, 0x05, 0x12, 0x03, 0x21, 0x0b, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, - 0x09, 0x01, 0x12, 0x03, 0x21, 0x10, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x09, 0x03, - 0x12, 0x03, 0x21, 0x1b, 0x1d, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x0a, 0x12, 0x03, 0x22, - 0x02, 0x21, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0a, 0x04, 0x12, 0x03, 0x22, 0x02, 0x0a, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0a, 0x05, 0x12, 0x03, 0x22, 0x0b, 0x11, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0a, 0x01, 0x12, 0x03, 0x22, 0x12, 0x1b, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x03, 0x02, 0x0a, 0x03, 0x12, 0x03, 0x22, 0x1e, 0x20, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x03, - 0x02, 0x0b, 0x12, 0x03, 0x23, 0x02, 0x21, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0b, 0x04, - 0x12, 0x03, 0x23, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0b, 0x05, 0x12, 0x03, - 0x23, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0b, 0x01, 0x12, 0x03, 0x23, 0x12, - 0x1b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0b, 0x03, 0x12, 0x03, 0x23, 0x1e, 0x20, 0x0a, - 0x0b, 0x0a, 0x04, 0x04, 0x03, 0x02, 0x0c, 0x12, 0x03, 0x24, 0x02, 0x22, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x03, 0x02, 0x0c, 0x04, 0x12, 0x03, 0x24, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, - 0x02, 0x0c, 0x05, 0x12, 0x03, 0x24, 0x0b, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0c, - 0x01, 0x12, 0x03, 0x24, 0x10, 0x1c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x03, 0x02, 0x0c, 0x03, 0x12, - 0x03, 0x24, 0x1f, 0x21, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x04, 0x12, 0x04, 0x27, 0x00, 0x2a, 0x01, - 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x04, 0x01, 0x12, 0x03, 0x27, 0x08, 0x0d, 0x0a, 0x0b, 0x0a, 0x04, - 0x04, 0x04, 0x02, 0x00, 0x12, 0x03, 0x28, 0x02, 0x20, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, - 0x00, 0x04, 0x12, 0x03, 0x28, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x05, - 0x12, 0x03, 0x28, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x01, 0x12, 0x03, - 0x28, 0x12, 0x1b, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x00, 0x03, 0x12, 0x03, 0x28, 0x1e, - 0x1f, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x04, 0x02, 0x01, 0x12, 0x03, 0x29, 0x02, 0x1e, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x04, 0x02, 0x01, 0x04, 0x12, 0x03, 0x29, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x04, 0x02, 0x01, 0x05, 0x12, 0x03, 0x29, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, - 0x02, 0x01, 0x01, 0x12, 0x03, 0x29, 0x12, 0x19, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x04, 0x02, 0x01, - 0x03, 0x12, 0x03, 0x29, 0x1c, 0x1d, 0x0a, 0x0a, 0x0a, 0x02, 0x04, 0x05, 0x12, 0x04, 0x2c, 0x00, - 0x30, 0x01, 0x0a, 0x0a, 0x0a, 0x03, 0x04, 0x05, 0x01, 0x12, 0x03, 0x2c, 0x08, 0x0e, 0x0a, 0x0b, - 0x0a, 0x04, 0x04, 0x05, 0x02, 0x00, 0x12, 0x03, 0x2d, 0x02, 0x1a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, - 0x05, 0x02, 0x00, 0x04, 0x12, 0x03, 0x2d, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, - 0x00, 0x06, 0x12, 0x03, 0x2d, 0x0b, 0x0f, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x00, 0x01, - 0x12, 0x03, 0x2d, 0x10, 0x15, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x00, 0x03, 0x12, 0x03, - 0x2d, 0x18, 0x19, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x01, 0x12, 0x03, 0x2e, 0x02, 0x1d, - 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x01, 0x04, 0x12, 0x03, 0x2e, 0x02, 0x0a, 0x0a, 0x0c, - 0x0a, 0x05, 0x04, 0x05, 0x02, 0x01, 0x05, 0x12, 0x03, 0x2e, 0x0b, 0x11, 0x0a, 0x0c, 0x0a, 0x05, - 0x04, 0x05, 0x02, 0x01, 0x01, 0x12, 0x03, 0x2e, 0x12, 0x18, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, - 0x02, 0x01, 0x03, 0x12, 0x03, 0x2e, 0x1b, 0x1c, 0x0a, 0x0b, 0x0a, 0x04, 0x04, 0x05, 0x02, 0x02, - 0x12, 0x03, 0x2f, 0x02, 0x1c, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x04, 0x12, 0x03, - 0x2f, 0x02, 0x0a, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x06, 0x12, 0x03, 0x2f, 0x0b, - 0x10, 0x0a, 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x01, 0x12, 0x03, 0x2f, 0x11, 0x17, 0x0a, - 0x0c, 0x0a, 0x05, 0x04, 0x05, 0x02, 0x02, 0x03, 0x12, 0x03, 0x2f, 0x1a, 0x1b, -]; - -static mut file_descriptor_proto_lazy: ::protobuf::lazy::Lazy<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::lazy::Lazy { - lock: ::protobuf::lazy::ONCE_INIT, - ptr: 0 as *const ::protobuf::descriptor::FileDescriptorProto, -}; +static file_descriptor_proto_data: &'static [u8] = b"\ + \n\x18include/data_model.proto\x12\x04void\"-\n\x03Tag\x12\x10\n\x03key\ + \x18\x01\x20\x02(\tR\x03key\x12\x14\n\x05value\x18\x02\x20\x02(\tR\x05va\ + lue\")\n\x03Gps\x12\x10\n\x03lat\x18\x01\x20\x01(\x02R\x03lat\x12\x10\n\ + \x03lon\x18\x02\x20\x01(\x02R\x03lon\"B\n\x04Date\x12\x10\n\x03day\x18\ + \x01\x20\x02(\rR\x03day\x12\x14\n\x05month\x18\x02\x20\x02(\rR\x05month\ + \x12\x12\n\x04year\x18\x03\x20\x02(\rR\x04year\"\xcf\x01\n\x04Meta\x12\ + \x14\n\x05ctime\x18\x01\x20\x02(\x04R\x05ctime\x12\x14\n\x05mtime\x18\ + \x02\x20\x02(\x04R\x05mtime\x12\x1f\n\x0bfinish_time\x18\x05\x20\x01(\ + \x04R\nfinishTime\x12\x1b\n\x03gps\x18\x03\x20\x02(\x0b2\t.void.GpsR\x03\ + gps\x12\x1d\n\x04tags\x18\x04\x20\x03(\x0b2\t.void.TagR\x04tags\x12\x17\ + \n\x07OLD_due\x18\x06\x20\x01(\x04R\x06OLDDue\x12%\n\x08due_date\x18\x07\ + \x20\x01(\x0b2\n.void.DateR\x07dueDate\"\xec\x02\n\x04Node\x12\x0e\n\x02\ + id\x18\x01\x20\x02(\x04R\x02id\x12\x1e\n\x04meta\x18\x02\x20\x02(\x0b2\n\ + .void.MetaR\x04meta\x12\x12\n\x04text\x18\x03\x20\x02(\tR\x04text\x12\ + \x1a\n\x08children\x18\x04\x20\x03(\x04R\x08children\x12\x1c\n\tcollapse\ + d\x18\x05\x20\x02(\x08R\tcollapsed\x12\x1a\n\x08stricken\x18\x06\x20\x02\ + (\x08R\x08stricken\x12#\n\rhide_stricken\x18\x07\x20\x02(\x08R\x0chideSt\ + ricken\x12\x0c\n\x01x\x18\x08\x20\x02(\rR\x01x\x12\x0c\n\x01y\x18\t\x20\ + \x02(\rR\x01y\x12\x1a\n\x08selected\x18\n\x20\x01(\x08R\x08selected\x12\ + \x1b\n\tparent_id\x18\x0b\x20\x02(\x04R\x08parentId\x12\x1b\n\tfree_text\ + \x18\x0c\x20\x01(\tR\x08freeText\x12!\n\x0cauto_arrange\x18\r\x20\x02(\ + \x08R\x0bautoArrange\x12\x10\n\x03url\x18\x0e\x20\x01(\tR\x03url\"=\n\ + \x05Arrow\x12\x1b\n\tfrom_node\x18\x01\x20\x02(\x04R\x08fromNode\x12\x17\ + \n\x07to_node\x18\x02\x20\x02(\x04R\x06toNode\"f\n\x06Screen\x12\x20\n\ + \x05nodes\x18\x01\x20\x03(\x0b2\n.void.NodeR\x05nodes\x12\x15\n\x06max_i\ + d\x18\x02\x20\x02(\x04R\x05maxId\x12#\n\x06arrows\x18\x03\x20\x03(\x0b2\ + \x0b.void.ArrowR\x06arrowsJ\xa9\x13\n\x06\x12\x04\0\08\x01\n\x08\n\x01\ + \x0c\x12\x03\0\0\x12\n\x08\n\x01\x02\x12\x03\x02\0\r\n\n\n\x02\x04\0\x12\ + \x04\x04\0\x07\x01\n\n\n\x03\x04\0\x01\x12\x03\x04\x08\x0b\n\x0b\n\x04\ + \x04\0\x02\0\x12\x03\x05\x02\x1a\n\x0c\n\x05\x04\0\x02\0\x04\x12\x03\x05\ + \x02\n\n\x0c\n\x05\x04\0\x02\0\x05\x12\x03\x05\x0b\x11\n\x0c\n\x05\x04\0\ + \x02\0\x01\x12\x03\x05\x12\x15\n\x0c\n\x05\x04\0\x02\0\x03\x12\x03\x05\ + \x18\x19\n\x0b\n\x04\x04\0\x02\x01\x12\x03\x06\x02\x1c\n\x0c\n\x05\x04\0\ + \x02\x01\x04\x12\x03\x06\x02\n\n\x0c\n\x05\x04\0\x02\x01\x05\x12\x03\x06\ + \x0b\x11\n\x0c\n\x05\x04\0\x02\x01\x01\x12\x03\x06\x12\x17\n\x0c\n\x05\ + \x04\0\x02\x01\x03\x12\x03\x06\x1a\x1b\n\n\n\x02\x04\x01\x12\x04\t\0\x0c\ + \x01\n\n\n\x03\x04\x01\x01\x12\x03\t\x08\x0b\n\x0b\n\x04\x04\x01\x02\0\ + \x12\x03\n\x02\x19\n\x0c\n\x05\x04\x01\x02\0\x04\x12\x03\n\x02\n\n\x0c\n\ + \x05\x04\x01\x02\0\x05\x12\x03\n\x0b\x10\n\x0c\n\x05\x04\x01\x02\0\x01\ + \x12\x03\n\x11\x14\n\x0c\n\x05\x04\x01\x02\0\x03\x12\x03\n\x17\x18\n\x0b\ + \n\x04\x04\x01\x02\x01\x12\x03\x0b\x02\x19\n\x0c\n\x05\x04\x01\x02\x01\ + \x04\x12\x03\x0b\x02\n\n\x0c\n\x05\x04\x01\x02\x01\x05\x12\x03\x0b\x0b\ + \x10\n\x0c\n\x05\x04\x01\x02\x01\x01\x12\x03\x0b\x11\x14\n\x0c\n\x05\x04\ + \x01\x02\x01\x03\x12\x03\x0b\x17\x18\n\n\n\x02\x04\x02\x12\x04\x0e\0\x12\ + \x01\n\n\n\x03\x04\x02\x01\x12\x03\x0e\x08\x0c\n\x0b\n\x04\x04\x02\x02\0\ + \x12\x03\x0f\x04\x1c\n\x0c\n\x05\x04\x02\x02\0\x04\x12\x03\x0f\x04\x0c\n\ + \x0c\n\x05\x04\x02\x02\0\x05\x12\x03\x0f\r\x13\n\x0c\n\x05\x04\x02\x02\0\ + \x01\x12\x03\x0f\x14\x17\n\x0c\n\x05\x04\x02\x02\0\x03\x12\x03\x0f\x1a\ + \x1b\n\x0b\n\x04\x04\x02\x02\x01\x12\x03\x10\x04\x1e\n\x0c\n\x05\x04\x02\ + \x02\x01\x04\x12\x03\x10\x04\x0c\n\x0c\n\x05\x04\x02\x02\x01\x05\x12\x03\ + \x10\r\x13\n\x0c\n\x05\x04\x02\x02\x01\x01\x12\x03\x10\x14\x19\n\x0c\n\ + \x05\x04\x02\x02\x01\x03\x12\x03\x10\x1c\x1d\n\x0b\n\x04\x04\x02\x02\x02\ + \x12\x03\x11\x04\x1d\n\x0c\n\x05\x04\x02\x02\x02\x04\x12\x03\x11\x04\x0c\ + \n\x0c\n\x05\x04\x02\x02\x02\x05\x12\x03\x11\r\x13\n\x0c\n\x05\x04\x02\ + \x02\x02\x01\x12\x03\x11\x14\x18\n\x0c\n\x05\x04\x02\x02\x02\x03\x12\x03\ + \x11\x1b\x1c\n\n\n\x02\x04\x03\x12\x04\x14\0\x1c\x01\n\n\n\x03\x04\x03\ + \x01\x12\x03\x14\x08\x0c\n\x0b\n\x04\x04\x03\x02\0\x12\x03\x15\x02\x1c\n\ + \x0c\n\x05\x04\x03\x02\0\x04\x12\x03\x15\x02\n\n\x0c\n\x05\x04\x03\x02\0\ + \x05\x12\x03\x15\x0b\x11\n\x0c\n\x05\x04\x03\x02\0\x01\x12\x03\x15\x12\ + \x17\n\x0c\n\x05\x04\x03\x02\0\x03\x12\x03\x15\x1a\x1b\n\x0b\n\x04\x04\ + \x03\x02\x01\x12\x03\x16\x02\x1c\n\x0c\n\x05\x04\x03\x02\x01\x04\x12\x03\ + \x16\x02\n\n\x0c\n\x05\x04\x03\x02\x01\x05\x12\x03\x16\x0b\x11\n\x0c\n\ + \x05\x04\x03\x02\x01\x01\x12\x03\x16\x12\x17\n\x0c\n\x05\x04\x03\x02\x01\ + \x03\x12\x03\x16\x1a\x1b\n\x0b\n\x04\x04\x03\x02\x02\x12\x03\x17\x02\"\n\ + \x0c\n\x05\x04\x03\x02\x02\x04\x12\x03\x17\x02\n\n\x0c\n\x05\x04\x03\x02\ + \x02\x05\x12\x03\x17\x0b\x11\n\x0c\n\x05\x04\x03\x02\x02\x01\x12\x03\x17\ + \x12\x1d\n\x0c\n\x05\x04\x03\x02\x02\x03\x12\x03\x17\x20!\n\x0b\n\x04\ + \x04\x03\x02\x03\x12\x03\x18\x02\x17\n\x0c\n\x05\x04\x03\x02\x03\x04\x12\ + \x03\x18\x02\n\n\x0c\n\x05\x04\x03\x02\x03\x06\x12\x03\x18\x0b\x0e\n\x0c\ + \n\x05\x04\x03\x02\x03\x01\x12\x03\x18\x0f\x12\n\x0c\n\x05\x04\x03\x02\ + \x03\x03\x12\x03\x18\x15\x16\n\x0b\n\x04\x04\x03\x02\x04\x12\x03\x19\x02\ + \x18\n\x0c\n\x05\x04\x03\x02\x04\x04\x12\x03\x19\x02\n\n\x0c\n\x05\x04\ + \x03\x02\x04\x06\x12\x03\x19\x0b\x0e\n\x0c\n\x05\x04\x03\x02\x04\x01\x12\ + \x03\x19\x0f\x13\n\x0c\n\x05\x04\x03\x02\x04\x03\x12\x03\x19\x16\x17\n\ + \x0b\n\x04\x04\x03\x02\x05\x12\x03\x1a\x02\x1e\n\x0c\n\x05\x04\x03\x02\ + \x05\x04\x12\x03\x1a\x02\n\n\x0c\n\x05\x04\x03\x02\x05\x05\x12\x03\x1a\ + \x0b\x11\n\x0c\n\x05\x04\x03\x02\x05\x01\x12\x03\x1a\x12\x19\n\x0c\n\x05\ + \x04\x03\x02\x05\x03\x12\x03\x1a\x1c\x1d\n\x0b\n\x04\x04\x03\x02\x06\x12\ + \x03\x1b\x02\x1d\n\x0c\n\x05\x04\x03\x02\x06\x04\x12\x03\x1b\x02\n\n\x0c\ + \n\x05\x04\x03\x02\x06\x06\x12\x03\x1b\x0b\x0f\n\x0c\n\x05\x04\x03\x02\ + \x06\x01\x12\x03\x1b\x10\x18\n\x0c\n\x05\x04\x03\x02\x06\x03\x12\x03\x1b\ + \x1b\x1c\n\n\n\x02\x04\x04\x12\x04\x1e\0-\x01\n\n\n\x03\x04\x04\x01\x12\ + \x03\x1e\x08\x0c\n\x0b\n\x04\x04\x04\x02\0\x12\x03\x1f\x02\x19\n\x0c\n\ + \x05\x04\x04\x02\0\x04\x12\x03\x1f\x02\n\n\x0c\n\x05\x04\x04\x02\0\x05\ + \x12\x03\x1f\x0b\x11\n\x0c\n\x05\x04\x04\x02\0\x01\x12\x03\x1f\x12\x14\n\ + \x0c\n\x05\x04\x04\x02\0\x03\x12\x03\x1f\x17\x18\n\x0b\n\x04\x04\x04\x02\ + \x01\x12\x03\x20\x02\x19\n\x0c\n\x05\x04\x04\x02\x01\x04\x12\x03\x20\x02\ + \n\n\x0c\n\x05\x04\x04\x02\x01\x06\x12\x03\x20\x0b\x0f\n\x0c\n\x05\x04\ + \x04\x02\x01\x01\x12\x03\x20\x10\x14\n\x0c\n\x05\x04\x04\x02\x01\x03\x12\ + \x03\x20\x17\x18\n\x0b\n\x04\x04\x04\x02\x02\x12\x03!\x02\x1b\n\x0c\n\ + \x05\x04\x04\x02\x02\x04\x12\x03!\x02\n\n\x0c\n\x05\x04\x04\x02\x02\x05\ + \x12\x03!\x0b\x11\n\x0c\n\x05\x04\x04\x02\x02\x01\x12\x03!\x12\x16\n\x0c\ + \n\x05\x04\x04\x02\x02\x03\x12\x03!\x19\x1a\n\x0b\n\x04\x04\x04\x02\x03\ + \x12\x03\"\x02\x1f\n\x0c\n\x05\x04\x04\x02\x03\x04\x12\x03\"\x02\n\n\x0c\ + \n\x05\x04\x04\x02\x03\x05\x12\x03\"\x0b\x11\n\x0c\n\x05\x04\x04\x02\x03\ + \x01\x12\x03\"\x12\x1a\n\x0c\n\x05\x04\x04\x02\x03\x03\x12\x03\"\x1d\x1e\ + \n\x0b\n\x04\x04\x04\x02\x04\x12\x03#\x02\x1e\n\x0c\n\x05\x04\x04\x02\ + \x04\x04\x12\x03#\x02\n\n\x0c\n\x05\x04\x04\x02\x04\x05\x12\x03#\x0b\x0f\ + \n\x0c\n\x05\x04\x04\x02\x04\x01\x12\x03#\x10\x19\n\x0c\n\x05\x04\x04\ + \x02\x04\x03\x12\x03#\x1c\x1d\n\x0b\n\x04\x04\x04\x02\x05\x12\x03$\x02\ + \x1d\n\x0c\n\x05\x04\x04\x02\x05\x04\x12\x03$\x02\n\n\x0c\n\x05\x04\x04\ + \x02\x05\x05\x12\x03$\x0b\x0f\n\x0c\n\x05\x04\x04\x02\x05\x01\x12\x03$\ + \x10\x18\n\x0c\n\x05\x04\x04\x02\x05\x03\x12\x03$\x1b\x1c\n\x0b\n\x04\ + \x04\x04\x02\x06\x12\x03%\x02\"\n\x0c\n\x05\x04\x04\x02\x06\x04\x12\x03%\ + \x02\n\n\x0c\n\x05\x04\x04\x02\x06\x05\x12\x03%\x0b\x0f\n\x0c\n\x05\x04\ + \x04\x02\x06\x01\x12\x03%\x10\x1d\n\x0c\n\x05\x04\x04\x02\x06\x03\x12\ + \x03%\x20!\n\x0b\n\x04\x04\x04\x02\x07\x12\x03&\x02\x18\n\x0c\n\x05\x04\ + \x04\x02\x07\x04\x12\x03&\x02\n\n\x0c\n\x05\x04\x04\x02\x07\x05\x12\x03&\ + \x0b\x11\n\x0c\n\x05\x04\x04\x02\x07\x01\x12\x03&\x12\x13\n\x0c\n\x05\ + \x04\x04\x02\x07\x03\x12\x03&\x16\x17\n\x0b\n\x04\x04\x04\x02\x08\x12\ + \x03'\x02\x18\n\x0c\n\x05\x04\x04\x02\x08\x04\x12\x03'\x02\n\n\x0c\n\x05\ + \x04\x04\x02\x08\x05\x12\x03'\x0b\x11\n\x0c\n\x05\x04\x04\x02\x08\x01\ + \x12\x03'\x12\x13\n\x0c\n\x05\x04\x04\x02\x08\x03\x12\x03'\x16\x17\n\x0b\ + \n\x04\x04\x04\x02\t\x12\x03(\x02\x1e\n\x0c\n\x05\x04\x04\x02\t\x04\x12\ + \x03(\x02\n\n\x0c\n\x05\x04\x04\x02\t\x05\x12\x03(\x0b\x0f\n\x0c\n\x05\ + \x04\x04\x02\t\x01\x12\x03(\x10\x18\n\x0c\n\x05\x04\x04\x02\t\x03\x12\ + \x03(\x1b\x1d\n\x0b\n\x04\x04\x04\x02\n\x12\x03)\x02!\n\x0c\n\x05\x04\ + \x04\x02\n\x04\x12\x03)\x02\n\n\x0c\n\x05\x04\x04\x02\n\x05\x12\x03)\x0b\ + \x11\n\x0c\n\x05\x04\x04\x02\n\x01\x12\x03)\x12\x1b\n\x0c\n\x05\x04\x04\ + \x02\n\x03\x12\x03)\x1e\x20\n\x0b\n\x04\x04\x04\x02\x0b\x12\x03*\x02!\n\ + \x0c\n\x05\x04\x04\x02\x0b\x04\x12\x03*\x02\n\n\x0c\n\x05\x04\x04\x02\ + \x0b\x05\x12\x03*\x0b\x11\n\x0c\n\x05\x04\x04\x02\x0b\x01\x12\x03*\x12\ + \x1b\n\x0c\n\x05\x04\x04\x02\x0b\x03\x12\x03*\x1e\x20\n\x0b\n\x04\x04\ + \x04\x02\x0c\x12\x03+\x02\"\n\x0c\n\x05\x04\x04\x02\x0c\x04\x12\x03+\x02\ + \n\n\x0c\n\x05\x04\x04\x02\x0c\x05\x12\x03+\x0b\x0f\n\x0c\n\x05\x04\x04\ + \x02\x0c\x01\x12\x03+\x10\x1c\n\x0c\n\x05\x04\x04\x02\x0c\x03\x12\x03+\ + \x1f!\n\x0b\n\x04\x04\x04\x02\r\x12\x03,\x02\x1b\n\x0c\n\x05\x04\x04\x02\ + \r\x04\x12\x03,\x02\n\n\x0c\n\x05\x04\x04\x02\r\x05\x12\x03,\x0b\x11\n\ + \x0c\n\x05\x04\x04\x02\r\x01\x12\x03,\x12\x15\n\x0c\n\x05\x04\x04\x02\r\ + \x03\x12\x03,\x18\x1a\n\n\n\x02\x04\x05\x12\x04/\02\x01\n\n\n\x03\x04\ + \x05\x01\x12\x03/\x08\r\n\x0b\n\x04\x04\x05\x02\0\x12\x030\x02\x20\n\x0c\ + \n\x05\x04\x05\x02\0\x04\x12\x030\x02\n\n\x0c\n\x05\x04\x05\x02\0\x05\ + \x12\x030\x0b\x11\n\x0c\n\x05\x04\x05\x02\0\x01\x12\x030\x12\x1b\n\x0c\n\ + \x05\x04\x05\x02\0\x03\x12\x030\x1e\x1f\n\x0b\n\x04\x04\x05\x02\x01\x12\ + \x031\x02\x1e\n\x0c\n\x05\x04\x05\x02\x01\x04\x12\x031\x02\n\n\x0c\n\x05\ + \x04\x05\x02\x01\x05\x12\x031\x0b\x11\n\x0c\n\x05\x04\x05\x02\x01\x01\ + \x12\x031\x12\x19\n\x0c\n\x05\x04\x05\x02\x01\x03\x12\x031\x1c\x1d\n\n\n\ + \x02\x04\x06\x12\x044\08\x01\n\n\n\x03\x04\x06\x01\x12\x034\x08\x0e\n\ + \x0b\n\x04\x04\x06\x02\0\x12\x035\x02\x1a\n\x0c\n\x05\x04\x06\x02\0\x04\ + \x12\x035\x02\n\n\x0c\n\x05\x04\x06\x02\0\x06\x12\x035\x0b\x0f\n\x0c\n\ + \x05\x04\x06\x02\0\x01\x12\x035\x10\x15\n\x0c\n\x05\x04\x06\x02\0\x03\ + \x12\x035\x18\x19\n\x0b\n\x04\x04\x06\x02\x01\x12\x036\x02\x1d\n\x0c\n\ + \x05\x04\x06\x02\x01\x04\x12\x036\x02\n\n\x0c\n\x05\x04\x06\x02\x01\x05\ + \x12\x036\x0b\x11\n\x0c\n\x05\x04\x06\x02\x01\x01\x12\x036\x12\x18\n\x0c\ + \n\x05\x04\x06\x02\x01\x03\x12\x036\x1b\x1c\n\x0b\n\x04\x04\x06\x02\x02\ + \x12\x037\x02\x1c\n\x0c\n\x05\x04\x06\x02\x02\x04\x12\x037\x02\n\n\x0c\n\ + \x05\x04\x06\x02\x02\x06\x12\x037\x0b\x10\n\x0c\n\x05\x04\x06\x02\x02\ + \x01\x12\x037\x11\x17\n\x0c\n\x05\x04\x06\x02\x02\x03\x12\x037\x1a\x1b\ +"; + +static file_descriptor_proto_lazy: ::protobuf::rt::LazyV2<::protobuf::descriptor::FileDescriptorProto> = ::protobuf::rt::LazyV2::INIT; fn parse_descriptor_proto() -> ::protobuf::descriptor::FileDescriptorProto { - ::protobuf::parse_from_bytes(file_descriptor_proto_data).unwrap() + ::protobuf::Message::parse_from_bytes(file_descriptor_proto_data).unwrap() } pub fn file_descriptor_proto() -> &'static ::protobuf::descriptor::FileDescriptorProto { - unsafe { - file_descriptor_proto_lazy.get(|| { - parse_descriptor_proto() - }) - } + file_descriptor_proto_lazy.get(|| { + parse_descriptor_proto() + }) } diff --git a/src/pb/mod.rs b/src/pb/mod.rs index 1e7cf76..87bc616 100644 --- a/src/pb/mod.rs +++ b/src/pb/mod.rs @@ -1,3 +1,3 @@ mod data_model; -pub use self::data_model::{Arrow, Gps, Meta, Node, Screen, Tag}; +pub use self::data_model::{Arrow, Date, Gps, Meta, Node, Screen, Tag}; diff --git a/src/plot.rs b/src/plot.rs index 4b364a4..72f8223 100644 --- a/src/plot.rs +++ b/src/plot.rs @@ -1,9 +1,11 @@ use std::cmp; -pub fn plot_sparkline(nums_in: Vec) -> String -where T: Into { - const BARS: [char; 9] = [' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']; +pub const BARS: [char; 9] = [' ', '▁', '▂', '▃', '▄', '▅', '▆', '▇', '█']; +pub fn plot_sparkline(nums_in: Vec) -> String +where + T: Into, +{ let nums: Vec<_> = nums_in.into_iter().map(|n| n.into()).collect(); let max = nums.iter().max().unwrap(); @@ -20,18 +22,26 @@ where T: Into { } pub fn bounded_count_sparkline(nums_in: Vec, start: T, end: T, bars: usize) -> String -where T: Into { +where + T: Into + PartialOrd, +{ if bars == 0 { return String::new(); } + let (start, end, rev) = if start <= end { + (start, end, false) + } else { + (end, start, true) + }; + let start = start.into(); let end = end.into(); let nums: Vec<_> = nums_in.into_iter().map(|n| n.into()).collect(); let step = (end - start) / bars as i64; let mut counts = vec![0; bars]; - if step == 0 || nums.is_empty() || end <= start { + if step == 0 || nums.is_empty() { return String::from_utf8(vec![b' '; bars]).unwrap(); } @@ -43,5 +53,11 @@ where T: Into { let idx = (n - start) / step; counts[cmp::min(idx, bars - 1)] += 1; } - plot_sparkline(counts) + + let plot = plot_sparkline(counts); + if rev { + plot.chars().rev().collect() + } else { + plot + } } diff --git a/src/screen.rs b/src/screen.rs index a25d15a..ae53fa1 100644 --- a/src/screen.rs +++ b/src/screen.rs @@ -1,11 +1,13 @@ use std::{ self, - cmp::{max, min}, + borrow::Cow, + cell::{RefCell, RefMut}, + cmp::{max, min, Ordering}, collections::{BTreeMap, BinaryHeap, HashMap, HashSet}, env, fmt::Write as FmtWrite, fs::{remove_file, rename, File, OpenOptions}, - io::{self, stdin, stdout, Error, ErrorKind, Read, Seek, SeekFrom, Stdout, Write}, + io::{self, stdin, stdout, BufWriter, Error, ErrorKind, Read, Seek, SeekFrom, Stdout, Write}, process, }; @@ -18,6 +20,7 @@ use termion::{ style, terminal_size, }; +use chrono::{Date, Datelike, Local, NaiveDate, TimeZone, Weekday}; use rand::{self, Rng}; use regex::Regex; use unicode_segmentation::UnicodeSegmentation; @@ -27,10 +30,29 @@ use crate::{ Action, Config, Coords, Dir, Node, NodeID, Pack, TagDB, }; +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +struct Selection { + selected_id: NodeID, + inserting: bool, +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +enum Cut { + Move(NodeID), + Yank(NodeID), + Empty, +} + +#[derive(Debug, PartialEq, Eq, Clone, Copy)] +enum UndoNode { + Delete(NodeID), + ToggleStricken(NodeID), +} + pub struct Screen { pub max_id: u64, pub nodes: HashMap, - pub arrows: Vec<(NodeID, NodeID)>, + pub arrows: Vec<(NodeID, NodeID, String)>, pub work_path: Option, pub autosave_every: usize, pub config: Config, @@ -42,14 +64,15 @@ pub struct Screen { // non-pub members are ephemeral drawing_root: NodeID, show_logs: bool, - selected: Option, - cut: Option, + show_calendar: bool, + selected: Option, + cut: Cut, drawing_arrow: Option, lookup: HashMap, drawn_at: HashMap, dragging_from: Option, dragging_to: Option, - stdout: Option>>>, + stdout: Option>>>>>, lowest_drawn: u16, // where we start drawing from view_y: u16, @@ -58,7 +81,7 @@ pub struct Screen { last_search: Option<(String, NodeID)>, // undo info - undo_stack: Vec, + undo_stack: Vec, // needs to be separate, as recursive deletion of nodes causes ordering issues undo_nodes: HashMap, @@ -81,19 +104,22 @@ pub struct Screen { impl Default for Screen { fn default() -> Screen { - let mut root = Node::default(); - root.content = "home".to_owned(); + let root = Node { + content: "home".to_owned(), + ..Node::default() + }; let mut screen = Screen { autosave_every: 25, config: Config::default(), arrows: vec![], selected: None, - cut: None, + cut: Cut::Empty, drawing_arrow: None, nodes: HashMap::new(), lookup: HashMap::new(), drawn_at: HashMap::new(), show_logs: false, + show_calendar: true, drawing_root: 0, stdout: None, dragging_from: None, @@ -119,11 +145,39 @@ impl Default for Screen { } } +macro_rules! write { + ($stdout:expr, $($arg:tt)*) => { + { + let out = ::std::format!($($arg)*); + ::std::write!($stdout, "{}", out) + } + }; +} + +macro_rules! writeln { + ($stdout:expr, $($arg:tt)*) => { + { + let out = ::std::format!($($arg)*); + ::std::writeln!($stdout, "{}", out) + } + }; +} + impl Screen { + fn assume_stdout(&self) -> RefMut<'_, impl Write> { + self.stdout.as_ref().unwrap().borrow_mut() + } + fn help(&mut self) { self.cleanup(); - println!("{}{}{}", cursor::Goto(1, 1), clear::All, self.config); self.start_raw_mode(); + writeln!( + self.assume_stdout(), + "{}{}{}", + cursor::Goto(1, 1), + clear::All, + self.config.to_string().replace("\n", "\r\n") + ); if self.single_key_prompt("").is_err() { // likely here because of testing } @@ -143,60 +197,100 @@ impl Screen { id } - pub fn with_node(&self, k: NodeID, mut f: F) -> Option + fn clone_node(&mut self, id: NodeID, new_parent_id: NodeID) -> Option { + let mut new_node = Node::new_from(self.nodes.get(&id)?); + let new_id = self.new_node_id(); + let new_children = new_node + .children + .iter() + .flat_map(|&child_id| self.clone_node(child_id, new_id)) + .collect(); + new_node.id = new_id; + new_node.children = new_children; + new_node.parent_id = new_parent_id; + + self.nodes.insert(new_id, new_node); + + Some(new_id) + } + + pub fn with_node(&self, k: NodeID, f: F) -> Option where F: FnMut(&Node) -> B, { - self.nodes.get(&k).map(|node| f(node)) + self.nodes.get(&k).map(f) } fn with_node_mut(&mut self, k: NodeID, mut f: F) -> Option where F: FnMut(&mut Node) -> B, { - self.nodes.get_mut(&k).map(|mut node| { + self.nodes.get_mut(&k).map(|node| { node.meta.bump_mtime(); - f(&mut node) + f(node) }) } - fn with_node_mut_no_meta(&mut self, k: NodeID, mut f: F) -> Option + fn with_node_mut_no_meta(&mut self, k: NodeID, f: F) -> Option where F: FnMut(&mut Node) -> B, { - self.nodes.get_mut(&k).map(|mut node| f(&mut node)) + self.nodes.get_mut(&k).map(f) } // return of false signals to the caller that we are done in this view pub fn handle_event(&mut self, evt: Event) -> bool { + // Write character to selection + if let Event::Key(Key::Char(k)) = evt { + if self.is_insert_mode() { + self.append(k); + return true; + } + } match self.config.map(evt) { Some(e) => match e { Action::LeftClick(x, y) => { let internal_coords = self.screen_to_internal_xy((x, y)); self.click_screen(internal_coords) - } + }, Action::RightClick(..) => { self.pop_focus(); - } + }, Action::Release(x, y) => { let internal_coords = self.screen_to_internal_xy((x, y)); self.release(internal_coords) - } - // Write character to selection - Action::Char(c) if self.selected.is_some() => { - self.append(c); - } + }, Action::Char('/') => { self.search_forward(); - } + }, Action::Char('?') => { self.search_backward(); - } - Action::Char(c) => { + }, + Action::Char(c) if !self.config.modal => { self.prefix_jump_to(c.to_string()); - } + }, + Action::Char(_) => {}, Action::Help => self.help(), - Action::UnselectRet => return self.unselect().is_some(), + Action::Insert => { + if let Some(sel) = self.selected.as_mut() { + // Invalidate the grapheme cache, because an insertion cursor is being added + self.grapheme_cache.remove(&sel.selected_id); + sel.inserting = true + } + }, + + Action::UnselectRet + if self.config.modal && self.selected.map(|s| s.inserting) == Some(true) => + { + if let Some(sel) = self.selected.as_mut() { + // Invalidate the grapheme cache, because an insertion cursor is being removed + self.grapheme_cache.remove(&sel.selected_id); + sel.inserting = false + } + }, + Action::UnselectRet => { + self.unselect(); + }, Action::ScrollUp => self.scroll_up(), Action::ScrollDown => self.scroll_down(), Action::DeleteSelected => self.delete_selected(true), @@ -204,7 +298,8 @@ impl Screen { Action::SelectDown => self.select_down(), Action::SelectLeft => self.select_left(), Action::SelectRight => self.select_right(), - Action::EraseChar => self.backspace(), + Action::EraseChar if self.is_insert_mode() => self.backspace(), + Action::EraseChar => {}, Action::CreateSibling => self.create_sibling(), Action::CreateChild => self.create_child(), Action::CreateFreeNode => self.create_free_node(), @@ -212,7 +307,7 @@ impl Screen { Action::DrillDown => self.drill_down(), Action::PopUp => self.pop_focus(), Action::PrefixJump => self.prefix_jump_prompt(), - Action::ToggleCompleted => self.toggle_stricken(), + Action::ToggleCompleted => self.toggle_stricken(true), Action::ToggleHideCompleted => self.toggle_hide_stricken(), Action::Arrow => self.add_or_remove_arrow(), Action::AutoArrange => self.toggle_auto_arrange(), @@ -222,14 +317,17 @@ impl Screen { Action::ToggleShowLogs => self.toggle_show_logs(), Action::EnterCmd => self.enter_cmd(), Action::FindTask => self.auto_task(), - Action::YankPasteNode => self.cut_paste(), + Action::YankPasteNode => self.cut_paste(true), + Action::MovePasteNode => self.cut_paste(false), Action::RaiseSelected => self.raise_selected(), Action::LowerSelected => self.lower_selected(), Action::Search => self.search_forward(), - Action::UndoDelete => self.undo_delete(), + Action::Undo => self.undo(), Action::SelectParent => self.select_parent(), Action::SelectNextSibling => self.select_next_sibling(), Action::SelectPrevSibling => self.select_prev_sibling(), + Action::SelectFirstSibling => self.select_first_sibling(), + Action::SelectLastSibling => self.select_last_sibling(), }, None => warn!("received unknown input"), } @@ -240,16 +338,35 @@ impl Screen { self.nodes.get(&node_id).is_some() } - fn cut_paste(&mut self) { - if let Some(selected_id) = self.selected { - if let Some(cut) = self.cut.take() { - self.reparent(cut, selected_id); - } else { - self.cut = Some(selected_id); - } - } else if let Some(cut) = self.cut.take() { - let root = self.drawing_root; - self.reparent(cut, root); + fn cut_paste(&mut self, yanking: bool) { + let can_cut = self.selected.is_some(); + let place = self + .selected + .map_or(self.drawing_root, |sel| sel.selected_id); + match self.cut { + Cut::Move(cut) => { + self.reparent(cut, place); + self.cut = Cut::Empty; + }, + Cut::Yank(cut) => { + if self.is_parent(cut, place) { + warn!("Can't copy a node into itself"); + return; + } + if let Some(new_id) = self.clone_node(cut, place) { + self.with_node_mut_no_meta(place, |parent_nd| { + parent_nd.children.push(new_id); + }); + } + self.cut = Cut::Empty; + }, + Cut::Empty if yanking && can_cut => { + self.cut = Cut::Yank(place); + }, + Cut::Empty if can_cut => { + self.cut = Cut::Move(place); + }, + Cut::Empty => {}, } } @@ -300,7 +417,10 @@ impl Screen { .children .iter() .cloned() - .filter(|&c| self.with_node(c, |c| !c.stricken).unwrap()) + .filter(|&c| { + self.with_node(c, |c| !c.stricken && !c.content.contains("#ignr")) + .unwrap() + }) .collect(); if incomplete_children.is_empty() { leaves.push(root_id); @@ -357,7 +477,7 @@ impl Screen { .and_then(|c| { if RE.is_match(&*c) { RE.captures_iter(&*c) - .nth(0) + .next() .and_then(|n| n.get(1).unwrap().as_str().parse::().ok()) } else { None @@ -372,17 +492,18 @@ impl Screen { } let stdin: Box = Box::new(stdin()); - print!( + write!( + self.assume_stdout(), "{}{}{}{}", - cursor::Goto(0, self.dims.1), + cursor::Goto(1, self.dims.1), style::Invert, clear::AfterCursor, prompt ); self.flush(); - let res = stdin.keys().nth(0).unwrap(); + let res = stdin.keys().next().unwrap(); debug!("read prompt: {:?}", res); - print!("{}", style::Reset); + write!(self.assume_stdout(), "{}", style::Reset); res } @@ -393,10 +514,11 @@ impl Screen { } let mut stdin: Box = Box::new(stdin()); - print!( + write!( + self.assume_stdout(), "{}{}{}{}{}", style::Invert, - cursor::Goto(0, self.dims.1), + cursor::Goto(1, self.dims.1), clear::AfterCursor, prompt, cursor::Show @@ -405,7 +527,7 @@ impl Screen { let res = stdin.read_line(); self.start_raw_mode(); debug!("read prompt: {:?}", res); - print!("{}", style::Reset); + write!(self.assume_stdout(), "{}", style::Reset); res } @@ -436,7 +558,7 @@ impl Screen { SearchDirection::Backward => format!("search backwards{}:", last_search_str), }; if let Ok(Some(mut query)) = self.prompt(&*prompt) { - if query == "" { + if query.is_empty() { if let Some((ref last, _)) = self.last_search { query = last.clone(); } else { @@ -447,12 +569,13 @@ impl Screen { self.last_search.take(); } - let mut f = |n: &Node| n.content.find(&*query).map(|idx| (idx, n.id)); - let mut candidates = self.recursive_child_filter_map(self.drawing_root, &mut f); + let mut f = + |n: &Node, _: ()| (n.content.find(&*query).map(|idx| (idx, n.id)), (), true); + let mut candidates = self.recursive_child_filter_map(self.drawing_root, (), &mut f); if candidates.is_empty() { return; } - candidates.sort(); + candidates.sort_unstable(); let choice = if let Some((_, last_choice)) = self.last_search.take() { let idx = candidates .iter() @@ -503,13 +626,19 @@ impl Screen { chars.split("").skip(1).zip(nodes.into_iter()).collect(); // clear the prompt - print!("{}{}", cursor::Goto(1, self.dims.1), clear::AfterCursor); + write!( + self.assume_stdout(), + "{}{}", + cursor::Goto(1, self.dims.1), + clear::AfterCursor + ); // print the hilighted char at each choice for (&c, &node_id) in &mapping { let &coords = self.drawn_at(node_id).unwrap(); let (x, y) = self.internal_to_screen_xy(coords).unwrap(); - print!( + write!( + self.assume_stdout(), "{}{}{}{}", cursor::Goto(x, y), style::Invert, @@ -549,21 +678,30 @@ impl Screen { // want to accidentally execute rm -rf / return; } - let selected_id = self.selected.unwrap(); + lazy_static! { + static ref RE_TAG: Regex = Regex::new(r"([^#])#[^#\s]+").unwrap(); + }; + let Selection { selected_id, .. } = self.selected.unwrap(); - let content_opt = self.with_node(selected_id, |n| n.content.clone()); + let content_opt = self.with_node(selected_id, |n| (n.url.clone(), n.content.clone())); if content_opt.is_none() { error!("tried to exec deleted node"); return; } - let content = content_opt.unwrap(); + let (url, content) = content_opt.unwrap(); + + // remove any tags from the exec + // except for those that are escaped as ## + let content = RE_TAG.replace_all(&content, "$1").replace("##", "#"); info!("executing command: {}", content); - if content.is_empty() { + let handle = if content.is_empty() { error!("cannot execute empty command"); + None } else if content.starts_with("txt:") { self.exec_text_editor(selected_id); - } else if content.starts_with("http") { + None + } else if let Some(url) = url { #[cfg(any(target_os = "macos",))] let default_open_cmd = "open"; #[cfg(target_os = "linux")] @@ -572,16 +710,29 @@ impl Screen { let default_open_cmd = "start"; let browser = env::var("BROWSER").unwrap_or_else(|_| default_open_cmd.to_owned()); - let cmd = process::Command::new(browser).arg(&content).spawn(); - if cmd.is_err() { - error!("command failed to start: {}", &content); - } + let cmd = process::Command::new(browser) + .arg(&url) + .stdout(process::Stdio::null()) + .stderr(process::Stdio::null()) + .spawn(); + Some(cmd) } else { let shell = env::var("SHELL").unwrap_or_else(|_| "bash".to_owned()); let cmd = process::Command::new(shell).arg("-c").arg(&content).spawn(); - if cmd.is_err() { + Some(cmd) + }; + match handle { + Some(Err(_)) => { error!("command failed to start: {}", &content); - } + }, + Some(Ok(mut child)) => { + std::thread::spawn(move || { + if matches!(child.wait(), Err(..)) { + error!("command failed to finish: {}", &content); + } + }); + }, + None => {}, } } @@ -672,19 +823,28 @@ impl Screen { } } - pub fn recursive_child_filter_map(&self, node_id: NodeID, filter_map: &mut F) -> Vec + pub fn recursive_child_filter_map( + &self, + node_id: NodeID, + context: C, + filter_map: &mut F, + ) -> Vec where - F: FnMut(&Node) -> Option, + F: FnMut(&Node, C) -> (Option, C, bool), + C: Copy, { trace!("recursive_child_filter_map({}, F...)", node_id); let mut ret = vec![]; if let Some(node) = self.nodes.get(&node_id) { - if let Some(b) = filter_map(node) { + let (filtered, context, walk) = filter_map(node, context); + if let Some(b) = filtered { ret.push(b); } - for &child_id in &node.children { - ret.append(&mut self.recursive_child_filter_map(child_id, filter_map)); + if walk { + for &child_id in &node.children { + ret.append(&mut self.recursive_child_filter_map(child_id, context, filter_map)); + } } } else { debug!("queried for node {} but it is not in self.nodes", node_id); @@ -707,7 +867,24 @@ impl Screen { let raw_node_opt = self.with_node(node_id, |n| n.clone()); if let Some(raw_node) = raw_node_opt { let node = self.format_node(&raw_node); - let width = 1 + (3 * depth as u16) + node.content.len() as u16; + let mut width = 2 + (3 * depth as u16) + node.content.len() as u16; + + if node.hide_stricken { + width += 1; + } + if node.free_text.is_some() { + width += 1; + } + if node.stricken { + width += 1; + } + if node.url.is_some() { + width += 1; + } + if node.collapsed { + width += 1; + } + let mut ret = vec![width]; let hide_stricken = self.with_node(node_id, |n| n.hide_stricken).unwrap(); if !node.collapsed { @@ -730,7 +907,7 @@ impl Screen { pub fn flush(&mut self) { trace!("flush()"); if let Some(mut s) = self.stdout.take() { - s.flush().unwrap(); + s.get_mut().flush().unwrap(); self.stdout = Some(s); } } @@ -738,9 +915,10 @@ impl Screen { fn unselect(&mut self) -> Option { trace!("unselect()"); lazy_static! { - static ref RE_DATE: Regex = Regex::new(r"\[(\S+)\]").unwrap(); + static ref RE_DATE: Regex = Regex::new(r"\[(\d{2}\.\d{2}\.\d{4})\]").unwrap(); + static ref RE_URL: Regex = Regex::new(r"#url=(.*)$").unwrap(); } - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { // nuke node if it's empty and has no children let deletable = self .with_node_mut_no_meta(selected_id, |n| { @@ -753,23 +931,37 @@ impl Screen { return None; } + let mut invalidate_cache = false; self.with_node_mut_no_meta(selected_id, |n| { // if parseable date, change date + let mut due_date_set = false; if let Some(date) = re_matches::(&RE_DATE, &*n.content).get(0) { - if let Some(date) = dateparse(date.clone()) { - n.content = RE_DATE.replace(&*n.content, "").trim_end().to_owned(); - if n.meta.finish_time.is_some() { - n.meta.finish_time = Some(date); - } else { - let now_in_s = now().as_secs(); - let future_date = now_in_s + (now_in_s - date); - n.meta.due = Some(future_date); - } + if let Ok(date) = NaiveDate::parse_from_str(date, "%d.%m.%Y") { + let date = Local.from_local_date(&date).unwrap(); + n.meta.due_date = Some(date); + due_date_set = true; + } + } + + if let Some(url) = re_matches::(&RE_URL, &*n.content).get(0) { + n.content = RE_URL.replace(&*n.content, "").trim_end().to_owned(); + invalidate_cache = true; + if url.is_empty() { + n.url = None; + } else { + n.url = Some(url.to_owned()); } } + + if !due_date_set { + n.meta.due_date = None; + } }); + if invalidate_cache { + self.grapheme_cache.remove(&selected_id); + } } - self.selected.take() + self.selected.take().map(|s| s.selected_id) } fn internal_to_screen_xy(&self, coords: Coords) -> Option { @@ -812,11 +1004,14 @@ impl Screen { node.selected = true; node_id }) - .and_then(|id| { - self.selected = Some(node_id); + .map(|id| { + self.selected = Some(Selection { + selected_id: node_id, + inserting: !self.config.modal, + }); self.dragging_from = Some(coords); self.dragging_to = Some(coords); - Some(id) + id }) .or_else(|| { trace!("found no node at {:?}", coords); @@ -830,16 +1025,36 @@ impl Screen { None } - fn toggle_stricken(&mut self) { + fn toggle_stricken(&mut self, make_undo: bool) { trace!("toggle_stricken()"); - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { + if make_undo { + self.undo_stack.push(UndoNode::ToggleStricken(selected_id)); + } self.with_node_mut(selected_id, |node| node.toggle_stricken()); + if let Some(parent_id) = self.parent(selected_id) { + if let Some(child_pos) = self.with_node(parent_id, |p| { + p.children + .iter() + .copied() + .enumerate() + .find(|(_, id)| *id == selected_id) + .unwrap() + .0 + }) { + if let Some(new_selection) = + self.find_near_sibling_or_parent(parent_id, child_pos) + { + self.select_node(new_selection); + } + } + } } } fn toggle_hide_stricken(&mut self) { trace!("toggle_hide_stricken()"); - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { self.with_node_mut(selected_id, |node| node.toggle_hide_stricken()); } } @@ -849,7 +1064,7 @@ impl Screen { if let Some(node) = self.nodes.remove(&node_id) { // clean up any arrow state self.arrows - .retain(|&(ref from, ref to)| from != &node_id && to != &node_id); + .retain(|&(ref from, ref to, _)| from != &node_id && to != &node_id); // remove from tag_db self.tag_db.remove(node_id); @@ -862,32 +1077,75 @@ impl Screen { } } + fn find_near_sibling_or_parent(&self, parent_id: NodeID, child_pos: usize) -> Option { + self.with_node(parent_id, |p| { + if p.children.is_empty() { + parent_id + } else if !p.hide_stricken { + p.children[min(child_pos, p.children.len() - 1)] + } else { + let forward_search = p + .children + .iter() + .copied() + .skip(child_pos) + .find(|id| self.with_node(*id, |sibling| !sibling.stricken) == Some(true)); + forward_search + .or_else(|| { + p.children.iter().copied().take(child_pos).rfind(|id| { + self.with_node(*id, |sibling| !sibling.stricken) == Some(true) + }) + }) + .unwrap_or(parent_id) + } + }) + } + fn delete_selected(&mut self, reselect: bool) { trace!("delete_selected()"); - if let Some(selected_id) = self.selected.take() { - let (_, height) = self.drawable_subtree_dims(selected_id).unwrap(); - let coords = self.drawn_at.remove(&selected_id); + if let Some(Selection { selected_id, .. }) = self.selected.take() { + self.drawn_at.remove(&selected_id); // remove ref from parent if let Some(parent_id) = self.parent(selected_id) { trace!("deleting node {} from parent {}", selected_id, parent_id); - self.with_node_mut_no_meta(parent_id, |p| p.children.retain(|c| c != &selected_id)) + let child_pos = self + .with_node_mut_no_meta(parent_id, |p| { + let self_pos = p + .children + .iter() + .enumerate() + .find(|(_, id)| **id == selected_id) + .unwrap() + .0; + p.children.remove(self_pos); + self_pos + }) .unwrap(); - } - // remove children - self.delete_recursive(selected_id); - if let Some((x, y)) = coords { if reselect { - self.click_select((x, y + height)); + if let Some(next_selection) = + self.find_near_sibling_or_parent(parent_id, child_pos) + { + self.select_node(next_selection); + } } } - self.undo_stack.push(selected_id); + // remove children + self.delete_recursive(selected_id); + self.undo_stack.push(UndoNode::Delete(selected_id)); } } - fn undo_delete(&mut self) { - if let Some(node_id) = self.undo_stack.pop() { - self.recursive_restore(node_id).unwrap(); - self.select_node(node_id); + fn undo(&mut self) { + match self.undo_stack.pop() { + Some(UndoNode::Delete(node_id)) => { + self.recursive_restore(node_id).unwrap(); + self.select_node(node_id); + }, + Some(UndoNode::ToggleStricken(node_id)) => { + self.select_node(node_id); + self.toggle_stricken(false); + }, + None => {}, } } @@ -929,8 +1187,6 @@ impl Screen { for (num_events, c) in stdin.events().enumerate() { let evt = c.unwrap(); - self.dims = terminal_size().unwrap(); - let should_break = !self.handle_event(evt); self.draw(); @@ -955,12 +1211,12 @@ impl Screen { } } trace!("leaving stdin.events() loop"); - print!("{}{}", cursor::Goto(1, 1), clear::All); + write!(self.assume_stdout(), "{}{}", cursor::Goto(1, 1), clear::All); } fn toggle_collapsed(&mut self) { trace!("toggle_collapsed()"); - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { self.with_node_mut_no_meta(selected_id, |node| node.toggle_collapsed()); } } @@ -970,7 +1226,10 @@ impl Screen { } fn create_child(&mut self) { - if let Some(mut selected_id) = self.selected { + if let Some(Selection { + mut selected_id, .. + }) = self.selected + { if self .with_node(selected_id, |n| n.content.is_empty()) .unwrap() @@ -1005,9 +1264,10 @@ impl Screen { self.with_node_mut_no_meta(node_id, |node| node.parent_id = selected_id); let added = self.with_node_mut_no_meta(selected_id, |selected| { selected.children.push(node_id); + selected.collapsed = false; }); if added.is_some() { - self.select_node(node_id); + self.select_node_ensure_inserting(node_id); } else { self.delete_recursive(node_id); } @@ -1015,7 +1275,10 @@ impl Screen { } fn create_sibling(&mut self) { - if let Some(mut selected_id) = self.selected { + if let Some(Selection { + mut selected_id, .. + }) = self.selected + { if self .with_node(selected_id, |n| n.content.is_empty()) .unwrap() @@ -1027,7 +1290,7 @@ impl Screen { // because that's not underneath the drawing root return; } - self.select_node(sel_parent); + self.select_node_ensure_inserting(sel_parent); selected_id = sel_parent; } let selected_id = selected_id; @@ -1052,7 +1315,7 @@ impl Screen { parent.children.insert(idx + 1, node_id); }); if added.is_some() { - self.select_node(node_id); + self.select_node_ensure_inserting(node_id); } else { self.delete_recursive(node_id); } @@ -1101,12 +1364,12 @@ impl Screen { node.parent_id = root; }); self.with_node_mut_no_meta(root, |root| root.children.push(node_id)); - self.select_node(node_id); + self.select_node_ensure_inserting(node_id); } fn backspace(&mut self) { trace!("backspace"); - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { if let Some(content) = self.with_node_mut(selected_id, |node| { let content = node.content.clone(); let chars = content.chars(); @@ -1123,7 +1386,7 @@ impl Screen { fn append(&mut self, c: char) { trace!("append({})", c); - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { if let Some(content) = self.with_node_mut(selected_id, |node| { node.content.push(c); node.content.clone() @@ -1212,7 +1475,7 @@ impl Screen { let dx = to.0 as i16 - from.0 as i16; let dy = to.1 as i16 - from.1 as i16; - let selected_id = if let Some(selected_id) = self.selected { + let selected_id = if let Some(Selection { selected_id, .. }) = self.selected { if self.is_parent(self.drawing_root, selected_id) { selected_id } else { @@ -1273,7 +1536,7 @@ impl Screen { } fn select_parent(&mut self) { - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { // If no parent, this should be a no-op. if let Some(parent_id) = self.parent(selected_id) { // If we're at a toplevel task (i.e., 0 is its parent ID), we don't want to @@ -1285,6 +1548,28 @@ impl Screen { } } + fn select_first_sibling(&mut self) { + if let Some(Selection { selected_id, .. }) = self.selected { + if let Some(parent_id) = self.parent(selected_id) { + if let Some(parent) = self.nodes.get(&parent_id) { + let choose = *parent.children.first().unwrap(); + self.select_node(choose); + } + } + } + } + + fn select_last_sibling(&mut self) { + if let Some(Selection { selected_id, .. }) = self.selected { + if let Some(parent_id) = self.parent(selected_id) { + if let Some(parent) = self.nodes.get(&parent_id) { + let choose = *parent.children.last().unwrap(); + self.select_node(choose); + } + } + } + } + fn select_next_sibling(&mut self) { self.select_neighbor(SearchDirection::Forward); } @@ -1295,7 +1580,7 @@ impl Screen { fn select_neighbor(&mut self, dir: SearchDirection) -> Option { use SearchDirection::*; - let selected_id = self.selected?; + let selected_id = self.selected?.selected_id; let parent = self.nodes.get(&self.parent(selected_id)?)?; let selected_idx = parent.children.iter().position(|&id| id == selected_id)? as u64; @@ -1337,14 +1622,6 @@ impl Screen { } } - fn click_select(&mut self, coords: Coords) -> Option { - trace!("click_select({:?})", coords); - let result = self.try_select(coords); - self.dragging_from.take(); - self.dragging_to.take(); - result - } - fn scroll_up(&mut self) { self.view_y = max(self.view_y, self.dims.1 / 2) - self.dims.1 / 2; self.unselect(); @@ -1358,7 +1635,7 @@ impl Screen { } fn scroll_to_selected(&mut self) -> bool { - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { self.scroll_to_node(selected_id) } else { false @@ -1394,17 +1671,13 @@ impl Screen { } } - // save old location and jump - let old_select = self.unselect().unwrap_or(0); - let breadcrumb = (self.drawing_root, old_select, self.view_y); - self.focus_stack.push(breadcrumb); self.drawing_root = cursor; self.select_node(node_id); self.draw(); } fn raise_selected(&mut self) { - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { if !self.exists(selected_id) { warn!("tried to raise deleted node"); return; @@ -1414,20 +1687,43 @@ impl Screen { // principle: don't modify things that are above the visible scope return; } - self.with_node_mut_no_meta(parent_id, |parent| { + + if let Some((swap_from, swap_to)) = self.with_node(parent_id, |parent| { let idx = parent .children .iter() .position(|&e| e == selected_id) .unwrap(); + let to = max(idx, 1) - 1; - parent.children.swap(idx, to); - }); + let hide_stricken = parent.hide_stricken; + if !hide_stricken { + (idx, to) + } else { + ( + idx, + parent.children[..idx] + .iter() + .enumerate() + .rfind(|(_, child_id)| { + self.with_node(**child_id, |child| child.stricken) == Some(false) + }) + .map(|(child_idx, _)| child_idx) + .unwrap_or(0), + ) + } + }) { + self.with_node_mut_no_meta(parent_id, |parent| { + for i in (swap_to..swap_from).rev() { + parent.children.swap(i, i + 1); + } + }); + } } } fn lower_selected(&mut self) { - if let Some(selected_id) = self.selected { + if let Some(Selection { selected_id, .. }) = self.selected { if !self.exists(selected_id) { warn!("tried to lower deleted node"); return; @@ -1437,18 +1733,45 @@ impl Screen { // principle: don't modify things that are above the visible scope return; } - self.with_node_mut_no_meta(parent_id, |parent| { + + if let Some((swap_from, swap_to)) = self.with_node(parent_id, |parent| { let idx = parent .children .iter() .position(|&e| e == selected_id) .unwrap(); + let len = parent.children.len(); - if len > 1 { - let to = min(idx, len - 2) + 1; - parent.children.swap(idx, to); + if len <= 1 { + return (idx, 1); } - }); + + let to = min(idx, len - 2) + 1; + let hide_stricken = parent.hide_stricken; + if !hide_stricken { + (idx, to) + } else { + ( + idx, + parent + .children + .iter() + .enumerate() + .skip(idx + 1) + .find(|(_, child_id)| { + self.with_node(**child_id, |child| child.stricken) == Some(false) + }) + .map(|(child_idx, _)| child_idx) + .unwrap_or(len - 1), + ) + } + }) { + self.with_node_mut_no_meta(parent_id, |parent| { + for i in swap_from..swap_to { + parent.children.swap(i, i + 1); + } + }); + } } } @@ -1524,7 +1847,7 @@ impl Screen { let cur = self .selected - .and_then(|s| self.bounds_for_lookup(s)) + .and_then(|s| self.bounds_for_lookup(s.selected_id)) .unwrap_or((rel_def_coords, rel_def_coords)); let mut node_costs = vec![]; @@ -1552,7 +1875,31 @@ impl Screen { .with_node_mut_no_meta(node_id, |node| node.selected = true) .is_some() { - self.selected = Some(node_id); + self.selected = Some(Selection { + selected_id: node_id, + inserting: !self.config.modal, + }); + } + } + } + + fn select_node_ensure_inserting(&mut self, node_id: NodeID) { + trace!("select_node({})", node_id); + self.unselect(); + if node_id != 0 { + // it's possible that unselecting above actually caused + // this node to be deleted, due to its parent (previous + // selection) being empty. To account for this, we need + // to only set self.selected to node_id if the with_node + // succeeds. + if self + .with_node_mut_no_meta(node_id, |node| node.selected = true) + .is_some() + { + self.selected = Some(Selection { + selected_id: node_id, + inserting: true, + }); } } } @@ -1563,7 +1910,7 @@ impl Screen { warn!("click way off-screen"); return; } - let old = self.selected; + let old = self.selected.map(|s| s.selected_id); let new = self.try_select(coords); if old.is_none() && self.dragging_from.is_none() { self.create_anchor(coords); @@ -1625,7 +1972,7 @@ impl Screen { debug!("testing that all arrows are existing nodes"); // no arrows that don't exist - for &(ref a, ref b) in &self.arrows { + for &(ref a, ref b, _) in &self.arrows { assert!(self.nodes.get(a).is_some()); assert!(self.nodes.get(b).is_some()); } @@ -1651,15 +1998,17 @@ impl Screen { pub fn cleanup(&mut self) { trace!("cleanup()"); - print!("{}", cursor::Show); - self.stdout.take().unwrap().flush().unwrap(); + write!(self.assume_stdout(), "{}", cursor::Show); + self.stdout.take().unwrap().get_mut().flush().unwrap(); } pub fn start_raw_mode(&mut self) { if self.stdout.is_none() { - self.stdout = Some(MouseTerminal::from( - AlternateScreen::from(stdout()).into_raw_mode().unwrap(), - )); + self.stdout = Some(RefCell::new(MouseTerminal::from( + AlternateScreen::from(BufWriter::with_capacity(8192 * 1024, stdout())) + .into_raw_mode() + .unwrap(), + ))); } } @@ -1669,24 +2018,28 @@ impl Screen { pub fn add_or_remove_arrow(&mut self) { if self.drawing_arrow.is_none() { - self.drawing_arrow = self.selected; + self.drawing_arrow = self.selected.map(|s| s.selected_id); return; } let from = self.drawing_arrow.take().unwrap(); - if let Some(arrow) = self.selected.map(|to| (from, to)) { + if let Some(arrow) = self.selected.map(|to| (from, to.selected_id)) { let (from, to) = arrow; if self.nodes.get(&from).is_some() && self.nodes.get(&to).is_some() { - let contains = self.arrows.iter().fold(false, |acc, &(ref nl1, ref nl2)| { - if nl1 == &from && nl2 == &to { - true - } else { - acc - } - }); + let contains = self + .arrows + .iter() + .fold(false, |acc, &(ref nl1, ref nl2, _)| { + if nl1 == &from && nl2 == &to { + true + } else { + acc + } + }); if contains { - self.arrows.retain(|e| e != &arrow); + self.arrows + .retain(|(old_from, old_to, _)| (*old_from, *old_to) != arrow); } else { - self.arrows.push(arrow); + self.arrows.push((from, to, random_fg_color())); } } } @@ -1712,6 +2065,167 @@ impl Screen { } } + fn reserve_and_draw_calendar(&mut self) { + if !self.show_calendar { + return; + } + const CALENDAR_WIDTH: u16 = 1 + // vertical line + 4 + // week numbers + padding + 3*7; // days + if self.dims.0 < CALENDAR_WIDTH { + return; + } + self.dims.0 -= CALENDAR_WIDTH; + + let today = Local::today(); + let mut date = today + .with_day(max( + 1i32, + today.day() as i32 - today.weekday().num_days_from_monday() as i32, + ) as u32) + .unwrap(); + let mut line = 2; + let max_line = self.dims.1; + 'make_month: loop { + if line >= max_line { + break; + } + + let (month, year) = (date.month(), date.year()); + let month_assigned_days = self.recursive_child_filter_map( + self.drawing_root, + None, + &mut |nd: &Node, default_date: Option>| { + let date = nd.meta.due_date.or(default_date); + if let Some(assigned) = date { + if !nd.stricken + && nd.children.is_empty() + && assigned.year() == year + && assigned.month() == month + { + (Some(assigned.day0()), date, false) + } else if !nd.stricken { + (None, date, true) + } else { + (None, None, false) + } + } else { + (None, None, !nd.stricken) + } + }, + ); + let mut counts_by_day = [0usize; 31]; + for day in month_assigned_days { + counts_by_day[day as usize] += 1; + } + + let month_header = format!( + "{}│{}{:^width$}{}", + cursor::Goto(self.dims.0, line), + style::Bold, + date.format("%B %Y").to_string(), + style::Reset, + width = (CALENDAR_WIDTH - 1) as usize, + ); + + writeln!(self.assume_stdout(), "{}", month_header); + line += 1; + if line >= max_line { + break; + } + + let weekday_header = format!( + "{}│ │ M T W T F S S", + cursor::Goto(self.dims.0, line) + ); + writeln!(self.assume_stdout(), "{}", weekday_header); + line += 1; + if line >= max_line { + break; + } + + let week_header = format!( + "{}│{:3}│{}│ │", + cursor::Goto(self.dims.0, line), + date.iso_week().week(), + cursor::Goto(self.dims.0, line + 1), + ); + write!(self.assume_stdout(), "{}", week_header); + + loop { + if line >= max_line { + break 'make_month; + } + + let offset_x = self.dims.0 + 5 + date.weekday().num_days_from_monday() as u16 * 3; + let day_label = format!( + "{}{}{:3}{}", + cursor::Goto(offset_x, line), + if today == date { + &style::Bold as &dyn std::fmt::Display + } else { + &style::Reset as &dyn std::fmt::Display + }, + date.day(), + style::Reset, + ); + write!(self.assume_stdout(), "{}", day_label); + + if line + 1 < max_line { + let assigned = counts_by_day[date.day0() as usize]; + if assigned > 0 && assigned < 100 { + let day_assigned_tasks_label = format!( + "{}{}{:3}{}", + cursor::Goto(offset_x, line + 1), + style::Italic, + assigned, + style::Reset, + ); + write!(self.assume_stdout(), "{}", day_assigned_tasks_label); + } else if assigned > 0 { + let day_assigned_tasks_label = format!( + "{}{}{:3}{}", + cursor::Goto(offset_x, line + 1), + style::Italic, + "?!", + style::Reset, + ); + write!(self.assume_stdout(), "{}", day_assigned_tasks_label); + } + } + + let prev_month = date.month(); + date = date.succ(); + + if prev_month != date.month() { + break; + } + + if date.weekday() == Weekday::Mon { + line += 2; + if line >= max_line { + break 'make_month; + } + + let week_header = format!( + "{}│{:3}│{}│ │", + cursor::Goto(self.dims.0, line), + date.iso_week().week(), + cursor::Goto(self.dims.0, line + 1), + ); + write!(self.assume_stdout(), "{}", week_header); + } + } + line += 2; + if line >= max_line { + break; + } + + writeln!(self.assume_stdout(), "{}│", cursor::Goto(self.dims.0, line)); + line += 1; + } + } + // * // * // *┌──┐ @@ -1731,42 +2245,50 @@ impl Screen { self.lookup.clear(); self.drawn_at.clear(); self.lowest_drawn = 0; - print!("{}", clear::All); + write!(self.assume_stdout(), "{}", clear::All); - // print visible nodes - self.draw_children_of_root(); + self.dims = terminal_size().unwrap(); // TODO figure out why header doesn't get shown // when a root node is NOT drawn at 1,1 // (this only happens when draw_header() is above // the call to draw_children_of_root()... + self.draw_header(); + self.reserve_and_draw_calendar(); + + // print visible nodes + self.draw_children_of_root(); // print logs if self.show_logs && self.dims.0 > 4 && self.dims.1 > 7 { let mut sep = format!( "{}{}logs{}", - cursor::Goto(0, self.dims.1 - 6), + cursor::Goto(1, self.dims.1 - 6), style::Invert, style::Reset ); for _ in 0..self.dims.0 - 4 { sep.push('█'); } - println!("{}", sep); + writeln!(self.assume_stdout(), "{}", sep); { let logs = logging::read_logs(); for msg in logs.iter().rev() { let line_width = min(msg.len(), self.dims.0 as usize); - println!("\r{}", msg[..line_width as usize].to_owned()); + writeln!( + self.assume_stdout(), + "\r{}", + msg[..line_width as usize].to_owned() + ); } } } // print arrows - for &(ref from, ref to) in &self.arrows { + for &(ref from, ref to, ref color) in &self.arrows { let (path, (direction1, direction2)) = self.path_between_nodes(*from, *to); - self.draw_path(path, direction1, direction2); + self.draw_path(path, direction1, direction2, color); } // conditionally print drag dest arrow @@ -1778,11 +2300,11 @@ impl Screen { if let Some(to_node) = self.lookup(to) { let (path, (direction1, direction2)) = self.path_between_nodes(*from_node, *to_node); - self.draw_path(path, direction1, direction2); + self.draw_path(path, direction1, direction2, &random_fg_color()); } else { let (path, (direction1, direction2)) = self.path_from_node_to_point(*from_node, to); - self.draw_path(path, direction1, direction2); + self.draw_path(path, direction1, direction2, &random_fg_color()); } } else { warn!("dragging_from set, but NOT dragging_to"); @@ -1795,7 +2317,7 @@ impl Screen { self.draw_scrollbar(); } - print!("{}", cursor::Hide); + write!(self.assume_stdout(), "{}", cursor::Hide); self.flush(); // let after = time::get_time(); @@ -1803,7 +2325,7 @@ impl Screen { // debug!("draw time: {}", after - before); } - fn draw_scrollbar(&self) { + fn draw_scrollbar(&mut self) { let bar_height = max(self.dims.1, 1) - 1; let normalized_lowest = f64::from(max(self.lowest_drawn, 1)); let fraction_viewable = f64::from(self.dims.1) / normalized_lowest; @@ -1815,9 +2337,9 @@ impl Screen { for (i, y) in (2..bar_height + 2).enumerate() { if i >= shade_start && i < shade_end { - print!("{}┃", cursor::Goto(self.dims.0, y)); + write!(self.assume_stdout(), "{}┃", cursor::Goto(self.dims.0, y)); } else { - print!("{}│", cursor::Goto(self.dims.0, y)); + write!(self.assume_stdout(), "{}│", cursor::Goto(self.dims.0, y)); } } } @@ -1883,17 +2405,21 @@ impl Screen { let reset = &*format!("{}", color::Fg(color::Reset)); let mut pre_meta = String::new(); + let mut post_content = String::new(); let mut buf = String::new(); // only actually print it if we're in-view if let Some((x, y)) = self.internal_to_screen_xy(internal_coords) { + if x < 1 || y < 1 { + warn!("drawn at {} {}", x, y); + } write!(pre_meta, "{}{}", cursor::Goto(x, y), color).unwrap(); - if node.selected { + if node.selected && !(self.config.modal && self.is_insert_mode()) { write!(&mut pre_meta, "{}", style::Invert).unwrap(); } write!(&mut buf, "{}", pre_meta).unwrap(); write!(&mut buf, "{}", prefix).unwrap(); - if prefix != "" { + if !prefix.is_empty() { // only anchor will have blank prefix if last { write!(&mut buf, "└─").unwrap(); @@ -1902,30 +2428,46 @@ impl Screen { } } if node.stricken { - write!(&mut buf, "☠").unwrap(); - } else if node.collapsed { - write!(&mut buf, "⊞").unwrap(); - } else if node.hide_stricken { - write!(&mut buf, "⚔").unwrap(); - } else if node.free_text.is_some() { - write!(&mut buf, "✏").unwrap(); - } else { - write!(&mut buf, " ").unwrap(); + buf.write_str(&self.config.stricken).unwrap(); } - // keep color for selected & tree root Fg - if !node.selected && prefix != "" { - write!(&mut buf, "{}", reset).unwrap(); + if node.collapsed { + buf.write_str(&self.config.collapsed).unwrap(); + } + if node.hide_stricken { + buf.write_str(&self.config.hide_stricken).unwrap(); + } + if node.free_text.is_some() { + buf.write_str(&self.config.free_text).unwrap(); + } + if node.url.is_some() { + buf.write_str(&self.config.url).unwrap(); } write!(&mut buf, "{}", node.content).unwrap(); + // write cursor if this node is being inserted to + if node.selected && self.config.modal && self.is_insert_mode() { + write!(&mut post_content, "{} {}", style::Invert, reset).unwrap(); + write!(&mut buf, "{}", post_content).unwrap(); + } + // keep color for selected & tree root Fg + if !node.selected && !prefix.is_empty() { + write!(&mut buf, "{}", reset).unwrap(); + } + let max_width = (max(self.dims.0, 1 + x) - 1 - x) as usize; let visible_graphemes = self.grapheme_cache .get(&node.id) .cloned() .unwrap_or_else(|| { - let visible = buf.replace(reset, "").replace(&*pre_meta, ""); + let visible = if !post_content.is_empty() { + buf.replace(&*post_content, " ") + .replace(reset, "") + .replace(&*pre_meta, "") + } else { + buf.replace(reset, "").replace(&*pre_meta, "") + }; let vg = UnicodeSegmentation::graphemes(&*visible, true).count(); self.grapheme_cache.insert(node.id, vg); vg @@ -1939,7 +2481,7 @@ impl Screen { buf.push('…'); } - print!("{}{}", buf, style::Reset); + write!(self.assume_stdout(), "{}{}", buf, style::Reset); } let visible_graphemes = self @@ -1947,7 +2489,13 @@ impl Screen { .get(&node.id) .cloned() .unwrap_or_else(|| { - let visible = buf.replace(reset, "").replace(&*pre_meta, ""); + let visible = if !post_content.is_empty() { + buf.replace(&*post_content, " ") + .replace(reset, "") + .replace(&*pre_meta, "") + } else { + buf.replace(reset, "").replace(&*pre_meta, "") + }; let vg = UnicodeSegmentation::graphemes(&*visible, true).count(); self.grapheme_cache.insert(node.id, vg); vg @@ -1965,8 +2513,8 @@ impl Screen { let mut prefix = prefix; if last { prefix.push_str(" "); - } else if prefix == "" { - prefix.push_str(" "); + } else if prefix.is_empty() { + prefix.push(' '); } else { prefix.push_str("│ "); } @@ -1992,60 +2540,81 @@ impl Screen { drawn } - fn draw_path(&self, internal_path: Vec, start_dir: Dir, dest_dir: Dir) { + fn draw_path(&self, internal_path: Vec, start_dir: Dir, dest_dir: Dir, color: &str) { let path: Vec<_> = internal_path .iter() .filter_map(|&c| self.internal_to_screen_xy(c)) .collect(); trace!("draw_path({:?}, {:?}, {:?})", path, start_dir, dest_dir); - print!("{}", random_fg_color()); - if path.len() == 1 { - print!("{} ↺", cursor::Goto(path[0].0, path[0].1)) - } else if path.len() > 1 { - let first = if path[1].1 > path[0].1 { - match start_dir { - Dir::R => '┐', - Dir::L => '┌', - } - } else if path[1].1 < path[0].1 { - match start_dir { - Dir::R => '┘', - Dir::L => '└', - } - } else { - '─' - }; - - print!("{}{}", cursor::Goto(path[0].0, path[0].1), first); - for items in path.windows(3) { - let (p, this, n) = (items[0], items[1], items[2]); - let c = if p.0 == n.0 { - '│' - } else if p.1 == n.1 { - '─' - } else if (this.1 < p.1 && this.0 < n.0) || (this.0 < p.0 && this.1 < n.1) { - '┌' // up+right or left+down - } else if (this.0 > p.0 && this.1 > n.1) || (this.1 > p.1 && this.0 > n.0) { - '┘' // right+up or down+left - } else if (this.0 > p.0 && this.1 < n.1) || (this.1 < p.1 && this.0 > n.0) { - '┐' // right+down or up+left - } else { - '└' // down+right or left+up + write!(self.assume_stdout(), "{}", color); + match path.len().cmp(&1) { + Ordering::Equal => { + write!( + self.assume_stdout(), + "{} ↺", + cursor::Goto(path[0].0, path[0].1) + ); + }, + Ordering::Greater => { + let first = match path[1].1.cmp(&path[0].1) { + Ordering::Greater => match start_dir { + Dir::R => '┐', + Dir::L => '┌', + }, + Ordering::Less => match start_dir { + Dir::R => '┘', + Dir::L => '└', + }, + Ordering::Equal => '─', }; - print!("{}{}", cursor::Goto(this.0, this.1), c) - } - let (end_x, end_y) = (path[path.len() - 1].0, path[path.len() - 1].1); - let end_char = match dest_dir { - Dir::L => '>', - Dir::R => '<', - }; - print!("{}{}", cursor::Goto(end_x, end_y), end_char); - } - print!("{}", color::Fg(color::Reset)); + write!( + self.assume_stdout(), + "{}{}", + cursor::Goto(path[0].0, path[0].1), + first + ); + for items in path.windows(3) { + let (p, this, n) = (items[0], items[1], items[2]); + let c = if p.0 == n.0 { + '│' + } else if p.1 == n.1 { + '─' + } else if (this.1 < p.1 && this.0 < n.0) || (this.0 < p.0 && this.1 < n.1) { + '┌' // up+right or left+down + } else if (this.0 > p.0 && this.1 > n.1) || (this.1 > p.1 && this.0 > n.0) { + '┘' // right+up or down+left + } else if (this.0 > p.0 && this.1 < n.1) || (this.1 < p.1 && this.0 > n.0) { + '┐' // right+down or up+left + } else { + '└' // down+right or left+up + }; + + write!( + self.assume_stdout(), + "{}{}", + cursor::Goto(this.0, this.1), + c + ); + } + let (end_x, end_y) = (path[path.len() - 1].0, path[path.len() - 1].1); + let end_char = match dest_dir { + Dir::L => '>', + Dir::R => '<', + }; + write!( + self.assume_stdout(), + "{}{}", + cursor::Goto(end_x, end_y), + end_char + ); + }, + _ => {}, + }; + write!(self.assume_stdout(), "{}", color::Fg(color::Reset)); } - fn draw_header(&self) { + fn draw_header(&mut self) { trace!("draw_header()"); let mut header_text = self .with_node(self.drawing_root, |node| node.content.clone()) @@ -2054,16 +2623,43 @@ impl Screen { if self.should_auto_arrange() { header_text.push_str(" [auto-arrange] "); } + if self.config.modal && self.is_insert_mode() { + header_text.push_str(" [insert] "); + } + match self.cut { + Cut::Move(id) | Cut::Yank(id) => { + let content = &self.nodes.get(&id).unwrap().content; + let restricted_chars = content.chars().take(10).collect::(); + let content_ellipsized = if restricted_chars.len() < content.len() { + Cow::from(format!("{}...", &restricted_chars)) + } else { + Cow::from(content) + }; + header_text.push_str(&format!( + " [{}: {}] ", + match self.cut { + Cut::Move(_) => "moving", + Cut::Yank(_) => "yanking", + Cut::Empty => unreachable!(), + }, + content_ellipsized + )); + }, + Cut::Empty => {}, + } let (plot, finished_today) = self.last_week_of_done_tasks(); let plot_line = format!("│{}│({} today)", plot, finished_today); header_text.push_str(&*plot_line); + let date = Local::today(); + header_text.push_str(&format!(" {}", date.format("%-d.%-m.%Y"))); + if self.dims.0 > header_text.len() as u16 && self.dims.1 > 1 { let mut sep = format!( "{}{}{}{}", - cursor::Goto(0, 1), + cursor::Goto(1, 1), style::Invert, header_text, style::Reset @@ -2072,7 +2668,7 @@ impl Screen { for _ in 0..(max(self.dims.0 as usize, text_len) - text_len) { sep.push('█'); } - println!("{}", sep); + write!(self.assume_stdout(), "{}", sep); } } @@ -2189,18 +2785,24 @@ impl Screen { let now = now().as_secs(); let day_in_sec = 60 * 60 * 24; let last_week = now - (day_in_sec * 7); - let tasks_finished_in_last_week = self.recursive_child_filter_map(0, &mut |n: &Node| { - let f = n.meta.finish_time; - if let Some(t) = f { - if t > last_week { - Some(t) + let tasks_finished_in_last_week = + self.recursive_child_filter_map(0, (), &mut |n: &Node, _: ()| { + let f = n.meta.finish_time; + if let Some(t) = f { + if t > last_week + && !n + .children + .iter() + .any(|ch| self.with_node(*ch, |sub_n| sub_n.stricken).unwrap()) + { + (Some(t), (), true) + } else { + (None, (), true) + } } else { - None + (None, (), true) } - } else { - None - } - }); + }); let mut counts = BTreeMap::new(); for d in 0..7 { let t = now - (d * day_in_sec); @@ -2215,7 +2817,7 @@ impl Screen { let today_normalized = now / day_in_sec * day_in_sec; let counts_clone = counts.clone(); let finished_today = counts_clone[&today_normalized]; - let week_line: Vec = counts.into_iter().map(|(_, v)| v).collect(); + let week_line: Vec = counts.into_iter().rev().map(|(_, v)| v).collect(); let plot = plot::plot_sparkline(week_line); (plot, finished_today as usize) } @@ -2259,7 +2861,7 @@ impl Screen { } let queried_nodes = tagged_children .map(|tc| tc.into_iter().collect()) - .unwrap_or_else(|| vec![]); + .unwrap_or_else(Vec::new); let mut since_opt = None; let mut until_opt = None; @@ -2322,7 +2924,7 @@ impl Screen { let now = now().as_secs(); let buckets = n_opt.cloned().unwrap_or(7); let since = since_opt.unwrap_or_else(|| now - 60 * 60 * 24 * 7); - let until = until_opt.unwrap_or_else(|| now); + let until = until_opt.unwrap_or(now); node.content = match plot.as_str() { "done" => self.plot(queried_nodes, PlotType::Done, buckets, since, until), @@ -2343,28 +2945,38 @@ impl Screen { ) -> String { let mut nodes = vec![]; for &c in &queried_nodes { - let mut new = self.recursive_child_filter_map(c, &mut |n: &Node| match kind { - PlotType::Done => { - if let Some(ft) = n.meta.finish_time { - if ft >= since { - return Some(ft as i64); + let mut new = + self.recursive_child_filter_map(c, (), &mut |n: &Node, _: ()| match kind { + PlotType::Done => { + if let Some(ft) = n.meta.finish_time { + if ft >= since + && !n + .children + .iter() + .any(|ch| self.with_node(*ch, |sub_n| sub_n.stricken).unwrap()) + { + return (Some(ft as i64), (), true); + } } - } - None - } - PlotType::New => { - if n.meta.ctime >= since { - Some(n.meta.ctime as i64) - } else { - None - } - } - }); + (None, (), true) + }, + PlotType::New => { + if n.meta.ctime >= since { + (Some(n.meta.ctime as i64), (), true) + } else { + (None, (), true) + } + }, + }); nodes.append(&mut new); } - let plot = plot::bounded_count_sparkline(nodes, since as i64, until as i64, buckets); + let plot = plot::bounded_count_sparkline(nodes, until as i64, since as i64, buckets); format!("|{}|", plot) } + + fn is_insert_mode(&self) -> bool { + self.selected.map(|s| s.inserting) == Some(true) + } } #[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)] diff --git a/src/serialization.rs b/src/serialization.rs index cd84265..b113304 100644 --- a/src/serialization.rs +++ b/src/serialization.rs @@ -1,3 +1,4 @@ +use chrono::{Datelike, Local, TimeZone}; use protobuf::{self, Message}; use crate::{pb, random_fg_color, Meta, Node, Screen}; @@ -14,7 +15,7 @@ pub fn serialize_screen(screen: &Screen) -> Vec { let arrows = screen .arrows .iter() - .map(|&(from, to)| { + .map(|&(from, to, _)| { let mut arrow_pb = pb::Arrow::default(); arrow_pb.set_from_node(from); arrow_pb.set_to_node(to); @@ -25,6 +26,14 @@ pub fn serialize_screen(screen: &Screen) -> Vec { screen_pb.write_to_bytes().unwrap() } +fn serialize_date(date: chrono::Date) -> pb::Date { + let mut date_pb = pb::Date::default(); + date_pb.set_day(date.day()); + date_pb.set_month(date.month()); + date_pb.set_year(date.year() as u32); + date_pb +} + fn serialize_meta(meta: &Meta) -> pb::Meta { let mut meta_pb = pb::Meta::default(); meta_pb.set_gps(pb::Gps::default()); @@ -33,6 +42,9 @@ fn serialize_meta(meta: &Meta) -> pb::Meta { if let Some(finish_time) = meta.finish_time { meta_pb.set_finish_time(finish_time); } + if let Some(due_date) = meta.due_date { + meta_pb.set_due_date(serialize_date(due_date)); + } let mut tags = vec![]; for (tagk, tagv) in &meta.tags { let mut tag = pb::Tag::default(); @@ -53,6 +65,7 @@ fn serialize_node(node: &Node) -> pb::Node { node_pb.set_stricken(node.stricken); node_pb.set_hide_stricken(node.hide_stricken); node_pb.set_parent_id(node.parent_id); + node_pb.set_selected(node.selected); node_pb.set_x(u32::from(node.rooted_coords.0)); node_pb.set_y(u32::from(node.rooted_coords.1)); node_pb.set_meta(serialize_meta(&node.meta)); @@ -60,9 +73,20 @@ fn serialize_node(node: &Node) -> pb::Node { if let Some(ref free_text) = node.free_text { node_pb.set_free_text(free_text.to_owned()); } + if let Some(ref url) = node.url { + node_pb.set_url(url.to_owned()); + } node_pb } +fn deserialize_date(date_pb: &pb::Date) -> chrono::Date { + let day = date_pb.get_day(); + let month = date_pb.get_month(); + let year = date_pb.get_year(); + + Local.ymd(year as i32, month, day) +} + fn deserialize_meta(meta_pb: &pb::Meta) -> Meta { Meta { ctime: meta_pb.get_ctime(), @@ -72,8 +96,8 @@ fn deserialize_meta(meta_pb: &pb::Meta) -> Meta { } else { None }, - due: if meta_pb.has_due() { - Some(meta_pb.get_due()) + due_date: if meta_pb.has_due_date() { + Some(deserialize_date(meta_pb.get_due_date())) } else { None }, @@ -91,7 +115,7 @@ fn deserialize_node(node_pb: &pb::Node) -> Node { rooted_coords: (node_pb.get_x() as u16, node_pb.get_y() as u16), content: node_pb.get_text().to_owned(), children: node_pb.get_children().to_vec(), - selected: node_pb.get_selected(), + selected: false, // Don't actually load this... collapsed: node_pb.get_collapsed(), stricken: node_pb.get_stricken(), hide_stricken: node_pb.get_hide_stricken(), @@ -102,13 +126,18 @@ fn deserialize_node(node_pb: &pb::Node) -> Node { } else { None }, + url: if node_pb.has_url() { + Some(node_pb.get_url().to_owned()) + } else { + None + }, color: random_fg_color(), auto_arrange: node_pb.get_auto_arrange(), } } pub fn deserialize_screen(data: Vec) -> Result { - let screen_pb: pb::Screen = protobuf::parse_from_bytes(&*data)?; + let screen_pb: pb::Screen = Message::parse_from_bytes(&*data)?; let mut screen = Screen::default(); screen.max_id = screen_pb.get_max_id(); screen.nodes = screen_pb @@ -127,7 +156,7 @@ pub fn deserialize_screen(data: Vec) -> Result>, tag_to_nodes: HashMap>, } -impl Default for TagDB { - fn default() -> TagDB { - TagDB { - node_to_tags: HashMap::new(), - tag_to_nodes: HashMap::new(), - } - } -} - impl TagDB { pub fn reindex(&mut self, node: NodeID, text: String) { lazy_static! { @@ -73,8 +65,8 @@ impl TagDB { .tag_to_nodes .get(&tag.to_owned()) .map(|set| set.clone().into_iter().collect()) - .unwrap_or_else(|| vec![]); - res.sort(); + .unwrap_or_else(Vec::new); + res.sort_unstable(); res } } diff --git a/test/screen.rs b/test/screen.rs index 1a357c6..152e340 100644 --- a/test/screen.rs +++ b/test/screen.rs @@ -22,12 +22,12 @@ impl fmt::Debug for Op { } impl Arbitrary for Op { - fn arbitrary(g: &mut G) -> Op { + fn arbitrary(generator: &mut G) -> Op { let (c, u, x, y) = ( - g.sample(Alphanumeric), - g.gen::(), - g.gen::(), - g.gen::(), + generator.sample(Alphanumeric), + generator.gen::(), + generator.gen::(), + generator.gen::(), ); let events = vec![ Event::Key(Key::Char('\n')), @@ -50,7 +50,7 @@ impl Arbitrary for Op { Event::Mouse(MouseEvent::Release(x, y)), ]; Op { - event: events.choose(g).unwrap().clone(), + event: events.choose(generator).unwrap().clone(), } } } @@ -94,7 +94,7 @@ impl Arbitrary for Content { let mut choice = vec![]; for _ in 0..g.gen_range(0, 2) { - let command = commands.choose(g).unwrap().clone(); + let command = commands.choose(g).unwrap(); let mut chars = command.chars().collect(); choice.append(&mut chars); if g.gen_range(0, 10) > 0 {