text
stringlengths
8
4.13M
//! **!!Notice!!** This crate was migrated to [kdbplus](https://crates.io/crates/kdbplus) which has IPC module as well. //! //! Rust crate mirroring the C API header file (`k.h`) for kdb+. The expected usage is to build a //! shared library for kdb+ in Rust. //! //! In order to avoid writing too large `unsafe` block leading to poor optimization, most of native C API functions were provided //! with a wrapper funtion with a bit of ergonomic safety and with intuitive implementation as a trait method. The only exceptions //! are `knk` and `k` which are using elipsis (`...`) as its argument. These functions are provided under `native` namespace with the other C API functions. //! //! # Note //! - This library is for kdb+ version >= 3.0. //! - Meangless C macros are excluded but accessors of an underlying array like `kC`, `kJ`, `kK` etc. are provided in Rust way. //! //! ## Examples //! //! The examples of using C API wrapper are included in `c_api_examples` folder. The examples are mirroring the examples in the document of `kdb_c_api` library and the functions are also used for simple tests of the library. The test is conducted in the `test.q` under `tests/` by loading the functions defined in a shared library built from the examples. //! //! Here are some examples: //! //! ### C API Style //! //! ```rust //! use kdb_c_api::*; //! use kdb_c_api::native::*; //! //! #[no_mangle] //! pub extern "C" fn create_symbol_list(_: K) -> K{ //! unsafe{ //! let mut list=ktn(qtype::SYMBOL as i32, 0); //! js(&mut list, ss(str_to_S!("Abraham"))); //! js(&mut list, ss(str_to_S!("Isaac"))); //! js(&mut list, ss(str_to_S!("Jacob"))); //! js(&mut list, sn(str_to_S!("Josephine"), 6)); //! list //! } //! } //! //! #[no_mangle] //! pub extern "C" fn catchy(func: K, args: K) -> K{ //! unsafe{ //! let result=ee(dot(func, args)); //! if (*result).qtype == qtype::ERROR{ //! println!("error: {}", S_to_str((*result).value.symbol)); //! // Decrement reference count of the error object //! r0(result); //! KNULL //! } //! else{ //! result //! } //! } //! } //! //! #[no_mangle] //! pub extern "C" fn dictionary_list_to_table() -> K{ //! unsafe{ //! let dicts=knk(3); //! let dicts_slice=dicts.as_mut_slice::<K>(); //! for i in 0..3{ //! let keys=ktn(qtype::SYMBOL as i32, 2); //! let keys_slice=keys.as_mut_slice::<S>(); //! keys_slice[0]=ss(str_to_S!("a")); //! keys_slice[1]=ss(str_to_S!("b")); //! let values=ktn(qtype::INT as i32, 2); //! values.as_mut_slice::<I>()[0..2].copy_from_slice(&[i*10, i*100]); //! dicts_slice[i as usize]=xD(keys, values); //! } //! // Format list of dictionary as a table. //! // ([] a: 0 10 20i; b: 0 100 200i) //! k(0, str_to_S!("{[dicts] -1 _ dicts, (::)}"), dicts, KNULL) //! } //! } //! ``` //! //! q can use these functions like this: //! //! ```q //! q)summon:`libc_api_examples 2: (`create_symbol_list; 1) //! q)summon[] //! `Abraham`Isaac`Jacob`Joseph //! q)`Abraham`Isaac`Jacob`Joseph ~ summon[] //! q)catchy: `libc_api_examples 2: (`catchy; 2); //! q)catchy[$; ("J"; "42")] //! 42 //! q)catchy[+; (1; `a)] //! error: type //! q)unfortunate_fact: `libc_api_examples 2: (`dictionary_list_to_table; 1); //! q)unfortunate_fact[] //! a b //! ------ //! 0 0 //! 10 100 //! 20 200 //! ``` //! //! ### Rust Style //! //! The examples below are written without `unsafe` code. You can see how comfortably breathing are the wrapped functions in the code. //! //! ```rust //! use kdb_c_api::*; //! //! #[no_mangle] //! pub extern "C" fn create_symbol_list2(_: K) -> K{ //! let mut list=new_simple_list(qtype::SYMBOL, 0); //! list.push_symbol("Abraham").unwrap(); //! list.push_symbol("Isaac").unwrap(); //! list.push_symbol("Jacob").unwrap(); //! list.push_symbol_n("Josephine", 6).unwrap(); //! list //! } //! //! #[no_mangle] //! fn no_panick(func: K, args: K) -> K{ //! let result=error_to_string(apply(func, args)); //! if result.get_type() == qtype::ERROR{ //! println!("FYI: {}", result.get_symbol().unwrap()); //! // Decrement reference count of the error object which is no longer used. //! decrement_reference_count(result); //! KNULL //! } //! else{ //! println!("success!"); //! result //! } //! } //! //! #[no_mangle] //! pub extern "C" fn create_table2(_: K) -> K{ //! // Build keys //! let keys=new_simple_list(qtype::SYMBOL, 2); //! let keys_slice=keys.as_mut_slice::<S>(); //! keys_slice[0]=internalize(str_to_S!("time")); //! keys_slice[1]=internalize_n(str_to_S!("temperature_and_humidity"), 11); //! //! // Build values //! let values=new_simple_list(qtype::COMPOUND, 2); //! let time=new_simple_list(qtype::TIMESTAMP, 3); //! // 2003.10.10D02:24:19.167018272 2006.05.24D06:16:49.419710368 2008.08.12D23:12:24.018691392 //! time.as_mut_slice::<J>().copy_from_slice(&[119067859167018272_i64, 201766609419710368, 271897944018691392]); //! let temperature=new_simple_list(qtype::FLOAT, 3); //! temperature.as_mut_slice::<F>().copy_from_slice(&[22.1_f64, 24.7, 30.5]); //! values.as_mut_slice::<K>().copy_from_slice(&[time, temperature]); //! //! flip(new_dictionary(keys, values)) //! } //! ``` //! //! And q code is here: //! //! ```q //! q)summon:`libc_api_examples 2: (`create_symbol_list2; 1) //! q)summon[] //! `Abraham`Isaac`Jacob`Joseph //! q)chill: `libc_api_examples 2: (`no_panick; 2); //! q)chill[$; ("J"; "42")] //! success! //! 42 //! q)chill[+; (1; `a)] //! FYI: type //! q)climate_change: libc_api_examples 2: (`create_table2; 1); //! q)climate_change[] //! time temperature //! ----------------------------------------- //! 2003.10.10D02:24:19.167018272 22.1 //! 2006.05.24D06:16:49.419710368 24.7 //! 2008.08.12D23:12:24.018691392 30.5 //! ``` #![allow(non_upper_case_globals)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Load Libraries // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// use std::str; use std::ffi::CStr; use std::os::raw::{c_char, c_double, c_float, c_int, c_longlong, c_short, c_schar, c_uchar, c_void}; use std::convert::TryInto; pub mod native; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Global Variables // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// pub mod qtype{ //! This module provides a list of q types. The motivation to contain them in a module is to //! tie them up as related items rather than scattered values. Hence user should use these //! indicators with `qtype::` prefix, e.g., `qtype::BOOL`. use std::os::raw::c_schar; /// Type indicator of q mixed list. /// Access function: `kK` pub const COMPOUND:c_schar=0; /// Type indicator of q bool. /// Access fucntion: `kG` pub const BOOL:c_schar=1; /// Type indicator of q GUID. /// Access function: `kU` pub const GUID:c_schar=2; /// Type indicator of q byte /// Access function: `kG` pub const BYTE:c_schar=4; /// Type indicator of q short. /// Access function: `kH` pub const SHORT:c_schar=5; /// Type indicator of q int. /// Access function: `kI` pub const INT:c_schar=6; /// Type indicator of q long. /// Access function: `kJ` pub const LONG:c_schar=7; /// Type indicator of q real. /// Access function: `kE` pub const REAL:c_schar=8; /// Type indicator of q float. /// Access function: `kF` pub const FLOAT:c_schar=9; /// Type indicator of q char. /// Access function: `kC` pub const CHAR:c_schar=10; /// Type indicator of q symbol. /// Access function: `kS` pub const SYMBOL:c_schar=11; /// Type indicator of q timestamp. /// Access function: `kJ` pub const TIMESTAMP:c_schar=12; /// Type indicator of q month. /// Access function: `kI` pub const MONTH:c_schar=13; /// Type indicator of q date. /// Access function: `kI` pub const DATE:c_schar=14; /// Type indicator of q datetime. /// Access function: `kF` pub const DATETIME:c_schar=15; /// Type indicator of q timespan. /// Access function: `kJ` pub const TIMESPAN:c_schar=16; /// Type indicator of q minute. /// Access function: `kI` pub const MINUTE:c_schar=17; /// Type indicator of q second. /// Access function: `kI` pub const SECOND:c_schar=18; /// Type indicator of q time. /// Access function: `kI` pub const TIME:c_schar=19; /// Type indicator of q table. /// `*(qstruct).k` is q dictionary. pub const TABLE:c_schar=98; /// Type indicator of q dictionary. /// - `kK(x)[0]`: keys /// - `kK(x)[1]`: values pub const DICTIONARY:c_schar=99; /// Type indicator of q foreign object. pub const FOREIGN:c_schar=112; /// Type indicator of q sorted dictionary pub const SORTED_DICTIONARY:c_schar=127; /// Type indicator of q error pub const ERROR:c_schar=-128; /// Type indicator of q general null pub const NULL:c_schar=101; } pub mod qattribute{ //! This module provides a list of q attributes. The motivation to contain them in a module is to //! tie them up as related items rather than scattered values. Hence user should use these //! indicators with `qattribute::` prefix, e.g., `qattribute::UNIQUE`. use std::os::raw::c_char; /// Indicates no attribute is appended on the q object. pub const NONE: c_char=0; /// Sorted attribute, meaning that the q list is sorted in ascending order. pub const SORTED: c_char=1; /// Unique attribute, meaning that each element in the q list has a unique value within the list. pub const UNIQUE: c_char=2; /// Parted attribute, meaning that all the elements with the same value in the q object appear in a chunk. pub const PARTED: c_char=3; /// Grouped attribute, meaning that the elements of the q list are grouped with their indices by values implicitly. pub const GROUPED: c_char=4; } /// `K` nullptr. This value is used as general null returned value (`(::)`). /// # Example /// ``` /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn vanity(_: K) -> K{ /// println!("Initialized something, probably it is your mindset."); /// KNULL /// } /// ``` pub const KNULL:K=0 as K; //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Macros // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //%% Utility %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Convert `&str` to `S` (null-terminated character array). /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn pingpong(_: K) -> K{ /// unsafe{native::k(0, str_to_S!("ping"), new_int(77), KNULL)} /// } /// ``` /// ```q /// q)ping:{[int] `$string[int], "_pong!!"} /// q)pingpong: `libc_api_examples 2: (`pingpong; 1); /// q)pingpong[] /// `77_pong!! /// ``` /// # Note /// This macro cannot be created as a function due to freeing resource of Rust (not sure). #[macro_export] macro_rules! str_to_S { ($string: expr) => { [$string.as_bytes(), &[b'\0']].concat().as_mut_ptr() as S }; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Structs // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //%% Alias %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// `char*` in C. Also used to access symbol of q. pub type S = *mut c_char; /// `const char*` in C. pub type const_S = *const c_char; /// `char` in C. Also used to access char of q. pub type C = c_char; /// `unsigned char` in C. Also used to access byte of q. pub type G = c_uchar; /// `i16` in C. Also used to access short of q. pub type H = c_short; /// `i32` in C. Also used to access int and compatible types (month, date, minute, second and time) of q. pub type I = c_int; /// `i64` in C. Also used to access long and compatible types (timestamp and timespan) of q. pub type J = c_longlong; /// `f32` in C. Also used to access real of q. pub type E = c_float; /// `f64` in C. Also used to access float and datetime of q. pub type F = c_double; /// `void` in C. pub type V = c_void; //%% U %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Struct representing 16-bytes GUID. #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct U{ pub guid: [G; 16] } //%% K %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Underlying list value of q object. /// # Note /// Usually this struct does not need to be accessed this struct directly unless user wants to /// access via a raw pointer for non-trivial stuff. #[derive(Clone, Copy, Debug)] #[repr(C)] pub struct k0_list_info{ /// Length of the list. pub n: J, /// Pointer referring to the head of the list. This pointer will be interpreted /// as various types when accessing `K` object to edit the list with /// [`as_mut_slice`](trait.KUtility.html#tymethod.as_mut_slice). pub G0: [G; 1] } /// Underlying atom value of q object. /// # Note /// Usually this struct does not need to be accessed directly unless user wants to /// access via a raw pointer for non-trivial stuff. #[derive(Clone, Copy)] #[repr(C)] pub union k0_inner{ /// Byte type holder. pub byte: G, /// Short type holder. pub short: H, /// Int type holder. pub int: I, /// Long type older. pub long: J, /// Real type holder. pub real: E, /// Float type holder. pub float: F, /// Symbol type holder. pub symbol: S, /// Table type holder. pub table: *mut k0, /// List type holder. pub list: k0_list_info } /// Underlying struct of `K` object. #[repr(C)] #[derive(Clone, Copy)] pub struct k0{ /// For internal usage. pub m: c_schar, /// For internal usage. pub a: c_schar, /// Type indicator. pub qtype: c_schar, /// Attribute of list. pub attribute: C, /// Reference count of the object. pub refcount: I, /// Underlying value. pub value: k0_inner } /// Struct representing q object. pub type K=*mut k0; //%% KList %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ pub trait KUtility{ /// Derefer `K` as a mutable slice of the specified type. The supported types are: /// - `G`: Equivalent to C API macro `kG`. /// - `H`: Equivalent to C API macro `kH`. /// - `I`: Equivalent to C API macro `kI`. /// - `J`: Equivalent to C API macro `kJ`. /// - `E`: Equivalent to C API macro `kE`. /// - `F`: Equivalent to C API macro `kF`. /// - `C`: Equivalent to C API macro `kC`. /// - `S`: Equivalent to C API macro `kS`. /// - `K`: Equivalent to C API macro `kK`. /// # Example /// ``` /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn modify_long_list_a_bit(long_list: K) -> K{ /// if long_list.len() >= 2{ /// // Derefer as a mutable i64 slice. /// long_list.as_mut_slice::<J>()[1]=30000_i64; /// // Increment the counter to reuse on q side. /// increment_reference_count(long_list) /// } /// else{ /// new_error("this list is not long enough. how ironic...\0") /// } /// } /// ``` /// ```q /// q)ironic: `libc_api_examples 2: (`modify_long_list_a_bit; 1); /// q)list:1 2 3; /// q)ironic list /// 1 30000 3 /// q)ironic enlist 1 /// ``` /// # Note /// Intuitively the parameter should be `&mut self` but it restricts a manipulating /// `K` objects in the form of slice simultaneously. As copying a pointer is not /// an expensive operation, using `self` should be fine. fn as_mut_slice<'a, T>(self) -> &'a mut[T]; /// Get an underlying q byte. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_bool(atom: K) -> K{ /// match atom.get_bool(){ /// Ok(boolean) => { /// println!("bool: {}", boolean); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_boole: `libc_api_examples 2: (`print_bool; 1); /// q)print_bool[1b] /// bool: true /// ``` fn get_bool(&self) -> Result<bool, &'static str>; /// Get an underlying q byte. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_guid(atom: K) -> K{ /// match atom.get_guid(){ /// Ok(guid) => { /// let strguid=guid.iter().map(|b| format!("{:02x}", b)).collect::<String>(); /// println!("GUID: {}-{}-{}-{}-{}", &strguid[0..4], &strguid[4..6], &strguid[6..8], &strguid[8..10], &strguid[10..16]); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_guid: `libc_api_examples 2: (`print_guid; 1); /// q)guid: first 1?0Ng; /// q)print_guid[guid] /// GUID: 8c6b-8b-64-68-156084 /// ``` fn get_guid(&self) -> Result<[u8; 16], &'static str>; /// Get an underlying q byte. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_byte(atom: K) -> K{ /// match atom.get_byte(){ /// Ok(byte) => { /// println!("byte: {:#4x}", byte); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_byte: `libc_api_examples 2: (`print_byte; 1); /// q)print_byte[0xc4] /// byte: 0xc4 /// ``` fn get_byte(&self) -> Result<u8, &'static str>; /// Get an underlying q short. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_short(atom: K) -> K{ /// match atom.get_short(){ /// Ok(short) => { /// println!("short: {}", short); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_short: `libc_api_examples 2: (`print_short; 1); /// q)print_short[10h] /// short: 10 /// ``` fn get_short(&self) -> Result<i16, &'static str>; /// Get an underlying q int. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_int(atom: K) -> K{ /// match atom.get_int(){ /// Ok(int) => { /// println!("int: {}", int); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_int: `libc_api_examples 2: (`print_int; 1); /// q)print_int[03:57:20] /// int: 14240 /// ``` fn get_int(&self) -> Result<i32, &'static str>; /// Get an underlying q long. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_long(atom: K) -> K{ /// match atom.get_long(){ /// Ok(long) => { /// println!("long: {}", long); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_long: `libc_api_examples 2: (`print_long; 1); /// q)print_long[2000.01.01D12:00:00.123456789] /// long: 43200123456789 /// ``` fn get_long(&self) -> Result<i64, &'static str>; /// Get an underlying q real. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_real(atom: K) -> K{ /// match atom.get_real(){ /// Ok(real) => { /// println!("real: {}", real); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_real: `libc_api_examples 2: (`print_real; 1); /// q)print_real[193810.32e] /// real: 193810.31 /// ``` fn get_real(&self) -> Result<f32, &'static str>; /// Get an underlying q float. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_float(atom: K) -> K{ /// match atom.get_float(){ /// Ok(float) => { /// println!("float: {:.8}", float); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_float: `libc_api_examples 2: (`print_float; 1); /// q)print_float[2002.01.12T10:03:45.332] /// float: 742.41927468 /// ``` fn get_float(&self) -> Result<f64, &'static str>; /// Get an underlying q char. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_char(atom: K) -> K{ /// match atom.get_char(){ /// Ok(character) => { /// println!("char: \"{}\"", character); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_char: `libc_api_examples 2: (`print_char; 1); /// q)print_char["k"] /// char: "k" /// ``` fn get_char(&self) -> Result<char, &'static str>; /// Get an underlying q symbol. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_symbol2(atom: K) -> K{ /// match atom.get_symbol(){ /// Ok(symbol) => { /// println!("symbol: `{}", symbol); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_symbol2: `libc_api_examples 2: (`print_symbol2; 1); /// q)print_symbol2[`locust] /// symbol: `locust /// ``` fn get_symbol(&self) -> Result<&str, &'static str>; /// Get an underlying q string as `&str`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_string(string: K) -> K{ /// match string.get_str(){ /// Ok(string_) => { /// println!("string: \"{}\"", string_); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_string: `libc_api_examples 2: (`print_string; 1); /// q)print_string["gnat"] /// string: "gnat" /// ``` fn get_str(&self) -> Result<&str, &'static str>; /// Get an underlying q string as `String`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_string2(string: K) -> K{ /// match string.get_string(){ /// Ok(string_) => { /// println!("string: \"{}\"", string_); /// KNULL /// }, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)print_string: `libc_api_examples 2: (`print_string; 1); /// q)print_string["grasshopper"] /// string: "grasshopper" /// ``` fn get_string(&self) -> Result<String, &'static str>; /// Get a flipped underlying q table as `K` (dictionary). /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn hidden_key(table: K) -> K{ /// match table.get_dictionary(){ /// Ok(dictionary) => dictionary.as_mut_slice::<K>()[0].q_ipc_encode(3).unwrap(), /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)perceive_the_man: `libc_api_examples 2: (`hidden_key; 1); /// q)perceive_the_man ([] t: `timestamp$.z.p+1e9*til 9; chr:"ljppkgfgs"; is: 7 8 12 14 21 316 400 1000 6000i) /// 0x01000000170000000b0003000000740063687200697300 /// ``` /// # Note /// This method is provided because the ony way to examine the value of table type is to access the underlying dictionary (flipped table). /// Also when some serialization is necessary for a table, you can reuse a serializer for a dictionary if it is already provided. Actually /// when q serialize a table object with `-8!` (q function) or `b9` (C code), it just serializes the underlying dictionary with an additional /// marker indicating a table type. fn get_dictionary(&self) -> Result<K, &'static str>; /// Get an attribute of a q object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn murmur(list: K) -> K{ /// match list.get_attribute(){ /// qattribute::SORTED => { /// new_string("Clean") /// }, /// qattribute::UNIQUE => { /// new_symbol("Alone") /// }, /// _ => KNULL /// } /// } /// ``` fn get_attribute(&self) -> C; /// Get a reference count of a q object. fn get_refcount(&self) -> I; /// Append a q list object to a q list. /// Returns a pointer to the (potentially reallocated) `K` object. /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn concat_list2(mut list1: K, list2: K) -> K{ /// if let Err(err) = list1.append(list2){ /// new_error(err) /// } /// else{ /// increment_reference_count(list1) /// } /// } /// ``` /// ```q /// q)plunder: `libc_api_examples 2: (`concat_list2; 2); /// q)plunder[(::; `metals; `fire); ("clay"; 316)] /// :: /// `metals /// `fire /// "clay" /// 316 /// q)plunder[1 2 3; 4 5] /// 1 2 3 4 5 /// q)plunder[`a`b`c; `d`e] /// `a`b`c`d`e /// ``` fn append(&mut self, list: K)->Result<K, &'static str>; /// Add a q object to a q compound list. /// Returns a pointer to the (potentially reallocated) `K` object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_compound_list(int: K) -> K{ /// let mut list=new_simple_list(qtype::COMPOUND, 0); /// for i in 0..5{ /// list.push(new_long(i)).unwrap(); /// } /// list.push(increment_reference_count(int)).unwrap(); /// list /// } /// ``` /// ```q /// q)nums: `libc_api_examples 2: (`create_compound_list2; 1); /// q)nums[5i] /// 0 /// 1 /// 2 /// 3 /// 4 /// 5i /// ``` /// # Note /// In this example we did not allocate an array as `new_simple_list(qtype::COMPOUND, 0)` to use `push`. /// As `new_simple_list` initializes the internal list size `n` with its argument, preallocating memory with `new_simple_list` and /// then using `push` will crash. If you want to allocate a memory in advance, you can substitute a value /// after converting the q list object into a slice with [`as_mut_slice`](rait.KUtility.html#tymethod.as_mut_slice). fn push(&mut self, atom: K)->Result<K, &'static str>; /// Add a raw value to a q simple list and returns a pointer to the (potentially reallocated) `K` object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_simple_list2(_: K) -> K{ /// let mut list=new_simple_list(qtype::DATE, 0); /// for i in 0..5{ /// list.push_raw(i).unwrap(); /// } /// list /// } /// ``` /// ```q /// q)simple_is_the_best: `lic_api_example 2: (`create_simple_list2; 1); /// q)simple_is_the_best[] /// 2000.01.01 2000.01.02 2000.01.03 2000.01.04 2000.01.05 /// ``` /// # Note /// - Concrete type of `T` is not checked. Its type must be either of `I`, `J` and `F` and it must be compatible /// with the list type. For example, timestamp list requires `J` type atom. /// - For symbol list, use [`push_symbol`](#fn.push_symbol) or [`push_symbol_n`](#fn.push_symbol_n). fn push_raw<T>(&mut self, atom: T)->Result<K, &'static str>; /// Add an internalized char array to symbol list. /// Returns a pointer to the (potentially reallocated) `K` object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_symbol_list2(_: K) -> K{ /// let mut list=new_simple_list(qtype::SYMBOL, 0); /// list.push_symbol("Abraham").unwrap(); /// list.push_symbol("Isaac").unwrap(); /// list.push_symbol("Jacob").unwrap(); /// list.push_symbol_n("Josephine", 6).unwrap(); /// list /// } /// ``` /// ```q /// q)summon:`libc_api_examples 2: (`create_symbol_list2; 1) /// q)summon[] /// `Abraham`Isaac`Jacob`Joseph /// q)`Abraham`Isaac`Jacob`Joseph ~ summon[] /// 1b /// ``` /// # Note /// In this example we did not allocate an array as `new_simple_list(qtype::SYMBOL as I, 0)` to use `push_symbol`. /// As `new_simple_list` initializes the internal list size `n` with its argument, preallocating memory with `new_simple_list` /// and then using `push_symbol` will crash. If you want to allocate a memory in advance, you can substitute a value /// after converting the q list object into a slice with [`as_mut_slice`](trait.KUtility.html#tymethod.as_mut_slice). fn push_symbol(&mut self, symbol: &str)->Result<K, &'static str>; /// Add an internalized char array to symbol list. /// Returns a pointer to the (potentially reallocated) `K` object. /// # Example /// See the example of [`push_symbol`](#fn.push_symbol). fn push_symbol_n(&mut self, symbol: &str, n: I)->Result<K, &'static str>; /// Get a length of the list. More specifically, a value of `k0.value.list.n` for list types. /// Otherwise 2 for table and 1 for atom and null. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn numbers(obj: K) -> K{ /// let count=format!("{} people are in numbers", obj.len()); /// new_string(&count) /// } /// ``` /// ```q /// q)census: `libc_api_examples 2: (`numbers; 1); /// q)census[(::)] /// "1 people are in numbers" /// q)census[til 4] /// "4 people are in numbers" /// q)census[`a`b!("many"; `split`asunder)] /// "2 people are in numbers" /// q)census[([] id: til 1000)] /// "1000 people are in numbers" /// ``` fn len(&self) -> i64; /// Get a type of `K` object. fn get_type(&self) -> i8; /// Set a type of `K` object. /// # Example /// See the example of [`load_as_q_function](fn.load_as_q_function.html). fn set_type(&self, qtype: i8); /// Serialize q object and return serialized q byte list object on success: otherwise null. /// Mode is either of: /// - -1: Serialize within the same process. /// - 1: retain enumerations, allow serialization of timespan and timestamp: Useful for passing data between threads /// - 2: unenumerate, allow serialization of timespan and timestamp /// - 3: unenumerate, compress, allow serialization of timespan and timestamp /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn encrypt(object: K)->K{ /// match object.q_ipc_encode(3){ /// Ok(bytes) => bytes, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)disguise: `libc_api_examples 2: (`encrypt; 1); /// q)list: (til 3; "abc"; 2018.02.18D04:30:00.000000000; `revive); /// q)disguise list /// 0x010000004600000000000400000007000300000000000000000000000100000000000000020.. /// ``` fn q_ipc_encode(&self, mode: I) -> Result<K, &'static str>; /// Deserialize a bytes into q object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn decrypt(bytes: K)->K{ /// match bytes.q_ipc_decode(){ /// Ok(object) => object, /// Err(error) => new_error(error) /// } /// } /// ``` /// ```q /// q)uncover: `libc_api_examples 2: (`decrypt; 1); /// q)uncover -8!"What is the purpose of CREATION?" /// "What is the purpose of CREATION?" /// ``` fn q_ipc_decode(&self) -> Result<K, &'static str>; } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Implementation // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //%% U %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ impl U{ /// Create 16-byte GUID object. pub fn new(guid: [u8; 16]) -> Self{ U{guid:guid} } } //%% K %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ unsafe impl Send for k0_inner{} unsafe impl Send for k0{} impl KUtility for K{ #[inline] fn as_mut_slice<'a, T>(self) -> &'a mut[T]{ unsafe{ std::slice::from_raw_parts_mut((*self).value.list.G0.as_mut_ptr() as *mut T, (*self).value.list.n as usize) } } #[inline] fn get_bool(&self) -> Result<bool, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::BOOL => Ok(unsafe{(**self).value.byte != 0}), _ => Err("not a bool\0") } } #[inline] fn get_guid(&self) -> Result<[u8; 16], &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::GUID => { Ok(unsafe{std::slice::from_raw_parts((**self).value.list.G0.as_ptr(), 16)}.try_into().unwrap()) }, _ => Err("not a GUID\0") } } #[inline] fn get_byte(&self) -> Result<u8, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::BYTE => Ok(unsafe{(**self).value.byte}), _ => Err("not a byte\0") } } #[inline] fn get_short(&self) -> Result<i16, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::SHORT => Ok(unsafe{(**self).value.short}), _ => Err("not a short\0") } } #[inline] fn get_int(&self) -> Result<i32, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::INT | qtype::MONTH | qtype::DATE | qtype::MINUTE | qtype::SECOND | qtype::TIME => Ok(unsafe{(**self).value.int}), _ => Err("not an int\0") } } #[inline] fn get_long(&self) -> Result<i64, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::LONG | qtype::TIMESTAMP | qtype::TIMESPAN => Ok(unsafe{(**self).value.long}), _ => Err("not a long\0") } } #[inline] fn get_real(&self) -> Result<f32, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::REAL => Ok(unsafe{(**self).value.real}), _ => Err("not a real\0") } } #[inline] fn get_float(&self) -> Result<f64, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::FLOAT | qtype::DATETIME => Ok(unsafe{(**self).value.float}), _ => Err("not a float\0") } } #[inline] fn get_char(&self) -> Result<char, &'static str>{ match unsafe{(**self).qtype}.saturating_mul(-1){ qtype::CHAR => Ok(unsafe{(**self).value.byte as char}), _ => Err("not a char\0") } } #[inline] fn get_symbol(&self) -> Result<&str, &'static str>{ if (unsafe{(**self).qtype} == -qtype::SYMBOL) || (unsafe{(**self).qtype} == qtype::ERROR){ Ok(S_to_str(unsafe{(**self).value.symbol})) } else{ Err("not a symbol\0") } } #[inline] fn get_str(&self) -> Result<&str, &'static str>{ match unsafe{(**self).qtype}{ qtype::CHAR => { Ok(unsafe{str::from_utf8_unchecked_mut(self.as_mut_slice::<G>())}) }, _ => Err("not a string\0") } } #[inline] fn get_string(&self) -> Result<String, &'static str>{ match unsafe{(**self).qtype}{ qtype::CHAR => { Ok(unsafe{String::from_utf8_unchecked(self.as_mut_slice::<G>().to_vec())}) }, _ => Err("not a string\0") } } #[inline] fn get_dictionary(&self) -> Result<K, &'static str>{ match unsafe{(**self).qtype}{ qtype::TABLE => { Ok(unsafe{(**self).value.table}) }, _ => Err("not a table\0") } } #[inline] fn get_attribute(&self) -> i8{ unsafe{(**self).attribute} } #[inline] fn get_refcount(&self) -> i32{ unsafe{(**self).refcount} } #[inline] fn append(&mut self, list: K)->Result<K, &'static str>{ if unsafe{(**self).qtype} >= 0 && unsafe{(**self).qtype} == unsafe{(*list).qtype}{ Ok(unsafe{native::jv(self, list)}) } else{ Err("not a list or types do not match\0") } } #[inline] fn push(&mut self, atom: K)->Result<K, &'static str>{ if unsafe{(**self).qtype} == 0 { Ok(unsafe{native::jk(self, atom)}) } else{ Err("not a list or types do not match\0") } } #[inline] fn push_raw<T>(&mut self, mut atom: T)->Result<K, &'static str>{ match unsafe{(**self).qtype}{ _t@1..=19 => Ok(unsafe{native::ja(self, std::mem::transmute::<*mut T, *mut V>(&mut atom))}), _ => Err("not a simple list or types do not match\0") } } #[inline] fn push_symbol(&mut self, symbol: &str)->Result<K, &'static str>{ if unsafe{(**self).qtype} == qtype::SYMBOL { Ok(unsafe{native::js(self, native::ss(str_to_S!(symbol)))}) } else{ Err("not a symbol list\0") } } #[inline] fn push_symbol_n(&mut self, symbol: &str, n: I)->Result<K, &'static str>{ if unsafe{(**self).qtype} == qtype::SYMBOL { Ok(unsafe{native::js(self, native::sn(str_to_S!(symbol), n))}) } else{ Err("not a symbol list or types do not match\0") } } #[inline] fn len(&self) -> i64{ unsafe{ if (**self).qtype < 0 || (**self).qtype == qtype::NULL{ // Atom or (::) 1 } else if (**self).qtype == qtype::TABLE{ // Table // Access underlying table (dictionary structure) and retrieve values of the dictionary. // The values (columns) is assured to be a list of lists as it is a table. so cast it to list of `K`. // Size of the table is a length of the first column. (*((**self).value.table).as_mut_slice::<K>()[1].as_mut_slice::<K>()[0]).value.list.n } else if (**self).qtype == qtype::DICTIONARY{ // Dictionary // Access to keys of the dictionary and retrieve its length. (*(*self).as_mut_slice::<K>()[0]).value.list.n } else{ // List (**self).value.list.n } } } #[inline] fn get_type(&self) -> i8{ unsafe{(**self).qtype} } #[inline] fn set_type(&self, qtype: i8){ unsafe{(**self).qtype=qtype}; } #[inline] fn q_ipc_encode(&self, mode: I) -> Result<K, &'static str>{ let result=error_to_string(unsafe{ native::b9(mode, *self) }); match unsafe{(*result).qtype}{ qtype::ERROR => { decrement_reference_count(result); Err("failed to encode\0") }, _ => Ok(result) } } #[inline] fn q_ipc_decode(&self) -> Result<K, &'static str>{ match unsafe{(**self).qtype}{ qtype::BYTE => { let result=error_to_string(unsafe{ native::d9(*self) }); match unsafe{(*result).qtype}{ qtype::ERROR => { decrement_reference_count(result); Err("failed to decode\0") }, _ => Ok(result) } }, _ => Err("not bytes\0") } } } impl k0{ /// Derefer `k0` as a mutable slice. For supported types, see [`as_mut_slice`](trait.KUtility.html#tymethod.as_mut_slice). /// # Note /// Used if `K` needs to be sent to another thread. `K` cannot implement `Send` and therefore /// its inner struct must be sent instead. /// # Example /// See the example of [`setm`](native/fn.setm.html). #[inline] pub fn as_mut_slice<'a, T>(&mut self) -> &'a mut[T]{ unsafe{ std::slice::from_raw_parts_mut(self.value.list.G0.as_mut_ptr() as *mut T, self.value.list.n as usize) } } } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Utility // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //%% Utility %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Convert `S` to `&str`. This function is intended to convert symbol type (null-terminated char-array) to `str`. /// # Extern /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn print_symbol(symbol: K) -> K{ /// unsafe{ /// if (*symbol).qtype == -qtype::SYMBOL{ /// println!("symbol: `{}", S_to_str((*symbol).value.symbol)); /// } /// // return null /// KNULL /// } /// } /// ``` /// ```q /// q)print_symbol:`libc_api_examples 2: (`print_symbol; 1) /// q)a:`kx /// q)print_symbol a /// symbol: `kx /// ``` #[inline] pub fn S_to_str<'a>(cstring: S) -> &'a str{ unsafe{ CStr::from_ptr(cstring).to_str().unwrap() } } /// Convert null-terminated `&str` to `S`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn pingpong2(_: K) -> K{ /// unsafe{native::k(0, null_terminated_str_to_S("ping\0"), new_int(77), KNULL)} /// } /// ``` /// ```q /// q)ping:{[int] `$string[int], "_pong!!"}; /// q)pingpong: `libc_api_examples 2: (`pingpong2; 1); /// q)pingpong[] /// `77_pong!! /// ``` #[inline] pub fn null_terminated_str_to_S(string: &str) -> S { unsafe{ CStr::from_bytes_with_nul_unchecked(string.as_bytes()).as_ptr() as S } } /// Convert null terminated `&str` into `const_S`. Expected usage is to build /// a q error object with `krr`. /// # Example /// ```no_run /// use kdb_c_api::*; /// use kdb_c_api::native::*; /// /// pub extern "C" fn must_be_int2(obj: K) -> K{ /// unsafe{ /// if (*obj).qtype != -qtype::INT{ /// krr(null_terminated_str_to_const_S("not an int\0")) /// } /// else{ /// KNULL /// } /// } /// } /// ``` /// ```q /// q)check:`libc_api_examples 2: (`must_be_int; 1) /// q)a:100 /// q)check a /// 'not an int /// [0] check a /// ^ /// q)a:42i /// q)check a /// ``` pub fn null_terminated_str_to_const_S(string: &str) -> const_S { string.as_bytes().as_ptr() as const_S } //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// // Re-export // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++// //%% Constructor %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Constructor of q bool object. Relabeling of `kb`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_bool(_: K) -> K{ /// new_bool(0) /// } /// ``` /// ```q /// q)no: `libc_api_examples 2: (`create_bool; 1); /// q)no[] /// 0b /// ``` #[inline] pub fn new_bool(boolean: I) -> K{ unsafe{ native::kb(boolean) } } /// Constructor of q GUID object. Relabeling of `ku`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_guid(_: K) -> K{ /// new_guid([0x1e_u8, 0x11, 0x17, 0x0c, 0x42, 0x24, 0x25, 0x2c, 0x1c, 0x14, 0x1e, 0x22, 0x4d, 0x3d, 0x46, 0x24]) /// } /// ``` /// ```q /// q)create_guid: `libc_api_examples 2: (`create_guid; 1); /// q)create_guid[] /// 1e11170c-4224-252c-1c14-1e224d3d4624 /// ``` #[inline] pub fn new_guid(guid: [G; 16]) -> K{ unsafe{ native::ku(U::new(guid)) } } /// Constructor of q byte object. Relabeling of `kg`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_byte(_: K) -> K{ /// new_byte(0x3c) /// } /// ``` /// ```q /// q)create_byte: `libc_api_examples 2: (`create_byte; 1); /// q)create_byte[] /// 0x3c /// ``` #[inline] pub fn new_byte(byte: I) -> K{ unsafe{ native::kg(byte) } } /// Constructor of q short object. Relabeling of `kh`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_short(_: K) -> K{ /// new_short(-144) /// } /// ``` /// ```q /// q)shortage: `libc_api_examples 2: (`create_short; 1); /// q)shortage[] /// -144h /// ``` #[inline] pub fn new_short(short: I) -> K{ unsafe{ native::kh(short) } } /// Constructor of q int object. Relabeling of `ki`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_int(_: K) -> K{ /// new_int(86400000) /// } /// ``` /// ```q /// q)trvial: `libc_api_examples 2: (`create_int; 1); /// q)trivial[] /// 86400000i /// ``` #[inline] pub fn new_int(int: I) -> K{ unsafe{ native::ki(int) } } /// Constructor of q long object. Relabeling of `kj`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_long(_: K) -> K{ /// new_long(-668541276001729000) /// } /// ``` /// ```q /// q)lengthy: `libc_api_examples 2: (`create_long; 1); /// q)lengthy[] /// -668541276001729000 /// ``` #[inline] pub fn new_long(long: J) -> K{ unsafe{ native::kj(long) } } /// Constructor of q real object. Relabeling of `ke`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_real(_: K) -> K{ /// new_real(0.00324) /// } /// ``` /// ```q /// q)reality: `libc_api_examples 2: (`create_real; 1); /// q)reality[] /// 0.00324e /// ``` #[inline] pub fn new_real(real: F) -> K{ unsafe{ native::ke(real) } } /// Constructor of q float object. Relabeling of `kf`. /// # Example /// ``` /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_float(_: K) -> K{ /// new_float(-6302.620) /// } /// ``` /// ```q /// q)coffee_float: `libc_api_examples 2: (`create_float; 1); /// q)coffee_float[] /// -6302.62 /// ``` #[inline] pub fn new_float(float: F) -> K{ unsafe{ native::kf(float) } } /// Constructor of q char object. Relabeling of `kc`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_char2(_: K) -> K{ /// new_char('t') /// } /// ``` /// ```q /// q)heavy: `libc_api_examples 2: (`create_char2; 1); /// q)heavy[] /// "t" /// ``` #[inline] pub fn new_char(character: char) -> K{ unsafe{ native::kc(character as I) } } /// Constructor of q symbol object. Relabeling of `ks`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_symbol2(_: K) -> K{ /// new_symbol("symbolic") /// } /// ``` /// ```q /// q)hard: `libc_api_examples 2: (`create_symbol2; 1); /// q)hard[] /// `symbolic /// q)`symbolic ~ hard[] /// 1b /// ``` #[inline] pub fn new_symbol(symbol: &str) -> K{ unsafe{ native::ks(str_to_S!(symbol)) } } /// Constructor of q timestamp from elapsed time in nanoseconds since kdb+ epoch (`2000.01.01`). Relabeling of `ktj`. /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_timestamp2(_: K) -> K{ /// // 2015.03.16D00:00:00:00.000000000 /// new_timestamp(479779200000000000) /// } /// ``` /// ```q /// q)stamp: `libc_api_examples 2: (`create_timestamp2; 1); /// q)stamp[] /// 2015.03.16D00:00:00.000000000 /// ``` #[inline] pub fn new_timestamp(nanoseconds: J) -> K{ unsafe{ native::ktj(-qtype::TIMESTAMP as I, nanoseconds) } } /// Create a month object from the number of months since kdb+ epoch (`2000.01.01`). /// This is a complememtal constructor of missing month type. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_month(_: K) -> K{ /// // 2010.07m /// new_month(126) /// } /// ``` /// ```q /// q)create_month: `libc_api_examples 2: (`create_month; 1); /// q)create_month[] /// 2010.07m /// ``` #[inline] pub fn new_month(months: I) -> K{ unsafe{ let month=native::ka(-qtype::MONTH as I); (*month).value.int=months; month } } /// Constructor of q date object. Relabeling of `kd`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_date(_: K) -> K{ /// // 1999.12.25 /// new_date(-7) /// } /// ``` /// ```q /// q)nostradamus: `libc_api_examples 2: (`create_date; 1); /// q)nostradamus[] /// 1999.12.25 /// ``` #[inline] pub fn new_date(days: I) -> K{ unsafe{ native::kd(days) } } /// Constructor of q datetime object from the number of days since kdb+ epoch (`2000.01.01`). Relabeling of `kz`. /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_datetime(_: K) -> K{ /// // 2015.03.16T12:00:00:00.000 /// new_datetime(5553.5) /// } /// ``` /// ```q /// q)omega_date: libc_api_examples 2: (`create_datetime; 1); /// q)omega_date[] /// 2015.03.16T12:00:00.000 /// ``` #[inline] pub fn new_datetime(days: F) -> K{ unsafe{ native::kz(days) } } /// Constructor of q timespan object from nanoseconds. Relabeling of `ktj`. /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_timespan2(_: K) -> K{ /// // -1D01:30:00.001234567 /// new_timespan(-91800001234567) /// } /// ``` /// ```q /// q)duration: libc_api_examples 2: (`create_timespan2; 1); /// q)duration[] /// -1D01:30:00.001234567 /// ``` #[inline] pub fn new_timespan(nanoseconds: J) -> K{ unsafe{ native::ktj(-qtype::TIMESPAN as I, nanoseconds) } } /// Create a month object. This is a complememtal constructor of /// missing minute type. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_minute(_: K) -> K{ /// // 10:40 /// new_minute(640) /// } /// ``` /// ```q /// q)minty: `libc_api_examples 2: (`create_minute; 1); /// q)minty[] /// 10:40 /// ``` #[inline] pub fn new_minute(minutes: I) -> K{ unsafe{ let minute=native::ka(-qtype::MINUTE as I); (*minute).value.int=minutes; minute } } /// Create a month object. This is a complememtal constructor of /// missing second type. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_second(_: K) -> K{ /// // -02:00:00 /// new_second(-7200) /// } /// ``` /// ```q /// q)third: `libc_api_examples 2: (`create_second; 1); /// q)third[] /// -02:00:00 /// ``` #[inline] pub fn new_second(seconds: I) -> K{ unsafe{ let second=native::ka(-qtype::SECOND as I); (*second).value.int=seconds; second } } /// Constructor of q time object. Relabeling of `kt`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_time(_: K) -> K{ /// // -01:30:00.123 /// new_time(-5400123) /// } /// ``` /// ```q /// q)ancient: libc_api_examples 2: (`create_time; 1); /// q)ancient[] /// -01:30:00.123 /// ``` #[inline] pub fn new_time(milliseconds: I) -> K{ unsafe{ native::kt(milliseconds) } } /// Constructor of q simple list. /// # Example /// See the example of [`new_dictionary`](fn.new_dictionary.html). #[inline] pub fn new_simple_list(qtype: i8, length: J) -> K{ unsafe{ native::ktn(qtype as I, length) } } /// Constructor of q string object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_string(_: K) -> K{ /// new_string("this is a text.") /// } /// ``` /// ```q /// q)text: libc_api_examples 2: (`create_string; 1); /// q)text[] /// "this is a text." /// ``` #[inline] pub fn new_string(string: &str) -> K{ unsafe{ native::kp(str_to_S!(string)) } } /// Constructor if q string object with a fixed length. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_string2(_: K) -> K{ /// new_string_n("The meeting was too long and I felt it s...", 24) /// } /// ``` /// ```q /// q)speak_inwardly: libc_api_examples 2: (`create_string2; 1); /// q)speak_inwardly[] /// "The meeting was too long" /// ``` #[inline] pub fn new_string_n(string: &str, length: J) -> K{ unsafe{ native::kpn(str_to_S!(string), length) } } /// Constructor of q dictionary object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_dictionary() -> K{ /// let keys=new_simple_list(qtype::INT, 2); /// keys.as_mut_slice::<I>()[0..2].copy_from_slice(&[0, 1]); /// let values=new_simple_list(qtype::COMPOUND, 2); /// let date_list=new_simple_list(qtype::DATE, 3); /// // 2000.01.01 2000.01.02 2000.01.03 /// date_list.as_mut_slice::<I>()[0..3].copy_from_slice(&[0, 1, 2]); /// let string=new_string("I'm afraid I would crash the application..."); /// values.as_mut_slice::<K>()[0..2].copy_from_slice(&[date_list, string]); /// new_dictionary(keys, values) /// } /// ``` /// ```q /// q)create_dictionary: `libc_api_examples 2: (`create_dictionary; 1); /// q)create_dictionary[] /// 0| 2000.01.01 2000.01.02 2000.01.03 /// 1| "I'm afraid I would crash the application..." /// ``` #[inline] pub fn new_dictionary(keys: K, values: K) -> K{ unsafe{ native::xD(keys, values) } } /// Constructor of q error. The input must be null-terminated. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// pub extern "C" fn thai_kick(_: K) -> K{ /// new_error("Thai kick unconditionally!!\0") /// } /// ``` /// ```q /// q)monstrous: `libc_api_examples 2: (`thai_kick; 1); /// q)monstrous[] /// 'Thai kick unconditionally!! /// [0] monstrous[] /// ^ /// ``` #[inline] pub fn new_error(message: &str) -> K{ unsafe{ native::krr(null_terminated_str_to_const_S(message)) } } /// Similar to `new_error` but this function appends a system-error message to string `S` before passing it to internal `krr`. /// The input must be null-terminated. #[inline] pub fn new_error_os(message: &str) -> K{ unsafe{ native::orr(null_terminated_str_to_const_S(message)) } } /// Convert an error object into usual K object which has the error string in the field `s`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// extern "C" fn no_panick(func: K, args: K) -> K{ /// let result=error_to_string(apply(func, args)); /// if result.get_type() == qtype::ERROR{ /// println!("FYI: {}", result.get_symbol().unwrap()); /// // Decrement reference count of the error object which is no longer used. /// decrement_reference_count(result); /// KNULL /// } /// else{ /// result /// } /// } /// ``` /// ```q /// q)chill: `libc_api_examples 2: (`no_panick; 2); /// q)chill[$; ("J"; "42")] /// success! /// 42 /// q)chill[+; (1; `a)] /// FYI: type /// ``` #[inline] pub fn error_to_string(error: K) -> K{ unsafe{ native::ee(error) } } //%% Symbol %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Intern `n` chars from a char array. /// Returns an interned char array and should be used to add char array to a symbol vector. /// # Example /// See the example of [`flip`](fn.flip.html). #[inline] pub fn internalize_n(string: S, n: I) -> S{ unsafe{ native::sn(string, n) } } /// Intern a null-terminated char array. /// Returns an interned char array and should be used to add char array to a symbol vector. /// # Example /// See the example of [`flip`](fn.flip.html). #[inline] pub fn internalize(string: S) -> S{ unsafe{ native::ss(string) } } //%% Table %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Constructor of q table object from a q dictionary object. /// # Note /// Basically this is a `flip` command of q. Hence the value of the dictionary must have /// lists as its elements. /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_table2(_: K) -> K{ /// // Build keys /// let keys=new_simple_list(qtype::SYMBOL, 2); /// let keys_slice=keys.as_mut_slice::<S>(); /// keys_slice[0]=internalize(str_to_S!("time")); /// keys_slice[1]=internalize_n(str_to_S!("temperature_and_humidity"), 11); /// /// // Build values /// let values=new_simple_list(qtype::COMPOUND, 2); /// let time=new_simple_list(qtype::TIMESTAMP, 3); /// // 2003.10.10D02:24:19.167018272 2006.05.24D06:16:49.419710368 2008.08.12D23:12:24.018691392 /// time.as_mut_slice::<J>().copy_from_slice(&[119067859167018272_i64, 201766609419710368, 271897944018691392]); /// let temperature=new_simple_list(qtype::FLOAT, 3); /// temperature.as_mut_slice::<F>().copy_from_slice(&[22.1_f64, 24.7, 30.5]); /// values.as_mut_slice::<K>().copy_from_slice(&[time, temperature]); /// /// flip(new_dictionary(keys, values)) /// } /// ``` /// ```q /// q)climate_change: libc_api_examples 2: (`create_table2; 1); /// q)climate_change[] /// time temperature /// ----------------------------------------- /// 2003.10.10D02:24:19.167018272 22.1 /// 2006.05.24D06:16:49.419710368 24.7 /// 2008.08.12D23:12:24.018691392 30.5 /// ``` #[inline] pub fn flip(dictionary: K) -> K{ match unsafe{(*dictionary).qtype}{ qtype::DICTIONARY => unsafe{native::xT(dictionary)}, _ => unsafe{native::krr(null_terminated_str_to_const_S("not a dictionary\0"))} } } /// Constructor of simple q table object from a q keyed table object. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_table2(_: K) -> K{ /// // Build keys /// let keys=new_simple_list(qtype::SYMBOL, 2); /// let keys_slice=keys.as_mut_slice::<S>(); /// keys_slice[0]=internalize(str_to_S!("time")); /// keys_slice[1]=internalize_n(str_to_S!("temperature_and_humidity"), 11); /// /// // Build values /// let values=new_simple_list(qtype::COMPOUND, 2); /// let time=new_simple_list(qtype::TIMESTAMP, 3); /// // 2003.10.10D02:24:19.167018272 2006.05.24D06:16:49.419710368 2008.08.12D23:12:24.018691392 /// time.as_mut_slice::<J>().copy_from_slice(&[119067859167018272_i64, 201766609419710368, 271897944018691392]); /// let temperature=new_simple_list(qtype::FLOAT, 3); /// temperature.as_mut_slice::<F>().copy_from_slice(&[22.1_f64, 24.7, 30.5]); /// values.as_mut_slice::<K>().copy_from_slice(&[time, temperature]); /// /// flip(new_dictionary(keys, values)) /// } /// /// #[no_mangle] /// pub extern "C" fn create_keyed_table(dummy: K) -> K{ /// enkey(create_table2(dummy), 1) /// } /// /// #[no_mangle] /// pub extern "C" fn keyed_to_simple_table(dummy: K) -> K{ /// unkey(create_keyed_table(dummy)) /// } /// ``` /// ```q /// q)unkey: libc_api_examples 2: (`keyed_to_simple_table; 1); /// q)unkey[] /// time temperature /// ----------------------------------------- /// 2003.10.10D02:24:19.167018272 22.1 /// 2006.05.24D06:16:49.419710368 24.7 /// 2008.08.12D23:12:24.018691392 30.5 /// ``` #[inline] pub fn unkey(keyed_table: K) -> K{ match unsafe{(*keyed_table).qtype}{ qtype::DICTIONARY => unsafe{native::ktd(keyed_table)}, _ => unsafe{native::krr(null_terminated_str_to_const_S("not a keyed table\0"))} } } /// Constructor of q keyed table object. /// # Parameters /// - `table`: q table object to be enkeyed. /// - `n`: The number of key columns from the left. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn create_table2(_: K) -> K{ /// // Build keys /// let keys=new_simple_list(qtype::SYMBOL, 2); /// let keys_slice=keys.as_mut_slice::<S>(); /// keys_slice[0]=internalize(str_to_S!("time")); /// keys_slice[1]=internalize_n(str_to_S!("temperature_and_humidity"), 11); /// /// // Build values /// let values=new_simple_list(qtype::COMPOUND, 2); /// let time=new_simple_list(qtype::TIMESTAMP, 3); /// // 2003.10.10D02:24:19.167018272 2006.05.24D06:16:49.419710368 2008.08.12D23:12:24.018691392 /// time.as_mut_slice::<J>().copy_from_slice(&[119067859167018272_i64, 201766609419710368, 271897944018691392]); /// let temperature=new_simple_list(qtype::FLOAT, 3); /// temperature.as_mut_slice::<F>().copy_from_slice(&[22.1_f64, 24.7, 30.5]); /// values.as_mut_slice::<K>().copy_from_slice(&[time, temperature]); /// /// flip(new_dictionary(keys, values)) /// } /// /// #[no_mangle] /// pub extern "C" fn create_keyed_table(dummy: K) -> K{ /// enkey(create_table2(dummy), 1) /// } /// ``` /// ```q /// q)locker: libc_api_examples 2: (`create_keyed_table; 1); /// q)locker[] /// time | temperature /// -----------------------------| ----------- /// 2003.10.10D02:24:19.167018272| 22.1 /// 2006.05.24D06:16:49.419710368| 24.7 /// 2008.08.12D23:12:24.018691392| 30.5 /// ``` #[inline] pub fn enkey(table: K, n: J) -> K{ match unsafe{(*table).qtype}{ qtype::TABLE => unsafe{native::knt(n, table)}, _ => unsafe{native::krr(null_terminated_str_to_const_S("not a table\0"))} } } //%% Reference Count %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Decrement reference count of the q object. The decrement must be done when `k` function gets an error /// object whose type is `qtype::ERROR` and when you created an object but do not intend to return it to /// q side. See details on [the reference page](https://code.kx.com/q/interfaces/c-client-for-q/#managing-memory-and-reference-counting). /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[no_mangle] /// pub extern "C" fn agriculture(_: K)->K{ /// // Produce an apple. /// let fruit=new_symbol("apple"); /// // Sow the apple seed. /// decrement_reference_count(fruit); /// // Return null. /// KNULL /// } /// ``` /// ```q /// q)do_something: libc_api_examples 2: (`agriculture; 1); /// q)do_something[] /// q) /// ``` #[inline] pub fn decrement_reference_count(qobject: K) -> V{ unsafe{native::r0(qobject)} } /// Increment reference count of the q object. Increment must be done when you passed arguments /// to Rust function and intends to return it to q side or when you pass some `K` objects to `k` /// function and intend to use the argument after the call. /// See details on [the reference page](https://code.kx.com/q/interfaces/c-client-for-q/#managing-memory-and-reference-counting). /// # Example /// ```no_run /// use kdb_c_api::*; /// /// fn eat(apple: K){ /// println!("おいしい!"); /// } /// /// #[no_mangle] /// pub extern "C" fn satisfy_5000_men(apple: K) -> K{ /// for _ in 0..10{ /// eat(apple); /// } /// unsafe{native::k(0, str_to_S!("eat"), increment_reference_count(apple), KNULL);} /// increment_reference_count(apple) /// } /// ``` /// ```q /// q)eat:{[apple] show "Collect the clutter of apples!";} /// q)bread_is_a_sermon: libc_api_examples 2: (`satisfy_5000_men; 1); /// q)bread_is_a_sermon[`green_apple] /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// おいしい! /// "Collect the clutter of apples!" /// ``` #[inline] pub fn increment_reference_count(qobject: K) -> K{ unsafe{native::r1(qobject)} } //%% Callback %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Remove callback from the associated kdb+ socket and call `kclose`. /// Return null if the socket is invalid or not the one which had been registered by `sd1`. /// # Note /// A function which calls this function must be executed at the exit of the process. #[inline] pub fn destroy_socket(socket: I){ unsafe{ native::sd0(socket); } } /// Remove callback from the associated kdb+ socket and call `kclose` if the given condition is satisfied. /// Return null if the socket is invalid or not the one which had been registered by `sd1`. /// # Note /// A function which calls this function must be executed at the exit of the process. #[inline] pub fn destroy_socket_if(socket: I, condition: bool){ unsafe{ native::sd0x(socket, condition as I); } } /// Register callback to the associated kdb+ socket. /// ```no_run /// use kdb_c_api::*; /// /// static mut PIPE:[I; 2]=[-1, -1]; /// /// // Callback for some message queue. /// extern "C" fn callback(socket: I)->K{ /// let mut buffer: [K; 1]=[0 as K]; /// unsafe{libc::read(socket, buffer.as_mut_ptr() as *mut V, 8)}; /// // Call `shout` function on q side with the received data. /// let result=error_to_string(unsafe{native::k(0, str_to_S!("shout"), buffer[0], KNULL)}); /// if result.get_type() == qtype::ERROR{ /// eprintln!("Execution error: {}", result.get_symbol().unwrap()); /// decrement_reference_count(result); /// }; /// KNULL /// } /// /// #[no_mangle] /// pub extern "C" fn plumber(_: K) -> K{ /// if 0 != unsafe{libc::pipe(PIPE.as_mut_ptr())}{ /// return new_error("Failed to create pipe\0"); /// } /// if KNULL == register_callback(unsafe{PIPE[0]}, callback){ /// return new_error("Failed to register callback\0"); /// } /// // Lock symbol in a worker thread. /// pin_symbol(); /// let handle=std::thread::spawn(move ||{ /// let mut precious=new_simple_list(qtype::SYMBOL, 3); /// let precious_array=precious.as_mut_slice::<S>(); /// precious_array[0]=internalize(null_terminated_str_to_S("belief\0")); /// precious_array[1]=internalize(null_terminated_str_to_S("love\0")); /// precious_array[2]=internalize(null_terminated_str_to_S("hope\0")); /// unsafe{libc::write(PIPE[1], std::mem::transmute::<*mut K, *mut V>(&mut precious), 8)}; /// }); /// handle.join().unwrap(); /// unpin_symbol(); /// KNULL /// } /// ``` /// ```q /// q)shout:{[precious] -1 "What are the three largest elements?: ", .Q.s1 precious;}; /// q)fall_into_pipe: `libc_api_example 2: (`plumber; 1); /// q)fall_into_pipe[] /// What are the three largest elements?: `belief`love`hope /// ``` #[inline] pub fn register_callback(socket: I, function: extern fn(I) -> K) -> K{ unsafe{ native::sd1(socket, function) } } //%% Miscellaneous %%//vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv/ /// Apply a function to q list object `.[func; args]`. /// # Example /// See the example of [`error_to_string`](fn.error_to_string.html). #[inline] pub fn apply(func: K, args: K) -> K{ unsafe{native::dot(func, args)} } /// Lock a location of internalized symbol in remote threads. /// Returns the previously set value. /// # Example /// See the example of [`register_callback`](fn.register_callback.html). #[inline] pub fn pin_symbol() -> I{ unsafe{ native::setm(1) } } /// Unlock a location of internalized symbol in remote threads. /// # Example /// See the example of [`register_callback`](fn.register_callback.html). #[inline] pub fn unpin_symbol() -> I{ unsafe{ native::setm(0) } } /// Drop Rust object inside q. Passed as the first element of a foreign object. /// # Parameters /// - `obj`: List of (function to free the object; foreign object). /// # Example /// See the example of [`load_as_q_function`](fn.load_as_q_function.html). pub extern "C" fn drop_q_object(obj: K) -> K{ let obj_slice=obj.as_mut_slice::<K>(); // Take ownership of `K` object from a raw pointer and drop at the end of this scope. unsafe{Box::from_raw(obj_slice[1])}; // Fill the list with null. obj_slice.copy_from_slice(&[KNULL, KNULL]); obj } /// Load C function as a q function (`K` object). /// # Parameters /// - `func`: A function takes a C function that would take `n` `K` objects as arguments and returns a `K` object. /// - `n`: The number of arguments for the function. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// #[derive(Clone, Debug)] /// struct Planet{ /// name: String, /// population: i64, /// water: bool /// } /// /// impl Planet{ /// /// Constructor of `Planet`. /// fn new(name: &str, population: i64, water: bool) -> Self{ /// Planet{ /// name: name.to_string(), /// population: population, /// water: water /// } /// } /// /// /// Description of the planet. /// fn description(&self)->String{ /// let mut desc=format!("The planet {} is a beautiful planet where {} people reside.", self.name, self.population); /// if self.water{ /// desc+=" Furthermore water is flowing on the surface of it."; /// } /// desc /// } /// } /// /// /// Example of `set_type`. /// #[no_mangle] /// pub extern "C" fn eden(_: K) -> K{ /// let earth=Planet::new("earth", 7500_000_000, true); /// let foreign=new_simple_list(qtype::COMPOUND, 2); /// let foreign_slice=foreign.as_mut_slice::<K>(); /// foreign_slice[0]=drop_q_object as K; /// foreign_slice[1]=Box::into_raw(Box::new(earth)) as K; /// // Set as foreign object. /// foreign.set_type(qtype::FOREIGN); /// foreign /// } /// /// extern "C" fn invade(planet: K, action: K) -> K{ /// let obj=planet.as_mut_slice::<K>()[1] as *const Planet; /// println!("{:?}", unsafe{obj.as_ref()}.unwrap()); /// let mut desc=unsafe{obj.as_ref()}.unwrap().description(); /// if action.get_bool().unwrap(){ /// desc+=" You shall not curse what God blessed."; /// } /// else{ /// desc+=" I perceived I could find favor of God by blessing them."; /// } /// new_string(&desc) /// } /// /// /// Example of `load_as_q_function`. /// #[no_mangle] /// pub extern "C" fn probe(planet: K)->K{ /// // Return monadic function /// unsafe{native::k(0, str_to_S!("{[func; planet] func[planet]}"), load_as_q_function(invade as *const V, 2), planet, KNULL)} /// } /// ``` /// ```q /// q)eden: libc_api_example 2: (`eden; 1); /// q)earth: eden[] /// q)type earth /// 112h /// q)probe: libc_api_example 2: (`probe; 1); /// q)invade: probe[earth]; /// q)\c 25 200 /// q)invade 1b /// "The planet earth is a beautiful planet where 7500000000 people reside. Furthermore water is flowing on the surface of it. You shall not curse what God blessed." /// ``` #[inline] pub fn load_as_q_function(func: *const V, n: J) -> K{ unsafe{ native::dl(func, n) } } /// Convert ymd to the number of days from `2000.01.01`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// fn main(){ /// /// let days=ymd_to_days(2020, 4, 1); /// assert_eq!(days, 7396); /// /// } /// ``` #[inline] pub fn ymd_to_days(year: I, month: I, date:I) -> I{ unsafe{ native::ymd(year, month, date) } } /// Convert the number of days from `2000.01.01` to a number expressed as `yyyymmdd`. /// # Example /// ```no_run /// use kdb_c_api::*; /// /// fn main(){ /// /// let number=days_to_ymd(7396); /// assert_eq!(number, 20200401); /// /// } /// ``` #[inline] pub fn days_to_ymd(days: I) -> I{ unsafe{ native::dj(days) } }
#![allow(clippy::float_cmp)] use crate::{Constraint, RelationalOperator, Solver, SolverError, Variable, STRENGTH_REQUIRED}; #[test] fn create_variable() { let var = Variable::new("var_name"); assert_eq!(var.name(), "var_name"); } #[test] fn create_term() { let var = Variable::new("var_name"); let _term = var * 1.0; } #[test] fn create_expression() { let var = Variable::new("var_name"); let _expr = var * 1.0 + 0.0; } #[test] fn create_constraint() { let expr = Variable::new("var_name") * 1.0 + 0.0; let _constraint = Constraint::new( &expr, RelationalOperator::GreaterThanEqualZero, STRENGTH_REQUIRED, ); } #[test] fn create_solver() { let var = Variable::new("var_name"); let expr = &var * 1.0 - 5.0; let constraint = Constraint::new( &expr, RelationalOperator::GreaterThanEqualZero, STRENGTH_REQUIRED, ); let mut solver = Solver::new(); assert!(solver.add_constraint(&constraint).is_ok()); solver.update_variables(); assert_eq!(var.value(), 5.0); } #[test] fn solver_duplicate_constraints() { let var = Variable::new("var_name"); let expr = &var * 1.0 - 5.0; let constraint = Constraint::new( &expr, RelationalOperator::GreaterThanEqualZero, STRENGTH_REQUIRED, ); let mut solver = Solver::new(); assert!(solver.add_constraint(&constraint).is_ok()); assert!(matches!( solver.add_constraint(&constraint), Err(SolverError::DuplicateConstraint) )); } #[test] fn remove_constraint() { let var = Variable::new("var_name"); let expr = &var * 1.0 - 5.0; let constraint = Constraint::new( &expr, RelationalOperator::GreaterThanEqualZero, STRENGTH_REQUIRED, ); let mut solver = Solver::new(); assert!(solver.add_constraint(&constraint).is_ok()); assert!(solver.remove_constraint(&constraint).is_ok()); assert!(matches!( solver.remove_constraint(&constraint), Err(SolverError::UnknownConstraint) )); }
use super::{body::Body, id::Id}; use crate::{ builtin_functions::BuiltinFunction, hir, impl_display_via_richir, module::Module, rich_ir::{ReferenceKey, RichIrBuilder, ToRichIr, TokenType}, }; use core::mem; use derive_more::{From, TryInto}; use enumset::EnumSet; use itertools::Itertools; use num_bigint::BigInt; use rustc_hash::{FxHashSet, FxHasher}; use std::{ cmp::Ordering, hash::{Hash, Hasher}, }; use strum_macros::EnumIs; #[derive(Clone, Debug, EnumIs, Eq, From, PartialEq, TryInto)] pub enum Expression { #[from] #[try_into] Int(BigInt), #[from] #[try_into] Text(String), Tag { symbol: String, value: Option<Id>, }, #[from] Builtin(BuiltinFunction), #[from] List(Vec<Id>), Struct(Vec<(Id, Id)>), Reference(Id), /// A HIR ID that can be used to refer to code in the HIR. #[from] HirId(hir::Id), /// In the MIR, responsibilities are explicitly tracked. All functions take /// a responsible HIR ID as an extra parameter. Based on whether the /// function is fuzzable or not, this parameter may be used to dynamically /// determine who's at fault if some `needs` is not fulfilled. Function { original_hirs: FxHashSet<hir::Id>, parameters: Vec<Id>, responsible_parameter: Id, body: Body, }, /// This expression is never contained in an actual MIR body, but when /// dealing with expressions, its easier to not special-case IDs referring /// to parameters. Parameter, Call { function: Id, arguments: Vec<Id>, responsible: Id, }, UseModule { current_module: Module, relative_path: Id, responsible: Id, }, /// This expression indicates that the code will panic. It's created in the /// generated `needs` function or if the compiler can statically determine /// that some expression will always panic. Panic { reason: Id, responsible: Id, }, TraceCallStarts { hir_call: Id, function: Id, arguments: Vec<Id>, responsible: Id, }, TraceCallEnds { return_value: Id, }, TraceExpressionEvaluated { hir_expression: Id, value: Id, }, TraceFoundFuzzableFunction { hir_definition: Id, function: Id, }, } impl Expression { pub fn tag(symbol: String) -> Self { Expression::Tag { symbol, value: None, } } pub fn nothing() -> Self { Self::tag("Nothing".to_string()) } } // Int impl From<i32> for Expression { fn from(value: i32) -> Self { Self::Int(value.into()) } } impl From<u64> for Expression { fn from(value: u64) -> Self { Self::Int(value.into()) } } impl From<usize> for Expression { fn from(value: usize) -> Self { Self::Int(value.into()) } } impl<'a> TryInto<&'a BigInt> for &'a Expression { type Error = (); fn try_into(self) -> Result<&'a BigInt, ()> { let Expression::Int(int) = self else { return Err(()); }; Ok(int) } } // Text impl<'a> From<&'a str> for Expression { fn from(value: &'a str) -> Self { Self::Text(value.to_string()) } } impl<'a> TryInto<&'a str> for &'a Expression { type Error = (); fn try_into(self) -> Result<&'a str, ()> { let Expression::Text(text) = self else { return Err(()); }; Ok(text) } } // Tag impl From<bool> for Expression { fn from(value: bool) -> Self { Self::tag(if value { "True" } else { "False" }.to_string()) } } impl TryInto<bool> for &Expression { type Error = (); fn try_into(self) -> Result<bool, ()> { let Expression::Tag { symbol, .. } = self else { return Err(()); }; match symbol.as_str() { "True" => Ok(true), "False" => Ok(false), _ => Err(()), } } } impl From<Ordering> for Expression { fn from(value: Ordering) -> Self { let symbol = match value { Ordering::Less => "Less", Ordering::Equal => "Equal", Ordering::Greater => "Greater", }; Self::tag(symbol.to_string()) } } impl From<Result<Id, Id>> for Expression { fn from(value: Result<Id, Id>) -> Self { let (symbol, value) = match value { Ok(it) => ("Ok", it), Err(it) => ("Error", it), }; Expression::Tag { symbol: symbol.to_string(), value: Some(value), } } } // Referene impl From<&Id> for Expression { fn from(value: &Id) -> Self { Self::Reference(*value) } } #[allow(clippy::derived_hash_with_manual_eq)] impl Hash for Expression { fn hash<H: Hasher>(&self, state: &mut H) { mem::discriminant(self).hash(state); match self { Expression::Int(int) => int.hash(state), Expression::Text(text) => text.hash(state), Expression::Tag { symbol, value } => { symbol.hash(state); value.hash(state); } Expression::Builtin(builtin) => builtin.hash(state), Expression::List(items) => items.hash(state), Expression::Struct(fields) => fields.len().hash(state), Expression::Reference(id) => id.hash(state), Expression::HirId(id) => id.hash(state), Expression::Function { original_hirs, parameters, responsible_parameter, body, } => { { let mut hash = 0; for id in original_hirs { let mut state = FxHasher::default(); id.hash(&mut state); hash ^= state.finish(); } hash.hash(state); } parameters.hash(state); responsible_parameter.hash(state); body.hash(state); } Expression::Parameter => {} Expression::Call { function, arguments, responsible, } => { function.hash(state); arguments.hash(state); responsible.hash(state); } Expression::UseModule { current_module, relative_path, responsible, } => { current_module.hash(state); relative_path.hash(state); responsible.hash(state); } Expression::Panic { reason, responsible, } => { reason.hash(state); responsible.hash(state); } Expression::TraceCallStarts { hir_call, function, arguments, responsible, } => { hir_call.hash(state); function.hash(state); arguments.hash(state); responsible.hash(state); } Expression::TraceCallEnds { return_value } => return_value.hash(state), Expression::TraceExpressionEvaluated { hir_expression, value, } => { hir_expression.hash(state); value.hash(state); } Expression::TraceFoundFuzzableFunction { hir_definition, function, } => { hir_definition.hash(state); function.hash(state); } } } } impl_display_via_richir!(Expression); impl ToRichIr for Expression { fn build_rich_ir(&self, builder: &mut RichIrBuilder) { match self { Expression::Int(int) => { int.build_rich_ir(builder); } Expression::Text(text) => { let range = builder.push(format!(r#""{}""#, text), TokenType::Text, EnumSet::empty()); builder.push_reference(text.to_owned(), range); } Expression::Tag { symbol, value } => { let range = builder.push(symbol, TokenType::Symbol, EnumSet::empty()); builder.push_reference(ReferenceKey::Symbol(symbol.to_owned()), range); if let Some(value) = value { builder.push(" ", None, EnumSet::empty()); value.build_rich_ir(builder); } } Expression::Builtin(builtin) => { builtin.build_rich_ir(builder); } Expression::List(items) => { builder.push("(", None, EnumSet::empty()); builder.push_children(items, ", "); if items.len() <= 1 { builder.push(",", None, EnumSet::empty()); } builder.push(")", None, EnumSet::empty()); } Expression::Struct(fields) => { builder.push("[", None, EnumSet::empty()); builder.push_children_custom( fields.iter().collect_vec(), |builder, (key, value)| { key.build_rich_ir(builder); builder.push(": ", None, EnumSet::empty()); value.build_rich_ir(builder); }, ", ", ); builder.push("]", None, EnumSet::empty()); } Expression::Reference(id) => id.build_rich_ir(builder), Expression::HirId(id) => { let range = builder.push(id.to_string(), TokenType::Symbol, EnumSet::empty()); builder.push_reference(id.to_owned(), range); } Expression::Function { // IDs are displayed by the body before the entire expression // assignment. original_hirs: _, parameters, responsible_parameter, body, } => { builder.push("{ ", None, EnumSet::empty()); builder.push_children_custom( parameters, |builder, parameter| { let range = builder.push( parameter.to_string(), TokenType::Parameter, EnumSet::empty(), ); builder.push_definition(*parameter, range); }, " ", ); builder.push( if parameters.is_empty() { "(responsible " } else { " (+ responsible " }, None, EnumSet::empty(), ); let range = builder.push( responsible_parameter.to_string(), TokenType::Parameter, EnumSet::empty(), ); builder.push_definition(*responsible_parameter, range); builder.push(") ->", None, EnumSet::empty()); builder.push_foldable(|builder| { builder.indent(); builder.push_newline(); body.build_rich_ir(builder); builder.dedent(); builder.push_newline(); }); builder.push("}", None, EnumSet::empty()); } Expression::Parameter => { builder.push("parameter", None, EnumSet::empty()); } Expression::Call { function, arguments, responsible, } => { builder.push("call ", None, EnumSet::empty()); function.build_rich_ir(builder); builder.push(" with ", None, EnumSet::empty()); if arguments.is_empty() { builder.push("no arguments", None, EnumSet::empty()); } else { builder.push_children(arguments, " "); } builder.push(" (", None, EnumSet::empty()); responsible.build_rich_ir(builder); builder.push(" is responsible)", None, EnumSet::empty()); } Expression::UseModule { current_module, relative_path, responsible, } => { builder.push("use ", None, EnumSet::empty()); relative_path.build_rich_ir(builder); builder.push(" (relative to ", None, EnumSet::empty()); current_module.build_rich_ir(builder); builder.push("; ", None, EnumSet::empty()); responsible.build_rich_ir(builder); builder.push(" is responsible)", None, EnumSet::empty()); } Expression::Panic { reason, responsible, } => { builder.push("panicking because ", None, EnumSet::empty()); reason.build_rich_ir(builder); builder.push(" (", None, EnumSet::empty()); responsible.build_rich_ir(builder); builder.push(" is at fault)", None, EnumSet::empty()); } Expression::TraceCallStarts { hir_call, function, arguments, responsible, } => { builder.push("trace: start of call of ", None, EnumSet::empty()); function.build_rich_ir(builder); builder.push(" with ", None, EnumSet::empty()); builder.push_children(arguments, " "); builder.push(" (", None, EnumSet::empty()); responsible.build_rich_ir(builder); builder.push(" is responsible, code is at ", None, EnumSet::empty()); hir_call.build_rich_ir(builder); builder.push(")", None, EnumSet::empty()); } Expression::TraceCallEnds { return_value } => { builder.push( "trace: end of call with return value ", None, EnumSet::empty(), ); return_value.build_rich_ir(builder); } Expression::TraceExpressionEvaluated { hir_expression, value, } => { builder.push("trace: expression ", None, EnumSet::empty()); hir_expression.build_rich_ir(builder); builder.push(" evaluated to ", None, EnumSet::empty()); value.build_rich_ir(builder); } Expression::TraceFoundFuzzableFunction { hir_definition, function, } => { builder.push("trace: found fuzzable function ", None, EnumSet::empty()); function.build_rich_ir(builder); builder.push(" defined at ", None, EnumSet::empty()); hir_definition.build_rich_ir(builder); } } } }
pub struct NumMatrix { matrix: Vec<Vec<i32>>, } impl NumMatrix { pub fn new(matrix: Vec<Vec<i32>>) -> Self { let mut matrix = matrix; for i in 0..matrix.len() { for j in 0..matrix[i].len() { if i > 0 { matrix[i][j] += matrix[i - 1][j]; } if j > 0 { matrix[i][j] += matrix[i][j - 1]; } if i > 0 && j > 0 { matrix[i][j] -= matrix[i - 1][j - 1]; } } } Self { matrix } } pub fn sum_region(&self, row1: i32, col1: i32, row2: i32, col2: i32) -> i32 { let mut sum = self.matrix[row2 as usize][col2 as usize]; if row1 > 0 { sum -= self.matrix[row1 as usize - 1][col2 as usize]; } if col1 > 0 { sum -= self.matrix[row2 as usize][col1 as usize - 1]; } if row1 > 0 && col1 > 0 { sum += self.matrix[row1 as usize - 1][col1 as usize - 1]; } sum } } #[test] fn test0304() { let obj = NumMatrix::new(vec![ vec![3, 0, 1, 4, 2], vec![5, 6, 3, 2, 1], vec![1, 2, 0, 1, 5], vec![4, 1, 0, 1, 7], vec![1, 0, 3, 0, 5], ]); assert_eq!(obj.sum_region(2, 1, 4, 3), 8); assert_eq!(obj.sum_region(1, 1, 2, 2), 11); assert_eq!(obj.sum_region(1, 2, 2, 4), 12); }
use petgraph::graph::{EdgeIndex, Graph, IndexType, NodeIndex}; use petgraph::visit::{EdgeCount, IntoNeighbors, IntoNodeIdentifiers}; use petgraph::EdgeType; use std::collections::{HashMap, HashSet}; use std::hash::Hash; pub fn louvain_step<G>(graph: &G) -> Option<HashMap<G::NodeId, G::NodeId>> where G: EdgeCount + IntoNeighbors + IntoNodeIdentifiers, G::NodeId: Eq + Hash, { let m = graph.edge_count() as f32; let k = graph .node_identifiers() .map(|u| (u, graph.neighbors(u).count() as f32)) .collect::<HashMap<_, _>>(); let mut sigma_total = k.clone(); let mut communities = graph .node_identifiers() .map(|u| (u, u)) .collect::<HashMap<_, _>>(); let mut community_nodes = graph .node_identifiers() .map(|u| (u, HashSet::new())) .collect::<HashMap<_, _>>(); let mut improve = false; for u in graph.node_identifiers() { let mut neighboring_communities = HashSet::new(); for v in graph.neighbors(u) { neighboring_communities.insert(communities[&v]); } neighboring_communities.remove(&communities[&u]); for &c in neighboring_communities.iter() { let prev_c = communities[&u]; community_nodes.get_mut(&prev_c).unwrap().remove(&u); let mut k_in = 0.; for v in graph.neighbors(u) { if communities[&v] == c { k_in += 1.; } } let delta_q = 0.5 * (k_in - k[&u] * sigma_total[&c] / m) / m; if delta_q > 0. { *sigma_total.get_mut(&c).unwrap() += k[&u]; *sigma_total.get_mut(&prev_c).unwrap() -= k[&u]; *communities.get_mut(&u).unwrap() = c; community_nodes.get_mut(&c).unwrap().insert(u); improve = true; } else { community_nodes.get_mut(&prev_c).unwrap().insert(u); } } } if improve { Some(communities) } else { None } } pub fn coarsen< N1, N2, E1, E2, Ty: EdgeType, Ix: IndexType, GF: FnMut(&Graph<N1, E1, Ty, Ix>, NodeIndex<Ix>) -> usize, NF: FnMut(&Graph<N1, E1, Ty, Ix>, &Vec<NodeIndex<Ix>>) -> N2, EF: FnMut(&Graph<N1, E1, Ty, Ix>, &Vec<EdgeIndex<Ix>>) -> E2, >( graph: &Graph<N1, E1, Ty, Ix>, node_groups: &mut GF, shrink_node: &mut NF, shrink_edge: &mut EF, ) -> (Graph<N2, E2, Ty, Ix>, HashMap<usize, NodeIndex<Ix>>) { let node_groups = graph .node_indices() .map(|u| (u, node_groups(graph, u))) .collect::<HashMap<_, _>>(); let mut groups = HashMap::<usize, Vec<NodeIndex<Ix>>>::new(); for u in graph.node_indices() { let g = node_groups[&u]; groups.entry(g).or_insert(vec![]).push(u); } let mut group_edges = HashMap::new(); for e in graph.edge_indices() { let (u, v) = graph.edge_endpoints(e).unwrap(); let key = { let source_group = node_groups[&u]; let target_group = node_groups[&v]; if source_group == target_group { continue; } if source_group < target_group { (source_group, (target_group)) } else { ((target_group), (source_group)) } }; group_edges.entry(key).or_insert(vec![]).push(e); } let mut coarsened_graph = Graph::with_capacity(0, 0); let mut coarsened_node_ids = HashMap::new(); for (&group_id, node_ids) in groups.iter() { coarsened_node_ids.insert( group_id, coarsened_graph.add_node(shrink_node(graph, &node_ids)), ); } for (&(u, v), edge_ids) in group_edges.iter() { coarsened_graph.add_edge( coarsened_node_ids[&u], coarsened_node_ids[&v], shrink_edge(graph, &edge_ids), ); } (coarsened_graph, coarsened_node_ids) }
// http://mathworld.wolfram.com/Runge-KuttaMethod.html pub trait State: Add<Self, Self> + Mul<f64, Self> { fn f(&self, t: f64) -> Self; } #[allow(dead_code)] pub fn step_rk2<Y>(t: f64, dt: f64, y: &Y) -> Y where Y: State { let k_1 = y.f(t) * dt; let k_2 = (*y + k_1 * 0.5).f(t + 0.5 * dt) * dt; *y + k_2 } pub fn step_rk4<Y>(t: f64, dt: f64, y: &Y) -> Y where Y: State { let k_1 = y.f(t) * dt; let k_2 = (*y + k_1 * 0.5).f(t + 0.5 * dt) * dt; let k_3 = (*y + k_2 * 0.5).f(t + 0.5 * dt) * dt; let k_4 = (*y + k_3).f(t + dt) * dt; *y + k_1 * (1.0 / 6.0) + k_2 * (1.0 / 3.0) + k_3 * (1.0 / 3.0) + k_4 * (1.0 / 6.0) }
mod calc; mod clear; mod config; mod error; mod schedule; mod track; mod watcher; use crate::config::Configuration; pub use crate::config::get_config; pub use error::TimeTrackerError; pub struct TimeTracker<'a> { config: &'a Configuration, } impl<'a> TimeTracker<'a> { pub fn new(config: &'a Configuration) -> Self { TimeTracker { config } } }
pub use health_check::*; pub use subscriptions::*; pub mod health_check; pub mod subscriptions;
use std::iter::Peekable; use crate::object::Object; fn read_integer<T: Iterator<Item = char>>(lexer: &mut Peekable<T>) -> Result<Object, String> { let c = lexer.next().unwrap(); let mut number = match c.to_string().parse::<i64>() { Ok(number) => number, Err(e) => { return Err(format!("error parsing number: {:?}", e)); } }; while let Some(Ok(digit)) = lexer.peek().map(|c| c.to_string().parse::<i64>()) { number = number * 10 + digit; lexer.next(); } Ok(Object::Integer(number)) } fn valid_symbol_char(c: &char) -> bool { if *c == '(' || *c == ')' { return false; } c.is_ascii_alphanumeric() || c.is_ascii_punctuation() } fn read_symbol<T: Iterator<Item = char>>(lexer: &mut Peekable<T>) -> Result<Object, String> { let c = lexer.next().unwrap(); let mut result = c.to_string(); while let Some(c) = lexer.peek() { if !valid_symbol_char(c) { break; } let c = lexer.next().unwrap(); result.push(c); } Ok(Object::Symbol(result)) } fn read_list<T: Iterator<Item = char>>(lexer: &mut Peekable<T>) -> Result<Object, String> { let mut elems = vec![]; lexer.next(); while let Some(&c) = lexer.peek() { if c == ')' { lexer.next(); break; } if c == ' ' || c == '\n' { lexer.next(); continue; } let element = if c == '(' { read_list(lexer)? } else { read_object(lexer)? }; elems.push(element); } Ok(Object::List(elems)) } fn read_object<T: Iterator<Item = char>>(lexer: &mut Peekable<T>) -> Result<Object, String> { match lexer.peek() { Some('0'...'9') => read_integer(lexer), Some('(') => read_list(lexer), Some(c) if valid_symbol_char(c) => read_symbol(lexer), c => Err(format!("unexpected character: {:?}", c)), } } pub fn read(code: &str) -> Result<Vec<Object>, String> { let mut lexer = code.chars().peekable(); let mut objects = Vec::new(); while let Some(&c) = lexer.peek() { if c == ' ' || c == '\n' { lexer.next(); continue; } let object = read_object(&mut lexer)?; objects.push(object); } Ok(objects) } #[cfg(test)] mod tests { use super::*; use std::ops::Deref; #[test] fn reading_single_numbers() { let objects = read("5").unwrap(); let number = objects.first().unwrap(); match number.deref() { Object::Integer(int) => assert_eq!(*int, 5), _ => assert!(false), } let objects = read("123456789").unwrap(); let number = objects.first().unwrap(); match number.deref() { Object::Integer(int) => assert_eq!(*int, 123456789), _ => assert!(false), } } #[test] fn read_multiple_numbers() { let objects = read("5 5 5 5").unwrap(); assert_eq!(objects.len(), 4); let number = objects.first().unwrap(); match number.deref() { Object::Integer(int) => assert_eq!(*int, 5), _ => assert!(false), } } #[test] fn reading_lists() { let objects = read("(1 2 3)").unwrap(); assert_eq!(objects.len(), 1); assert_eq!( objects.first().unwrap(), &Object::List(vec![ Object::Integer(1), Object::Integer(2), Object::Integer(3) ]) ); } #[test] fn reading_lists_of_lists() { let objects = read("(1 (2 3 (4 5)))").unwrap(); assert_eq!(objects.len(), 1); assert_eq!( objects.first().unwrap(), &Object::List(vec![ Object::Integer(1), Object::List(vec![ Object::Integer(2), Object::Integer(3), Object::List(vec![Object::Integer(4), Object::Integer(5)]), ]), ]) ); } #[test] fn testing_valid_symbol_characters() { assert!(valid_symbol_char(&'a')); assert!(valid_symbol_char(&'z')); assert!(valid_symbol_char(&'A')); assert!(valid_symbol_char(&'Z')); assert!(valid_symbol_char(&'-')); assert!(valid_symbol_char(&'!')); assert!(valid_symbol_char(&'+')); assert!(!valid_symbol_char(&' ')); } #[test] fn reading_symbols() { let objects = read("(list)").unwrap(); assert_eq!(objects.len(), 1); assert_eq!( objects.first().unwrap(), &Object::List(vec![Object::Symbol(String::from("list"))]) ); let objects = read("(list-one)").unwrap(); assert_eq!(objects.len(), 1); assert_eq!( objects.first().unwrap(), &Object::List(vec![Object::Symbol(String::from("list-one"))]) ); let objects = read("(+ 1 2 3)").unwrap(); assert_eq!(objects.len(), 1); assert_eq!( objects.first().unwrap(), &Object::List(vec![ Object::Symbol(String::from("+")), Object::Integer(1), Object::Integer(2), Object::Integer(3) ]) ); } #[test] fn reading_multiple_lists() { let input = "(1) (foobar) (7)"; let objects = read(input).unwrap(); assert_eq!(objects.len(), 3); assert_eq!(objects[0], Object::List(vec![Object::Integer(1)])); assert_eq!( objects[1], Object::List(vec![Object::Symbol(String::from("foobar"))]) ); assert_eq!(objects[2], Object::List(vec![Object::Integer(7)])); } }
extern crate itertools; use std::fmt; use std::collections::HashMap; use itertools::Itertools; pub struct Object { pub map: HashMap<String, Value>, } impl Object { pub fn to_basic_string(&self) -> String { [ "{", self.map.iter().map(|(key, value)| format!("\"{}\":{}", key, value)).join(",").as_str(), "}" ].join("") } pub fn to_pretty_string(&self, depth: usize) -> String { let indent: String = std::iter::repeat(" ").take(depth * 2).join(""); [ format!("{{\n"), self.map.iter().map(|(key, value)| format!("{} \"{}\": {}", indent, key, value.to_pretty_string(depth + 1))).join(",\n"), format!("\n{}}}", indent), ].join("") } } impl fmt::Display for Object { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_basic_string()) } } impl fmt::Debug for Object { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_basic_string()) } } pub struct Array { pub values: Vec<Value> } impl Array { pub fn to_basic_string(&self) -> String { [ "[", self.values.iter().map(|value| value.to_string()).join(",").as_str(), "]" ].join("") } pub fn to_pretty_string(&self, depth: usize) -> String { let indent: String = std::iter::repeat(" ").take(depth * 2).join(""); [ format!("[\n"), self.values.iter().map(|value| format!("{} {}", indent, value.to_pretty_string(depth + 1))).join(",\n"), format!("\n{}]", indent) ].join("") } } impl fmt::Display for Array { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_pretty_string(0)) } } impl fmt::Debug for Array { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self.to_basic_string()) } } pub enum Value { Object(Object), Number(f64), String(String), Array(Array), Keyword(String) } impl fmt::Display for Value { fn fmt(&self, f : &mut fmt::Formatter) -> fmt::Result { let value = match self { Value::Object(object) => object.to_basic_string(), Value::Array(array) => array.to_basic_string(), Value::String(string) => format!("\"{}\"", string), Value::Number(number) => number.to_string(), Value::Keyword(string) => string.to_string() }; write!(f, "{}", value) } } impl Value { pub fn to_pretty_string(&self, depth: usize) -> String { match self { Value::Object(object) => object.to_pretty_string(depth), Value::Array(array) => array.to_pretty_string(depth), Value::String(string) => format!("\"{}\"", string), Value::Number(number) => number.to_string(), Value::Keyword(string) => string.to_string() } } }
/* * Given an array of integers and an integer k, * you need to find the total number of continuous subarrays whose sum equals to k. * * Example 1: * ---------- * Input: nums = [1, 1, 1], k = 2 * Output: 2 */ use std::collections::HashMap; pub fn subarray_sum(nums: Vec<i32>, k: i32) -> i32 { let mut count = 0; let mut sum = 0; let mut map: HashMap<i32, i32> = HashMap::new(); map.insert(0, 1); for i in nums { sum += i; match map.get(&(sum - k)) { None => (), Some(v) => { count += v } } match map.get(&sum) { None => { map.insert(sum, 1); }, Some(v) => { map.insert(sum, v + 1); } } } return count } #[cfg(test)] mod test { use super::subarray_sum; #[test] fn example1() { let nums = vec![1, 1, 1]; let k = 2; assert_eq!(subarray_sum(nums, k), 2); } }
// The objects that help render and are to be rendered. Built on the data structures as defined in // structures.rs. use crate::structures::*; use std::fs::File; use std::io::prelude::*; use std::ops::Mul; #[derive(Debug, Clone)] pub enum Colour { Rgba(f64, f64, f64, f64), // (r, g, b, a) Grey(f64), // (a) } // The point of view of which to render from #[derive(Debug, Clone)] pub struct Camera { pub pos: Vector, pub target: Vector, pub up: Vector, } #[derive(Debug, Clone)] pub struct Face { pub vertices: [usize; 3], pub colour: Colour, pub normal: Vector, } // A mesh to be rendered. Contains vertex information and the like. #[derive(Debug, Clone)] pub struct Mesh { pub name: String, pub vertices: Vec<Vector>, pub faces: Vec<Face>, pub pos: Vector, pub rot: Vector, } impl Camera { pub fn new() -> Camera { Camera { pos: Vector::new(), target: Vector::new(), up: Vector::from(0.0, 1.0, 0.0, 0.0), } } pub fn from(pos: Vector, target: Vector, up: Vector) -> Camera { Camera { pos: pos, target: target, up: up, } } } impl Mesh { pub fn new(name: String) -> Mesh { Mesh { name: name, vertices: Vec::new(), faces: Vec::new(), pos: Vector::new(), rot: Vector::new(), } } pub fn from(name: String, vertices: Vec<Vector>, faces: Vec<Face>, pos: Vector, rot: Vector) -> Mesh { // This function is pretty much useless because actually implementing it would be horrific. // Instead, use from_file. Mesh { name: name, vertices: vertices, faces: faces, pos: pos, rot: rot, } } // Reads a file containing vector information and returns a mesh. // Much easier than just making a vector with the information like *some people I know* pub fn from_file(filename: String, pos: Vector, rot: Vector) -> Result<Mesh, String> { let mut f: File = File::open(filename).unwrap(); let mut contents = String::new(); f.read_to_string(&mut contents).unwrap(); let mut lines: Vec<&str> = contents.split("\n").collect(); let mut vertex_data: Vec<Vector> = Vec::new(); let mut faces: Vec<([usize; 3], usize)> = Vec::new(); let mut normals: Vec<Vector> = Vec::new(); let mut mesh = Mesh { name: String::new(), vertices: Vec::new(), faces: Vec::new(), pos: pos, rot: rot, }; for i in 0..(lines.len()-1) { // Note that the last element of lines is an empty list. let mut l: Vec<&str> = lines[i].split(" ").collect(); match l[0] { "o" => { mesh.name = String::from(l[1]); }, "v" => { let mut v = Vector::new(); v.x = l[1].parse::<f64>().unwrap(); v.y = l[2].parse::<f64>().unwrap(); v.z = l[3].parse::<f64>().unwrap(); v.w = 1.0; vertex_data.push(v); }, "vn" => { let mut vn = Vector::new(); vn.x = l[1].parse::<f64>().unwrap(); vn.y = l[2].parse::<f64>().unwrap(); vn.z = l[3].parse::<f64>().unwrap(); vn.w = 0.0; normals.push(vn); }, "f" => { let mut vertices = [0usize; 3]; let mut normal = 0usize; for j in 1..l.len() { let vf: Vec<&str> = l[j].split("//").collect(); if j == 1 { // We're assuming the normal is the same for each vector normal = vf[1].parse::<usize>().unwrap()-1; } vertices[j-1] = vf[0].parse::<usize>().unwrap()-1; } faces.push((vertices, normal)); }, _ => {} } } let mut face_structs: Vec<Face> = Vec::new(); for i in 0..faces.len() { let test = normals[faces[i].1].clone(); face_structs.push( Face::from(faces[i].0[0], faces[i].0[1], faces[i].0[2], normals[faces[i].1].clone(), Colour::Grey(1.0)) // TODO Actually calculate colour ); } mesh.vertices = vertex_data; mesh.faces = face_structs; Ok(mesh) } } impl Mul<Matrix> for Mesh { type Output = Mesh; fn mul(self, rhs: Matrix) -> Mesh { let mut m = self.clone(); for i in 0..m.vertices.len() { m.vertices[i] = rhs.clone()*m.vertices[i].clone(); } m } } impl Face { fn from(v1: usize, v2: usize, v3: usize, normal: Vector, colour: Colour) -> Face { Face { vertices: [v1, v2, v3], colour: colour, normal: normal, } } fn new() -> Face { Face { vertices: [0; 3], colour: Colour::Grey(1.0), normal: Vector::new(), } } }
//! Prelude for this crate, this contains a lot of useful exports pub use crate::Element as SVGElem; pub use crate::Point2D; pub use crate::attributes::Attribute as Attr; pub use crate::tag_name::TagName as Tag; pub use crate::path::PathDefinitionString as PathData; #[cfg(feature = "parsing")] pub use crate::parser::{parse_file as SVGParseFile, parse_text as SVGParseText};
use std::io; fn main() { let mut buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); let n: usize = buf.trim().parse().unwrap(); buf = String::new(); io::stdin().read_line(&mut buf).unwrap(); let mut iter = buf.split_whitespace(); let mut num_vec: Vec<i64> = Vec::new(); for _ in 0..n { let num: i64 = iter.next().unwrap().parse().unwrap(); num_vec.push(num); } let mut div2_count = 0; for num in &num_vec { let mut num = *num; while num % 2 == 0 { div2_count += 1; num /= 2; } } println!("{}", div2_count); }
#[allow(unused_variables)] pub fn hello_trait() { trait Summarizable { fn summary(&self) -> String; fn default_summary(&self) -> String { String::from("(read more...)") } } struct NewsArticle { headline: String, location: String, author: String, content: String, } impl Summarizable for NewsArticle { fn summary(&self) -> String { format!("{}, by {} ({})", self.headline, self.author, self.location) } } struct Tweet { username: String, content: String, replay: bool, re_tweet: bool, } impl Summarizable for Tweet { fn summary(&self) -> String { format!("{}: {} ", self.username, self.content) } } let tweet = Tweet { username: String::from("the book"), content: String::from("hello_rust"), replay: false, re_tweet: false, }; println!("1 new tweet : {}", tweet.summary()); println!("1 new tweet : {}", tweet.default_summary()); fn notify<T: Summarizable>(item: &T) { println!("breaking news! {}", item.summary()); } fn notify_simplify<T>(item: &T) where T: Summarizable, { println!("simplify news! {}", item.default_summary()); } let news = NewsArticle { headline: String::from("so funny"), location: String::from("turpan"), author: String::from("oatiz"), content: String::from("no content"), }; notify(&news); notify_simplify(&news); }
#[cfg(feature = "cli")] mod cli { #[cfg(not(feature = "std"))] compile_error!("`std` feature is required for cli"); use std::io::BufRead; use std::io::Write; use clap::Clap; #[derive(Clap, Copy, Clone)] #[clap(version = "1.0")] struct Opts { #[clap(short, long)] verify_uniqueness: bool, #[clap(short, long)] count_steps: bool, #[clap(subcommand)] mode: Mode, } #[derive(Clap, Copy, Clone)] enum Mode { Solve(Solve), Select(Select), Difficulty, CountSolutions(CountSolutions), #[cfg(feature = "generate")] Generate(Generate), ListTechniques, Info, } #[derive(Clap, Copy, Clone)] struct Solve { #[clap(short, long, default_value = "1")] count: usize, } #[derive(Clap, Copy, Clone)] struct Select { #[clap(short, long)] invert: bool, } #[derive(Clap, Copy, Clone)] struct CountSolutions { n: usize, } #[cfg(feature = "generate")] #[derive(Clap, Copy, Clone)] struct Generate { #[clap(subcommand)] mode: GenerateMode, #[clap(short, long)] display_score: bool, } #[cfg(feature = "generate")] #[derive(Clap, Copy, Clone)] enum GenerateMode { Once(GenerateOnce), Continuous(GenerateContinuous), } #[cfg(feature = "generate")] #[derive(Clap, Copy, Clone)] struct GenerateOnce { cells_to_remove: usize, } #[cfg(feature = "generate")] #[derive(Clap, Copy, Clone)] struct GenerateContinuous { #[clap(short, long)] n: Option<std::num::NonZeroUsize>, } fn score_sudoku(sudoku: &msolve::Sudoku, opts: &Opts) -> Option<i32> { sudoku.difficulty(opts.count_steps) } pub fn main() { let opts: Opts = Opts::parse(); let stdin = std::io::stdin(); let mut input = stdin.lock(); let mut buffer = String::with_capacity(82); let stdout = std::io::stdout(); let mut output_handle = stdout.lock(); let mut info = [0; 3]; #[cfg(feature = "rand")] let mut rng = rand::thread_rng(); #[cfg(feature = "generate")] if let Mode::Generate(generate) = opts.mode { if let GenerateMode::Continuous(continuous) = generate.mode { let n = continuous.n.map(|n| n.get()).unwrap_or(0); let mut counter = 0; for (sudoku, score) in msolve::Sudoku::generate(rand::thread_rng(), opts.count_steps) { if generate.display_score { let _ = output_handle.write_all(&score.to_string().as_bytes()); let _ = output_handle.write_all(b";"); } let _ = output_handle.write_all(&sudoku.to_bytes()); let _ = output_handle.write_all(b"\n"); if n != 0 { counter += 1; if counter >= n { return; } } } } } while let Ok(result) = input.read_line(&mut buffer) { if result == 0 { break; } let sudoku = buffer.parse::<msolve::Sudoku>().unwrap(); match opts.mode { Mode::Solve(solve) => { if opts.verify_uniqueness { if let Some(solution) = sudoku.solve_unique() { let _ = output_handle.write_all(&solution.to_bytes()); let _ = output_handle.write_all(b"\n"); } } else { for solution in sudoku.iter().take(solve.count) { let _ = output_handle.write_all(&solution.to_bytes()); let _ = output_handle.write_all(b"\n"); } } } Mode::Select(select) => { let mut does_match = if opts.verify_uniqueness { sudoku.has_single_solution() } else { sudoku.has_solution() }; if select.invert { does_match = !does_match; } if does_match { let _ = output_handle.write_all(&sudoku.to_bytes()); let _ = output_handle.write_all(b"\n"); } } Mode::Difficulty => { if let Some(difficulty) = score_sudoku(&sudoku, &opts) { let _ = output_handle.write_all(&difficulty.to_string().as_bytes()); let _ = output_handle.write_all(b";"); let _ = output_handle.write_all(&sudoku.to_bytes()); let _ = output_handle.write_all(b"\n"); } } Mode::CountSolutions(n) => { let count = sudoku.count_solutions(n.n); let _ = output_handle.write_all(&count.to_string().as_bytes()); let _ = output_handle.write_all(b";"); let _ = output_handle.write_all(&sudoku.to_bytes()); let _ = output_handle.write_all(b"\n"); } #[cfg(feature = "generate")] Mode::Generate(generate) => { if let GenerateMode::Once(once) = generate.mode { let (sudoku, score) = sudoku.generate_from_seed( &mut rng, once.cells_to_remove, opts.count_steps, ); if generate.display_score { let _ = output_handle.write_all(&score.to_string().as_bytes()); let _ = output_handle.write_all(b";"); } let _ = output_handle.write_all(&sudoku.to_bytes()); let _ = output_handle.write_all(b"\n"); } else { unimplemented!() } } Mode::ListTechniques => { for (explanation, state) in sudoku.list_techniques().iter() { let _ = output_handle.write_all(&explanation.as_bytes()); let _ = output_handle.write_all(b"\n"); let _ = output_handle.write_all(&state.to_pencilmark_bytes()); let _ = output_handle.write_all(b"\n"); std::thread::sleep(std::time::Duration::from_secs(1)); } } Mode::Info => { info[sudoku.count_solutions(2)] += 1; } } buffer.clear(); } if let Mode::Info = opts.mode { println!( "0 Solutions: {}, 1 Solution: {}, 2+ Solutions: {}", info[0], info[1], info[2] ); } } } fn main() { #[cfg(feature = "cli")] cli::main() }
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::collections::HashSet; use chrono::DateTime; use chrono::NaiveDate; use chrono::NaiveDateTime; use chrono::NaiveTime; use chrono::Utc; use common_meta_app as mt; use common_meta_app::principal::UserIdentity; use common_meta_app::principal::UserPrivilegeType; use common_meta_app::storage::StorageFsConfig; use common_meta_app::storage::StorageGcsConfig; use common_meta_app::storage::StorageOssConfig; use common_meta_app::storage::StorageParams; use common_meta_app::storage::StorageS3Config; use common_meta_app::storage::StorageWebhdfsConfig; use common_proto_conv::FromToProto; use common_proto_conv::Incompatible; use common_proto_conv::VER; use common_protos::pb; use enumflags2::make_bitflags; use pretty_assertions::assert_eq; use crate::common::print_err; fn test_user_info() -> mt::principal::UserInfo { let option = mt::principal::UserOption::default() .with_set_flag(mt::principal::UserOptionFlag::TenantSetting) .with_default_role(Some("role1".into())); mt::principal::UserInfo { name: "test_user".to_string(), hostname: "localhost".to_string(), auth_info: mt::principal::AuthInfo::Password { hash_value: [ 116, 101, 115, 116, 95, 112, 97, 115, 115, 119, 111, 114, 100, ] .to_vec(), hash_method: mt::principal::PasswordHashMethod::DoubleSha1, }, grants: mt::principal::UserGrantSet::new( vec![mt::principal::GrantEntry::new( mt::principal::GrantObject::Global, make_bitflags!(UserPrivilegeType::{Create}), )], HashSet::new(), ), quota: mt::principal::UserQuota { max_cpu: 10, max_memory_in_bytes: 10240, max_storage_in_bytes: 20480, }, option, } } pub(crate) fn test_fs_stage_info() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "fs://dir/to/files".to_string(), stage_type: mt::principal::StageType::LegacyInternal, stage_params: mt::principal::StageParams { storage: mt::storage::StorageParams::Fs(mt::storage::StorageFsConfig { root: "/dir/to/files".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "\\".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "row".to_string(), quote: "\'\'".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::AbortNum(2), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), number_of_files: 100, creator: Some(UserIdentity { username: "databend".to_string(), hostname: "databend.rs".to_string(), }), } } pub(crate) fn test_s3_stage_info() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "s3://mybucket/data/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::S3(StorageS3Config { bucket: "mybucket".to_string(), root: "/data/files".to_string(), access_key_id: "my_key_id".to_string(), secret_access_key: "my_secret_key".to_string(), security_token: "my_security_token".to_string(), master_key: "my_master_key".to_string(), ..Default::default() }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "row".to_string(), quote: "'".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } pub(crate) fn test_s3_stage_info_v16() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "s3://mybucket/data/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::S3(StorageS3Config { bucket: "mybucket".to_string(), root: "/data/files".to_string(), access_key_id: "my_key_id".to_string(), secret_access_key: "my_secret_key".to_string(), security_token: "my_security_token".to_string(), master_key: "my_master_key".to_string(), role_arn: "aws::iam::xxx".to_string(), external_id: "hello,world".to_string(), ..Default::default() }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 1024, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } pub(crate) fn test_s3_stage_info_v14() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "s3://mybucket/data/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::S3(StorageS3Config { bucket: "mybucket".to_string(), root: "/data/files".to_string(), access_key_id: "my_key_id".to_string(), secret_access_key: "my_secret_key".to_string(), security_token: "my_security_token".to_string(), master_key: "my_master_key".to_string(), role_arn: "aws::iam::xxx".to_string(), external_id: "hello,world".to_string(), ..Default::default() }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } // Version 4 added Google Cloud Storage as a stage backend, should be tested pub(crate) fn test_gcs_stage_info() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "gcs://my_bucket/data/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::Gcs(StorageGcsConfig { endpoint_url: "https://storage.googleapis.com".to_string(), bucket: "my_bucket".to_string(), root: "/data/files".to_string(), credential: "my_credential".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "row".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } // Version 13 added OSS as a stage backend, should be tested pub(crate) fn test_oss_stage_info() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "oss://my_bucket/data/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::Oss(StorageOssConfig { endpoint_url: "https://oss-cn-litang.example.com".to_string(), bucket: "my_bucket".to_string(), root: "/data/files".to_string(), access_key_id: "access_key_id".to_string(), access_key_secret: "access_key_secret".to_string(), presign_endpoint_url: "".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "row".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } // version 29 added WebHDFS as a stage backend, should be tested pub(crate) fn test_webhdfs_stage_info() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "webhdfs://path/to/stage/files".to_string(), stage_type: mt::principal::StageType::External, stage_params: mt::principal::StageParams { storage: StorageParams::Webhdfs(StorageWebhdfsConfig { endpoint_url: "https://webhdfs.example.com".to_string(), root: "/path/to/stage/files".to_string(), delegation: "<delegation_token>".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "row".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(3141), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } pub(crate) fn test_stage_file() -> mt::principal::StageFile { let dt = NaiveDateTime::new( NaiveDate::from_ymd_opt(2022, 9, 16).unwrap(), NaiveTime::from_hms_opt(0, 1, 2).unwrap(), ); let user_id = mt::principal::UserIdentity::new("datafuselabs", "datafuselabs.rs"); mt::principal::StageFile { path: "/path/to/stage".to_string(), size: 233, md5: None, last_modified: DateTime::from_utc(dt, Utc), creator: Some(user_id), etag: None, } } #[test] fn test_user_pb_from_to() -> anyhow::Result<()> { let test_user_info = test_user_info(); let test_user_info_pb = test_user_info.to_pb()?; let got = mt::principal::UserInfo::from_pb(test_user_info_pb)?; assert_eq!(got, test_user_info); Ok(()) } #[test] fn test_stage_file_pb_from_to() -> anyhow::Result<()> { let test_stage_file = test_stage_file(); let test_stage_file_pb = test_stage_file.to_pb()?; let got = mt::principal::StageFile::from_pb(test_stage_file_pb)?; assert_eq!(got, test_stage_file); Ok(()) } #[test] fn test_user_incompatible() -> anyhow::Result<()> { { let user_info = test_user_info(); let mut p = user_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::UserInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ); } { let stage_file = test_stage_file(); let mut p = stage_file.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageFile::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ) } { let fs_stage_info = test_fs_stage_info(); let mut p = fs_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ) } { let s3_stage_info = test_s3_stage_info(); let mut p = s3_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ); } { let s3_stage_info = test_s3_stage_info_v14(); let mut p = s3_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ); } { let gcs_stage_info = test_gcs_stage_info(); let mut p = gcs_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ); } { let oss_stage_info = test_oss_stage_info(); let mut p = oss_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ) } { let webhdfs_stage_info = test_webhdfs_stage_info(); let mut p = webhdfs_stage_info.to_pb()?; p.ver = VER + 1; p.min_reader_ver = VER + 1; let res = mt::principal::StageInfo::from_pb(p); assert_eq!( Incompatible { reason: format!( "executable ver={} is smaller than the min reader version({}) that can read this message", VER, VER + 1 ) }, res.unwrap_err() ) } Ok(()) } #[test] fn test_build_user_pb_buf() -> anyhow::Result<()> { // build serialized buf of protobuf data, for backward compatibility test with a new version binary. // UserInfo { let user_info = test_user_info(); let p = user_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("user_info: {:?}", buf); } // StageFile { let stage_file = test_stage_file(); let p = stage_file.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("stage_file: {:?}", buf); } // Stage on local file system { let fs_stage_info = test_fs_stage_info(); let p = fs_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("fs_stage_info: {:?}", buf); } // Stage on S3 { let s3_stage_info = test_s3_stage_info(); let p = s3_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("s3_stage_info: {:?}", buf); } // Stage on S3 v16 { let s3_stage_info = test_s3_stage_info_v16(); let p = s3_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("s3_stage_info_v16: {:?}", buf); } // Stage on S3 v14 { let s3_stage_info = test_s3_stage_info_v14(); let p = s3_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("s3_stage_info_v14: {:?}", buf); } // Stage on GCS, supported in version >=4. { let gcs_stage_info = test_gcs_stage_info(); let p = gcs_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("gcs_stage_info: {:?}", buf); } // Stage on OSS, supported in version >= 13. { let oss_stage_info = test_oss_stage_info(); let p = oss_stage_info.to_pb()?; let mut buf = vec![]; common_protos::prost::Message::encode(&p, &mut buf)?; println!("oss_stage_info: {:?}", buf); } Ok(()) } #[test] fn test_load_old_user() -> anyhow::Result<()> { // built with `test_build_user_pb_buf()` { // User information generated by test_build_user_pb_buf() let user_info_v4: Vec<u8> = vec![ 10, 9, 116, 101, 115, 116, 95, 117, 115, 101, 114, 18, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 26, 25, 18, 17, 10, 13, 116, 101, 115, 116, 95, 112, 97, 115, 115, 119, 111, 114, 100, 16, 1, 160, 6, 4, 168, 6, 1, 34, 26, 10, 18, 10, 8, 10, 0, 160, 6, 4, 168, 6, 1, 16, 2, 160, 6, 4, 168, 6, 1, 160, 6, 4, 168, 6, 1, 42, 15, 8, 10, 16, 128, 80, 24, 128, 160, 1, 160, 6, 4, 168, 6, 1, 50, 15, 8, 1, 18, 5, 114, 111, 108, 101, 49, 160, 6, 4, 168, 6, 1, 160, 6, 4, 168, 6, 1, ]; let p: pb::UserInfo = common_protos::prost::Message::decode(user_info_v4.as_slice()).map_err(print_err)?; let got = mt::principal::UserInfo::from_pb(p).map_err(print_err)?; let want = test_user_info(); assert_eq!(want, got); } // UserInfo is loadable { let user_info_v1: Vec<u8> = vec![ 10, 9, 116, 101, 115, 116, 95, 117, 115, 101, 114, 18, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 26, 22, 18, 17, 10, 13, 116, 101, 115, 116, 95, 112, 97, 115, 115, 119, 111, 114, 100, 16, 1, 160, 6, 1, 34, 17, 10, 12, 10, 5, 10, 0, 160, 6, 1, 16, 2, 160, 6, 1, 160, 6, 1, 42, 12, 8, 10, 16, 128, 80, 24, 128, 160, 1, 160, 6, 1, 50, 5, 8, 1, 160, 6, 1, 160, 6, 1, ]; let p: pb::UserInfo = common_protos::prost::Message::decode(user_info_v1.as_slice()).map_err(print_err)?; let got = mt::principal::UserInfo::from_pb(p).map_err(print_err)?; println!("got: {:?}", got); assert_eq!(got.name, "test_user".to_string()); assert_eq!(got.option.default_role().clone(), None); } { let user_info_v3: Vec<u8> = vec![ 10, 9, 116, 101, 115, 116, 95, 117, 115, 101, 114, 18, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 26, 25, 18, 17, 10, 13, 116, 101, 115, 116, 95, 112, 97, 115, 115, 119, 111, 114, 100, 16, 1, 160, 6, 3, 168, 6, 1, 34, 26, 10, 18, 10, 8, 10, 0, 160, 6, 3, 168, 6, 1, 16, 2, 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1, 42, 15, 8, 10, 16, 128, 80, 24, 128, 160, 1, 160, 6, 3, 168, 6, 1, 50, 15, 8, 1, 18, 5, 114, 111, 108, 101, 49, 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1, ]; let p: pb::UserInfo = common_protos::prost::Message::decode(user_info_v3.as_slice()).map_err(print_err)?; let got = mt::principal::UserInfo::from_pb(p).map_err(print_err)?; let want = test_user_info(); assert_eq!(want, got); } { // a legacy UserInfo with ConfigReload flag set, running on S3 service let user_info_v3: Vec<u8> = vec![ 10, 9, 116, 101, 115, 116, 95, 117, 115, 101, 114, 18, 9, 108, 111, 99, 97, 108, 104, 111, 115, 116, 26, 25, 18, 17, 10, 13, 116, 101, 115, 116, 95, 112, 97, 115, 115, 119, 111, 114, 100, 16, 1, 160, 6, 3, 168, 6, 1, 34, 26, 10, 18, 10, 8, 10, 0, 160, 6, 3, 168, 6, 1, 16, 2, 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1, 42, 15, 8, 10, 16, 128, 80, 24, 128, 160, 1, 160, 6, 3, 168, 6, 1, 50, 15, 8, 2, 18, 5, 114, 111, 108, 101, 49, 160, 6, 3, 168, 6, 1, 160, 6, 3, 168, 6, 1, ]; let p: pb::UserInfo = common_protos::prost::Message::decode(user_info_v3.as_slice()).map_err(print_err)?; let got = mt::principal::UserInfo::from_pb(p).map_err(print_err)?; assert!(got.option.flags().is_empty()); } Ok(()) } #[test] fn test_old_stage_file() -> anyhow::Result<()> { // Encoded data of version 7 of StageFile: // Generated with `test_build_user_pb_buf` { let stage_file_v7 = vec![ 10, 14, 47, 112, 97, 116, 104, 47, 116, 111, 47, 115, 116, 97, 103, 101, 16, 233, 1, 34, 23, 50, 48, 50, 50, 45, 48, 57, 45, 49, 54, 32, 48, 48, 58, 48, 49, 58, 48, 50, 32, 85, 84, 67, 42, 37, 10, 12, 100, 97, 116, 97, 102, 117, 115, 101, 108, 97, 98, 115, 18, 15, 100, 97, 116, 97, 102, 117, 115, 101, 108, 97, 98, 115, 46, 114, 115, 160, 6, 8, 168, 6, 1, 160, 6, 8, 168, 6, 1, ]; let p: pb::StageFile = common_protos::prost::Message::decode(stage_file_v7.as_slice()).map_err(print_err)?; let got = mt::principal::StageFile::from_pb(p).map_err(print_err)?; let dt = NaiveDateTime::new( NaiveDate::from_ymd_opt(2022, 9, 16).unwrap(), NaiveTime::from_hms_opt(0, 1, 2).unwrap(), ); let user_id = mt::principal::UserIdentity::new("datafuselabs", "datafuselabs.rs"); let want = mt::principal::StageFile { path: "/path/to/stage".to_string(), size: 233, md5: None, last_modified: DateTime::from_utc(dt, Utc), creator: Some(user_id), ..Default::default() }; assert_eq!(got, want); } Ok(()) } pub(crate) fn test_internal_stage_info_v17() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "fs://dir/to/files".to_string(), stage_type: mt::principal::StageType::Internal, stage_params: mt::principal::StageParams { storage: StorageParams::Fs(StorageFsConfig { root: "/dir/to/files".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } } pub(crate) fn test_stage_info_v18() -> mt::principal::StageInfo { mt::principal::StageInfo { stage_name: "root".to_string(), stage_type: mt::principal::StageType::User, stage_params: mt::principal::StageParams { storage: StorageParams::Fs(StorageFsConfig { root: "/dir/to/files".to_string(), }), }, file_format_options: mt::principal::FileFormatOptions { format: mt::principal::StageFileFormatType::Json, skip_header: 1024, field_delimiter: "|".to_string(), record_delimiter: "//".to_string(), nan_display: "NaN".to_string(), escape: "".to_string(), compression: mt::principal::StageFileCompression::Bz2, row_tag: "".to_string(), quote: "".to_string(), name: None, }, copy_options: mt::principal::CopyOptions { on_error: mt::principal::OnErrorMode::SkipFileNum(666), size_limit: 1038, split_size: 0, purge: true, single: false, max_file_size: 0, }, comment: "test".to_string(), ..Default::default() } }
//! Incremental solving. use partial_ref::{partial, PartialRef}; use varisat_formula::Lit; use varisat_internal_proof::{clause_hash, lit_hash, ClauseHash, ProofStep}; use crate::{ context::{parts::*, Context}, proof, prop::{enqueue_assignment, full_restart, Reason}, state::SatState, variables, }; /// Incremental solving. #[derive(Default)] pub struct Assumptions { assumptions: Vec<Lit>, failed_core: Vec<Lit>, user_failed_core: Vec<Lit>, assumption_levels: usize, failed_propagation_hashes: Vec<ClauseHash>, } impl Assumptions { /// Current number of decision levels used for assumptions. pub fn assumption_levels(&self) -> usize { self.assumption_levels } /// Resets assumption_levels to zero on a full restart. pub fn full_restart(&mut self) { self.assumption_levels = 0; } /// Subset of assumptions that made the formula unsatisfiable. pub fn failed_core(&self) -> &[Lit] { &self.failed_core } /// Subset of assumptions that made the formula unsatisfiable. pub fn user_failed_core(&self) -> &[Lit] { &self.user_failed_core } /// Current assumptions. pub fn assumptions(&self) -> &[Lit] { &self.assumptions } } /// Return type of [`enqueue_assumption`]. pub enum EnqueueAssumption { Done, Enqueued, Conflict, } /// Change the currently active assumptions. /// /// The input uses user variable names. pub fn set_assumptions<'a>( mut ctx: partial!( Context<'a>, mut AnalyzeConflictP, mut AssignmentP, mut AssumptionsP, mut BinaryClausesP, mut ImplGraphP, mut ProofP<'a>, mut SolverStateP, mut TmpFlagsP, mut TrailP, mut VariablesP, mut VsidsP, mut WatchlistsP, ), user_assumptions: &[Lit], ) { full_restart(ctx.borrow()); let state = ctx.part_mut(SolverStateP); state.sat_state = match state.sat_state { SatState::Unsat => SatState::Unsat, SatState::Sat | SatState::UnsatUnderAssumptions | SatState::Unknown => SatState::Unknown, }; let (assumptions, mut ctx_2) = ctx.split_part_mut(AssumptionsP); for lit in assumptions.assumptions.iter() { ctx_2 .part_mut(VariablesP) .var_data_solver_mut(lit.var()) .assumed = false; } variables::solver_from_user_lits( ctx_2.borrow(), &mut assumptions.assumptions, user_assumptions, true, ); for lit in assumptions.assumptions.iter() { ctx_2 .part_mut(VariablesP) .var_data_solver_mut(lit.var()) .assumed = true; } proof::add_step( ctx_2.borrow(), true, &ProofStep::Assumptions { assumptions: &assumptions.assumptions, }, ); } /// Enqueue another assumption if possible. /// /// Returns whether an assumption was enqueued, whether no assumptions are left or whether the /// assumptions result in a conflict. pub fn enqueue_assumption<'a>( mut ctx: partial!( Context<'a>, mut AssignmentP, mut AssumptionsP, mut ImplGraphP, mut ProofP<'a>, mut SolverStateP, mut TmpFlagsP, mut TrailP, ClauseAllocP, VariablesP, ), ) -> EnqueueAssumption { while let Some(&assumption) = ctx .part(AssumptionsP) .assumptions .get(ctx.part(TrailP).current_level()) { match ctx.part(AssignmentP).lit_value(assumption) { Some(false) => { analyze_assumption_conflict(ctx.borrow(), assumption); return EnqueueAssumption::Conflict; } Some(true) => { // The next assumption is already implied by other assumptions so we can remove it. let level = ctx.part(TrailP).current_level(); let assumptions = ctx.part_mut(AssumptionsP); assumptions.assumptions.swap_remove(level); } None => { ctx.part_mut(TrailP).new_decision_level(); enqueue_assignment(ctx.borrow(), assumption, Reason::Unit); let (assumptions, ctx) = ctx.split_part_mut(AssumptionsP); assumptions.assumption_levels = ctx.part(TrailP).current_level(); return EnqueueAssumption::Enqueued; } } } EnqueueAssumption::Done } /// Analyze a conflicting set of assumptions. /// /// Compute a set of incompatible assumptions given an assumption that is incompatible with the /// assumptions enqueued so far. fn analyze_assumption_conflict<'a>( mut ctx: partial!( Context<'a>, mut AssumptionsP, mut ProofP<'a>, mut SolverStateP, mut TmpFlagsP, ClauseAllocP, ImplGraphP, TrailP, VariablesP, ), assumption: Lit, ) { let (assumptions, mut ctx) = ctx.split_part_mut(AssumptionsP); let (tmp, mut ctx) = ctx.split_part_mut(TmpFlagsP); let (trail, mut ctx) = ctx.split_part(TrailP); let (impl_graph, mut ctx) = ctx.split_part(ImplGraphP); let flags = &mut tmp.flags; assumptions.failed_core.clear(); assumptions.failed_core.push(assumption); assumptions.failed_propagation_hashes.clear(); flags[assumption.index()] = true; let mut flag_count = 1; for &lit in trail.trail().iter().rev() { if flags[lit.index()] { flags[lit.index()] = false; flag_count -= 1; match impl_graph.reason(lit.var()) { Reason::Unit => { if impl_graph.level(lit.var()) > 0 { assumptions.failed_core.push(lit); } } reason => { let (ctx_lits, ctx) = ctx.split_borrow(); let reason_lits = reason.lits(&ctx_lits); if ctx.part(ProofP).clause_hashes_required() { let hash = clause_hash(reason_lits) ^ lit_hash(lit); assumptions.failed_propagation_hashes.push(hash); } for &reason_lit in reason_lits { if !flags[reason_lit.index()] { flags[reason_lit.index()] = true; flag_count += 1; } } } } if flag_count == 0 { break; } } } assumptions.failed_propagation_hashes.reverse(); assumptions.user_failed_core.clear(); assumptions .user_failed_core .extend(assumptions.failed_core.iter().map(|solver_lit| { solver_lit .map_var(|solver_var| ctx.part(VariablesP).existing_user_from_solver(solver_var)) })); proof::add_step( ctx.borrow(), true, &ProofStep::FailedAssumptions { failed_core: &assumptions.failed_core, propagation_hashes: &assumptions.failed_propagation_hashes, }, ); } #[cfg(test)] mod tests { use super::*; use proptest::{bool, prelude::*}; use partial_ref::IntoPartialRefMut; use varisat_formula::{test::conditional_pigeon_hole, ExtendFormula, Var}; use crate::{cdcl::conflict_step, load::load_clause, solver::Solver, state::SatState}; proptest! { #[test] fn pigeon_hole_unsat_assumption_core_internal( (enable_row, columns, formula) in conditional_pigeon_hole(1..5usize, 1..5usize), chain in bool::ANY, ) { let mut ctx = Context::default(); let mut ctx = ctx.into_partial_ref_mut(); for clause in formula.iter() { load_clause(ctx.borrow(), clause); } if chain { for (&a, &b) in enable_row.iter().zip(enable_row.iter().skip(1)) { load_clause(ctx.borrow(), &[!a, b]); } } while ctx.part(SolverStateP).sat_state == SatState::Unknown { conflict_step(ctx.borrow()); } prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::Sat); set_assumptions(ctx.borrow(), &enable_row); prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::Unknown); while ctx.part(SolverStateP).sat_state == SatState::Unknown { conflict_step(ctx.borrow()); } prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::UnsatUnderAssumptions); let mut candidates = ctx.part(AssumptionsP).user_failed_core().to_owned(); let mut core: Vec<Lit> = vec![]; loop { set_assumptions(ctx.borrow(), &candidates[0..candidates.len() - 1]); while ctx.part(SolverStateP).sat_state == SatState::Unknown { conflict_step(ctx.borrow()); } match ctx.part(SolverStateP).sat_state { SatState::Unknown => unreachable!(), SatState::Unsat => break, SatState::Sat => { let skipped = *candidates.last().unwrap(); core.push(skipped); load_clause(ctx.borrow(), &[skipped]); }, SatState::UnsatUnderAssumptions => { candidates = ctx.part(AssumptionsP).user_failed_core().to_owned(); } } } if chain { prop_assert_eq!(core.len(), 1); } else { prop_assert_eq!(core.len(), columns + 1); } } #[test] fn pigeon_hole_unsat_assumption_core_solver( (enable_row, columns, formula) in conditional_pigeon_hole(1..5usize, 1..5usize), ) { let mut solver = Solver::new(); solver.add_formula(&formula); prop_assert_eq!(solver.solve().ok(), Some(true)); let mut assumptions = enable_row; assumptions.push(Lit::positive(Var::from_index(formula.var_count() + 10))); solver.assume(&assumptions); prop_assert_eq!(solver.solve().ok(), Some(false)); let mut candidates = solver.failed_core().unwrap().to_owned(); let mut core: Vec<Lit> = vec![]; while !candidates.is_empty() { solver.assume(&candidates[0..candidates.len() - 1]); match solver.solve() { Err(_) => unreachable!(), Ok(true) => { let skipped = *candidates.last().unwrap(); core.push(skipped); solver.add_clause(&[skipped]); solver.hide_var(skipped.var()); }, Ok(false) => { candidates = solver.failed_core().unwrap().to_owned(); } } } prop_assert_eq!(core.len(), columns + 1); } } }
use rand::prelude::*; use rand_chacha::ChaChaRng; use snapcd::file::{put_data, read_data}; use snapcd::{ds::sqlite::SqliteDS, DataStore}; use std::collections::HashSet; fn internal_test<T: DataStore, F: FnMut() -> T>( ctor: &mut F, size_upper_bound: usize, seed_lower_bound: u64, seed_upper_bound: u64, ) { for i in seed_lower_bound..seed_upper_bound { let mut rng = ChaChaRng::seed_from_u64(i); let mut data = ctor(); let mut test_vector = Vec::new(); test_vector.resize(rng.gen_range(1, size_upper_bound), 0); rng.fill(&mut test_vector[..]); let hash = put_data(&mut data, &test_vector[..]).unwrap(); let mut to = Vec::new(); read_data(&data, hash, &mut to).unwrap(); if to != test_vector { dbg!(to.len(), test_vector.len()); panic!("failed at seed {}", i); } } } #[test] fn sanity_check() { let mut sqlite_ds = || SqliteDS::new(":memory:").unwrap(); internal_test(&mut sqlite_ds, 1 << 20, 0, 8); internal_test(&mut sqlite_ds, 1 << 14, 8, 64); internal_test(&mut sqlite_ds, 1 << 10, 64, 128); } proptest::proptest! { #[test] fn identity_read_write(value: Vec<u8>) { let mut ds = SqliteDS::new(":memory:").unwrap(); let key = put_data(&mut ds, &value[..]).unwrap(); let mut to = Vec::new(); read_data(&ds, key, &mut to).unwrap(); assert_eq!(value, to); } #[test] fn between_test(mut keys: HashSet<Vec<u8>>, start: Vec<u8>, end: Option<Vec<u8>>) { let ds = SqliteDS::new(":memory:").unwrap(); keys.retain(|x| x.len() > 0); for key in &keys { ds.raw_put(key, key).expect("failed to put key"); } let expected_keys: HashSet<Vec<u8>> = if let Some(e) = &end { keys.iter().filter(|x| (&start..&e).contains(x)).cloned().collect() } else { keys.iter().filter(|x| (&start..).contains(x)).cloned().collect() }; let got_keys = ds.raw_between(&start, end.as_deref()).expect("failed to get keys between").into_iter().collect(); assert_eq!(expected_keys, got_keys); } }
// --------------------------------------- // Dreamspell server // --------------------------------------- use axum::{ extract::State, http::{ header::{AUTHORIZATION, CONTENT_TYPE}, Method, StatusCode, }, response::IntoResponse, routing::{get, post}, Json, Router, }; use axum_auth::AuthBearer; use serde::Deserialize; use std::{env, fs, net::SocketAddr, sync::Arc}; use tower_http::cors::{Any, CorsLayer}; use tzolkin::{Seals, Tzolkin}; pub mod tables; pub mod tzolkin; const SEALS: &str = "resources/seals.json"; const SEALS_EN: &str = "resources/seals_en.json"; #[derive(Deserialize)] struct Input { birth_date: String, } struct DreamspellState { secret: String, seals: Seals, seals_en: Seals, } #[tokio::main] async fn main() { let secret = env::var("SECRET").expect("SECRET must be set"); let seals = { let seals = fs::read_to_string(SEALS).expect("Can't find seals file"); serde_json::from_str::<Seals>(&seals).expect("Can't parse seals file") }; let seals_en = { let seals = fs::read_to_string(SEALS_EN).expect("Can't find seals en file"); serde_json::from_str::<Seals>(&seals).expect("Can't parse seals en file") }; let state = Arc::new(DreamspellState { secret, seals, seals_en, }); let dreamspell = Router::new() .route("/", get(home)) .route("/tzolkin", post(tzolkin)) .route("/tzolkin_en", post(tzolkin_en)) .layer( CorsLayer::new() .allow_headers([AUTHORIZATION, CONTENT_TYPE]) .allow_methods([Method::POST]) .allow_origin(Any), ) .with_state(state) .fallback(nothing); let addr = SocketAddr::from(([127, 0, 0, 1], 8888)); println!("Listening on {}", addr); axum::Server::bind(&addr) .serve(dreamspell.into_make_service()) .await .unwrap(); } async fn home() -> impl IntoResponse { (StatusCode::OK, "Welcome to Dreamspell!") } async fn tzolkin( AuthBearer(token): AuthBearer, State(state): State<Arc<DreamspellState>>, Json(input): Json<Input>, ) -> impl IntoResponse { if !token.eq(&state.secret) { (StatusCode::UNAUTHORIZED, Json(Tzolkin::empty())) } else { ( StatusCode::OK, Json(Tzolkin::new( &state.seals, false, &input .birth_date .split('-') .map(|s| s.parse::<u32>().unwrap_or(0)) .collect::<Vec<u32>>() .try_into() .unwrap_or([0; 3]), )), ) } } async fn tzolkin_en( AuthBearer(token): AuthBearer, State(state): State<Arc<DreamspellState>>, Json(input): Json<Input>, ) -> impl IntoResponse { if !token.eq(&state.secret) { (StatusCode::UNAUTHORIZED, Json(Tzolkin::empty())) } else { ( StatusCode::OK, Json(Tzolkin::new( &state.seals_en, true, &input .birth_date .split('-') .map(|s| s.parse::<u32>().unwrap_or(0)) .collect::<Vec<u32>>() .try_into() .unwrap_or([0; 3]), )), ) } } async fn nothing() -> impl IntoResponse { (StatusCode::NOT_FOUND, "Nothing to see here") }
use std::sync::atomic::{self, AtomicUsize}; use std::collections::HashMap; use crate::types::*; use crate::user::User; use crate::pensioner::Pensioner; use crate::calculations::*; static USER_COUNTER: AtomicUsize = atomic::ATOMIC_USIZE_INIT; pub struct Contributor { id: usize, wallet: Unit, pub contributions: HashMap<Period, Unit>, pub dpts: HashMap<Period, Dpt>, } impl Contributor { pub fn new() -> Self { Contributor { id: USER_COUNTER.fetch_add(1, atomic::Ordering::SeqCst), wallet: 10000000.0, contributions: HashMap::new(), dpts: HashMap::new(), } } pub fn id(&self) -> usize { self.id } pub fn wallet(&self) -> Unit { self.wallet } pub fn contribute(&mut self, contribution: Unit, period: Period) -> Result<(), String> { if contribution <= 0.0 { return Err("contribution must be bigger than 0".to_string()); } if contribution > self.wallet { return Err("contribution to bigger than wallet".to_string()); } if self.contributions.len() > 480 { return Err("contribution can only be done for 480 periods".to_string()); } match self.contributions.get_mut(&period) { Some(contributions) => *contributions += contribution, None => { self.contributions.insert(period, contribution); () } } self.wallet -= contribution; Ok(()) } pub fn claim_dpt(&mut self, dpt: Dpt, period: Period) -> Result<(), String> { if self.dpts.contains_key(&period) { return Err(format!("dpt already claimed for period {}", period)); } self.dpts.insert(period, dpt); Ok(()) } pub fn retire(self) -> User { User::Pensioner(Pensioner::new(self)) } pub fn contribution_periods(&self) -> u64 { self.contributions.len() as u64 } pub fn has_retire_months(&self) -> bool { self.allowed_pension_periods() >= 1 } pub fn allowed_pension_periods(&self) -> u64 { let periods = self.contribution_periods(); calculate_entitlement_months(periods) } pub fn dpt_total(&self) -> Dpt { self.dpts.values().map(|dpt| dpt).sum() } } #[cfg(test)] mod tests { use crate::*; use crate::contributor::Contributor; #[test] fn contribute_contribution_must_be_bigger_than_0() { let mut contributor = Contributor::new(); assert!(contributor.contribute(0.0,1).is_err()); assert!(contributor.contribute(-1.0, 1).is_err()) } #[test] fn contribute_contribution_bigger_than_wallet() { let mut contributor = Contributor::new(); assert!(contributor.contribute(10000001.0,1).is_err()); } #[test] fn contribute_max_period() { let mut contributor = Contributor::new(); for periond in 1..481 { contributor.contribute(1.0, periond).unwrap(); } assert_eq!(contributor.contributions.len(), 480); contributor.contribute(1.0, 481).unwrap(); assert!(contributor.contribute(1.0,482).is_err()); } #[test] fn contribute_contribution_done() { let mut contributor = Contributor::new(); for periond in 1..481 { contributor.contribute(1.0, periond).unwrap(); } assert_eq!(contributor.wallet(), 9999520.0); } #[test] fn claim_dpt_dpt_already_claimed_for_period(){ let mut contributor = Contributor::new(); contributor.dpts.insert(1, 1.0); assert!(contributor.claim_dpt(1.0, 1).is_err()); } #[test] fn claim_dpt_done(){ let mut contributor = Contributor::new(); contributor.dpts.insert(1, 1.0); assert_eq!(contributor.dpts.len(), 1); } #[test] fn dpt_total(){ let mut contributor = Contributor::new(); for periond in 1..481 { contributor.dpts.insert(periond, 1.0); } assert_eq!(contributor.dpt_total(), 480.0); } }
// Copyright 2018 The Rust Project Developers. See the COPYRIGHT // file at the top-level directory of this distribution and at // http://rust-lang.org/COPYRIGHT. // // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your // option. This file may not be copied, modified, or distributed // except according to those terms. // compile-flags: -Z borrowck=compare const ALL_THE_NUMS: [u32; 1] = [ 1 ]; #[inline(never)] fn array(i: usize) -> &'static u32 { return &ALL_THE_NUMS[i]; } #[inline(never)] fn tuple_field() -> &'static u32 { &(42,).0 } fn main() { assert_eq!(tuple_field().to_string(), "42"); assert_eq!(array(0).to_string(), "1"); }
mod util; extern crate rcgen; use rcgen::{RcgenError, KeyPair, Certificate}; #[test] fn test_key_params_mismatch() { let available_key_params = [ &rcgen::PKCS_RSA_SHA256, &rcgen::PKCS_ECDSA_P256_SHA256, &rcgen::PKCS_ECDSA_P384_SHA384, &rcgen::PKCS_ED25519, ]; for (i, kalg_1) in available_key_params.iter().enumerate() { for (j, kalg_2) in available_key_params.iter().enumerate() { if i == j { continue; } let mut wrong_params = util::default_params(); if i != 0 { wrong_params.key_pair = Some(KeyPair::generate(kalg_1).unwrap()); } else { let kp = KeyPair::from_pem(util::RSA_TEST_KEY_PAIR_PEM).unwrap(); wrong_params.key_pair = Some(kp); } wrong_params.alg = *kalg_2; assert_eq!( Certificate::from_params(wrong_params).err(), Some(RcgenError::CertificateKeyPairMismatch), "i: {} j: {}", i, j); } } }
use crate::ast; use crate::{Spanned, ToTokens}; use runestick::Span; /// Helper to force an expression to have a specific semi-colon policy. #[derive(Debug, Clone, PartialEq, Eq)] pub struct ForceSemi { /// The span of the whole wrapping expression. pub span: Span, /// Whether or not the expressions needs a semi. pub needs_semi: bool, /// The expression to override the policy for. pub expr: ast::Expr, } impl Spanned for ForceSemi { fn span(&self) -> Span { self.span } } impl ToTokens for ForceSemi { fn to_tokens(&self, context: &crate::MacroContext, stream: &mut crate::TokenStream) { self.expr.to_tokens(context, stream) } }
use proconio::input; #[allow(unused_imports)] use proconio::marker::*; #[allow(unused_imports)] use std::cmp::*; #[allow(unused_imports)] use std::collections::*; #[allow(unused_imports)] use std::f64::consts::*; #[allow(unused)] const INF: usize = std::usize::MAX / 4; #[allow(unused)] const M: usize = 1000000007; fn main() { input! { x: usize, y: usize, a: usize, b: usize, c: usize, mut p: [usize; a], mut q: [usize; b], mut r: [usize; c], } p.sort(); p.reverse(); q.sort(); q.reverse(); r.sort(); r.reverse(); p.push(0); q.push(0); r.push(0); let mut i = 0; let mut j = 0; let mut k = 0; let mut d = 0; let mut e = 0; let mut result = 0; for _ in 0..x + y { if d < x && ((p[i] >= q[j] && p[i] >= r[k]) || (e == y && p[i] >= r[k])) { // eprintln!("p"); result += p[i]; d += 1; i += 1; } else if e < y && ((q[j] >= p[i] && q[j] >= r[k]) || (d == x && q[j] >= r[k])) { // eprintln!("q"); result += q[j]; e += 1; j += 1; } else { // eprintln!("r"); result += r[k]; k += 1; } } println!("{}", result); }
fn main() { let args: Vec<String> = env::args().collect(); match args.len() { 2 => search_by_title(args[1]), 3 => search_by_title_and_year(args[1], args[2]), _ => invalid_input() } } fn search_by_title(title: &str) { } fn search_by_title_and_year(title: &str, year: &str) { } fn invalid_input() { } fn print_help() { }
use crate::{FunctionData, Instruction, Value, ConstType, BinaryOp, Map, Type}; #[derive(Clone)] struct Chain { value: Value, consts: Vec<u64>, ty: ConstType, op: BinaryOp, } pub struct SimplifyExpressionsPass; impl super::Pass for SimplifyExpressionsPass { fn name(&self) -> &str { "expression simplification" } fn time(&self) -> crate::timing::TimedBlock { crate::timing::simplify_expressions() } fn run_on_function(&self, function: &mut FunctionData) -> bool { let labels = function.reachable_labels(); let mut did_something = false; let mut chains: Map<Value, Chain> = Map::default(); let mut consts = function.constant_values_with_labels(&labels); let creators = function.value_creators_with_labels(&labels); // Chain commulative operations with at least two constant operands. // (a + 1) + 1 // // Gets optimized to: // a + 2 // // TODO: Make a tree-based expression simplifier. // Evaluate chain of (a op (C1 op (C2 op C3))) to (a op C). macro_rules! evaluate_chain { ($chain: expr, $type: ty) => {{ let chain: &Chain = $chain; // Current partial value of right hand side expression. There must be // at least one constant there. let mut current = chain.consts[0] as $type; // Calculate whole value of right hand side expression. for &constant in &chain.consts[1..] { let constant = constant as $type; let a = current; let b = constant; let result = match chain.op { BinaryOp::Add => a.wrapping_add(b), BinaryOp::Mul => a.wrapping_mul(b), BinaryOp::And => a & b, BinaryOp::Or => a | b, BinaryOp::Xor => a ^ b, _ => unreachable!(), }; current = result; } current as u64 }} } { time!(build_expression_chains); function.for_each_instruction_with_labels(&labels, |_, instruction| { // We only simplify binary expressions for now. if let Instruction::ArithmeticBinary { dst, a, op, b } = instruction { // If operator is associative then (a op b) op c == a op (a b). // We cannot chain non-associative operations. if !op.is_associative() { return; } // Get 1 unknown value, 1 constant value and return type. let result = match (consts.get(a), consts.get(b)) { (Some(&a), None) => Some((*b, a.1, ConstType::new(a.0))), (None, Some(&b)) => Some((*a, b.1, ConstType::new(b.0))), _ => None, }; // If there are 2 constant values or 2 unknown values we can't do anything. if let Some((value, constant, ty)) = result { let chain = match chains.get(&value) { Some(chain) => { // This is next part of previously calculated chain. // We cannot chain both operations if they have different // binary operator. if chain.op != *op { None } else { // Join current operation and previous chain into one. let mut chain = chain.clone(); chain.consts.push(constant); Some(chain) } } None => { // Beginning of the chain, with one value and one constant. Some(Chain { value, consts: vec![constant], op: *op, ty, }) } }; if let Some(chain) = chain { // This value has a valid expression chain, add it to the list. assert!(chains.insert(*dst, chain).is_none(), "Multiple chains from the same value?"); } } } }); } // Evaluate all chain and replace instructions. for (output_value, chain) in &chains { // We don't gain anything from simplifying already simple chains. if chain.consts.len() <= 1 { continue; } // Evaluate right hand side of the chain. It must be integer value. let (chain_value, ir_type) = match chain.ty { ConstType::U1 => unreachable!(), ConstType::U8 => (evaluate_chain!(&chain, u8), Type::U8), ConstType::U16 => (evaluate_chain!(&chain, u16), Type::U16), ConstType::U32 => (evaluate_chain!(&chain, u32), Type::U32), ConstType::U64 => (evaluate_chain!(&chain, u64), Type::U64), }; // Create instruction which will calculate simplified expression. let constant = function.add_constant(ir_type, chain_value); let simplified = Instruction::ArithmeticBinary { dst: *output_value, a: chain.value, op: chain.op, b: constant, }; // Add new constant to the list. consts.insert(constant, (ir_type, chain_value)); // Get the block which created expression which we are going to simplify. let creator = creators[&output_value]; let body = function.blocks.get_mut(&creator.label()).unwrap(); // Replace old expression with new one. body[creator.index()] = simplified; did_something = true; } did_something } }
use crate::gpu::GPU; pub const SRAM_SIZE: usize = 0x2000; pub const VRAM_SIZE: usize = 0x2000; pub const BOOT_ROM: usize = 0x0100; pub const BANK_ZERO: usize = 0x3FFF - 0x0000 + 1; pub const BANK_N: usize = 0x7FFF - 0x4000 + 1; pub const HIGH_RAM: usize = 0xFFFF - 0xFF80 + 1; pub const IO_REG: usize = 0xFF7F - 0xFF00 + 1; pub const CART_RAM: usize = 0xBFFF - 0xA000 + 1; pub struct MMU { boot: [u8; BOOT_ROM], sram: [u8; SRAM_SIZE], hram: [u8; HIGH_RAM], rom0: [u8; BANK_ZERO], romn: [u8; BANK_N], cram: [u8; CART_RAM], pub gpu: GPU, } impl MMU { pub fn new() -> Self { MMU { boot: *include_bytes!("../ROMS/DMG_ROM.bin"), sram: [0; SRAM_SIZE], hram: [0; HIGH_RAM], rom0: [0; BANK_ZERO], romn: [0; BANK_N], cram: [0; CART_RAM], gpu: GPU::new(), } } pub fn read_rom(&mut self, rom: Vec<u8>) { let mut i: u16 = 0x0000; for &byte in rom.iter() { self.write_memory(i, byte); i += 1; } } pub fn read_memory(&self, address: u16) -> u8 { match address { 0x0000..=0x3FFF => { if address < 0x0100 && self.gpu.read_ior(0xFF50) == 0 { self.boot[address as usize] } else { self.rom0[address as usize] } }, 0x4000..=0x7FFF => self.romn[address as usize - 0x4000], 0x8000..=0x9FFF => self.gpu.read_vram(address as usize), 0xA000..=0xBFFF => self.cram[address as usize - 0xA000], 0xC000..=0xDFFF => self.sram[address as usize - 0xC000], 0xE000..=0xFDFF => 0, // ECHO RAM 0xFE00..=0xFE9F => self.gpu.read_oam(address as usize), 0xFEA0..=0xFEFF => 0, // UNUSED 0xFF00..=0xFF7F => self.gpu.read_ior(address as usize), 0xFF80..=0xFFFF => self.hram[address as usize - 0xFF80], _ => panic!("Unrecognized address in MMU: {:#X}", address), } } pub fn write_memory(&mut self, address: u16, value: u8) { match address { 0x0000..=0x3FFF => self.rom0[address as usize] = value, 0x4000..=0x7FFF => self.romn[address as usize - 0x4000] = value, 0x8000..=0x9FFF => self.gpu.write_vram(address as usize, value), 0xA000..=0xBFFF => self.cram[address as usize - 0xA000] = value, 0xC000..=0xDFFF => self.sram[address as usize - 0xC000] = value, 0xE000..=0xFDFF => {}, // ECHO RAM 0xFE00..=0xFE9F => self.gpu.write_oam(address as usize, value), 0xFEA0..=0xFEFF => {}, // UNUSED 0xFF00..=0xFF7F => self.gpu.write_ior(address as usize, value), 0xFF80..=0xFFFF => self.hram[address as usize - 0xFF80] = value, _ => panic!("Unrecognized address in MMU: {:#X}", address), } } }
use petgraph::graph::NodeIndex; use super::super::{LayoutTree, TreeError}; use super::super::commands::CommandResult; use super::super::core::container::{Container, ContainerType}; /// The mode the borders can be in. This affects the color primarily. pub enum Mode { /// Borders are active, this means they are focused. Active, /// Borders are inactive, this means they are not focused. Inactive } impl LayoutTree { /// Sets the borders for the given node to active. /// Automatically sets the borders for the ancestor borders as well. pub fn set_borders(&mut self, mut node_ix: NodeIndex, focus: Mode) -> CommandResult { match self.tree[node_ix] { Container::Root(id) | Container::Output {id, .. } | Container::Workspace {id, .. } => return Err( TreeError::UuidWrongType(id, vec![ContainerType::View, ContainerType::Container])), _ => {} } while self.tree[node_ix].get_type() != ContainerType::Workspace { match focus { Mode::Active => if !self.tree.on_path(node_ix) { break }, Mode::Inactive => if self.tree.on_path(node_ix) { break } } { let container = &mut self.tree[node_ix]; match focus { Mode::Active => container.active_border_color()?, Mode::Inactive => container.clear_border_color()? } container.draw_borders()?; } node_ix = self.tree.parent_of(node_ix)?; } Ok(()) } }
fn main() { let mut sum: i64 = 0; let n: i64 = 1000000000; println!("n: {}", n); for i in 0..n { sum = sum + i; } println!("sum = {}", sum); }
// This file contains the raw stuff to libcmaes use libc::{c_double, c_int, c_void}; #[link(name = "rcmaesglue", kind = "static")] #[link(name = "cmaes")] extern "C" { pub fn cmaes_optimize( noisy: c_int, use_elitism: c_int, use_surrogates: c_int, algo: c_int, initial: *mut c_double, sigma: c_double, lambda: c_int, num_coords: u64, evaluate: extern "C" fn( *const c_double, *const c_int, *const c_void, *mut c_int, ) -> c_double, iterator: extern "C" fn(*const c_void) -> (), userdata: *const c_void, ); pub fn const_CMAES_DEFAULT() -> c_int; pub fn const_IPOP_CMAES() -> c_int; pub fn const_BIPOP_CMAES() -> c_int; pub fn const_aCMAES() -> c_int; pub fn const_aIPOP_CMAES() -> c_int; pub fn const_aBIPOP_CMAES() -> c_int; pub fn const_sepCMAES() -> c_int; pub fn const_sepIPOP_CMAES() -> c_int; pub fn const_sepBIPOP_CMAES() -> c_int; pub fn const_sepaCMAES() -> c_int; pub fn const_sepaIPOP_CMAES() -> c_int; pub fn const_sepaBIPOP_CMAES() -> c_int; pub fn const_VD_CMAES() -> c_int; pub fn const_VD_IPOP_CMAES() -> c_int; pub fn const_VD_BIPOP_CMAES() -> c_int; }
#![deny(missing_docs)] //! A non-empty vector with a cursor. #[cfg(feature = "use_serde")] extern crate serde; #[cfg(feature = "use_serde")] #[macro_use] extern crate serde_derive; #[cfg(feature = "use_serde")] #[cfg(test)] extern crate serde_json; use std::error; use std::fmt; #[cfg(feature = "use_serde")] use serde::de; #[cfg(feature = "use_serde")] use serde::{Deserialize, Deserializer}; /// A non-empty vector with a cursor. NO operations panic. #[derive(Clone, Eq, PartialEq, Debug)] #[cfg_attr(feature = "use_serde", derive(Serialize))] pub struct NonEmptyWithCursor<T> { cursor: usize, data: NonEmpty<T>, } impl<T> NonEmptyWithCursor<T> { // *** Cursor methods /// Create a new NonEmptyWithCursor with a single element and cursor set to 0. #[inline] pub fn new(head: T) -> Self { NonEmptyWithCursor { cursor: 0, data: NonEmpty::new(head) } } /// Construct a new NonEmptyWithCursor from the first element and a vector of the rest of the /// elements. #[inline] pub fn new_with_rest(head: T, rest: Vec<T>) -> Self { NonEmptyWithCursor { cursor: 0, data: NonEmpty::new_with_rest(head, rest) } } /// Construct a NonEmptyWithCursor from a vector. Returns None if the vector is empty. #[inline] pub fn from_vec(vec: Vec<T>) -> Option<Self> { NonEmpty::from_vec(vec).map(|ne| NonEmptyWithCursor { cursor: 0, data: ne }) } /// Get the current element, as determined by the cursor. #[inline] pub fn get_current(&self) -> &T { self.data.get(self.cursor).unwrap() } /// Get a mutable reference to the current element. #[inline] pub fn get_current_mut(&mut self) -> &mut T { let i = self.cursor; self.data.get_mut(i).unwrap() } /// Set the cursor. Returns None if the cursor is out of bounds. #[inline] pub fn set_cursor(&mut self, cursor: usize) -> Option<()> { if self.data.len() > cursor { self.cursor = cursor; Some(()) } else { None } } /// Increment the cursor by one, and wrap around to 0 if it goes past the end of the vector. #[inline] pub fn next_circular(&mut self) { let newcursor = self.cursor + 1; self.cursor = if newcursor >= self.data.len() { 0 } else { newcursor } } /// Decrement the cursor by one, and wrap around to the end if it goes past the beginning of the /// vector. #[inline] pub fn prev_circular(&mut self) { if self.cursor == 0 { self.cursor = self.data.len() - 1; } else { self.cursor = self.cursor - 1; } } /// Invoke a function to mutate the underlying vector. /// If the function removes all of the elements of the vector, the first element of the tuple /// will be an `Error`. /// If the function truncates the vector such that the cursor is out-of-bounds, the cursor will /// be adjusted to point to the last item in the vector. /// The second element of the tuple is the return value of the function. /// /// # Examples /// /// ``` /// use nonempty::NonEmptyWithCursor; /// let ne = NonEmptyWithCursor::new(0); /// let (result, f_result) = ne.mutate(|v| {v.push(1); "Hello, world!" }); /// assert_eq!(f_result, "Hello, world!"); /// assert_eq!(result, Ok(NonEmptyWithCursor::new_with_rest(0, vec![1]))) /// ``` /// /// ``` /// use nonempty::NonEmptyWithCursor; /// let mut ne = NonEmptyWithCursor::new_with_rest(0, vec![1,2,3]); /// ne.set_cursor(2); /// let (result, _) = ne.mutate(|v| v.truncate(2)); /// let mut expected = NonEmptyWithCursor::new_with_rest(0, vec![1]); /// expected.set_cursor(1); /// assert_eq!(result, Ok(expected)); /// ``` pub fn mutate<F, R>(mut self, f: F) -> (Result<NonEmptyWithCursor<T>, Error>, R) where F: FnMut(&mut Vec<T>) -> R, { let (res, f_res) = self.data.mutate(f); match res { Ok(ne) => { if self.cursor >= ne.len() { self.cursor = ne.len() - 1; } self.data = ne; (Ok(self), f_res) } Err(x) => (Err(x), f_res), } } /// Get the current cursor. #[inline] pub fn get_cursor(&self) -> usize { self.cursor } /// Remove an element by index, adjusting the cursor so that it points at the same element. /// /// # Examples /// /// ``` /// use nonempty::NonEmptyWithCursor; /// let mut ne = NonEmptyWithCursor::new_with_rest(1, vec![2, 3, 4]); /// assert_eq!(ne.remove(1).unwrap(), 2); /// assert_eq!(ne.get_cursor(), 0); // No adjustment needed for cursor /// assert_eq!(ne, NonEmptyWithCursor::new_with_rest(1, vec![3, 4])); /// ``` /// /// ``` /// use nonempty::NonEmptyWithCursor; /// let mut ne = NonEmptyWithCursor::new_with_rest(1, vec![2, 3, 4]); /// ne.set_cursor(1); /// assert_eq!(ne.remove(0).unwrap(), 1); /// assert_eq!(ne.get_cursor(), 0); // Cursor adjusted left /// assert_eq!(ne, NonEmptyWithCursor::new_with_rest(2, vec![3, 4])); /// ``` /// /// ``` /// use nonempty::NonEmptyWithCursor; /// let mut ne = NonEmptyWithCursor::new_with_rest(1, vec![2, 3, 4]); /// ne.set_cursor(1); /// assert_eq!(ne.remove(1).unwrap(), 2); /// assert_eq!(ne.get_cursor(), 1); // Cursor remained the same, pointing at the next element /// let mut ne2 = NonEmptyWithCursor::new_with_rest(1, vec![3, 4]); /// ne2.set_cursor(1); /// assert_eq!(ne, ne2); /// ``` /// /// ``` /// use nonempty::{NonEmptyWithCursor, Error}; /// let mut ne = NonEmptyWithCursor::new(1); /// assert_eq!(ne.remove(0), Err(Error::RemoveLastElement)) /// ``` pub fn remove(&mut self, index: usize) -> Result<T, Error> { let r = self.data.remove(index)?; if index < self.cursor { self.cursor -= 1; } Ok(r) } /// See Vec::sort_by_key. Note that the cursor is NOT affected. pub fn sort_by_key<B, F>(&mut self, f: F) where B: Ord, F: FnMut(&T) -> B, { self.data.sort_by_key(f) } // *** Pass-through methods /// Get the length of the underlying non-empty vector. #[inline] pub fn len(&self) -> usize { self.data.len() } /// Iterate over the elements, providing &T. #[inline] pub fn iter(&self) -> std::slice::Iter<T> { self.data.iter() } /// Consume the NonEmptyWithCursor and iterate over the owned elements, providing T. #[inline] pub fn into_iter(self) -> std::vec::IntoIter<T> { self.data.into_iter() } /// Iterate over the elements, providing &mut T. #[inline] pub fn iter_mut(&mut self) -> std::slice::IterMut<T> { self.data.iter_mut() } /// Get an immutable reference to an arbitrary element, by index. #[inline] pub fn get(&self, idx: usize) -> Option<&T> { self.data.get(idx) } /// Get a mutable reference to an arbitrary element, by index. #[inline] pub fn get_mut(&mut self, idx: usize) -> Option<&mut T> { self.data.get_mut(idx) } /// Append an element. #[inline] pub fn push(&mut self, t: T) { self.data.push(t) } /// Check if a NonEmptyWithCursor contains the given element, by equality. #[inline] pub fn contains(&self, el: &T) -> bool where T: PartialEq<T>, { self.data.contains(el) } } /// A non-empty vector. NO operations panic. // The canonical representation is something like (A, Vec<A>), but this layout actually makes // it MUCH easier to implement the various methods, and perhaps more optimized. #[derive(Clone, Eq, PartialEq, Debug)] #[cfg_attr(feature = "use_serde", derive(Serialize))] pub struct NonEmpty<T>(Vec<T>); impl<T> NonEmpty<T> { /// Construct a new NonEmpty. The first element is necessary. #[inline] pub fn new(head: T) -> Self { NonEmpty(vec![head]) } /// Invoke a function to mutate the underlying vector. /// If the function removes all of the elements of the vector, the first element of the tuple /// will be an `Error`. /// The second element of the tuple is the return value of the function. /// /// # Examples /// /// ``` /// use nonempty::NonEmpty; /// let ne = NonEmpty::new(0); /// let (result, f_result) = ne.mutate(|v| {v.push(1); "Hello, world!" }); /// assert_eq!(f_result, "Hello, world!"); /// assert_eq!(result, Ok(NonEmpty::new_with_rest(0, vec![1]))) /// ``` /// /// ``` /// use nonempty::{NonEmpty, Error}; /// let ne = NonEmpty::new("hello"); /// let (result, f_result) = ne.mutate(|v| v.remove(0)); /// assert_eq!(result, Err(Error::RemoveLastElement)); /// assert_eq!(f_result, "hello"); /// ``` pub fn mutate<F, R>(mut self, mut f: F) -> (Result<NonEmpty<T>, Error>, R) where F: FnMut(&mut Vec<T>) -> R, { let result = f(&mut self.0); if self.0.len() == 0 { (Err(Error::RemoveLastElement), result) } else { (Ok(self), result) } } /// Construct a new NonEmpty from the first element and a vector of the rest of the elements. #[inline] pub fn new_with_rest(head: T, rest: Vec<T>) -> Self { let mut v = vec![head]; v.extend(rest); NonEmpty(v) } /// Construct a new NonEmpty from a Vec, if it has at least one element. #[inline] pub fn from_vec(vec: Vec<T>) -> Option<Self> { if vec.len() >= 1 { Some(NonEmpty(vec)) } else { None } } /// Iterate over the elements, providing &T. #[inline] pub fn iter(&self) -> std::slice::Iter<T> { self.0.iter() } /// Consume the NonEmpty and iterate over the owned elements, providing T. #[inline] pub fn into_iter(self) -> std::vec::IntoIter<T> { self.0.into_iter() } /// Iterate over the elements, providing &mut T. #[inline] pub fn iter_mut(&mut self) -> std::slice::IterMut<T> { self.0.iter_mut() } /// Get an immutable reference to an arbitrary element, by index. #[inline] pub fn get(&self, idx: usize) -> Option<&T> { self.0.get(idx) } /// Get a mutable reference to an arbitrary element, by index. #[inline] pub fn get_mut(&mut self, idx: usize) -> Option<&mut T> { self.0.get_mut(idx) } /// Append an element. #[inline] pub fn push(&mut self, t: T) { self.0.push(t) } /// Remove a single element matching a predicate. /// /// # Examples /// /// ``` /// use nonempty::{NonEmpty, Error}; /// /// let mut ne = NonEmpty::new_with_rest(1, vec![2]); /// // Removing an existing element: /// assert_eq!(ne.remove(0).unwrap(), 1); /// assert_eq!(ne, NonEmpty::new(2)); /// // Removing a non-existent element: /// assert_eq!(ne.remove(1), Err(Error::OutOfBounds{index: 1, length: 1})); /// // Removing the last element: /// assert_eq!(ne.remove(0), Err(Error::RemoveLastElement)); /// /// assert_eq!(ne, NonEmpty::new(2)); // The NonEmpty is unchanged /// ``` pub fn remove(&mut self, idx: usize) -> Result<T, Error> { if idx == 0 && self.len() == 1 { Err(Error::RemoveLastElement) } else if idx >= self.len() { Err(Error::OutOfBounds { index: idx, length: self.len() }) } else { Ok(self.0.remove(idx)) } } /// See Vec::sort_by_key. /// /// # Examples /// ``` /// use nonempty::NonEmpty; /// let mut ne = NonEmpty::new_with_rest(1, vec![2,3]); /// ne.sort_by_key(|el| -el); /// assert_eq!(ne, NonEmpty::new_with_rest(3, vec![2, 1])); /// ``` pub fn sort_by_key<B, F>(&mut self, f: F) where B: Ord, F: FnMut(&T) -> B, { self.0.sort_by_key(f) } /// Return the total length. #[inline] pub fn len(&self) -> usize { self.0.len() } /// Check if an element is contained in the NonEmpty, by equality. /// /// # Examples /// /// ``` /// use nonempty::NonEmpty; /// let ne = NonEmpty::new_with_rest(1, vec![2,3,4]); /// assert_eq!(ne.contains(&1), true); /// assert_eq!(ne.contains(&0), false); /// ``` #[inline] pub fn contains(&self, el: &T) -> bool where T: PartialEq<T>, { self.0.contains(el) } } /// An Error that may be returned by some operations on NonEmpty. #[derive(Debug, Eq, PartialEq)] pub enum Error { /// Tried to access an element outside the bounds of the NonEmpty. OutOfBounds { /// The attempted index index: usize, /// The length of the NonEmpty length: usize, }, /// Tried to remove the last element of the NonEmpty. RemoveLastElement, } impl fmt::Display for Error { fn fmt(&self, fmter: &mut fmt::Formatter) -> fmt::Result { write!(fmter, "{}", format!("{:?}", self)) } } impl error::Error for Error { fn description(&self) -> &str { "A Game Error occurred" } } // *** Deserializing NonEmptyWithCursor. // This is way more work than it should be. We just want to *validate* the data after parsing, // while using the normal parser. It'd be nice to just pass off a derived Deserialize, but we have // no way to do that. #[cfg(feature = "use_serde")] #[derive(Deserialize)] struct FakeNEC<T> { cursor: usize, data: Vec<T>, } #[cfg(feature = "use_serde")] impl<'de, T> Deserialize<'de> for NonEmptyWithCursor<T> where T: Deserialize<'de>, { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { let x: FakeNEC<T> = Deserialize::deserialize(deserializer)?; if x.data.len() == 0 { Err(serde::de::Error::invalid_length(0, &format!("at least one element").as_ref())) } else if x.cursor >= x.data.len() { Err(serde::de::Error::invalid_value( de::Unexpected::Unsigned(x.cursor as u64), &format!("< {}", x.data.len()).as_ref(), )) } else { let res: NonEmptyWithCursor<T> = NonEmptyWithCursor { cursor: x.cursor, data: NonEmpty::from_vec(x.data).unwrap() }; Ok(res) } } } // *** Likewise for NonEmpty #[cfg(feature = "use_serde")] impl<'de, T> Deserialize<'de> for NonEmpty<T> where T: Deserialize<'de>, { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { let x: Vec<T> = Deserialize::deserialize(deserializer)?; if x.len() == 0 { Err(serde::de::Error::invalid_length(0, &"at least one element")) } else { Ok(NonEmpty(x)) } } } #[cfg(feature = "use_serde")] #[test] fn test_serialize_deserialize_nonempty() { let ne: NonEmpty<i32> = NonEmpty::new_with_rest(5, vec![50, 55]); assert_eq!(serde_json::to_string(&ne).unwrap(), "[5,50,55]"); let parsed: Result<NonEmpty<i32>, _> = serde_json::from_str("[5,50,55]"); assert_eq!(parsed.unwrap(), ne); } #[cfg(feature = "use_serde")] #[test] fn test_deserialize_invalid_nonempty() { let parsed: Result<NonEmpty<i32>, _> = serde_json::from_str("[]"); match parsed { Ok(x) => panic!("Somehow this parsed: {:?}", x), Err(e) => assert_eq!(format!("{}", e), "invalid length 0, expected at least one element"), } } #[test] fn test_set_cursor() { let mut ne: NonEmptyWithCursor<i32> = NonEmptyWithCursor::new(1); assert_eq!(ne.get_cursor(), 0); assert_eq!(ne.get_current(), &1); assert_eq!(ne.set_cursor(0), Some(())); assert_eq!(ne.get_cursor(), 0); assert_eq!(ne.get_current(), &1); assert_eq!(ne.set_cursor(1), None); assert_eq!(ne.get_cursor(), 0); assert_eq!(ne.get_current(), &1); ne.push(5); assert_eq!(ne.get_cursor(), 0); assert_eq!(ne.get_current(), &1); assert_eq!(ne.set_cursor(1), Some(())); assert_eq!(ne.get_cursor(), 1); assert_eq!(ne.get_current(), &5); } #[cfg(feature = "use_serde")] #[test] fn test_serialize_deserialize_with_cursor() { let ne: NonEmptyWithCursor<i32> = NonEmptyWithCursor::new_with_rest(5, vec![50, 55]); assert_eq!(serde_json::to_string(&ne).unwrap(), "{\"cursor\":0,\"data\":[5,50,55]}"); match serde_json::from_str("{\"cursor\":0,\"data\":[5,50,55]}") { Ok(ne2) => assert_eq!(ne, ne2), Err(e) => panic!("Couldn't parse json: {}", e), } } #[cfg(feature = "use_serde")] #[test] fn test_deserialize_invalid_cursor() { let res: Result<NonEmptyWithCursor<i32>, _> = serde_json::from_str("{\"cursor\":1,\"data\":[5]}"); match res { Ok(x) => panic!("Should not have parsed to {:?}", x), // TODO: position here is 0, 0 because our parser is dumb. Err(e) => assert_eq!(format!("{}", e), "invalid value: integer `1`, expected < 1"), } } #[cfg(feature = "use_serde")] #[test] fn test_deserialize_invalid_empty() { let res: Result<NonEmptyWithCursor<i32>, _> = serde_json::from_str("{\"cursor\":0,\"data\":[]}"); match res { Ok(x) => panic!("Should not have parsed to {:?}", x), // TODO: position here is 0, 0 because our parser is dumb. Err(e) => assert_eq!(format!("{}", e), "invalid length 0, expected at least one element"), } } #[test] fn test_iter() { let ne: NonEmpty<i32> = NonEmpty::new_with_rest(5, vec![50, 55]); let v: Vec<&i32> = ne.iter().collect(); assert_eq!(v, vec![&5, &50, &55]); } #[cfg(test)] #[derive(Debug)] struct A(()); #[test] fn test_non_clonable() { NonEmpty::new(A(())); }
use crate::planning::chronicles::{StateFun, Type}; use crate::planning::ref_store::{RefPool, RefStore}; use crate::planning::symbols::{Instances, SymId, SymbolTable}; use crate::planning::utils::enumerate; use core::num::NonZeroU32; use fixedbitset::FixedBitSet; use std::collections::HashSet; use std::fmt::{Display, Error, Formatter}; use std::hash::Hash; use streaming_iterator::StreamingIterator; /// Compact, numeric representation of a state variable. /// /// A state variable is typically an s-expression of symbols /// such as (at bob kitchen) where "at" is a state function and "bob" and "kitchen" /// are its two parameters. /// /// TODO: ref to implement with macro. #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Hash)] pub struct SVId(NonZeroU32); impl SVId { pub fn raw(self) -> u32 { self.0.get() } pub fn from_raw(id: u32) -> Self { SVId(NonZeroU32::new(id).unwrap()) } } impl Into<usize> for SVId { fn into(self) -> usize { (self.0.get() - 1) as usize } } impl From<usize> for SVId { fn from(i: usize) -> Self { let nz = NonZeroU32::new((i + 1) as u32).unwrap(); SVId(nz) } } /// Association of a boolean state variable (i.e. predicate) to a boolean value. #[derive(Copy, Clone, Ord, PartialOrd, Eq, PartialEq, Debug, Hash)] pub struct Lit { inner: NonZeroU32, } impl Lit { /// Creates a new (boolean) literal by associating a state variable /// with a boolean value. pub fn new(sv: SVId, value: bool) -> Lit { let sv_usize: usize = sv.into(); let sv_part: usize = (sv_usize + 1usize) << 1; let x = (sv_part as u32) + (value as u32); let nz = NonZeroU32::new(x).unwrap(); Lit { inner: nz } } /// Returns state variable part of the literal pub fn var(self) -> SVId { SVId::from((self.inner.get() as usize >> 1) - 1usize) } /// Returns the value taken by the literal pub fn val(self) -> bool { (self.inner.get() & 1u32) != 0u32 } } impl Into<usize> for Lit { fn into(self) -> usize { self.inner.get() as usize - 2usize } } impl From<usize> for Lit { fn from(x: usize) -> Self { Lit { inner: NonZeroU32::new(x as u32 + 2u32).unwrap(), } } } /// Composition of a state variable ID and its defining world. /// IT allows looking up information in the world to /// implements things such as Display. struct DispSV<'a, T, I>(SVId, &'a World<T, I>); impl<'a, T, I: Display> Display for DispSV<'a, T, I> { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { write!(f, "(")?; let mut it = self.1.expressions[self.0].iter().peekable(); while let Some(x) = it.next() { write!(f, "{}", self.1.table.symbol(*x))?; if it.peek().is_some() { write!(f, " ")?; } } write!(f, ")")?; Ok(()) } } /// Keeps track of all state variables that can appear in a state. #[derive(Clone, Debug)] pub struct World<T, I> { pub table: SymbolTable<T, I>, /// Associates each state variable (represented as an array of symbols [SymId] /// to a unique ID (SVId) expressions: RefPool<SVId, Box<[SymId]>>, } impl<T, Sym> World<T, Sym> { /// Construct a new World (collection of state variables) by building all /// state variables that can be constructed from the available state functions. /// /// Currently, state functions are restricted to take boolean values. pub fn new(table: SymbolTable<T, Sym>, state_funs: &[StateFun]) -> Result<Self, String> where T: Clone + Eq + Hash + Display, Sym: Clone + Eq + Hash + Display, { let mut s = World { table, expressions: Default::default(), }; debug_assert_eq!( state_funs .iter() .map(|p| &p.sym) .collect::<HashSet<_>>() .len(), state_funs.len(), "Duplicated predicate" ); for pred in state_funs { let mut generators = Vec::with_capacity(1 + pred.argument_types().len()); let pred_id = pred.sym; if pred.return_type() != Type::Boolean { return Err(format!( "Non boolean state variable: {}", s.table.symbol(pred_id) )); } generators.push(Instances::singleton(pred_id)); for tpe in pred.argument_types() { if let Type::Symbolic(tpe_id) = tpe { generators.push(s.table.instances_of_type(*tpe_id)); } else { return Err("Non symbolic argument type".to_string()); } } let mut iter = enumerate(generators); while let Some(sv) = iter.next() { let cpy: Box<[SymId]> = sv.into(); assert!(s.expressions.get_ref(&cpy).is_none()); s.expressions.push(cpy); } } Ok(s) } pub fn sv_id(&self, sv: &[SymId]) -> Option<SVId> { self.expressions.get_ref(sv) } pub fn sv_of(&self, sv: SVId) -> &[SymId] { self.expressions.get(sv) } pub fn make_new_state(&self) -> State { State { svs: FixedBitSet::with_capacity(self.expressions.len()), } } } /// State : association of each state variable to its value #[derive(Clone, Ord, PartialOrd, PartialEq, Eq, Hash)] pub struct State { svs: FixedBitSet, } impl State { pub fn size(&self) -> usize { self.svs.len() } pub fn is_set(&self, sv: SVId) -> bool { self.svs.contains(sv.into()) } pub fn set_to(&mut self, sv: SVId, value: bool) { self.svs.set(sv.into(), value) } pub fn add(&mut self, sv: SVId) { self.set_to(sv, true); } pub fn del(&mut self, sv: SVId) { self.set_to(sv, false); } pub fn set(&mut self, lit: Lit) { self.set_to(lit.var(), lit.val()); } pub fn set_all(&mut self, lits: &[Lit]) { lits.iter().for_each(|&l| self.set(l)); } pub fn state_variables(&self) -> impl Iterator<Item = SVId> { (0..self.svs.len()).map(SVId::from) } pub fn literals(&self) -> impl Iterator<Item = Lit> + '_ { self.state_variables() .map(move |sv| Lit::new(sv, self.is_set(sv))) } pub fn set_svs(&self) -> impl Iterator<Item = SVId> + '_ { self.svs.ones().map(SVId::from) } pub fn entails(&self, lit: Lit) -> bool { self.is_set(lit.var()) == lit.val() } pub fn entails_all(&self, lits: &[Lit]) -> bool { lits.iter().all(|&l| self.entails(l)) } pub fn displayable<T, I: Display>(self, desc: &World<T, I>) -> impl Display + '_ { FullState(self, desc) } } struct FullState<'a, T, I>(State, &'a World<T, I>); impl<'a, T, I: Display> Display for FullState<'a, T, I> { fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> { for sv in self.0.set_svs() { writeln!(f, "{}", DispSV(sv, self.1))?; } Ok(()) } } /// Representation of classical planning operator // TODO: should use a small vec to avoid indirection in the common case // TODO: a comon requirement is that effects be applied with delete effects first // and add effects second. We should enforce an invariant on the order of effects for this. pub struct Operator { /// SExpression giving the name of the action and its parameters, e.g. (goto bob1 kitchen) pub name: Vec<SymId>, /// Preconditions of the the operator (might contain negative preconditions. pub precond: Vec<Lit>, /// Effects of this operator : /// - delete effects are literals with a negative value. /// - add effects are literals with a positive value. pub effects: Vec<Lit>, } impl Operator { pub fn pre(&self) -> &[Lit] { &self.precond } pub fn eff(&self) -> &[Lit] { &self.effects } } /// Unique numeric identifer of an `Operator`. /// The correspondence between the id and the operator is done /// in the `Operators` data structure. #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq)] pub struct Op(usize); impl Into<usize> for Op { fn into(self) -> usize { self.0 } } impl From<usize> for Op { fn from(x: usize) -> Self { Op(x) } } pub struct Operators { all: RefStore<Op, Operator>, watchers: RefStore<Lit, Vec<Op>>, } impl Operators { pub fn new() -> Self { Operators { all: RefStore::new(), watchers: RefStore::new(), } } pub fn push(&mut self, o: Operator) -> Op { let op = self.all.push(o); for &lit in self.all[op].pre() { // grow watchers until we have an entry for lit while self.watchers.last_key().filter(|&k| k >= lit).is_none() { self.watchers.push(Vec::new()); } self.watchers[lit].push(op); } op } pub fn preconditions(&self, op: Op) -> &[Lit] { self.all[op].pre() } pub fn effects(&self, op: Op) -> &[Lit] { self.all[op].eff() } pub fn name(&self, op: Op) -> &[SymId] { &self.all[op].name } pub fn dependent_on(&self, lit: Lit) -> &[Op] { self.watchers[lit].as_slice() } pub fn iter(&self) -> impl Iterator<Item = Op> { self.all.keys() } pub fn size(&self) -> usize { self.all.len() } } //Pour lier Op et une etape #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq)] pub struct Resume{ opkey: Option<Op>, etape: i32, } impl Resume{ pub fn op(&self)-> Option<Op> { self.opkey } pub fn numero(&self)-> i32{ self.etape } } pub fn newresume(ope: Op,num: i32)->Resume{ Resume { opkey : Some(ope), etape : num, } } pub fn defaultresume()->Resume{ Resume{ opkey : None, etape : -1, } } pub fn goalresume(num: i32)->Resume{ Resume{ opkey : None, etape : num, } } //#[cfg(test)] //mod tests { // use super::*; // use crate::planning::symbols::tests::table; // // // #[test] // fn state() { // let table = table(); // let predicates = vec![ // PredicateDesc { name: "at", types: vec!["rover", "location"]}, // PredicateDesc { name: "can_traverse", types: vec!["rover", "location", "location"]} // ]; // let sd = StateDesc::new(table, predicates).unwrap(); // println!("{:?}", sd); // // let mut s = sd.make_new_state(); // for sv in s.state_variables() { // s.add(sv); // } // println!("{}", FullState(s, &sd)); // } //} // #[derive(Debug, Clone, Ord, PartialOrd, Eq, PartialEq)] pub struct Necessaire{ operateur: Resume, nec: bool, chemin: Option<Vec<Resume>>, longueur: u32, } impl Necessaire{ pub fn opnec(&self)->Resume{self.operateur} pub fn nec(&self)->bool{self.nec} pub fn chemin(&self)->Option<Vec<Resume>>{self.chemin.clone()} pub fn long(&self)->u32{self.longueur} pub fn presence(&self,res:Resume)->bool{self.operateur==res} pub fn affiche (&self){ println!(" l'étape {} est nécessaire {} dans le chemin de longueur {} composé par :"/*,self.opnec().op()*/,self.opnec().numero(),self.nec,self.long()); if self.chemin().is_none(){println!("pas de chemin");} else{ for res in self.chemin().unwrap(){ println!(" l'étape {}", res.numero()); } } } } pub fn newnec(op:Resume, b:bool, way:Vec<Resume>, l:u32)->Necessaire{ Necessaire{ operateur:op, chemin:Some(way), nec:b, longueur:l, } } pub fn newnecgoal(op:Resume)->Necessaire{ Necessaire{ operateur:op, nec:true, chemin:None, longueur: 0, } } pub fn newnecess(op:Resume)->Necessaire{ Necessaire{ operateur:op, nec:false, chemin:None, longueur: 0, } } pub fn initnec(op:Resume, inf:u32)->Necessaire{ Necessaire{ operateur:op, nec:false, chemin:None, longueur: inf, } } #[derive(Debug, Clone, Copy, Ord, PartialOrd, Eq, PartialEq)] pub struct Unique{ operateur : Op, unicite : bool, } impl Unique{ pub fn operateur(&self)->Op{self.operateur} pub fn unicite(&self)->bool{self.unicite} pub fn duplicite(&mut self){ self.unicite=false; } } pub fn newunique(ope:Op)->Unique{ Unique{ operateur:ope, unicite : true, } } pub struct Obligationtemp{ ope1 : Op, etape1: i32, ope2: Op, etape2: i32 } impl Obligationtemp{ pub fn operateur(&self)->(Op,Op){(self.ope1,self.ope2)} pub fn etape(&self)->(i32,i32){(self.etape1,self.etape2)} pub fn premiereetape(&self)->(Op,i32){ if self.etape2>self.etape1{ (self.ope1,self.etape1) }else{ (self.ope2,self.etape2) } } pub fn deuxiemeetape(&self)->(Op,i32){ if self.etape1>self.etape2{ (self.ope1,self.etape1) }else{ (self.ope2,self.etape2) } } pub fn affichage(&self){ println!(" l'étape {} et l'étape {} ne sont pas inversible",self.etape1,self.etape2); } } pub fn newot(ope:Op,step:i32,oper:Op,next:i32)->Obligationtemp{ Obligationtemp{ ope1 : ope, etape1 : step, ope2 : oper, etape2 : next, } }
fn main() { cxx_build::bridge("src/multi_cxx1.rs") .flag_if_supported("-std=c++14") .compile("multi_cxx1"); cxx_build::bridge("src/multi_cxx2.rs") .flag_if_supported("-std=c++14") .compile("multi_cxx2"); }
use std::ops::{Deref, DerefMut}; use rustwlc::{Geometry, Size, Point}; use super::super::borders::Borders; use ::render::{BaseDraw, Drawable, DrawErr}; /// Draws the borders around windows. /// They are all of the same size, including the top. pub struct ViewDraw { base: BaseDraw<Borders> } impl ViewDraw { pub fn new(base: BaseDraw<Borders>) -> Self { ViewDraw { base: base } } fn draw_left_border(mut self, mut x: f64, mut y: f64, mut w: f64, mut h: f64, border_geometry: Geometry, output_res: Size) -> Result<Self, DrawErr<Borders>> { let title_size = self.base.inner().title_bar_size() as f64; // yay clamping if x < 0.0 { w += x; } if y < 0.0 { h += y - title_size; } x = 0.0; y = title_size; if border_geometry.origin.x + border_geometry.size.w as i32 > output_res.w as i32 { let offset = (border_geometry.origin.x + border_geometry.size.w as i32) - output_res.w as i32; x += offset as f64; } if border_geometry.origin.y + border_geometry.size.h as i32 > output_res.h as i32 { let offset = (border_geometry.origin.y + border_geometry.size.h as i32) - output_res.h as i32; y += offset as f64; } self.base.rectangle(x, y, w, h); self.base = try!(self.base.check_cairo()); self.base.fill(); self.base = try!(self.base.check_cairo()); Ok(self) } fn draw_right_border(mut self, mut x: f64, mut y: f64, w: f64, mut h: f64, border_geometry: Geometry, output_res: Size) -> Result<Self, DrawErr<Borders>> { let title_size = self.base.inner().title_bar_size() as f64; // yay clamping if border_geometry.origin.x < 0 { x += border_geometry.origin.x as f64; } if y < 0.0 { h += y - title_size; } y = title_size; if border_geometry.origin.x + border_geometry.size.w as i32 > output_res.w as i32 { let offset = (border_geometry.origin.x + border_geometry.size.w as i32) - output_res.w as i32; x += offset as f64; } if border_geometry.origin.y + border_geometry.size.h as i32 > output_res.h as i32 { let offset = (border_geometry.origin.y + border_geometry.size.h as i32) - output_res.h as i32; y += offset as f64; } self.base.rectangle(x, y, w, h); self.base = try!(self.base.check_cairo()); self.base.fill(); self.base = try!(self.base.check_cairo()); Ok(self) } fn draw_title_bar(mut self, mut x: f64, _y: f64, mut w: f64, _h: f64, border_geometry: Geometry, output_res: Size) -> Result<Self, DrawErr<Borders>> { let title_size = self.base.inner().title_bar_size() as f64; let title_color = self.base.inner().title_background_color(); let title_font_color = self.base.inner().title_font_color(); let title: String = self.inner().title().into(); if x < 0.0 { w += x; } let mut title_x = Borders::thickness() as f64; let mut title_y = title_size - 5.0; x = 0.0; let mut y = 0.0; if border_geometry.origin.x + border_geometry.size.w as i32 > output_res.w as i32 { let offset = (border_geometry.origin.x + border_geometry.size.w as i32) - output_res.w as i32; x += offset as f64; title_x += offset as f64; } if border_geometry.origin.y + border_geometry.size.h as i32 > output_res.h as i32 { let offset = (border_geometry.origin.y + border_geometry.size.h as i32) - output_res.h as i32; y += offset as f64; title_y += offset as f64; } // Draw background of title bar self.base.set_source_rgb(1.0, 0.0, 0.0); self.base.set_color_source(title_color); self.base.rectangle(x, y, w, title_size); self.base = try!(self.base.check_cairo()); self.base.fill(); self.base = try!(self.base.check_cairo()); // Draw title text self.base.move_to(title_x, title_y); self.base = try!(self.base.check_cairo()); self.base.set_color_source(title_font_color); self.base = try!(self.base.check_cairo()); self.base.show_text(title.as_str()); self.base = try!(self.base.check_cairo()); Ok(self) } fn draw_top_border(mut self, mut x: f64, mut y: f64, mut w: f64, mut h: f64, border_geometry: Geometry, output_res: Size) -> Result<Self, DrawErr<Borders>> { // Don't draw the top bar when we are in tabbed/stacked if !self.base.inner().draw_title { return Ok(self) } let title_size = self.base.inner().title_bar_size() as f64; // yay clamping if x < 0.0 { w += x; } if y < 0.0 { h += y; } x = 0.0; y = title_size; if border_geometry.origin.x + border_geometry.size.w as i32 > output_res.w as i32 { let offset = (border_geometry.origin.x + border_geometry.size.w as i32) - output_res.w as i32; x += offset as f64; } if border_geometry.origin.y + border_geometry.size.h as i32 > output_res.h as i32 { let offset = (border_geometry.origin.y + border_geometry.size.h as i32) - output_res.h as i32; y += offset as f64; } self.base.rectangle(x, y, w, h); self.base = try!(self.base.check_cairo()); self.base.fill(); self.base = try!(self.base.check_cairo()); Ok(self) } fn draw_bottom_border(mut self, mut x: f64, mut y: f64, mut w: f64, h: f64, border_geometry: Geometry, output_res: Size) -> Result<Self, DrawErr<Borders>> { // yay clamping if x < 0.0 { w += x; } if border_geometry.origin.y < 0 { y += border_geometry.origin.y as f64; } x = 0.0; if border_geometry.origin.x + border_geometry.size.w as i32 > output_res.w as i32 { let offset = (border_geometry.origin.x + border_geometry.size.w as i32) - output_res.w as i32; x += offset as f64; } if border_geometry.origin.y + border_geometry.size.h as i32 > output_res.h as i32 { let offset = (border_geometry.origin.y + border_geometry.size.h as i32) - output_res.h as i32; y += offset as f64; } self.base.rectangle(x, y, w, h); self.base = try!(self.base.check_cairo()); self.base.fill(); self.base = try!(self.base.check_cairo()); Ok(self) } } impl Drawable<Borders> for ViewDraw { fn draw(mut self, view_g: Geometry) -> Result<Borders, DrawErr<Borders>> { let mut border_g = view_g; let thickness = Borders::thickness(); let edge_thickness = thickness / 2; let output_res = self.inner().get_output().get_resolution() .expect("Could not get focused output's resolution"); let title_size = self.base.inner().title_bar_size(); border_g.origin.x -= edge_thickness as i32; border_g.origin.y -= edge_thickness as i32; border_g.origin.y -= title_size as i32; border_g.size.w += thickness; border_g.size.h += thickness; border_g.size.h += title_size; self.base.set_source_rgba(0.0, 0.0, 0.0, 0.0); self.base.paint(); let color = self.base.inner().color(); self.base.set_color_source(color); let Size { w, h } = border_g.size; let Point { x, y } = border_g.origin; // basically after everything after this point is floating point arithmetic // whee! let (x, y, w, h) = (x as f64, y as f64, w as f64, h as f64); let edge_thickness = edge_thickness as f64; self = self.draw_left_border(x, y, edge_thickness, h, border_g, output_res)? .draw_right_border(w - edge_thickness, y, edge_thickness, h, border_g, output_res)? .draw_top_border(x, y, w, edge_thickness, border_g, output_res)? .draw_bottom_border(x, h, w, -edge_thickness, border_g, output_res)? .draw_title_bar(x, y, w, edge_thickness, border_g, output_res)?; Ok(self.base.finish(border_g)) } } impl Deref for ViewDraw { type Target = BaseDraw<Borders>; fn deref(&self) -> &BaseDraw<Borders> { &self.base } } impl DerefMut for ViewDraw { fn deref_mut(&mut self) -> &mut BaseDraw<Borders> { &mut self.base } }
use std; use std::io::Write; use errors::*; use types::Client; use utils::http; use httpstream::{read_from_stream, HttpStream}; use openssl; pub struct TlsStream { pub tcp_stream: std::net::TcpStream, pub stream: openssl::ssl::SslStream<std::net::TcpStream>, } impl HttpStream for TlsStream { fn connect(client: Client) -> Result<TlsStream> { let tcp_opts = client .tcp_options .chain_err(|| "TLS backend chosen with no TCP information")?; let tcp_stream = std::net::TcpStream::connect((&*tcp_opts.host, tcp_opts.port)) .chain_err(|| "Could not initialise TCP stream to engine")?; let tls_opts = client .tls_files .chain_err(|| "TLS backend chosen with no TLS information")?; let mut context_builder = openssl::ssl::SslContextBuilder::new( openssl::ssl::SslMethod::tls(), ).chain_err(|| "Could not create SSL context")?; context_builder .set_private_key_file(tls_opts.key, openssl::ssl::SslFiletype::PEM) .chain_err(|| "Could not set key file for TLS")?; context_builder .set_certificate_file(tls_opts.cert, openssl::ssl::SslFiletype::PEM) .chain_err(|| "Could not set certificate for TLS")?; context_builder .set_ca_file(tls_opts.ca) .chain_err(|| "Could not set CA for TLS")?; let context = context_builder.build(); let stream = tcp_stream .try_clone() .chain_err(|| "Could not clone TCP stream")?; let ssl = openssl::ssl::Ssl::new(&context).chain_err(|| "Could not create SSL object")?; let ssl_stream = ssl.connect(stream).chain_err(|| "SSL handshake error")?; Ok(TlsStream { tcp_stream, stream: ssl_stream, }) } fn request(&mut self, req: http::Request) -> Result<http::Response> { let req_str = http::gen_request_string(req); let _ = self.stream.write(req_str.as_bytes()); let data = read_from_stream(&mut self.stream).chain_err(|| "Could not read from TLS stream")?; http::parse_response(&data) } }
use crate::{DocBase, VarType}; const DESCRIPTION: &'static str = r#" The round function returns the value of the argument rounded to the nearest integer, with ties rounding up. "#; const ARGUMENTS: &'static str = r#" source (series(float)) Series of values to process. length (int) Offset from the current bar to the previous bar. "#; pub fn gen_doc() -> Vec<DocBase> { let fn_doc = DocBase { var_type: VarType::Function, name: "round", signatures: vec![], description: DESCRIPTION, example: "", returns: "The value of the argument rounded to the nearest integer.", arguments: ARGUMENTS, remarks: "", links: "[ceil](#fun-ceil) [floor](#fun-floor)", }; vec![fn_doc] }
use super::{Form, Content}; use database::{Database, Store, Serialize}; use std::marker::PhantomData; pub struct Former<S: Store + Form + Default + Send + Sync, F: Fn(S) + Send + Sync> { load: Option<S>, function: F } impl<S: Store + Form + Default + Send + Sync, F: Fn(S) + Send + Sync> Former<S, F> { pub fn update(object: S, function: F) -> Former<S, F> { Former { load: Some(object), function: function } } } impl<S: Store + Form + Default + Send + Sync, F: Fn(S) + Send + Sync> Content for Former<S, F> { fn get(&self, database: &Database) -> Vec<u8> { match &self.load { Some(object) => { object.html() }, None => { S::default().html() } } } fn post(&self, _: &Database) -> Vec<u8> { Vec::new() } }
use collections::{EntityMap, EntitySet}; use ecs::{ComponentManager, ComponentManagerBase, Component, Entity}; use engine::*; use math::*; use std::{mem, ptr}; use std::fmt::{self, Debug, Formatter}; use std::cell::RefCell; use stopwatch::Stopwatch; /// HACK: Used to keep the data rows from reallocating and invalidating all of the pointers. const ROW_CAPACITY: usize = 1_000; /// Component manager for the `Transform` component. #[derive(Debug, Clone)] pub struct TransformManager { /// A map between the entity owning the transform and the location of the transform. /// /// The first value of the mapped tuple is the row containing the transform, the /// second is the index of the transform within that row. transforms: EntityMap<Box<Transform>>, /// The actual data for each transform. /// /// TODO: This documentation should be public, but it's not clear where it should go. /// /// Transform data is kept compact in rows for SUPER EFFICIENT UPDATES(tm). Each row represents /// a depth in the hierarchy and each row is updated in turn which guarantees that by the time /// a transform is updated it's parent will already have been updated. It also allows for /// transforms to be rearranged to keep only dirty transforms next to each other. This method /// is adopted from [Ogre](http://www.ogre3d.org/). transform_data: Vec<Vec<TransformData>>, marked_for_destroy: RefCell<EntitySet>, // HACK: This should just be a static, but we don't have const initialization so that would be // too much a pain to manually initialize all that junk. dummy_transform_data: Box<TransformData>, } impl TransformManager { pub fn new() -> TransformManager { TransformManager { transforms: EntityMap::default(), transform_data: vec![Vec::with_capacity(ROW_CAPACITY)], marked_for_destroy: RefCell::new(EntitySet::default()), dummy_transform_data: Box::new(TransformData { parent: 0 as *const _, transform: 0 as *mut _, index: 0, row: 0, position: Point::origin(), rotation: Quaternion::identity(), scale: Vector3::one(), position_derived: Point::origin(), rotation_derived: Quaternion::identity(), scale_derived: Vector3::one(), matrix_derived: Matrix4::identity(), }), } } pub fn assign(&self, entity: Entity) -> &Transform { // Use `UnsafeCell` trick to get a mutable reference. This is for the convenience of not having to // wrap all the members in `RefCell` when we know it's safe. let ptr = self as *const TransformManager as *mut TransformManager; unsafe { &mut *ptr }.assign_impl(entity) } /// Walks the transform hierarchy depth-first, invoking `callback` with each entity and its transform. /// /// # Details /// /// The callback is also invoked for the root entity. If the root entity does not have a transform /// the callback is never invoked. pub fn walk_hierarchy<F: FnMut(Entity, &Transform)>(&self, entity: Entity, callback: &mut F) { if let Some(transform) = self.transforms.get(&entity) { callback(entity, &*transform); // Recursively walk children. for child_entity in &transform.children { self.walk_hierarchy(*child_entity, callback); } } } /// Walks the transform hierarchy depth-first, invoking `callback` with each entity. /// /// # Details /// /// The callback is also invoked for the root entity. If the root entity does not have a transform /// the callback is never invoked. Note that the transform itself is not passed to the callback, /// if you need to access the transform use `walk_hierarchy()` instead. pub fn walk_children<F: FnMut(Entity)>(&self, entity: Entity, callback: &mut F) { if let Some(transform) = self.transforms.get(&entity) { callback(entity); // Recursively walk children. for child_entity in &transform.children { self.walk_children(*child_entity, callback); } } } /// Marks the transform associated with the entity for destruction. /// /// # Details /// /// Components marked for destruction are destroyed at the end of every frame. It can be used /// to destroy components without needing a mutable borrow on the component manager. /// /// TODO: Actually support deferred destruction. pub fn destroy(&self, entity: Entity) { let mut marked_for_destroy = self.marked_for_destroy.borrow_mut(); marked_for_destroy.insert(entity); // TODO: Warning, error if entity has already been marked? } pub fn destroy_immediate(&mut self, entity: Entity) { self.remove(entity); } // ======================== // PRIVATE HELPER FUNCTIONS // ======================== fn assign_impl(&mut self, entity: Entity) -> &Transform { // It's only possible for there to be outstanding references to the boxed `Transform` // objects, so no mutation can cause any memory unsafety. We still have to manually update // the data pointers for any moved transforms, but that is an internal detail that doesn't // leak to client code. // Create boxed transform so we can create the transform data and give it a pointer to the // transform object. let mut transform = Box::new(Transform { entity: entity, parent: None, children: Vec::new(), data: ptr::null_mut(), messages: RefCell::new(Vec::new()), }); // Get the row for root transforms. let row = &mut self.transform_data[0]; // HACK: This is our way of ensuring that pushing to the Vec doesn't reallocate. Switch to // a non-reallocating data structure (link list of cache line-sized blocks). assert!(row.len() < ROW_CAPACITY, "Tried to add transform data to row 0 but it is at capacity"); // Add a new `TransformData` for the the transform. let index = row.len(); row.push(TransformData { parent: &*self.dummy_transform_data as *const _, transform: &mut *transform as *mut _, row: 0, index: index, position: Point::origin(), rotation: Quaternion::identity(), scale: Vector3::one(), position_derived: Point::origin(), rotation_derived: Quaternion::identity(), scale_derived: Vector3::one(), matrix_derived: Matrix4::identity(), }); // Give the transform a pointer to its data. let data = unsafe { row.get_unchecked(index) }; transform.data = data as *const _ as *mut _; // TODO: Use `UnsafeCell` to avoid Rust doing illegal optimizations. // Add to the transform map. self.transforms.insert(entity, transform); &**self.transforms.get(&entity).unwrap() } fn get_mut(&mut self, entity: Entity) -> Option<&'static mut Transform> { self.transforms .get_mut(&entity) .map(|transform| { let ptr = &mut **transform as *mut _; unsafe { &mut *ptr } }) } fn process_messages(&mut self) { let transforms = { let ptr = &self.transforms as *const EntityMap<Box<Transform>>; unsafe { &*ptr } }; for (_, transform) in transforms { // Remove the messages list from the transform so we don't have a borrow on it. let mut messages = mem::replace(&mut *transform.messages.borrow_mut(), Vec::new()); for message in messages.drain(..) { match message { Message::SetParent(parent) => { self.set_parent(transform.entity, parent); }, Message::AddChild(child) => { self.set_parent(child, transform.entity); }, Message::SetPosition(position) => { transform.data_mut().position = position; }, Message::Translate(translation) => { transform.data_mut().position += translation; }, Message::SetScale(scale) => { transform.data_mut().scale = scale; }, Message::SetOrientation(orientation) => { transform.data_mut().rotation = orientation; }, Message::Rotate(rotation) => { transform.data_mut().rotation *= rotation; // TODO: Is this the right order for quaternion multiplication? I can never remember. }, Message::LookAt { interest, up } => { let data = transform.data_mut(); let forward = interest - data.position; data.rotation = Quaternion::look_rotation(forward, up); }, Message::LookDirection { forward, up } => { transform.data_mut().rotation = Quaternion::look_rotation(forward, up); }, } } // Put the messages list back so it doesn't loose its allocation. mem::replace(&mut *transform.messages.borrow_mut(), messages); } } fn process_destroyed(&mut self) { let mut marked_for_destroy = RefCell::new(EntitySet::default()); ::std::mem::swap(&mut marked_for_destroy, &mut self.marked_for_destroy); let mut marked_for_destroy = marked_for_destroy.into_inner(); for entity in marked_for_destroy.drain() { self.destroy_immediate(entity); } } fn update_transforms(&mut self) { for row in self.transform_data.iter_mut() { // TODO: The transforms in a row can be processed independently so they should be done // in parallel. for transform_data in row.iter_mut() { transform_data.update(); } } } fn set_parent(&mut self, entity: Entity, parent: Entity) { // Remove the moved entity from its parent's list of children. if let Some(old_parent) = self.get(entity).unwrap().parent { // TODO: Can this unwrap fail? let mut old_parent = self.get_mut(old_parent).unwrap(); // TODO: Can this unwrap fail? I think it indicates a bug within the library. What if the old parent was destroyed? let index = old_parent.children.iter().position(|&child| child == entity).unwrap(); // TODO: Don't panic! old_parent.children.swap_remove(index); } // Add the moved entity to its new parent's list of children. let parent_data = { let mut parent_transform = self.get_mut(parent).unwrap(); // TODO: Don't panic? Panicing here would mean an error within Gunship. parent_transform.children.push(entity); parent_transform.data_mut() }; // Update the entity's parent. { let transform = self.get_mut(entity).unwrap(); transform.parent = Some(parent); transform.data_mut().parent = parent_data as *mut _; } // Recursively move the transform data for this transform and all of its children to their // new rows. self.set_row_recursive(entity, parent_data.row + 1); } /// Moves a transform to the specified row and moves its children to the rows below. fn set_row_recursive(&mut self, entity: Entity, new_row_index: usize) { let transform = self.get_mut(entity).unwrap(); // Get information needed to remove the data from its current row. let (row, index) = { let data = transform.data(); (data.row, data.index) }; // Move transform data out of old row. let data = self.transform_data[row].swap_remove(index); // If the data wasn't at the end of the row then another data was moved to its position. We // need to update any pointers to that data. That means the Transform and the data for its // children. if self.transform_data[row].len() > index { transform.data_mut().fix_pointers(self); } // Make sure there are enough rows for the new data. while self.transform_data.len() <= new_row_index { self.transform_data.push(Vec::with_capacity(ROW_CAPACITY)); } // Add the transform data to its new row and fix any pointers to it. let data_ptr = { let new_row = &mut self.transform_data[new_row_index]; assert!(new_row.len() < ROW_CAPACITY, "Tried to add data to row {} but it was full", new_row_index); new_row.push(data); let index = new_row.len() - 1; &mut new_row[index] as *mut TransformData }; unsafe { &mut *data_ptr }.fix_pointers(self); // Repeate for all of its children forever. for child_entity in transform.children.iter().cloned() { self.set_row_recursive(child_entity, new_row_index + 1); } } // Removes the transform associated with the given entity. fn remove(&mut self, entity: Entity) { // Remove the transform from the transform map. let transform = self.transforms.remove(&entity).unwrap(); // TODO: Don't panic? Is it possible to get to this point and the transform doesn't exist? let data_ptr = transform.data; // Remove the transform data from its row. let data = transform.data_mut(); let data = self.transform_data[data.row].swap_remove(data.index); // Make sure that if we moved another data node that we fix up its pointers. if self.transform_data[data.row].len() > data.index { unsafe { &mut *data_ptr }.fix_pointers(self); } } } impl ComponentManagerBase for TransformManager { fn update(&mut self) { let _stopwatch = Stopwatch::new("transform update"); self.process_messages(); self.process_destroyed(); self.update_transforms(); } } impl ComponentManager for TransformManager { type Component = Transform; fn register(builder: &mut EngineBuilder) { builder.register_manager(TransformManager::new()); } fn get(&self, entity: Entity) -> Option<&Transform> { self.transforms.get(&entity).map(|boxed_transform| &**boxed_transform) } fn destroy(&self, entity: Entity) { self.marked_for_destroy.borrow_mut().insert(entity); } } /// TODO: This should be module-level documentation. /// /// A component representing the total transform (position, orientation, /// and scale) of an object in the world. /// /// # Details /// /// The `Transform` component is a fundamental part of the Gunship engine. /// It has the dual role of managing each individual entity's local transformation, /// as well as representing the individual nodes within the scene hierarchy. /// /// ## Scene hierarchy /// /// Each transform component may have one parent and any number of children. If a transform has /// a parent then its world transformation is the concatenation of its local transformation with /// its parent's world transformation. Using simple combinations of nested transforms can allow /// otherwise complex patterns of movement and positioning to be much easier to represent. /// /// Transforms that have no parent are said to be at the root level and have the property /// that their local transformation is also their world transformation. If a transform is /// known to be at the root of the hierarchy it is recommended that its local values be modified /// directly to achieve best performance. #[derive(Clone)] pub struct Transform { entity: Entity, parent: Option<Entity>, children: Vec<Entity>, data: *mut TransformData, messages: RefCell<Vec<Message>>, } impl Transform { /// Sends a message to the transform to make itself a child of the specified entity. pub fn set_parent(&self, parent: Entity) { self.messages.borrow_mut().push(Message::SetParent(parent)); } pub fn add_child(&self, child: Entity) { self.messages.borrow_mut().push(Message::AddChild(child)); } /// Gets the local postion of the transform. pub fn position(&self) -> Point { let data = unsafe { &*self.data }; data.position } /// Sets the local position of the transform. pub fn set_position(&self, new_position: Point) { self.messages.borrow_mut().push(Message::SetPosition(new_position)); } /// Gets the location rotation of the transform. pub fn rotation(&self) -> Quaternion { let data = unsafe { &*self.data }; data.rotation } /// Sets the local rotation of the transform. pub fn set_rotation(&self, new_rotation: Quaternion) { self.messages.borrow_mut().push(Message::SetOrientation(new_rotation)); } /// Gets the local scale of the transform. pub fn scale(&self) -> Vector3 { let data = unsafe { &*self.data }; data.scale } /// Sets the local scale of the transform. pub fn set_scale(&self, new_scale: Vector3) { self.messages.borrow_mut().push(Message::SetScale(new_scale)); } /// Gets the derived position of the transform. /// /// In debug builds this method asserts if the transform is out of date. pub fn position_derived(&self) -> Point { let data = unsafe { &*self.data }; data.position_derived } /// Gets the derived rotation of the transform. /// /// In debug builds this method asserts if the transform is out of date. pub fn rotation_derived(&self) -> Quaternion { let data = unsafe { &*self.data }; data.rotation_derived } /// Gets the derived scale of the transform. /// /// In debug builds this method asserts if the transform is out of date. pub fn scale_derived(&self) -> Vector3 { self.data().scale_derived } /// Gets the world-space matrix for the transform. pub fn derived_matrix(&self) -> Matrix4 { let data = unsafe { &*self.data }; data.matrix_derived } /// Gets the world-space normal matrix for the transform. /// /// The normal matrix is used to transform the vertex normals of meshes. The normal is /// calculated as the inverse transpose of the transform's world matrix. pub fn derived_normal_matrix(&self) -> Matrix4 { let data = unsafe { &*self.data }; let inv_scale = Matrix4::from_scale_vector(1.0 / data.scale_derived); let inv_rotation = data.rotation_derived.as_matrix4().transpose(); let inv_translation = Matrix4::from_point(-data.position_derived); let inverse = inv_scale * (inv_rotation * inv_translation); inverse.transpose() } /// Translates the transform in its local space. pub fn translate(&self, translation: Vector3) { self.messages.borrow_mut().push(Message::Translate(translation)); } /// Rotates the transform in its local space. pub fn rotate(&self, rotation: Quaternion) { self.messages.borrow_mut().push(Message::Rotate(rotation)); } /// Overrides the transform's orientation to look at the specified point. pub fn look_at(&self, interest: Point, up: Vector3) { self.messages.borrow_mut().push(Message::LookAt { interest: interest, up: up, }); } /// Overrides the transform's orientation to look in the specified direction. pub fn look_direction(&self, forward: Vector3, up: Vector3) { self.messages.borrow_mut().push(Message::LookDirection { forward: forward, up: up, }); } /// Gets the transform's local forward direction. /// /// The forward direction is the negative z axis. pub fn forward(&self) -> Vector3 { // TODO: Make this not dumb and slow. let matrix = Matrix3::from_quaternion(self.rotation()); -matrix.z_part() } /// Gets the transform's local right direction. /// /// The right direction is the positive x axis. pub fn right(&self) -> Vector3 { // TODO: Make this not dumb and slow. let matrix = Matrix3::from_quaternion(self.rotation()); matrix.x_part() } /// Gets the transform's local up direction. /// /// The up direction is the positive y axis. pub fn up(&self) -> Vector3 { // TODO: Make this not dumb and slow. let matrix = Matrix3::from_quaternion(self.rotation()); matrix.y_part() } fn data(&self) -> &TransformData { unsafe { &*self.data } } fn data_mut(&self) -> &mut TransformData { unsafe { &mut *self.data } } } impl Debug for Transform { fn fmt(&self, f: &mut Formatter) -> Result<(), fmt::Error> { write!( f, "Transform {{ entity: {:?}, parent: {:?}, children: {:?}, position: {:?}, orientation: {:?}, scale: {:?}, position_derived: {:?}, orientation_derived: {:?}, scale_derived: {:?} }}", self.entity, self.parent, &self.children, self.data().position, self.data().rotation, self.data().scale, self.data().position_derived, self.data().rotation_derived, self.data().scale_derived, ) } } impl Component for Transform { type Manager = TransformManager; type Message = Message; } #[derive(Debug, Clone)] struct TransformData { /// A pointer to the parent's transform data. /// /// Even if the node is at the root (and therefore has no parent) this will still point to a /// dummy `TransformData` that that has all identity values. parent: *const TransformData, transform: *mut Transform, row: usize, index: usize, position: Point, rotation: Quaternion, scale: Vector3, position_derived: Point, rotation_derived: Quaternion, scale_derived: Vector3, matrix_derived: Matrix4, } impl TransformData { /// Updates the derived transform data. fn update(&mut self) { let parent = unsafe { &*self.parent }; let local_matrix = self.local_matrix(); self.matrix_derived = parent.matrix_derived * local_matrix; self.position_derived = self.matrix_derived.translation_part(); self.rotation_derived = parent.rotation_derived * self.rotation; self.scale_derived = self.scale * parent.scale_derived; } fn local_matrix(&self) -> Matrix4 { let position = Matrix4::from_point(self.position); let rotation = Matrix4::from_quaternion(self.rotation); let scale = Matrix4::from_scale_vector(self.scale); position * (rotation * scale) } /// Corrects all pointers that are supposed to point to this object. /// /// `TransformData` objects need to relocate in memory in order to maintain cache coherency and /// improve performance, so when one is moved any pointers that are supposed to point to it /// need to be updated with its new location in memory. Only the data's transform and its child /// data objects will have pointers to it, so we can safely correct all pointers. fn fix_pointers(&mut self, transform_manager: &mut TransformManager) { // Fix the transforms pointer back to the data object. let mut transform = unsafe { &mut *self.transform }; transform.data = self as *mut _; // Retrieve the data for each child transform and update its parent pointer. for child in transform.children.iter().cloned() { let child_transform = transform_manager.get(child).unwrap(); // TODO: Don't panic! let mut child_data = child_transform.data_mut(); child_data.parent = self as *mut _; } } } // TODO: Provide a way to specify the space in which the transformation should take place, currently // all transformations are in local space but it's often valueable to be able to set the transform's // world coordinates. #[derive(Debug, Clone)] pub enum Message { SetParent(Entity), AddChild(Entity), SetPosition(Point), Translate(Vector3), SetScale(Vector3), SetOrientation(Quaternion), Rotate(Quaternion), LookAt { interest: Point, up: Vector3, }, LookDirection { forward: Vector3, up: Vector3, }, }
// auto generated, do not modify. // created: Mon Feb 22 23:57:02 2016 // src-file: /QtCore/qeventtransition.h // dst-file: /src/core/qeventtransition.rs // // header block begin => #![feature(libc)] #![feature(core)] #![feature(collections)] extern crate libc; use self::libc::*; // <= header block end // main block begin => // <= main block end // use block begin => use super::qabstracttransition::*; // 773 use std::ops::Deref; use super::qobject::*; // 773 use super::qstate::*; // 773 use super::qobjectdefs::*; // 773 // <= use block end // ext block begin => // #[link(name = "Qt5Core")] // #[link(name = "Qt5Gui")] // #[link(name = "Qt5Widgets")] // #[link(name = "QtInline")] extern { fn QEventTransition_Class_Size() -> c_int; // proto: void QEventTransition::~QEventTransition(); fn C_ZN16QEventTransitionD2Ev(qthis: u64 /* *mut c_void*/); // proto: void QEventTransition::setEventSource(QObject * object); fn C_ZN16QEventTransition14setEventSourceEP7QObject(qthis: u64 /* *mut c_void*/, arg0: *mut c_void); // proto: void QEventTransition::QEventTransition(QState * sourceState); fn C_ZN16QEventTransitionC2EP6QState(arg0: *mut c_void) -> u64; // proto: const QMetaObject * QEventTransition::metaObject(); fn C_ZNK16QEventTransition10metaObjectEv(qthis: u64 /* *mut c_void*/) -> *mut c_void; // proto: QObject * QEventTransition::eventSource(); fn C_ZNK16QEventTransition11eventSourceEv(qthis: u64 /* *mut c_void*/) -> *mut c_void; } // <= ext block end // body block begin => // class sizeof(QEventTransition)=1 #[derive(Default)] pub struct QEventTransition { qbase: QAbstractTransition, pub qclsinst: u64 /* *mut c_void*/, } impl /*struct*/ QEventTransition { pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QEventTransition { return QEventTransition{qbase: QAbstractTransition::inheritFrom(qthis), qclsinst: qthis, ..Default::default()}; } } impl Deref for QEventTransition { type Target = QAbstractTransition; fn deref(&self) -> &QAbstractTransition { return & self.qbase; } } impl AsRef<QAbstractTransition> for QEventTransition { fn as_ref(& self) -> & QAbstractTransition { return & self.qbase; } } // proto: void QEventTransition::~QEventTransition(); impl /*struct*/ QEventTransition { pub fn free<RetType, T: QEventTransition_free<RetType>>(& self, overload_args: T) -> RetType { return overload_args.free(self); // return 1; } } pub trait QEventTransition_free<RetType> { fn free(self , rsthis: & QEventTransition) -> RetType; } // proto: void QEventTransition::~QEventTransition(); impl<'a> /*trait*/ QEventTransition_free<()> for () { fn free(self , rsthis: & QEventTransition) -> () { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZN16QEventTransitionD2Ev()}; unsafe {C_ZN16QEventTransitionD2Ev(rsthis.qclsinst)}; // return 1; } } // proto: void QEventTransition::setEventSource(QObject * object); impl /*struct*/ QEventTransition { pub fn setEventSource<RetType, T: QEventTransition_setEventSource<RetType>>(& self, overload_args: T) -> RetType { return overload_args.setEventSource(self); // return 1; } } pub trait QEventTransition_setEventSource<RetType> { fn setEventSource(self , rsthis: & QEventTransition) -> RetType; } // proto: void QEventTransition::setEventSource(QObject * object); impl<'a> /*trait*/ QEventTransition_setEventSource<()> for (&'a QObject) { fn setEventSource(self , rsthis: & QEventTransition) -> () { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZN16QEventTransition14setEventSourceEP7QObject()}; let arg0 = self.qclsinst as *mut c_void; unsafe {C_ZN16QEventTransition14setEventSourceEP7QObject(rsthis.qclsinst, arg0)}; // return 1; } } // proto: void QEventTransition::QEventTransition(QState * sourceState); impl /*struct*/ QEventTransition { pub fn new<T: QEventTransition_new>(value: T) -> QEventTransition { let rsthis = value.new(); return rsthis; // return 1; } } pub trait QEventTransition_new { fn new(self) -> QEventTransition; } // proto: void QEventTransition::QEventTransition(QState * sourceState); impl<'a> /*trait*/ QEventTransition_new for (Option<&'a QState>) { fn new(self) -> QEventTransition { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZN16QEventTransitionC2EP6QState()}; let ctysz: c_int = unsafe{QEventTransition_Class_Size()}; let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64; let arg0 = (if self.is_none() {0} else {self.unwrap().qclsinst}) as *mut c_void; let qthis: u64 = unsafe {C_ZN16QEventTransitionC2EP6QState(arg0)}; let rsthis = QEventTransition{qbase: QAbstractTransition::inheritFrom(qthis), qclsinst: qthis, ..Default::default()}; return rsthis; // return 1; } } // proto: const QMetaObject * QEventTransition::metaObject(); impl /*struct*/ QEventTransition { pub fn metaObject<RetType, T: QEventTransition_metaObject<RetType>>(& self, overload_args: T) -> RetType { return overload_args.metaObject(self); // return 1; } } pub trait QEventTransition_metaObject<RetType> { fn metaObject(self , rsthis: & QEventTransition) -> RetType; } // proto: const QMetaObject * QEventTransition::metaObject(); impl<'a> /*trait*/ QEventTransition_metaObject<QMetaObject> for () { fn metaObject(self , rsthis: & QEventTransition) -> QMetaObject { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZNK16QEventTransition10metaObjectEv()}; let mut ret = unsafe {C_ZNK16QEventTransition10metaObjectEv(rsthis.qclsinst)}; let mut ret1 = QMetaObject::inheritFrom(ret as u64); return ret1; // return 1; } } // proto: QObject * QEventTransition::eventSource(); impl /*struct*/ QEventTransition { pub fn eventSource<RetType, T: QEventTransition_eventSource<RetType>>(& self, overload_args: T) -> RetType { return overload_args.eventSource(self); // return 1; } } pub trait QEventTransition_eventSource<RetType> { fn eventSource(self , rsthis: & QEventTransition) -> RetType; } // proto: QObject * QEventTransition::eventSource(); impl<'a> /*trait*/ QEventTransition_eventSource<QObject> for () { fn eventSource(self , rsthis: & QEventTransition) -> QObject { // let qthis: *mut c_void = unsafe{calloc(1, 32)}; // unsafe{_ZNK16QEventTransition11eventSourceEv()}; let mut ret = unsafe {C_ZNK16QEventTransition11eventSourceEv(rsthis.qclsinst)}; let mut ret1 = QObject::inheritFrom(ret as u64); return ret1; // return 1; } } // <= body block end
use crate::{records::Bed3, ChromName}; use num::Num; use std::io::{Result, Write}; pub trait Parsable<'a>: Sized { fn parse(s: &'a str) -> Option<(Self, usize)>; } pub trait Serializable { fn dump<W: Write>(&self, fp: W) -> Result<()>; } pub trait WithRegionCore<Chrom: ChromName> { fn begin(&self) -> u32; fn end(&self) -> u32; fn chrom(&self) -> &Chrom; #[inline(always)] fn empty(&self) -> bool { self.end() <= self.begin() } #[inline(always)] fn length(&self) -> u32 { self.end().max(self.begin()) - self.begin() } #[inline(always)] fn to_bed3(&self) -> Bed3<Chrom> { Bed3 { chrom: self.chrom().clone(), begin: self.begin(), end: self.end(), } } } pub trait WithRegion<Chrom: ChromName>: WithRegionCore<Chrom> { #[inline(always)] fn overlaps(&self, b: &impl WithRegion<Chrom>) -> bool { let a = self; if a.chrom() != b.chrom() { return false; } !(a.end() <= b.begin() || b.end() <= a.begin()) } } impl<C: ChromName, T: WithRegionCore<C>> WithRegion<C> for T {} impl<'a, Chrom: ChromName, T: WithRegion<Chrom>> WithRegionCore<Chrom> for &'a T { fn begin(&self) -> u32 { T::begin(*self) } fn end(&self) -> u32 { T::end(*self) } fn chrom(&self) -> &Chrom { T::chrom(*self) } } impl<Chrom: ChromName, A: WithRegion<Chrom>, B: WithRegion<Chrom>> WithRegionCore<Chrom> for (A, B) { #[inline(always)] fn begin(&self) -> u32 { if self.0.overlaps(&self.1) { self.0.begin().max(self.1.begin()) } else { 0 } } #[inline(always)] fn end(&self) -> u32 { if self.0.overlaps(&self.1) { self.0.end().min(self.1.end()) } else { 0 } } #[inline(always)] fn chrom(&self) -> &Chrom { self.0.chrom() } } pub trait Intersection<Chrom: ChromName>: WithRegionCore<Chrom> { fn original(&self, idx: usize) -> &dyn WithRegionCore<Chrom>; fn size(&self) -> usize; } macro_rules! impl_intersection_trait { ($($t_name: ident),* => $($idx: tt),*) => { impl <Chrom: ChromName, $($t_name: WithRegion<Chrom>),*> Intersection<Chrom> for ($($t_name),*) { fn original(&self, idx: usize) -> &dyn WithRegionCore<Chrom> { match idx { $($idx => &self.$idx,)* _ => panic!("Index out of range") } } fn size(&self) -> usize { $(let _ret = $idx;)* _ret + 1 } } } } impl_intersection_trait!(A, B => 0, 1); macro_rules! impl_with_region_for_tuple { (($($t_var:ident),*), ($($head:tt),*), $tail:tt) => { impl <Chrom: ChromName, $($t_var: WithRegion<Chrom>),*> WithRegionCore<Chrom> for ($($t_var),*) { #[inline(always)] fn begin(&self) -> u32 { if ($(&self . $head,)*).overlaps(&self.$tail) { ($(&self . $head,)*).begin().max(self.$tail.begin()) } else { 0 } } #[inline(always)] fn end(&self) -> u32 { if ($(&self . $head,)*).overlaps(&self.$tail) { ($(&self . $head,)*).end().min(self.$tail.end()) } else { 0 } } #[inline(always)] fn chrom(&self) -> &Chrom { self.0.chrom() } } impl_intersection_trait!($($t_var),* => $($head,)* $tail); }; } impl_with_region_for_tuple!((A, B, C), (0, 1), 2); impl_with_region_for_tuple!((A, B, C, D), (0, 1, 2), 3); impl_with_region_for_tuple!((A, B, C, D, E), (0, 1, 2, 3), 4); impl_with_region_for_tuple!((A, B, C, D, E, F), (0, 1, 2, 3, 4), 5); impl_with_region_for_tuple!((A, B, C, D, E, F, G), (0, 1, 2, 3, 4, 5), 6); impl_with_region_for_tuple!((A, B, C, D, E, F, G, H), (0, 1, 2, 3, 4, 5, 6), 7); pub trait WithName { fn name(&self) -> &str; } pub trait WithScore<T: Num> { fn score(&self) -> Option<T> { None } } pub enum Strand { Neg, Pos, } pub trait WithStrand { fn strand(&self) -> Option<Strand> { None } } impl<A: Serializable, B: Serializable> Serializable for (A, B) { fn dump<W: Write>(&self, mut fp: W) -> Result<()> { self.0.dump(&mut fp)?; write!(fp, "\t|\t")?; self.1.dump(&mut fp) } } pub enum Nuclide { A, T, C, G, U, N, } pub trait WithSequence { type RangeType: IntoIterator<Item = Nuclide>; fn at(&self, offset: usize) -> Nuclide; fn range(&self, from: usize, to: usize) -> Self::RangeType; }
mod front_of_house; pub use crate::front_of_house::hosting; pub fn eat_at_restaurant() { hosting::add_to_waitlist(); hosting::add_to_waitlist(); hosting::add_to_waitlist(); } fn main() { println!("Hello, world!"); crate::eat_at_restaurant(); }
use midi_message::MidiMessage; use color::Color; use color_strip::ColorStrip; use effects::effect::Effect; use rainbow::get_rainbow_color; pub struct StreamCenter { color_strip: ColorStrip, pressed_keys: Vec<u8>, i: u64, i2: u64 } impl StreamCenter { pub fn new(led_count: usize) -> StreamCenter { StreamCenter { color_strip: ColorStrip::new(led_count / 2), pressed_keys: vec![], i: 0, i2: 0 } } } impl Effect for StreamCenter { fn paint(&mut self, color_strip: &mut ColorStrip) { let self_length = self.color_strip.pixel.len(); for (i, pixel) in color_strip.pixel.iter_mut().enumerate() { if i < self_length { *pixel += self.color_strip.pixel[i]; } else { *pixel += self.color_strip.pixel[self_length - (i - self_length) - 1]; } } } fn tick(&mut self) { self.i2 = self.i2 + 1; if self.i2 % 5 != 0 { return; } if !self.pressed_keys.is_empty() { let key_index = (self.i / 11) as usize % self.pressed_keys.len(); self.color_strip.insert(get_rainbow_color(self.pressed_keys[key_index])); self.i += 1; } else { let darkened_first_pixel = self.color_strip.pixel[0] - Color::gray(10); self.color_strip.insert(darkened_first_pixel); } } fn on_midi_message(&mut self, midi_message: MidiMessage) { match midi_message { MidiMessage::NoteOn(_, note, _) => { self.pressed_keys.push(note); self.color_strip.pixel[0] = get_rainbow_color(note); } MidiMessage::NoteOff(_, message_note, _) => { self.pressed_keys.retain(|&note| note != message_note); } _ => {} } } }
//! RTC use e310x::RTC; /// Rtc configuration pub struct RtcConf { enalways: bool, scale: u8, counter: u64, cmp: u32, } impl RtcConf { pub fn new() -> Self { Self { enalways: true, scale: 0, counter: 0, cmp: 0, } } pub fn set_enalways(&mut self, en: bool) -> &mut Self { self.enalways = en; self } pub fn set_scale(&mut self, scale: u8) -> &mut Self { assert!(scale < 16); self.scale = scale; self } pub fn set_counter(&mut self, counter: u64) -> &mut Self { assert!(counter < (1 << 49) - 1); self.counter = counter; self } pub fn set_cmp(&mut self, cmp: u32) -> &mut Self { self.cmp = cmp; self } pub fn end(&self, rtc: &RTC) { let rtc = Rtc(rtc); unsafe { rtc.0.rtccfg.modify(|_, w| { w.enalways().bit(self.enalways) .scale().bits(self.scale) }); rtc.0.rtchi.write(|w| w.bits((self.counter >> 32) as u32)); rtc.0.rtclo.write(|w| w.bits(self.counter as u32)); rtc.0.rtccmp.write(|w| w.bits(self.cmp)); } } } /// Rtc interface pub struct Rtc<'a>(pub &'a RTC); impl<'a> Clone for Rtc<'a> { fn clone(&self) -> Self { *self } } impl<'a> Copy for Rtc<'a> {} impl<'a> ::hal::Timer for Rtc<'a> { type Time = ::aonclk::Ticks<u32>; fn get_timeout(&self) -> ::aonclk::Ticks<u32> { ::aonclk::Ticks(self.0.rtccmp.read().bits()) } fn pause(&self) { self.0.rtccfg.modify(|_, w| w.enalways().bit(false)); } fn restart(&self) { unsafe { self.0.rtchi.write(|w| w.bits(0)); self.0.rtclo.write(|w| w.bits(0)); } self.0.rtccfg.modify(|_, w| w.enalways().bit(true)); } fn resume(&self) { self.0.rtccfg.modify(|_, w| w.enalways().bit(true)); } fn set_timeout<T>(&self, timeout: T) where T: Into<::aonclk::Ticks<u32>>, { self.pause(); unsafe { self.0.rtccmp.write(|w| w.bits(timeout.into().into())); } self.restart(); } fn wait(&self) -> ::nb::Result<(), !> { if self.0.rtccfg.read().cmpip().bit() { Ok(()) } else { Err(::nb::Error::WouldBlock) } } }
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use std::sync::Arc; use common_catalog::table::CompactTarget; use common_exception::Result; use common_sql::plans::OptimizeTableAction; use common_sql::plans::OptimizeTablePlan; use crate::interpreters::Interpreter; use crate::pipelines::executor::ExecutorSettings; use crate::pipelines::executor::PipelineCompleteExecutor; use crate::pipelines::Pipeline; use crate::pipelines::PipelineBuildResult; use crate::sessions::QueryContext; use crate::sessions::TableContext; pub struct OptimizeTableInterpreter { ctx: Arc<QueryContext>, plan: OptimizeTablePlan, } impl OptimizeTableInterpreter { pub fn try_create(ctx: Arc<QueryContext>, plan: OptimizeTablePlan) -> Result<Self> { Ok(OptimizeTableInterpreter { ctx, plan }) } } #[async_trait::async_trait] impl Interpreter for OptimizeTableInterpreter { fn name(&self) -> &str { "OptimizeTableInterpreter" } async fn execute2(&self) -> Result<PipelineBuildResult> { let plan = &self.plan; let ctx = self.ctx.clone(); let mut table = self .ctx .get_table(&plan.catalog, &plan.database, &plan.table) .await?; let action = &plan.action; let do_purge = matches!( action, OptimizeTableAction::Purge(_) | OptimizeTableAction::All ); let do_compact_blocks = matches!( action, OptimizeTableAction::CompactBlocks(_) | OptimizeTableAction::All ); let do_compact_segments_only = matches!(action, OptimizeTableAction::CompactSegments(_)); let limit_opt = match action { OptimizeTableAction::CompactBlocks(limit_opt) => *limit_opt, OptimizeTableAction::CompactSegments(limit_opt) => *limit_opt, _ => None, }; if do_compact_segments_only { let mut pipeline = Pipeline::create(); table .compact( ctx.clone(), CompactTarget::Segments, limit_opt, &mut pipeline, ) .await?; return Ok(PipelineBuildResult::create()); } if do_compact_blocks { let mut pipeline = Pipeline::create(); if table .compact(ctx.clone(), CompactTarget::Blocks, limit_opt, &mut pipeline) .await? { let settings = ctx.get_settings(); pipeline.set_max_threads(settings.get_max_threads()? as usize); let query_id = ctx.get_id(); let executor_settings = ExecutorSettings::try_create(&settings, query_id)?; let executor = PipelineCompleteExecutor::try_create(pipeline, executor_settings)?; ctx.set_executor(Arc::downgrade(&executor.get_inner())); executor.execute()?; drop(executor); } if do_purge { // currently, context caches the table, we have to "refresh" // the table by using the catalog API directly table = self .ctx .get_catalog(&plan.catalog)? .get_table(ctx.get_tenant().as_str(), &plan.database, &plan.table) .await?; } } if do_purge { let table = if let OptimizeTableAction::Purge(Some(point)) = action { table.navigate_to(point).await? } else { table }; let keep_latest = true; table.purge(self.ctx.clone(), keep_latest).await?; } Ok(PipelineBuildResult::create()) } }
extern crate spell_game; extern crate time; use std::sync::{Arc,Mutex}; use ted_net_code::{Client}; use std::thread; use std; pub fn game_thread(client_list: Arc<Mutex<Vec<Client>>>){ let mut game=spell_game::SpellGame::new(); let mut last_time=time::precise_time_ns(); loop{ { let mut client_lock=client_list.lock().unwrap(); game.interact(&mut client_lock); } game.step(); let current_time=time::precise_time_ns(); let sleep_time=(current_time-last_time)/1000000; let sleep_time=if sleep_time>=20 {0} else {20-sleep_time}; if sleep_time==0 {game.lagged=true} else {game.lagged=false} if game.timer%100==0 {println!("Game did {}lag this step",if game.lagged {""} else {"not "})}; last_time=current_time; thread::sleep(std::time::Duration::from_millis(sleep_time)); } }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use fidl_fuchsia_ui_input as uii; /// Generates a default `TextInputState`, suitable for tests. #[cfg(test)] pub fn default_state() -> uii::TextInputState { uii::TextInputState { revision: 1, text: "".to_string(), selection: uii::TextSelection { base: 0, extent: 0, affinity: uii::TextAffinity::Upstream }, composing: uii::TextRange { start: -1, end: -1 }, } } /// Clones a `TextInputState`. pub fn clone_state(state: &uii::TextInputState) -> uii::TextInputState { uii::TextInputState { revision: state.revision, text: state.text.clone(), selection: uii::TextSelection { base: state.selection.base, extent: state.selection.extent, affinity: state.selection.affinity, }, composing: uii::TextRange { start: state.composing.start, end: state.composing.end }, } } /// Clones a `KeyboardEvent`. pub fn clone_keyboard_event(ev: &uii::KeyboardEvent) -> uii::KeyboardEvent { uii::KeyboardEvent { event_time: ev.event_time, device_id: ev.device_id, phase: ev.phase, hid_usage: ev.hid_usage, code_point: ev.code_point, modifiers: ev.modifiers, } }
extern crate circle_gh_tee; use std::process; use circle_gh_tee::run; fn main() { match run() { Ok(s) => { print!("{}", s.command_result.result); if let Some(error_message) = s.error_message { eprintln!("circle-gh-tee: error: {}", error_message); process::exit(1); } else { process::exit(s.command_result.exit_status); } } Err(f) => { eprintln!("circle-gh-tee: error: {}", f.message); process::exit(1); } } }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //! This module defines a framework for using the crate::expectations module in //! asynchronous situations, where you wish you detect the satisfiability of the //! expectations at some undetermined point in the future. //! //! An `ExpectationFuture` implements `Future` and will complete when the //! underlying state satisfies the predicate. Failure can be detected by wrapping //! the future in a timeout, as is implemented by the method `when_satisfied`. //! //! To use `ExpectationFuture`s, you must implement `ExpectableState` for the //! type of state you wish to track, which defines how the state will update and //! notify tasks that are waiting on state changes. //! //! A common pattern is to await the expectation of a given state, and then //! check further predicate expectations to determine success or failure at that //! point in time. //! //! e.g. //! //! ```ignore //! // Wait for the action to have completed one way or the other //! let state = state.when_satisfied(action_complete, timeout).await?; //! // Then check that the action completed successfully //! action_success.satisfied(state) //! ``` use { failure::{format_err, Error}, fuchsia_async::{DurationExt, TimeoutExt}, fuchsia_zircon as zx, futures::{future::FutureObj, task, Future, FutureExt, Poll}, parking_lot::{MappedRwLockWriteGuard, RwLock, RwLockWriteGuard}, slab::Slab, std::{pin::Pin, sync::Arc}, }; use crate::expectation::Predicate; /// Future that completes once a Predicate is satisfied for the `T::State` type /// where `T` is some type that allows monitoring of State updates pub struct ExpectationFuture<T: ExpectableState> { state: T, expectation: Predicate<T::State>, waker_key: Option<usize>, } impl<T: ExpectableState> ExpectationFuture<T> { fn new(state: T, expectation: Predicate<T::State>) -> ExpectationFuture<T> { ExpectationFuture { state, expectation, waker_key: None } } fn clear_waker(&mut self) { if let Some(key) = self.waker_key { self.state.remove_task(key); self.waker_key = None; } } fn store_task(&mut self, cx: &mut task::Context<'_>) { let key = self.state.store_task(cx); self.waker_key = Some(key); } } impl<T: ExpectableState> std::marker::Unpin for ExpectationFuture<T> {} #[must_use = "futures do nothing unless polled"] impl<T: ExpectableState> Future for ExpectationFuture<T> { type Output = T::State; fn poll(mut self: Pin<&mut Self>, cx: &mut task::Context<'_>) -> Poll<Self::Output> { self.clear_waker(); let state = self.state.read(); if self.expectation.satisfied(&state) { Poll::Ready(state) } else { self.store_task(cx); Poll::Pending } } } /// Trait for objects that allow futures to trigger based on state changes /// /// This trait will commonly be used via the `ExpectableStateExt` extension /// trait which provides the convenient `when_satisfied` function. /// /// You can implement this trait for your own types which implement their own /// state tracking and notification of futures, or you can use the /// `ExpectationHarness` struct in this module which provides a ready to use /// implementation. pub trait ExpectableState: Clone { /// Type of current state we are tracking type State: 'static; /// Register a task as needing waking when state changes fn store_task(&mut self, cx: &mut task::Context<'_>) -> usize; /// Remove a task from being tracked. Called by `ExpectationFuture` when /// polled. fn remove_task(&mut self, key: usize); /// Notify all pending tasks that state has changed fn notify_state_changed(&self); /// Read a snapshot of the current State fn read(&self) -> Self::State; } pub trait ExpectableStateExt: ExpectableState + Sized { /// Convenience method for awaiting expectations on the underlying state /// Provides a simple syntax for asynchronously awaiting expectations: /// /// ```ignore /// // Wait for the action to have completed one way or the other /// let state = state.when_satisfied(action_complete, timeout).await?; /// ``` fn when_satisfied( &self, expectation: Predicate<Self::State>, timeout: zx::Duration, ) -> FutureObj<Result<Self::State, Error>>; } impl<T: ExpectableState + Sized> ExpectableStateExt for T where T: Send + Sync + 'static, T::State: Send + Sync + 'static, { fn when_satisfied( &self, expectation: Predicate<T::State>, timeout: zx::Duration, ) -> FutureObj<Result<Self::State, Error>> { let msg = expectation.describe(); FutureObj::new(Box::pin( ExpectationFuture::new(self.clone(), expectation) .map(|s| Ok(s)) .on_timeout(timeout.after_now(), move || { Err(format_err!("Timed out waiting for expectation: {}", msg)) }), )) } } /// Shared Harness for awaiting predicate expectations on type `S`, using /// auxilliary data `A` /// /// This type is the easiest way to get an implementation of 'ExpectableState' /// to await upon. The Aux type `A` is commonly used to hold a FIDL Proxy to /// drive the behavior under test. pub struct ExpectationHarness<S, A>(Arc<RwLock<HarnessInner<S, A>>>); impl<S, A> Clone for ExpectationHarness<S, A> { fn clone(&self) -> ExpectationHarness<S, A> { ExpectationHarness(self.0.clone()) } } /// Harness for State `S` and Auxilliary data `A` struct HarnessInner<S, A> { /// Snapshot of current state state: S, /// All the tasks currently pending on a state change tasks: Slab<task::Waker>, /// Arbitrary auxilliary data. Commonly used to hold a FIDL proxy, but can /// be used to store any data necessary for driving the behavior that will /// result in state updates. aux: A, } impl<S: Clone + 'static, A> ExpectableState for ExpectationHarness<S, A> { type State = S; /// Register a task as needing waking when state changes fn store_task(&mut self, cx: &mut task::Context<'_>) -> usize { self.0.write().tasks.insert(cx.waker().clone()) } /// Remove a task from being tracked fn remove_task(&mut self, key: usize) { let mut harness = self.0.write(); if harness.tasks.contains(key) { harness.tasks.remove(key); } } /// Notify all pending tasks that state has changed fn notify_state_changed(&self) { for task in &self.0.read().tasks { task.1.wake_by_ref(); } self.0.write().tasks.clear() } fn read(&self) -> Self::State { self.0.read().state.clone() } } impl<S, A> ExpectationHarness<S, A> { pub fn init(aux: A, state: S) -> ExpectationHarness<S, A> { ExpectationHarness(Arc::new(RwLock::new(HarnessInner { aux, tasks: Slab::new(), state }))) } pub fn aux(&self) -> MappedRwLockWriteGuard<A> { RwLockWriteGuard::map(self.0.write(), |harness| &mut harness.aux) } pub fn write_state(&self) -> MappedRwLockWriteGuard<S> { RwLockWriteGuard::map(self.0.write(), |harness| &mut harness.state) } } impl<S: Default, A> ExpectationHarness<S, A> { pub fn new(aux: A) -> ExpectationHarness<S, A> { ExpectationHarness::<S, A>::init(aux, S::default()) } }
use std::cell::UnsafeCell; use std::env; use std::ffi::OsString; use std::fmt; use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering}; use std::sync::Mutex; pub use super::backtrace::Backtrace; const GENERAL_BACKTRACE: &str = "RUST_BACKTRACE"; const FAILURE_BACKTRACE: &str = "RUST_FAILURE_BACKTRACE"; pub(super) struct InternalBacktrace { backtrace: Option<MaybeResolved>, } struct MaybeResolved { resolved: Mutex<bool>, backtrace: UnsafeCell<Backtrace>, } unsafe impl Send for MaybeResolved {} unsafe impl Sync for MaybeResolved {} impl InternalBacktrace { pub(super) fn new() -> InternalBacktrace { static ENABLED: AtomicUsize = ATOMIC_USIZE_INIT; match ENABLED.load(Ordering::SeqCst) { 0 => { let enabled = is_backtrace_enabled(|var| env::var_os(var)); ENABLED.store(enabled as usize + 1, Ordering::SeqCst); if !enabled { return InternalBacktrace { backtrace: None } } } 1 => return InternalBacktrace { backtrace: None }, _ => {} } InternalBacktrace { backtrace: Some(MaybeResolved { resolved: Mutex::new(false), backtrace: UnsafeCell::new(Backtrace::new_unresolved()), }), } } pub(super) fn none() -> InternalBacktrace { InternalBacktrace { backtrace: None } } pub(super) fn as_backtrace(&self) -> Option<&Backtrace> { let bt = match self.backtrace { Some(ref bt) => bt, None => return None, }; let mut resolved = bt.resolved.lock().unwrap(); unsafe { if !*resolved { (*bt.backtrace.get()).resolve(); *resolved = true; } Some(&*bt.backtrace.get()) } } pub(super) fn is_none(&self) -> bool { self.backtrace.is_none() } } impl fmt::Debug for InternalBacktrace { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { f.debug_struct("InternalBacktrace") .field("backtrace", &self.as_backtrace()) .finish() } } fn is_backtrace_enabled<F: Fn(&str) -> Option<OsString>>(get_var: F) -> bool { match get_var(FAILURE_BACKTRACE) { Some(ref val) if val != "0" => true, Some(ref val) if val == "0" => false, _ => match get_var(GENERAL_BACKTRACE) { Some(ref val) if val != "0" => true, _ => false, } } } #[cfg(test)] mod tests { use super::*; const YEA: Option<&str> = Some("1"); const NAY: Option<&str> = Some("0"); const NOT_SET: Option<&str> = None; macro_rules! test_enabled { (failure: $failure:ident, general: $general:ident => $result:expr) => {{ assert_eq!(is_backtrace_enabled(|var| match var { FAILURE_BACKTRACE => $failure.map(OsString::from), GENERAL_BACKTRACE => $general.map(OsString::from), _ => panic!() }), $result); }} } #[test] fn always_enabled_if_failure_is_set_to_yes() { test_enabled!(failure: YEA, general: YEA => true); test_enabled!(failure: YEA, general: NOT_SET => true); test_enabled!(failure: YEA, general: NAY => true); } #[test] fn never_enabled_if_failure_is_set_to_no() { test_enabled!(failure: NAY, general: YEA => false); test_enabled!(failure: NAY, general: NOT_SET => false); test_enabled!(failure: NAY, general: NAY => false); } #[test] fn follows_general_if_failure_is_not_set() { test_enabled!(failure: NOT_SET, general: YEA => true); test_enabled!(failure: NOT_SET, general: NOT_SET => false); test_enabled!(failure: NOT_SET, general: NAY => false); } }
use coi::{container, Inject}; use std::sync::Arc; #[derive(Inject)] #[coi(provides Dep1 with Dep1)] struct Dep1; #[derive(Inject)] #[coi(provides Impl1 with Impl1(dep1))] struct Impl1(#[coi(inject = "dep1")] Arc<Dep1>); #[test] fn main() { let container = container! { dep1 => Dep1Provider, impl1 => Impl1Provider, }; let impl1 = container.resolve::<Impl1>("impl1").expect("Should exist"); let _dep1: Arc<Dep1> = Arc::clone(&impl1.0); }
//! To run this code in your own project, first install it: //! //! cargo install rusty_engine --example collider //! //! Then run it in your own project (with the asset pack present) with an image //! placed somewhere in your `assets/` directory. //! //! collider assets/some_image.png //! //! Of course, you could also clone the rusty_engine repository, place your image //! in `assets/` somewhere, and run: //! //! cargo run --release --example collider assets/some_image.png use std::path::PathBuf; use rusty_engine::prelude::*; struct GameState { circle_radius: f32, scale: f32, } impl Default for GameState { fn default() -> Self { Self { circle_radius: 16.0, scale: 1.0, } } } fn main() { // Some trickiness to make assets load relative to the current working directory, which // makes using it from `cargo install rusty_engine --example collider` possible. // This takes advantage of bevy's hard-coded asset loading behavior, and may break in future // bevy versions. std::env::set_var( "CARGO_MANIFEST_DIR", std::env::var("PWD").unwrap_or_default(), ); // Make engine logging a bit quieter since we've got console instructions we want folks to see. std::env::set_var("RUST_LOG", "error"); // We need an image file to work with, so the user must pass in the path of an image let args = std::env::args().skip(1).collect::<Vec<_>>(); if args.len() != 1 { println!( "Please pass in the path of an image inside the `assets/` directory! For example:\n\ cargo run --release --example collider assets/sprite/racing/car_green.png" ); std::process::exit(1); } // Remove "./" or ".\" from the start of the argument if necessary. let mut path: PathBuf = args[0] .as_str() .trim_start_matches("./") .trim_start_matches(r".\") .into(); // If the user passed in `assets/something...` then we need to strip `assets/` (the asset loader will prepend `assets/`) if path.starts_with("assets") { path = path.strip_prefix("assets").unwrap().to_path_buf(); } if !(PathBuf::from("assets").join(&path)).exists() { println!("Couldn't find the file {}", path.to_string_lossy()); std::process::exit(1); } // Start with the "game" part let mut game = Game::new(); game.show_colliders = true; game.window_settings(WindowDescriptor { title: "Collider Creator".into(), ..Default::default() }); let _ = game.add_sprite("sprite", path); // Print instructions to the console println!("\n\ Collider Instructions:\n\ \n\ 1-9: Set Zoom level (sprite scale) to this amount.\n\ Del/Backspace: Delete existing collider.*\n\ Mouse Click: Add a collider point. Add points in a CLOCKWISE direction. Must be a CONVEX polygon to work correctly!\n\ - Hold SHIFT while clicking the mouse to change the LAST point added.\n\ c: Generate a circle collider at the current radius (radius defaults to 16.0)*\n\ +: Increase the radius by 0.5 and generate a circle collider*\n\ -: Decrease the radius by 0.5 and generate a circle collider*\n\ w: Write the collider file. NOTE: This will overwrite the existing collider file (if any), so make a backup if you need the old one!\n\ \n\ *This command deletes the current collider in memory, but only writing the collider file will affect the collider file on disk."); // Tell the user to look to the console for the instructions let msg = game.add_text("msg", "See console output for instructions."); msg.translation = Vec2::new(0.0, -325.0); // Text to let the user know whether or not their polygon is convex let convex = game.add_text("convex", "???"); convex.translation = Vec2::new(0.0, 325.0); game.add_logic(game_logic); game.run(Default::default()); } fn game_logic(engine: &mut Engine, game_state: &mut GameState) { // Zoom levels if engine.keyboard_state.just_pressed(KeyCode::Key1) { game_state.scale = 1.0; } if engine.keyboard_state.just_pressed(KeyCode::Key2) { game_state.scale = 2.0; } if engine.keyboard_state.just_pressed(KeyCode::Key3) { game_state.scale = 3.0; } if engine.keyboard_state.just_pressed(KeyCode::Key4) { game_state.scale = 4.0; } if engine.keyboard_state.just_pressed(KeyCode::Key5) { game_state.scale = 5.0; } if engine.keyboard_state.just_pressed(KeyCode::Key6) { game_state.scale = 6.0; } if engine.keyboard_state.just_pressed(KeyCode::Key7) { game_state.scale = 7.0; } if engine.keyboard_state.just_pressed(KeyCode::Key8) { game_state.scale = 8.0; } if engine.keyboard_state.just_pressed(KeyCode::Key9) { game_state.scale = 9.0; } // Update scale let sprite = engine.sprites.get_mut("sprite").unwrap(); sprite.scale = game_state.scale; // Rotate if engine.mouse_state.pressed(MouseButton::Right) { sprite.rotation += engine.delta_f32 * 6.0; } // Delete collider if engine.keyboard_state.just_pressed(KeyCode::Delete) || engine.keyboard_state.just_pressed(KeyCode::Back) { sprite.collider = Collider::NoCollider; sprite.collider_dirty = true; } // Modify a collider point if engine.mouse_state.just_pressed(MouseButton::Left) { if let Some(location) = engine.mouse_state.location() { let location = (((location / game_state.scale) * 2.0).round() * 0.5) * game_state.scale; if engine .keyboard_state .pressed_any(&[KeyCode::RShift, KeyCode::LShift]) { sprite.change_last_collider_point(location); } else { sprite.add_collider_point(location); } } } // Generate a circle collider if engine .keyboard_state .just_pressed_any(&[KeyCode::Plus, KeyCode::Equals, KeyCode::NumpadAdd]) { game_state.circle_radius += 0.5; } if engine .keyboard_state .just_pressed_any(&[KeyCode::Minus, KeyCode::NumpadSubtract]) { game_state.circle_radius -= 0.5; } if engine.keyboard_state.just_pressed_any(&[ KeyCode::Plus, KeyCode::Equals, KeyCode::NumpadAdd, KeyCode::Minus, KeyCode::NumpadSubtract, KeyCode::C, ]) { sprite.collider = Collider::circle(game_state.circle_radius); sprite.collider_dirty = true; } // Let the user know whether or not their collider is currently convex let convex = engine.texts.get_mut("convex").unwrap(); const CONVEX_MESSAGE: &str = "Convex!"; const NOT_CONVEX_MESSAGE: &str = "Not a convex polygon. :-("; if sprite.collider.is_convex() { if convex.value != CONVEX_MESSAGE { convex.value = CONVEX_MESSAGE.into(); } } else { if convex.value != NOT_CONVEX_MESSAGE { convex.value = NOT_CONVEX_MESSAGE.into(); } } // Write the collider file if engine.keyboard_state.just_pressed(KeyCode::W) { if sprite.write_collider() { println!( "Successfully wrote the new collider file: {}", sprite.collider_filepath.to_string_lossy() ); } else { eprintln!( "Error: unable to write the collider file: {}", sprite.collider_filepath.to_string_lossy() ); } } }
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "Win32_UI_Controls_Dialogs")] pub mod Dialogs; #[cfg(feature = "Win32_UI_Controls_RichEdit")] pub mod RichEdit; #[link(name = "windows")] extern "system" { #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn BeginBufferedAnimation(hwnd: super::super::Foundation::HWND, hdctarget: super::super::Graphics::Gdi::HDC, prctarget: *const super::super::Foundation::RECT, dwformat: BP_BUFFERFORMAT, ppaintparams: *const BP_PAINTPARAMS, panimationparams: *const BP_ANIMATIONPARAMS, phdcfrom: *mut super::super::Graphics::Gdi::HDC, phdcto: *mut super::super::Graphics::Gdi::HDC) -> isize; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn BeginBufferedPaint(hdctarget: super::super::Graphics::Gdi::HDC, prctarget: *const super::super::Foundation::RECT, dwformat: BP_BUFFERFORMAT, ppaintparams: *const BP_PAINTPARAMS, phdc: *mut super::super::Graphics::Gdi::HDC) -> isize; #[cfg(feature = "Win32_Foundation")] pub fn BeginPanningFeedback(hwnd: super::super::Foundation::HWND) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn BufferedPaintClear(hbufferedpaint: isize, prc: *const super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; pub fn BufferedPaintInit() -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn BufferedPaintRenderAnimation(hwnd: super::super::Foundation::HWND, hdctarget: super::super::Graphics::Gdi::HDC) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn BufferedPaintSetAlpha(hbufferedpaint: isize, prc: *const super::super::Foundation::RECT, alpha: u8) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn BufferedPaintStopAllAnimations(hwnd: super::super::Foundation::HWND) -> ::windows_sys::core::HRESULT; pub fn BufferedPaintUnInit() -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn CheckDlgButton(hdlg: super::super::Foundation::HWND, nidbutton: i32, ucheck: DLG_BUTTON_CHECK_STATE) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn CheckRadioButton(hdlg: super::super::Foundation::HWND, nidfirstbutton: i32, nidlastbutton: i32, nidcheckbutton: i32) -> super::super::Foundation::BOOL; pub fn CloseThemeData(htheme: isize) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn CreateMappedBitmap(hinstance: super::super::Foundation::HINSTANCE, idbitmap: isize, wflags: u32, lpcolormap: *const COLORMAP, inummaps: i32) -> super::super::Graphics::Gdi::HBITMAP; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub fn CreatePropertySheetPageA(constpropsheetpagepointer: *mut PROPSHEETPAGEA) -> HPROPSHEETPAGE; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub fn CreatePropertySheetPageW(constpropsheetpagepointer: *mut PROPSHEETPAGEW) -> HPROPSHEETPAGE; #[cfg(feature = "Win32_Foundation")] pub fn CreateStatusWindowA(style: i32, lpsztext: super::super::Foundation::PSTR, hwndparent: super::super::Foundation::HWND, wid: u32) -> super::super::Foundation::HWND; #[cfg(feature = "Win32_Foundation")] pub fn CreateStatusWindowW(style: i32, lpsztext: super::super::Foundation::PWSTR, hwndparent: super::super::Foundation::HWND, wid: u32) -> super::super::Foundation::HWND; #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub fn CreateSyntheticPointerDevice(pointertype: super::WindowsAndMessaging::POINTER_INPUT_TYPE, maxcount: u32, mode: POINTER_FEEDBACK_MODE) -> HSYNTHETICPOINTERDEVICE; #[cfg(feature = "Win32_Foundation")] pub fn CreateToolbarEx(hwnd: super::super::Foundation::HWND, ws: u32, wid: u32, nbitmaps: i32, hbminst: super::super::Foundation::HINSTANCE, wbmid: usize, lpbuttons: *mut TBBUTTON, inumbuttons: i32, dxbutton: i32, dybutton: i32, dxbitmap: i32, dybitmap: i32, ustructsize: u32) -> super::super::Foundation::HWND; #[cfg(feature = "Win32_Foundation")] pub fn CreateUpDownControl(dwstyle: u32, x: i32, y: i32, cx: i32, cy: i32, hparent: super::super::Foundation::HWND, nid: i32, hinst: super::super::Foundation::HINSTANCE, hbuddy: super::super::Foundation::HWND, nupper: i32, nlower: i32, npos: i32) -> super::super::Foundation::HWND; pub fn DPA_Clone(hdpa: HDPA, hdpanew: HDPA) -> HDPA; pub fn DPA_Create(citemgrow: i32) -> HDPA; #[cfg(feature = "Win32_Foundation")] pub fn DPA_CreateEx(cpgrow: i32, hheap: super::super::Foundation::HANDLE) -> HDPA; #[cfg(feature = "Win32_Foundation")] pub fn DPA_DeleteAllPtrs(hdpa: HDPA) -> super::super::Foundation::BOOL; pub fn DPA_DeletePtr(hdpa: HDPA, i: i32) -> *mut ::core::ffi::c_void; #[cfg(feature = "Win32_Foundation")] pub fn DPA_Destroy(hdpa: HDPA) -> super::super::Foundation::BOOL; pub fn DPA_DestroyCallback(hdpa: HDPA, pfncb: PFNDAENUMCALLBACK, pdata: *const ::core::ffi::c_void); pub fn DPA_EnumCallback(hdpa: HDPA, pfncb: PFNDAENUMCALLBACK, pdata: *const ::core::ffi::c_void); pub fn DPA_GetPtr(hdpa: HDPA, i: isize) -> *mut ::core::ffi::c_void; pub fn DPA_GetPtrIndex(hdpa: HDPA, p: *const ::core::ffi::c_void) -> i32; pub fn DPA_GetSize(hdpa: HDPA) -> u64; #[cfg(feature = "Win32_Foundation")] pub fn DPA_Grow(pdpa: HDPA, cp: i32) -> super::super::Foundation::BOOL; pub fn DPA_InsertPtr(hdpa: HDPA, i: i32, p: *const ::core::ffi::c_void) -> i32; #[cfg(feature = "Win32_System_Com")] pub fn DPA_LoadStream(phdpa: *mut HDPA, pfn: PFNDPASTREAM, pstream: super::super::System::Com::IStream, pvinstdata: *const ::core::ffi::c_void) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn DPA_Merge(hdpadest: HDPA, hdpasrc: HDPA, dwflags: u32, pfncompare: PFNDACOMPARE, pfnmerge: PFNDPAMERGE, lparam: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_System_Com")] pub fn DPA_SaveStream(hdpa: HDPA, pfn: PFNDPASTREAM, pstream: super::super::System::Com::IStream, pvinstdata: *const ::core::ffi::c_void) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn DPA_Search(hdpa: HDPA, pfind: *const ::core::ffi::c_void, istart: i32, pfncompare: PFNDACOMPARE, lparam: super::super::Foundation::LPARAM, options: u32) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DPA_SetPtr(hdpa: HDPA, i: i32, p: *const ::core::ffi::c_void) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DPA_Sort(hdpa: HDPA, pfncompare: PFNDACOMPARE, lparam: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL; pub fn DSA_Clone(hdsa: HDSA) -> HDSA; pub fn DSA_Create(cbitem: i32, citemgrow: i32) -> HDSA; #[cfg(feature = "Win32_Foundation")] pub fn DSA_DeleteAllItems(hdsa: HDSA) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DSA_DeleteItem(hdsa: HDSA, i: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DSA_Destroy(hdsa: HDSA) -> super::super::Foundation::BOOL; pub fn DSA_DestroyCallback(hdsa: HDSA, pfncb: PFNDAENUMCALLBACK, pdata: *const ::core::ffi::c_void); pub fn DSA_EnumCallback(hdsa: HDSA, pfncb: PFNDAENUMCALLBACK, pdata: *const ::core::ffi::c_void); #[cfg(feature = "Win32_Foundation")] pub fn DSA_GetItem(hdsa: HDSA, i: i32, pitem: *mut ::core::ffi::c_void) -> super::super::Foundation::BOOL; pub fn DSA_GetItemPtr(hdsa: HDSA, i: i32) -> *mut ::core::ffi::c_void; pub fn DSA_GetSize(hdsa: HDSA) -> u64; pub fn DSA_InsertItem(hdsa: HDSA, i: i32, pitem: *const ::core::ffi::c_void) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DSA_SetItem(hdsa: HDSA, i: i32, pitem: *const ::core::ffi::c_void) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DSA_Sort(pdsa: HDSA, pfncompare: PFNDACOMPARE, lparam: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DestroyPropertySheetPage(param0: HPROPSHEETPAGE) -> super::super::Foundation::BOOL; pub fn DestroySyntheticPointerDevice(device: HSYNTHETICPOINTERDEVICE); #[cfg(feature = "Win32_Foundation")] pub fn DlgDirListA(hdlg: super::super::Foundation::HWND, lppathspec: super::super::Foundation::PSTR, nidlistbox: i32, nidstaticpath: i32, ufiletype: DLG_DIR_LIST_FILE_TYPE) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirListComboBoxA(hdlg: super::super::Foundation::HWND, lppathspec: super::super::Foundation::PSTR, nidcombobox: i32, nidstaticpath: i32, ufiletype: DLG_DIR_LIST_FILE_TYPE) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirListComboBoxW(hdlg: super::super::Foundation::HWND, lppathspec: super::super::Foundation::PWSTR, nidcombobox: i32, nidstaticpath: i32, ufiletype: DLG_DIR_LIST_FILE_TYPE) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirListW(hdlg: super::super::Foundation::HWND, lppathspec: super::super::Foundation::PWSTR, nidlistbox: i32, nidstaticpath: i32, ufiletype: DLG_DIR_LIST_FILE_TYPE) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirSelectComboBoxExA(hwnddlg: super::super::Foundation::HWND, lpstring: super::super::Foundation::PSTR, cchout: i32, idcombobox: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirSelectComboBoxExW(hwnddlg: super::super::Foundation::HWND, lpstring: super::super::Foundation::PWSTR, cchout: i32, idcombobox: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirSelectExA(hwnddlg: super::super::Foundation::HWND, lpstring: super::super::Foundation::PSTR, chcount: i32, idlistbox: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DlgDirSelectExW(hwnddlg: super::super::Foundation::HWND, lpstring: super::super::Foundation::PWSTR, chcount: i32, idlistbox: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn DrawInsert(handparent: super::super::Foundation::HWND, hlb: super::super::Foundation::HWND, nitem: i32); #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawShadowText(hdc: super::super::Graphics::Gdi::HDC, psztext: super::super::Foundation::PWSTR, cch: u32, prc: *const super::super::Foundation::RECT, dwflags: u32, crtext: u32, crshadow: u32, ixoffset: i32, iyoffset: i32) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawStatusTextA(hdc: super::super::Graphics::Gdi::HDC, lprc: *mut super::super::Foundation::RECT, psztext: super::super::Foundation::PSTR, uflags: u32); #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawStatusTextW(hdc: super::super::Graphics::Gdi::HDC, lprc: *mut super::super::Foundation::RECT, psztext: super::super::Foundation::PWSTR, uflags: u32); #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeBackground(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, prect: *const super::super::Foundation::RECT, pcliprect: *const super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeBackgroundEx(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, prect: *const super::super::Foundation::RECT, poptions: *const DTBGOPTS) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeEdge(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, pdestrect: *const super::super::Foundation::RECT, uedge: u32, uflags: u32, pcontentrect: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeIcon(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, prect: *const super::super::Foundation::RECT, himl: HIMAGELIST, iimageindex: i32) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeParentBackground(hwnd: super::super::Foundation::HWND, hdc: super::super::Graphics::Gdi::HDC, prc: *const super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeParentBackgroundEx(hwnd: super::super::Foundation::HWND, hdc: super::super::Graphics::Gdi::HDC, dwflags: DRAW_THEME_PARENT_BACKGROUND_FLAGS, prc: *const super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeText(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, psztext: super::super::Foundation::PWSTR, cchtext: i32, dwtextflags: u32, dwtextflags2: u32, prect: *const super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn DrawThemeTextEx(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, psztext: super::super::Foundation::PWSTR, cchtext: i32, dwtextflags: u32, prect: *mut super::super::Foundation::RECT, poptions: *const DTTOPTS) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn EnableScrollBar(hwnd: super::super::Foundation::HWND, wsbflags: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, warrows: ENABLE_SCROLL_BAR_ARROWS) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn EnableThemeDialogTexture(hwnd: super::super::Foundation::HWND, dwflags: u32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn EnableTheming(fenable: super::super::Foundation::BOOL) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn EndBufferedAnimation(hbpanimation: isize, fupdatetarget: super::super::Foundation::BOOL) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn EndBufferedPaint(hbufferedpaint: isize, fupdatetarget: super::super::Foundation::BOOL) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn EndPanningFeedback(hwnd: super::super::Foundation::HWND, fanimateback: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn EvaluateProximityToPolygon(numvertices: u32, controlpolygon: *const super::super::Foundation::POINT, phittestinginput: *const TOUCH_HIT_TESTING_INPUT, pproximityeval: *mut TOUCH_HIT_TESTING_PROXIMITY_EVALUATION) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn EvaluateProximityToRect(controlboundingbox: *const super::super::Foundation::RECT, phittestinginput: *const TOUCH_HIT_TESTING_INPUT, pproximityeval: *mut TOUCH_HIT_TESTING_PROXIMITY_EVALUATION) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn FlatSB_EnableScrollBar(param0: super::super::Foundation::HWND, param1: i32, param2: u32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_GetScrollInfo(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, param2: *mut super::WindowsAndMessaging::SCROLLINFO) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_GetScrollPos(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn FlatSB_GetScrollProp(param0: super::super::Foundation::HWND, propindex: WSB_PROP, param2: *mut i32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_GetScrollRange(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, param2: *mut i32, param3: *mut i32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_SetScrollInfo(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, psi: *mut super::WindowsAndMessaging::SCROLLINFO, fredraw: super::super::Foundation::BOOL) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_SetScrollPos(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, pos: i32, fredraw: super::super::Foundation::BOOL) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn FlatSB_SetScrollProp(param0: super::super::Foundation::HWND, index: WSB_PROP, newvalue: isize, param3: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_SetScrollRange(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, min: i32, max: i32, fredraw: super::super::Foundation::BOOL) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn FlatSB_ShowScrollBar(param0: super::super::Foundation::HWND, code: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, param2: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetBufferedPaintBits(hbufferedpaint: isize, ppbbuffer: *mut *mut super::super::Graphics::Gdi::RGBQUAD, pcxrow: *mut i32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetBufferedPaintDC(hbufferedpaint: isize) -> super::super::Graphics::Gdi::HDC; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetBufferedPaintTargetDC(hbufferedpaint: isize) -> super::super::Graphics::Gdi::HDC; #[cfg(feature = "Win32_Foundation")] pub fn GetBufferedPaintTargetRect(hbufferedpaint: isize, prc: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetComboBoxInfo(hwndcombo: super::super::Foundation::HWND, pcbi: *mut COMBOBOXINFO) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn GetCurrentThemeName(pszthemefilename: super::super::Foundation::PWSTR, cchmaxnamechars: i32, pszcolorbuff: super::super::Foundation::PWSTR, cchmaxcolorchars: i32, pszsizebuff: super::super::Foundation::PWSTR, cchmaxsizechars: i32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetEffectiveClientRect(hwnd: super::super::Foundation::HWND, lprc: *mut super::super::Foundation::RECT, lpinfo: *const i32); #[cfg(feature = "Win32_Foundation")] pub fn GetListBoxInfo(hwnd: super::super::Foundation::HWND) -> u32; pub fn GetMUILanguage() -> u16; pub fn GetThemeAnimationProperty(htheme: isize, istoryboardid: i32, itargetid: i32, eproperty: TA_PROPERTY, pvproperty: *mut ::core::ffi::c_void, cbsize: u32, pcbsizeout: *mut u32) -> ::windows_sys::core::HRESULT; pub fn GetThemeAnimationTransform(htheme: isize, istoryboardid: i32, itargetid: i32, dwtransformindex: u32, ptransform: *mut TA_TRANSFORM, cbsize: u32, pcbsizeout: *mut u32) -> ::windows_sys::core::HRESULT; pub fn GetThemeAppProperties() -> u32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemeBackgroundContentRect(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, pboundingrect: *const super::super::Foundation::RECT, pcontentrect: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemeBackgroundExtent(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, pcontentrect: *const super::super::Foundation::RECT, pextentrect: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemeBackgroundRegion(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, prect: *const super::super::Foundation::RECT, pregion: *mut super::super::Graphics::Gdi::HRGN) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeBitmap(htheme: isize, ipartid: i32, istateid: i32, ipropid: THEME_PROPERTY_SYMBOL_ID, dwflags: GET_THEME_BITMAP_FLAGS, phbitmap: *mut super::super::Graphics::Gdi::HBITMAP) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeBool(htheme: isize, ipartid: i32, istateid: i32, ipropid: THEME_PROPERTY_SYMBOL_ID, pfval: *mut super::super::Foundation::BOOL) -> ::windows_sys::core::HRESULT; pub fn GetThemeColor(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pcolor: *mut u32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeDocumentationProperty(pszthemename: super::super::Foundation::PWSTR, pszpropertyname: super::super::Foundation::PWSTR, pszvaluebuff: super::super::Foundation::PWSTR, cchmaxvalchars: i32) -> ::windows_sys::core::HRESULT; pub fn GetThemeEnumValue(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pival: *mut i32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeFilename(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pszthemefilename: super::super::Foundation::PWSTR, cchmaxbuffchars: i32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeFont(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, ipropid: i32, pfont: *mut super::super::Graphics::Gdi::LOGFONTW) -> ::windows_sys::core::HRESULT; pub fn GetThemeInt(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pival: *mut i32) -> ::windows_sys::core::HRESULT; pub fn GetThemeIntList(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pintlist: *mut INTLIST) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemeMargins(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, ipropid: i32, prc: *const super::super::Foundation::RECT, pmargins: *mut MARGINS) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeMetric(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, ipropid: THEME_PROPERTY_SYMBOL_ID, pival: *mut i32) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemePartSize(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, prc: *const super::super::Foundation::RECT, esize: THEMESIZE, psz: *mut super::super::Foundation::SIZE) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemePosition(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, ppoint: *mut super::super::Foundation::POINT) -> ::windows_sys::core::HRESULT; pub fn GetThemePropertyOrigin(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, porigin: *mut PROPERTYORIGIN) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeRect(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, prect: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeStream(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, ppvstream: *mut *mut ::core::ffi::c_void, pcbstream: *mut u32, hinst: super::super::Foundation::HINSTANCE) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeString(htheme: isize, ipartid: i32, istateid: i32, ipropid: i32, pszbuff: super::super::Foundation::PWSTR, cchmaxbuffchars: i32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeSysBool(htheme: isize, iboolid: i32) -> super::super::Foundation::BOOL; pub fn GetThemeSysColor(htheme: isize, icolorid: i32) -> u32; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeSysColorBrush(htheme: isize, icolorid: THEME_PROPERTY_SYMBOL_ID) -> super::super::Graphics::Gdi::HBRUSH; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeSysFont(htheme: isize, ifontid: THEME_PROPERTY_SYMBOL_ID, plf: *mut super::super::Graphics::Gdi::LOGFONTW) -> ::windows_sys::core::HRESULT; pub fn GetThemeSysInt(htheme: isize, iintid: i32, pivalue: *mut i32) -> ::windows_sys::core::HRESULT; pub fn GetThemeSysSize(htheme: isize, isizeid: i32) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn GetThemeSysString(htheme: isize, istringid: THEME_PROPERTY_SYMBOL_ID, pszstringbuff: super::super::Foundation::PWSTR, cchmaxstringchars: i32) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn GetThemeTextExtent(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, psztext: super::super::Foundation::PWSTR, cchcharcount: i32, dwtextflags: u32, pboundingrect: *const super::super::Foundation::RECT, pextentrect: *mut super::super::Foundation::RECT) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn GetThemeTextMetrics(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, ptm: *mut super::super::Graphics::Gdi::TEXTMETRICW) -> ::windows_sys::core::HRESULT; pub fn GetThemeTimingFunction(htheme: isize, itimingfunctionid: i32, ptimingfunction: *mut TA_TIMINGFUNCTION, cbsize: u32, pcbsizeout: *mut u32) -> ::windows_sys::core::HRESULT; pub fn GetThemeTransitionDuration(htheme: isize, ipartid: i32, istateidfrom: i32, istateidto: i32, ipropid: i32, pdwduration: *mut u32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn GetWindowFeedbackSetting(hwnd: super::super::Foundation::HWND, feedback: FEEDBACK_TYPE, dwflags: u32, psize: *mut u32, config: *mut ::core::ffi::c_void) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn GetWindowTheme(hwnd: super::super::Foundation::HWND) -> isize; pub fn HIMAGELIST_QueryInterface(himl: HIMAGELIST, riid: *const ::windows_sys::core::GUID, ppv: *mut *mut ::core::ffi::c_void) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn HitTestThemeBackground(htheme: isize, hdc: super::super::Graphics::Gdi::HDC, ipartid: i32, istateid: i32, dwoptions: u32, prect: *const super::super::Foundation::RECT, hrgn: super::super::Graphics::Gdi::HRGN, pttest: super::super::Foundation::POINT, pwhittestcode: *mut u16) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn ImageList_Add(himl: HIMAGELIST, hbmimage: super::super::Graphics::Gdi::HBITMAP, hbmmask: super::super::Graphics::Gdi::HBITMAP) -> i32; #[cfg(feature = "Win32_Graphics_Gdi")] pub fn ImageList_AddMasked(himl: HIMAGELIST, hbmimage: super::super::Graphics::Gdi::HBITMAP, crmask: u32) -> i32; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_BeginDrag(himltrack: HIMAGELIST, itrack: i32, dxhotspot: i32, dyhotspot: i32) -> super::super::Foundation::BOOL; pub fn ImageList_CoCreateInstance(rclsid: *const ::windows_sys::core::GUID, punkouter: ::windows_sys::core::IUnknown, riid: *const ::windows_sys::core::GUID, ppv: *mut *mut ::core::ffi::c_void) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_Copy(himldst: HIMAGELIST, idst: i32, himlsrc: HIMAGELIST, isrc: i32, uflags: IMAGE_LIST_COPY_FLAGS) -> super::super::Foundation::BOOL; pub fn ImageList_Create(cx: i32, cy: i32, flags: IMAGELIST_CREATION_FLAGS, cinitial: i32, cgrow: i32) -> HIMAGELIST; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_Destroy(himl: HIMAGELIST) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_DragEnter(hwndlock: super::super::Foundation::HWND, x: i32, y: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_DragLeave(hwndlock: super::super::Foundation::HWND) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_DragMove(x: i32, y: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_DragShowNolock(fshow: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn ImageList_Draw(himl: HIMAGELIST, i: i32, hdcdst: super::super::Graphics::Gdi::HDC, x: i32, y: i32, fstyle: IMAGE_LIST_DRAW_STYLE) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn ImageList_DrawEx(himl: HIMAGELIST, i: i32, hdcdst: super::super::Graphics::Gdi::HDC, x: i32, y: i32, dx: i32, dy: i32, rgbbk: u32, rgbfg: u32, fstyle: IMAGE_LIST_DRAW_STYLE) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn ImageList_DrawIndirect(pimldp: *const IMAGELISTDRAWPARAMS) -> super::super::Foundation::BOOL; pub fn ImageList_Duplicate(himl: HIMAGELIST) -> HIMAGELIST; pub fn ImageList_EndDrag(); pub fn ImageList_GetBkColor(himl: HIMAGELIST) -> u32; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_GetDragImage(ppt: *mut super::super::Foundation::POINT, ppthotspot: *mut super::super::Foundation::POINT) -> HIMAGELIST; #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub fn ImageList_GetIcon(himl: HIMAGELIST, i: i32, flags: u32) -> super::WindowsAndMessaging::HICON; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_GetIconSize(himl: HIMAGELIST, cx: *mut i32, cy: *mut i32) -> super::super::Foundation::BOOL; pub fn ImageList_GetImageCount(himl: HIMAGELIST) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn ImageList_GetImageInfo(himl: HIMAGELIST, i: i32, pimageinfo: *mut IMAGEINFO) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn ImageList_LoadImageA(hi: super::super::Foundation::HINSTANCE, lpbmp: super::super::Foundation::PSTR, cx: i32, cgrow: i32, crmask: u32, utype: u32, uflags: super::WindowsAndMessaging::IMAGE_FLAGS) -> HIMAGELIST; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn ImageList_LoadImageW(hi: super::super::Foundation::HINSTANCE, lpbmp: super::super::Foundation::PWSTR, cx: i32, cgrow: i32, crmask: u32, utype: u32, uflags: super::WindowsAndMessaging::IMAGE_FLAGS) -> HIMAGELIST; pub fn ImageList_Merge(himl1: HIMAGELIST, i1: i32, himl2: HIMAGELIST, i2: i32, dx: i32, dy: i32) -> HIMAGELIST; #[cfg(feature = "Win32_System_Com")] pub fn ImageList_Read(pstm: super::super::System::Com::IStream) -> HIMAGELIST; #[cfg(feature = "Win32_System_Com")] pub fn ImageList_ReadEx(dwflags: u32, pstm: super::super::System::Com::IStream, riid: *const ::windows_sys::core::GUID, ppv: *mut *mut ::core::ffi::c_void) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_Remove(himl: HIMAGELIST, i: i32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub fn ImageList_Replace(himl: HIMAGELIST, i: i32, hbmimage: super::super::Graphics::Gdi::HBITMAP, hbmmask: super::super::Graphics::Gdi::HBITMAP) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub fn ImageList_ReplaceIcon(himl: HIMAGELIST, i: i32, hicon: super::WindowsAndMessaging::HICON) -> i32; pub fn ImageList_SetBkColor(himl: HIMAGELIST, clrbk: u32) -> u32; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_SetDragCursorImage(himldrag: HIMAGELIST, idrag: i32, dxhotspot: i32, dyhotspot: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_SetIconSize(himl: HIMAGELIST, cx: i32, cy: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_SetImageCount(himl: HIMAGELIST, unewcount: u32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn ImageList_SetOverlayImage(himl: HIMAGELIST, iimage: i32, ioverlay: i32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub fn ImageList_Write(himl: HIMAGELIST, pstm: super::super::System::Com::IStream) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_System_Com")] pub fn ImageList_WriteEx(himl: HIMAGELIST, dwflags: u32, pstm: super::super::System::Com::IStream) -> ::windows_sys::core::HRESULT; pub fn InitCommonControls(); #[cfg(feature = "Win32_Foundation")] pub fn InitCommonControlsEx(picce: *const INITCOMMONCONTROLSEX) -> super::super::Foundation::BOOL; pub fn InitMUILanguage(uilang: u16); #[cfg(feature = "Win32_Foundation")] pub fn InitializeFlatSB(param0: super::super::Foundation::HWND) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsAppThemed() -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsCharLowerW(ch: u16) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsCompositionActive() -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsDlgButtonChecked(hdlg: super::super::Foundation::HWND, nidbutton: i32) -> u32; #[cfg(feature = "Win32_Foundation")] pub fn IsThemeActive() -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsThemeBackgroundPartiallyTransparent(htheme: isize, ipartid: i32, istateid: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsThemeDialogTextureEnabled(hwnd: super::super::Foundation::HWND) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn IsThemePartDefined(htheme: isize, ipartid: i32, istateid: i32) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn LBItemFromPt(hlb: super::super::Foundation::HWND, pt: super::super::Foundation::POINT, bautoscroll: super::super::Foundation::BOOL) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn LoadIconMetric(hinst: super::super::Foundation::HINSTANCE, pszname: super::super::Foundation::PWSTR, lims: _LI_METRIC, phico: *mut super::WindowsAndMessaging::HICON) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn LoadIconWithScaleDown(hinst: super::super::Foundation::HINSTANCE, pszname: super::super::Foundation::PWSTR, cx: i32, cy: i32, phico: *mut super::WindowsAndMessaging::HICON) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn MakeDragList(hlb: super::super::Foundation::HWND) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn MenuHelp(umsg: u32, wparam: super::super::Foundation::WPARAM, lparam: super::super::Foundation::LPARAM, hmainmenu: super::WindowsAndMessaging::HMENU, hinst: super::super::Foundation::HINSTANCE, hwndstatus: super::super::Foundation::HWND, lpwids: *const u32); #[cfg(feature = "Win32_Foundation")] pub fn OpenThemeData(hwnd: super::super::Foundation::HWND, pszclasslist: super::super::Foundation::PWSTR) -> isize; #[cfg(feature = "Win32_Foundation")] pub fn OpenThemeDataEx(hwnd: super::super::Foundation::HWND, pszclasslist: super::super::Foundation::PWSTR, dwflags: OPEN_THEME_DATA_FLAGS) -> isize; #[cfg(feature = "Win32_Foundation")] pub fn PackTouchHitTestingProximityEvaluation(phittestinginput: *const TOUCH_HIT_TESTING_INPUT, pproximityeval: *const TOUCH_HIT_TESTING_PROXIMITY_EVALUATION) -> super::super::Foundation::LRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub fn PropertySheetA(param0: *mut PROPSHEETHEADERA_V2) -> isize; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub fn PropertySheetW(param0: *mut PROPSHEETHEADERW_V2) -> isize; #[cfg(feature = "Win32_Foundation")] pub fn RegisterPointerDeviceNotifications(window: super::super::Foundation::HWND, notifyrange: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn RegisterTouchHitTestingWindow(hwnd: super::super::Foundation::HWND, value: u32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn SetScrollInfo(hwnd: super::super::Foundation::HWND, nbar: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, lpsi: *const super::WindowsAndMessaging::SCROLLINFO, redraw: super::super::Foundation::BOOL) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn SetScrollPos(hwnd: super::super::Foundation::HWND, nbar: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, npos: i32, bredraw: super::super::Foundation::BOOL) -> i32; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn SetScrollRange(hwnd: super::super::Foundation::HWND, nbar: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, nminpos: i32, nmaxpos: i32, bredraw: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; pub fn SetThemeAppProperties(dwflags: u32); #[cfg(feature = "Win32_Foundation")] pub fn SetWindowFeedbackSetting(hwnd: super::super::Foundation::HWND, feedback: FEEDBACK_TYPE, dwflags: u32, size: u32, configuration: *const ::core::ffi::c_void) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn SetWindowTheme(hwnd: super::super::Foundation::HWND, pszsubappname: super::super::Foundation::PWSTR, pszsubidlist: super::super::Foundation::PWSTR) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn SetWindowThemeAttribute(hwnd: super::super::Foundation::HWND, eattribute: WINDOWTHEMEATTRIBUTETYPE, pvattribute: *const ::core::ffi::c_void, cbattribute: u32) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn ShowHideMenuCtl(hwnd: super::super::Foundation::HWND, uflags: usize, lpinfo: *const i32) -> super::super::Foundation::BOOL; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn ShowScrollBar(hwnd: super::super::Foundation::HWND, wbar: super::WindowsAndMessaging::SCROLLBAR_CONSTANTS, bshow: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn Str_SetPtrW(ppsz: *mut super::super::Foundation::PWSTR, psz: super::super::Foundation::PWSTR) -> super::super::Foundation::BOOL; #[cfg(feature = "Win32_Foundation")] pub fn TaskDialog(hwndowner: super::super::Foundation::HWND, hinstance: super::super::Foundation::HINSTANCE, pszwindowtitle: super::super::Foundation::PWSTR, pszmaininstruction: super::super::Foundation::PWSTR, pszcontent: super::super::Foundation::PWSTR, dwcommonbuttons: TASKDIALOG_COMMON_BUTTON_FLAGS, pszicon: super::super::Foundation::PWSTR, pnbutton: *mut i32) -> ::windows_sys::core::HRESULT; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub fn TaskDialogIndirect(ptaskconfig: *const TASKDIALOGCONFIG, pnbutton: *mut i32, pnradiobutton: *mut i32, pfverificationflagchecked: *mut super::super::Foundation::BOOL) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn UninitializeFlatSB(param0: super::super::Foundation::HWND) -> ::windows_sys::core::HRESULT; #[cfg(feature = "Win32_Foundation")] pub fn UpdatePanningFeedback(hwnd: super::super::Foundation::HWND, ltotaloverpanoffsetx: i32, ltotaloverpanoffsety: i32, fininertia: super::super::Foundation::BOOL) -> super::super::Foundation::BOOL; } pub const ACM_ISPLAYING: u32 = 1128u32; pub const ACM_OPEN: u32 = 1127u32; pub const ACM_OPENA: u32 = 1124u32; pub const ACM_OPENW: u32 = 1127u32; pub const ACM_PLAY: u32 = 1125u32; pub const ACM_STOP: u32 = 1126u32; pub const ACN_START: u32 = 1u32; pub const ACN_STOP: u32 = 2u32; pub const ACS_AUTOPLAY: u32 = 4u32; pub const ACS_CENTER: u32 = 1u32; pub const ACS_TIMER: u32 = 8u32; pub const ACS_TRANSPARENT: u32 = 2u32; pub const BCM_FIRST: u32 = 5632u32; pub const BCM_GETIDEALSIZE: u32 = 5633u32; pub const BCM_GETIMAGELIST: u32 = 5635u32; pub const BCM_GETNOTE: u32 = 5642u32; pub const BCM_GETNOTELENGTH: u32 = 5643u32; pub const BCM_GETSPLITINFO: u32 = 5640u32; pub const BCM_GETTEXTMARGIN: u32 = 5637u32; pub const BCM_SETDROPDOWNSTATE: u32 = 5638u32; pub const BCM_SETIMAGELIST: u32 = 5634u32; pub const BCM_SETNOTE: u32 = 5641u32; pub const BCM_SETSHIELD: u32 = 5644u32; pub const BCM_SETSPLITINFO: u32 = 5639u32; pub const BCM_SETTEXTMARGIN: u32 = 5636u32; pub const BCN_DROPDOWN: u32 = 4294966048u32; pub const BCN_FIRST: u32 = 4294966046u32; pub const BCN_HOTITEMCHANGE: u32 = 4294966047u32; pub const BCSIF_GLYPH: u32 = 1u32; pub const BCSIF_IMAGE: u32 = 2u32; pub const BCSIF_SIZE: u32 = 8u32; pub const BCSIF_STYLE: u32 = 4u32; pub const BCSS_ALIGNLEFT: u32 = 4u32; pub const BCSS_IMAGE: u32 = 8u32; pub const BCSS_NOSPLIT: u32 = 1u32; pub const BCSS_STRETCH: u32 = 2u32; pub type BGTYPE = i32; pub const BT_IMAGEFILE: BGTYPE = 0i32; pub const BT_BORDERFILL: BGTYPE = 1i32; pub const BT_NONE: BGTYPE = 2i32; pub type BORDERTYPE = i32; pub const BT_RECT: BORDERTYPE = 0i32; pub const BT_ROUNDRECT: BORDERTYPE = 1i32; pub const BT_ELLIPSE: BORDERTYPE = 2i32; #[repr(C)] pub struct BP_ANIMATIONPARAMS { pub cbSize: u32, pub dwFlags: u32, pub style: BP_ANIMATIONSTYLE, pub dwDuration: u32, } impl ::core::marker::Copy for BP_ANIMATIONPARAMS {} impl ::core::clone::Clone for BP_ANIMATIONPARAMS { fn clone(&self) -> Self { *self } } pub type BP_ANIMATIONSTYLE = i32; pub const BPAS_NONE: BP_ANIMATIONSTYLE = 0i32; pub const BPAS_LINEAR: BP_ANIMATIONSTYLE = 1i32; pub const BPAS_CUBIC: BP_ANIMATIONSTYLE = 2i32; pub const BPAS_SINE: BP_ANIMATIONSTYLE = 3i32; pub type BP_BUFFERFORMAT = i32; pub const BPBF_COMPATIBLEBITMAP: BP_BUFFERFORMAT = 0i32; pub const BPBF_DIB: BP_BUFFERFORMAT = 1i32; pub const BPBF_TOPDOWNDIB: BP_BUFFERFORMAT = 2i32; pub const BPBF_TOPDOWNMONODIB: BP_BUFFERFORMAT = 3i32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct BP_PAINTPARAMS { pub cbSize: u32, pub dwFlags: BP_PAINTPARAMS_FLAGS, pub prcExclude: *mut super::super::Foundation::RECT, pub pBlendFunction: *mut super::super::Graphics::Gdi::BLENDFUNCTION, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for BP_PAINTPARAMS {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for BP_PAINTPARAMS { fn clone(&self) -> Self { *self } } pub type BP_PAINTPARAMS_FLAGS = u32; pub const BPPF_ERASE: BP_PAINTPARAMS_FLAGS = 1u32; pub const BPPF_NOCLIP: BP_PAINTPARAMS_FLAGS = 2u32; pub const BPPF_NONCLIENT: BP_PAINTPARAMS_FLAGS = 4u32; pub const BST_DROPDOWNPUSHED: u32 = 1024u32; pub const BST_HOT: u32 = 512u32; pub const BS_COMMANDLINK: i32 = 14i32; pub const BS_DEFCOMMANDLINK: i32 = 15i32; pub const BS_DEFSPLITBUTTON: i32 = 13i32; pub const BS_SPLITBUTTON: i32 = 12i32; pub const BTNS_AUTOSIZE: u32 = 16u32; pub const BTNS_BUTTON: u32 = 0u32; pub const BTNS_CHECK: u32 = 2u32; pub const BTNS_DROPDOWN: u32 = 8u32; pub const BTNS_GROUP: u32 = 4u32; pub const BTNS_NOPREFIX: u32 = 32u32; pub const BTNS_SEP: u32 = 1u32; pub const BTNS_SHOWTEXT: u32 = 64u32; pub const BTNS_WHOLEDROPDOWN: u32 = 128u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct BUTTON_IMAGELIST { pub himl: HIMAGELIST, pub margin: super::super::Foundation::RECT, pub uAlign: BUTTON_IMAGELIST_ALIGN, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for BUTTON_IMAGELIST {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for BUTTON_IMAGELIST { fn clone(&self) -> Self { *self } } pub type BUTTON_IMAGELIST_ALIGN = u32; pub const BUTTON_IMAGELIST_ALIGN_LEFT: BUTTON_IMAGELIST_ALIGN = 0u32; pub const BUTTON_IMAGELIST_ALIGN_RIGHT: BUTTON_IMAGELIST_ALIGN = 1u32; pub const BUTTON_IMAGELIST_ALIGN_TOP: BUTTON_IMAGELIST_ALIGN = 2u32; pub const BUTTON_IMAGELIST_ALIGN_BOTTOM: BUTTON_IMAGELIST_ALIGN = 3u32; pub const BUTTON_IMAGELIST_ALIGN_CENTER: BUTTON_IMAGELIST_ALIGN = 4u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct BUTTON_SPLITINFO { pub mask: u32, pub himlGlyph: HIMAGELIST, pub uSplitStyle: u32, pub size: super::super::Foundation::SIZE, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for BUTTON_SPLITINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for BUTTON_SPLITINFO { fn clone(&self) -> Self { *self } } pub const CBEMAXSTRLEN: u32 = 260u32; pub const CBEM_GETCOMBOCONTROL: u32 = 1030u32; pub const CBEM_GETEDITCONTROL: u32 = 1031u32; pub const CBEM_GETEXSTYLE: u32 = 1033u32; pub const CBEM_GETEXTENDEDSTYLE: u32 = 1033u32; pub const CBEM_GETIMAGELIST: u32 = 1027u32; pub const CBEM_GETITEM: u32 = 1037u32; pub const CBEM_GETITEMA: u32 = 1028u32; pub const CBEM_GETITEMW: u32 = 1037u32; pub const CBEM_GETUNICODEFORMAT: u32 = 8198u32; pub const CBEM_HASEDITCHANGED: u32 = 1034u32; pub const CBEM_INSERTITEM: u32 = 1035u32; pub const CBEM_INSERTITEMA: u32 = 1025u32; pub const CBEM_INSERTITEMW: u32 = 1035u32; pub const CBEM_SETEXSTYLE: u32 = 1032u32; pub const CBEM_SETEXTENDEDSTYLE: u32 = 1038u32; pub const CBEM_SETIMAGELIST: u32 = 1026u32; pub const CBEM_SETITEM: u32 = 1036u32; pub const CBEM_SETITEMA: u32 = 1029u32; pub const CBEM_SETITEMW: u32 = 1036u32; pub const CBEM_SETUNICODEFORMAT: u32 = 8197u32; pub const CBEM_SETWINDOWTHEME: u32 = 8203u32; pub const CBENF_DROPDOWN: u32 = 4u32; pub const CBENF_ESCAPE: u32 = 3u32; pub const CBENF_KILLFOCUS: u32 = 1u32; pub const CBENF_RETURN: u32 = 2u32; pub const CBES_EX_CASESENSITIVE: u32 = 16u32; pub const CBES_EX_NOEDITIMAGE: u32 = 1u32; pub const CBES_EX_NOEDITIMAGEINDENT: u32 = 2u32; pub const CBES_EX_NOSIZELIMIT: u32 = 8u32; pub const CBES_EX_PATHWORDBREAKPROC: u32 = 4u32; pub const CBES_EX_TEXTENDELLIPSIS: u32 = 32u32; pub const CBM_FIRST: u32 = 5888u32; pub const CB_GETCUEBANNER: u32 = 5892u32; pub const CB_GETMINVISIBLE: u32 = 5890u32; pub const CB_SETCUEBANNER: u32 = 5891u32; pub const CB_SETMINVISIBLE: u32 = 5889u32; pub const CCF_NOTEXT: u32 = 1u32; pub const CCHCCCLASS: u32 = 32u32; pub const CCHCCDESC: u32 = 32u32; pub const CCHCCTEXT: u32 = 256u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct CCINFOA { pub szClass: [super::super::Foundation::CHAR; 32], pub flOptions: u32, pub szDesc: [super::super::Foundation::CHAR; 32], pub cxDefault: u32, pub cyDefault: u32, pub flStyleDefault: u32, pub flExtStyleDefault: u32, pub flCtrlTypeMask: u32, pub szTextDefault: [super::super::Foundation::CHAR; 256], pub cStyleFlags: i32, pub aStyleFlags: *mut CCSTYLEFLAGA, pub lpfnStyle: LPFNCCSTYLEA, pub lpfnSizeToText: LPFNCCSIZETOTEXTA, pub dwReserved1: u32, pub dwReserved2: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for CCINFOA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for CCINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct CCINFOW { pub szClass: [u16; 32], pub flOptions: u32, pub szDesc: [u16; 32], pub cxDefault: u32, pub cyDefault: u32, pub flStyleDefault: u32, pub flExtStyleDefault: u32, pub flCtrlTypeMask: u32, pub cStyleFlags: i32, pub aStyleFlags: *mut CCSTYLEFLAGW, pub szTextDefault: [u16; 256], pub lpfnStyle: LPFNCCSTYLEW, pub lpfnSizeToText: LPFNCCSIZETOTEXTW, pub dwReserved1: u32, pub dwReserved2: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for CCINFOW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for CCINFOW { fn clone(&self) -> Self { *self } } pub const CCM_DPISCALE: u32 = 8204u32; pub const CCM_FIRST: u32 = 8192u32; pub const CCM_GETCOLORSCHEME: u32 = 8195u32; pub const CCM_GETDROPTARGET: u32 = 8196u32; pub const CCM_GETUNICODEFORMAT: u32 = 8198u32; pub const CCM_GETVERSION: u32 = 8200u32; pub const CCM_LAST: u32 = 8704u32; pub const CCM_SETBKCOLOR: u32 = 8193u32; pub const CCM_SETCOLORSCHEME: u32 = 8194u32; pub const CCM_SETNOTIFYWINDOW: u32 = 8201u32; pub const CCM_SETUNICODEFORMAT: u32 = 8197u32; pub const CCM_SETVERSION: u32 = 8199u32; pub const CCM_SETWINDOWTHEME: u32 = 8203u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct CCSTYLEA { pub flStyle: u32, pub flExtStyle: u32, pub szText: [super::super::Foundation::CHAR; 256], pub lgid: u16, pub wReserved1: u16, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for CCSTYLEA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for CCSTYLEA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct CCSTYLEFLAGA { pub flStyle: u32, pub flStyleMask: u32, pub pszStyle: super::super::Foundation::PSTR, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for CCSTYLEFLAGA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for CCSTYLEFLAGA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct CCSTYLEFLAGW { pub flStyle: u32, pub flStyleMask: u32, pub pszStyle: super::super::Foundation::PWSTR, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for CCSTYLEFLAGW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for CCSTYLEFLAGW { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct CCSTYLEW { pub flStyle: u32, pub flExtStyle: u32, pub szText: [u16; 256], pub lgid: u16, pub wReserved1: u16, } impl ::core::marker::Copy for CCSTYLEW {} impl ::core::clone::Clone for CCSTYLEW { fn clone(&self) -> Self { *self } } pub const CCS_ADJUSTABLE: i32 = 32i32; pub const CCS_BOTTOM: i32 = 3i32; pub const CCS_NODIVIDER: i32 = 64i32; pub const CCS_NOMOVEY: i32 = 2i32; pub const CCS_NOPARENTALIGN: i32 = 8i32; pub const CCS_NORESIZE: i32 = 4i32; pub const CCS_TOP: i32 = 1i32; pub const CCS_VERT: i32 = 128i32; pub const CDDS_ITEM: u32 = 65536u32; pub const CDDS_POSTERASE: u32 = 4u32; pub const CDIS_CHECKED: u32 = 8u32; pub const CDIS_DEFAULT: u32 = 32u32; pub const CDIS_DISABLED: u32 = 4u32; pub const CDIS_DROPHILITED: u32 = 4096u32; pub const CDIS_FOCUS: u32 = 16u32; pub const CDIS_GRAYED: u32 = 2u32; pub const CDIS_HOT: u32 = 64u32; pub const CDIS_INDETERMINATE: u32 = 256u32; pub const CDIS_MARKED: u32 = 128u32; pub const CDIS_NEARHOT: u32 = 1024u32; pub const CDIS_OTHERSIDEHOT: u32 = 2048u32; pub const CDIS_SELECTED: u32 = 1u32; pub const CDIS_SHOWKEYBOARDCUES: u32 = 512u32; pub const CDRF_DODEFAULT: u32 = 0u32; pub const CDRF_DOERASE: u32 = 8u32; pub const CDRF_NEWFONT: u32 = 2u32; pub const CDRF_NOTIFYITEMDRAW: u32 = 32u32; pub const CDRF_NOTIFYPOSTERASE: u32 = 64u32; pub const CDRF_NOTIFYPOSTPAINT: u32 = 16u32; pub const CDRF_NOTIFYSUBITEMDRAW: u32 = 32u32; pub const CDRF_SKIPDEFAULT: u32 = 4u32; pub const CDRF_SKIPPOSTPAINT: u32 = 256u32; pub type CLOCKPARTS = i32; pub const CLP_TIME: CLOCKPARTS = 1i32; pub type CLOCKSTATES = i32; pub const CLS_NORMAL: CLOCKSTATES = 1i32; pub const CLS_HOT: CLOCKSTATES = 2i32; pub const CLS_PRESSED: CLOCKSTATES = 3i32; pub const CLR_DEFAULT: i32 = -16777216i32; pub const CLR_HILIGHT: i32 = -16777216i32; pub const CLR_NONE: i32 = -1i32; pub const CMB_MASKED: u32 = 2u32; #[repr(C)] pub struct COLORMAP { pub from: u32, pub to: u32, } impl ::core::marker::Copy for COLORMAP {} impl ::core::clone::Clone for COLORMAP { fn clone(&self) -> Self { *self } } pub const COLORMGMTDLGORD: u32 = 1551u32; #[repr(C)] pub struct COLORSCHEME { pub dwSize: u32, pub clrBtnHighlight: u32, pub clrBtnShadow: u32, } impl ::core::marker::Copy for COLORSCHEME {} impl ::core::clone::Clone for COLORSCHEME { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct COMBOBOXEXITEMA { pub mask: COMBOBOX_EX_ITEM_FLAGS, pub iItem: isize, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub iOverlay: i32, pub iIndent: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for COMBOBOXEXITEMA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for COMBOBOXEXITEMA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct COMBOBOXEXITEMW { pub mask: COMBOBOX_EX_ITEM_FLAGS, pub iItem: isize, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub iOverlay: i32, pub iIndent: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for COMBOBOXEXITEMW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for COMBOBOXEXITEMW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct COMBOBOXINFO { pub cbSize: u32, pub rcItem: super::super::Foundation::RECT, pub rcButton: super::super::Foundation::RECT, pub stateButton: COMBOBOXINFO_BUTTON_STATE, pub hwndCombo: super::super::Foundation::HWND, pub hwndItem: super::super::Foundation::HWND, pub hwndList: super::super::Foundation::HWND, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for COMBOBOXINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for COMBOBOXINFO { fn clone(&self) -> Self { *self } } pub type COMBOBOXINFO_BUTTON_STATE = u32; pub const STATE_SYSTEM_INVISIBLE: COMBOBOXINFO_BUTTON_STATE = 32768u32; pub const STATE_SYSTEM_PRESSED: COMBOBOXINFO_BUTTON_STATE = 8u32; pub const STATE_SYSTEM_FOCUSABLE: COMBOBOXINFO_BUTTON_STATE = 1048576u32; pub const STATE_SYSTEM_OFFSCREEN: COMBOBOXINFO_BUTTON_STATE = 65536u32; pub const STATE_SYSTEM_UNAVAILABLE: COMBOBOXINFO_BUTTON_STATE = 1u32; pub type COMBOBOX_EX_ITEM_FLAGS = u32; pub const CBEIF_DI_SETITEM: COMBOBOX_EX_ITEM_FLAGS = 268435456u32; pub const CBEIF_IMAGE: COMBOBOX_EX_ITEM_FLAGS = 2u32; pub const CBEIF_INDENT: COMBOBOX_EX_ITEM_FLAGS = 16u32; pub const CBEIF_LPARAM: COMBOBOX_EX_ITEM_FLAGS = 32u32; pub const CBEIF_OVERLAY: COMBOBOX_EX_ITEM_FLAGS = 8u32; pub const CBEIF_SELECTEDIMAGE: COMBOBOX_EX_ITEM_FLAGS = 4u32; pub const CBEIF_TEXT: COMBOBOX_EX_ITEM_FLAGS = 1u32; pub const COMCTL32_VERSION: u32 = 6u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct COMPAREITEMSTRUCT { pub CtlType: u32, pub CtlID: u32, pub hwndItem: super::super::Foundation::HWND, pub itemID1: u32, pub itemData1: usize, pub itemID2: u32, pub itemData2: usize, pub dwLocaleId: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for COMPAREITEMSTRUCT {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for COMPAREITEMSTRUCT { fn clone(&self) -> Self { *self } } pub type CONTENTALIGNMENT = i32; pub const CA_LEFT: CONTENTALIGNMENT = 0i32; pub const CA_CENTER: CONTENTALIGNMENT = 1i32; pub const CA_RIGHT: CONTENTALIGNMENT = 2i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct DATETIMEPICKERINFO { pub cbSize: u32, pub rcCheck: super::super::Foundation::RECT, pub stateCheck: u32, pub rcButton: super::super::Foundation::RECT, pub stateButton: u32, pub hwndEdit: super::super::Foundation::HWND, pub hwndUD: super::super::Foundation::HWND, pub hwndDropDown: super::super::Foundation::HWND, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for DATETIMEPICKERINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for DATETIMEPICKERINFO { fn clone(&self) -> Self { *self } } pub const DA_ERR: i32 = -1i32; pub const DA_LAST: u32 = 2147483647u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct DELETEITEMSTRUCT { pub CtlType: DRAWITEMSTRUCT_CTL_TYPE, pub CtlID: u32, pub itemID: u32, pub hwndItem: super::super::Foundation::HWND, pub itemData: usize, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for DELETEITEMSTRUCT {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for DELETEITEMSTRUCT { fn clone(&self) -> Self { *self } } pub type DLG_BUTTON_CHECK_STATE = u32; pub const BST_CHECKED: DLG_BUTTON_CHECK_STATE = 1u32; pub const BST_INDETERMINATE: DLG_BUTTON_CHECK_STATE = 2u32; pub const BST_UNCHECKED: DLG_BUTTON_CHECK_STATE = 0u32; pub type DLG_DIR_LIST_FILE_TYPE = u32; pub const DDL_ARCHIVE: DLG_DIR_LIST_FILE_TYPE = 32u32; pub const DDL_DIRECTORY: DLG_DIR_LIST_FILE_TYPE = 16u32; pub const DDL_DRIVES: DLG_DIR_LIST_FILE_TYPE = 16384u32; pub const DDL_EXCLUSIVE: DLG_DIR_LIST_FILE_TYPE = 32768u32; pub const DDL_HIDDEN: DLG_DIR_LIST_FILE_TYPE = 2u32; pub const DDL_READONLY: DLG_DIR_LIST_FILE_TYPE = 1u32; pub const DDL_READWRITE: DLG_DIR_LIST_FILE_TYPE = 0u32; pub const DDL_SYSTEM: DLG_DIR_LIST_FILE_TYPE = 4u32; pub const DDL_POSTMSGS: DLG_DIR_LIST_FILE_TYPE = 8192u32; pub const DL_COPYCURSOR: u32 = 2u32; pub const DL_CURSORSET: u32 = 0u32; pub const DL_MOVECURSOR: u32 = 3u32; pub const DL_STOPCURSOR: u32 = 1u32; pub type DPAMM_MESSAGE = u32; pub const DPAMM_MERGE: DPAMM_MESSAGE = 1u32; pub const DPAMM_DELETE: DPAMM_MESSAGE = 2u32; pub const DPAMM_INSERT: DPAMM_MESSAGE = 3u32; pub const DPAM_INTERSECT: u32 = 8u32; pub const DPAM_NORMAL: u32 = 2u32; pub const DPAM_SORTED: u32 = 1u32; pub const DPAM_UNION: u32 = 4u32; #[repr(C)] pub struct DPASTREAMINFO { pub iPos: i32, pub pvItem: *mut ::core::ffi::c_void, } impl ::core::marker::Copy for DPASTREAMINFO {} impl ::core::clone::Clone for DPASTREAMINFO { fn clone(&self) -> Self { *self } } pub const DPAS_INSERTAFTER: u32 = 4u32; pub const DPAS_INSERTBEFORE: u32 = 2u32; pub const DPAS_SORTED: u32 = 1u32; pub const DPA_APPEND: u32 = 2147483647u32; pub const DPA_ERR: i32 = -1i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct DRAGLISTINFO { pub uNotification: DRAGLISTINFO_NOTIFICATION_FLAGS, pub hWnd: super::super::Foundation::HWND, pub ptCursor: super::super::Foundation::POINT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for DRAGLISTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for DRAGLISTINFO { fn clone(&self) -> Self { *self } } pub type DRAGLISTINFO_NOTIFICATION_FLAGS = u32; pub const DL_BEGINDRAG: DRAGLISTINFO_NOTIFICATION_FLAGS = 1157u32; pub const DL_CANCELDRAG: DRAGLISTINFO_NOTIFICATION_FLAGS = 1160u32; pub const DL_DRAGGING: DRAGLISTINFO_NOTIFICATION_FLAGS = 1158u32; pub const DL_DROPPED: DRAGLISTINFO_NOTIFICATION_FLAGS = 1159u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct DRAWITEMSTRUCT { pub CtlType: DRAWITEMSTRUCT_CTL_TYPE, pub CtlID: u32, pub itemID: u32, pub itemAction: u32, pub itemState: u32, pub hwndItem: super::super::Foundation::HWND, pub hDC: super::super::Graphics::Gdi::HDC, pub rcItem: super::super::Foundation::RECT, pub itemData: usize, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for DRAWITEMSTRUCT {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for DRAWITEMSTRUCT { fn clone(&self) -> Self { *self } } pub type DRAWITEMSTRUCT_CTL_TYPE = u32; pub const ODT_BUTTON: DRAWITEMSTRUCT_CTL_TYPE = 4u32; pub const ODT_COMBOBOX: DRAWITEMSTRUCT_CTL_TYPE = 3u32; pub const ODT_LISTBOX: DRAWITEMSTRUCT_CTL_TYPE = 2u32; pub const ODT_LISTVIEW: DRAWITEMSTRUCT_CTL_TYPE = 102u32; pub const ODT_MENU: DRAWITEMSTRUCT_CTL_TYPE = 1u32; pub const ODT_STATIC: DRAWITEMSTRUCT_CTL_TYPE = 5u32; pub const ODT_TAB: DRAWITEMSTRUCT_CTL_TYPE = 101u32; pub type DRAW_THEME_PARENT_BACKGROUND_FLAGS = u32; pub const DTPB_WINDOWDC: DRAW_THEME_PARENT_BACKGROUND_FLAGS = 1u32; pub const DTPB_USECTLCOLORSTATIC: DRAW_THEME_PARENT_BACKGROUND_FLAGS = 2u32; pub const DTPB_USEERASEBKGND: DRAW_THEME_PARENT_BACKGROUND_FLAGS = 4u32; pub const DSA_APPEND: u32 = 2147483647u32; pub const DSA_ERR: i32 = -1i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct DTBGOPTS { pub dwSize: u32, pub dwFlags: u32, pub rcClip: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for DTBGOPTS {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for DTBGOPTS { fn clone(&self) -> Self { *self } } pub const DTBG_CLIPRECT: u32 = 1u32; pub const DTBG_COMPUTINGREGION: u32 = 16u32; pub const DTBG_DRAWSOLID: u32 = 2u32; pub const DTBG_MIRRORDC: u32 = 32u32; pub const DTBG_NOMIRROR: u32 = 64u32; pub const DTBG_OMITBORDER: u32 = 4u32; pub const DTBG_OMITCONTENT: u32 = 8u32; pub const DTM_CLOSEMONTHCAL: u32 = 4109u32; pub const DTM_FIRST: u32 = 4096u32; pub const DTM_GETDATETIMEPICKERINFO: u32 = 4110u32; pub const DTM_GETIDEALSIZE: u32 = 4111u32; pub const DTM_GETMCCOLOR: u32 = 4103u32; pub const DTM_GETMCFONT: u32 = 4106u32; pub const DTM_GETMCSTYLE: u32 = 4108u32; pub const DTM_GETMONTHCAL: u32 = 4104u32; pub const DTM_GETRANGE: u32 = 4099u32; pub const DTM_GETSYSTEMTIME: u32 = 4097u32; pub const DTM_SETFORMAT: u32 = 4146u32; pub const DTM_SETFORMATA: u32 = 4101u32; pub const DTM_SETFORMATW: u32 = 4146u32; pub const DTM_SETMCCOLOR: u32 = 4102u32; pub const DTM_SETMCFONT: u32 = 4105u32; pub const DTM_SETMCSTYLE: u32 = 4107u32; pub const DTM_SETRANGE: u32 = 4100u32; pub const DTM_SETSYSTEMTIME: u32 = 4098u32; pub const DTS_APPCANPARSE: u32 = 16u32; pub const DTS_LONGDATEFORMAT: u32 = 4u32; pub const DTS_RIGHTALIGN: u32 = 32u32; pub const DTS_SHORTDATECENTURYFORMAT: u32 = 12u32; pub const DTS_SHORTDATEFORMAT: u32 = 0u32; pub const DTS_SHOWNONE: u32 = 2u32; pub const DTS_TIMEFORMAT: u32 = 9u32; pub const DTS_UPDOWN: u32 = 1u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct DTTOPTS { pub dwSize: u32, pub dwFlags: u32, pub crText: u32, pub crBorder: u32, pub crShadow: u32, pub iTextShadowType: i32, pub ptShadowOffset: super::super::Foundation::POINT, pub iBorderSize: i32, pub iFontPropId: i32, pub iColorPropId: i32, pub iStateId: i32, pub fApplyOverlay: super::super::Foundation::BOOL, pub iGlowSize: i32, pub pfnDrawTextCallback: DTT_CALLBACK_PROC, pub lParam: super::super::Foundation::LPARAM, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for DTTOPTS {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for DTTOPTS { fn clone(&self) -> Self { *self } } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub type DTT_CALLBACK_PROC = ::core::option::Option<unsafe extern "system" fn(hdc: super::super::Graphics::Gdi::HDC, psztext: super::super::Foundation::PWSTR, cchtext: i32, prc: *mut super::super::Foundation::RECT, dwflags: u32, lparam: super::super::Foundation::LPARAM) -> i32>; pub const DTT_FLAGS2VALIDBITS: u32 = 1u32; pub const DTT_GRAYED: u32 = 1u32; pub const ECM_FIRST: u32 = 5376u32; pub type EC_ENDOFLINE = i32; pub const EC_ENDOFLINE_DETECTFROMCONTENT: EC_ENDOFLINE = 0i32; pub const EC_ENDOFLINE_CRLF: EC_ENDOFLINE = 1i32; pub const EC_ENDOFLINE_CR: EC_ENDOFLINE = 2i32; pub const EC_ENDOFLINE_LF: EC_ENDOFLINE = 3i32; pub type EC_SEARCHWEB_ENTRYPOINT = i32; pub const EC_SEARCHWEB_ENTRYPOINT_EXTERNAL: EC_SEARCHWEB_ENTRYPOINT = 0i32; pub const EC_SEARCHWEB_ENTRYPOINT_CONTEXTMENU: EC_SEARCHWEB_ENTRYPOINT = 1i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct EDITBALLOONTIP { pub cbStruct: u32, pub pszTitle: super::super::Foundation::PWSTR, pub pszText: super::super::Foundation::PWSTR, pub ttiIcon: EDITBALLOONTIP_ICON, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for EDITBALLOONTIP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for EDITBALLOONTIP { fn clone(&self) -> Self { *self } } pub type EDITBALLOONTIP_ICON = u32; pub const TTI_ERROR: EDITBALLOONTIP_ICON = 3u32; pub const TTI_INFO: EDITBALLOONTIP_ICON = 1u32; pub const TTI_NONE: EDITBALLOONTIP_ICON = 0u32; pub const TTI_WARNING: EDITBALLOONTIP_ICON = 2u32; pub const TTI_INFO_LARGE: EDITBALLOONTIP_ICON = 4u32; pub const TTI_WARNING_LARGE: EDITBALLOONTIP_ICON = 5u32; pub const TTI_ERROR_LARGE: EDITBALLOONTIP_ICON = 6u32; #[cfg(feature = "Win32_Foundation")] pub type EDITWORDBREAKPROCA = ::core::option::Option<unsafe extern "system" fn(lpch: super::super::Foundation::PSTR, ichcurrent: i32, cch: i32, code: WORD_BREAK_ACTION) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type EDITWORDBREAKPROCW = ::core::option::Option<unsafe extern "system" fn(lpch: super::super::Foundation::PWSTR, ichcurrent: i32, cch: i32, code: WORD_BREAK_ACTION) -> i32>; pub type EMPTYMARKUPPARTS = i32; pub const EMP_MARKUPTEXT: EMPTYMARKUPPARTS = 1i32; pub const EM_CANUNDO: u32 = 198u32; pub const EM_CHARFROMPOS: u32 = 215u32; pub const EM_EMPTYUNDOBUFFER: u32 = 205u32; pub const EM_ENABLEFEATURE: u32 = 218u32; pub const EM_ENABLESEARCHWEB: u32 = 5390u32; pub const EM_FILELINEFROMCHAR: u32 = 5395u32; pub const EM_FILELINEINDEX: u32 = 5396u32; pub const EM_FILELINELENGTH: u32 = 5397u32; pub const EM_FMTLINES: u32 = 200u32; pub const EM_GETCARETINDEX: u32 = 5394u32; pub const EM_GETCUEBANNER: u32 = 5378u32; pub const EM_GETENDOFLINE: u32 = 5389u32; pub const EM_GETEXTENDEDSTYLE: u32 = 5387u32; pub const EM_GETFILELINE: u32 = 5398u32; pub const EM_GETFILELINECOUNT: u32 = 5399u32; pub const EM_GETFIRSTVISIBLELINE: u32 = 206u32; pub const EM_GETHANDLE: u32 = 189u32; pub const EM_GETHILITE: u32 = 5382u32; pub const EM_GETIMESTATUS: u32 = 217u32; pub const EM_GETLIMITTEXT: u32 = 213u32; pub const EM_GETLINE: u32 = 196u32; pub const EM_GETLINECOUNT: u32 = 186u32; pub const EM_GETMARGINS: u32 = 212u32; pub const EM_GETMODIFY: u32 = 184u32; pub const EM_GETPASSWORDCHAR: u32 = 210u32; pub const EM_GETRECT: u32 = 178u32; pub const EM_GETSEL: u32 = 176u32; pub const EM_GETTHUMB: u32 = 190u32; pub const EM_GETWORDBREAKPROC: u32 = 209u32; pub const EM_HIDEBALLOONTIP: u32 = 5380u32; pub const EM_LIMITTEXT: u32 = 197u32; pub const EM_LINEFROMCHAR: u32 = 201u32; pub const EM_LINEINDEX: u32 = 187u32; pub const EM_LINELENGTH: u32 = 193u32; pub const EM_LINESCROLL: u32 = 182u32; pub const EM_NOSETFOCUS: u32 = 5383u32; pub const EM_POSFROMCHAR: u32 = 214u32; pub const EM_REPLACESEL: u32 = 194u32; pub const EM_SCROLL: u32 = 181u32; pub const EM_SCROLLCARET: u32 = 183u32; pub const EM_SEARCHWEB: u32 = 5391u32; pub const EM_SETCARETINDEX: u32 = 5393u32; pub const EM_SETCUEBANNER: u32 = 5377u32; pub const EM_SETENDOFLINE: u32 = 5388u32; pub const EM_SETEXTENDEDSTYLE: u32 = 5386u32; pub const EM_SETHANDLE: u32 = 188u32; pub const EM_SETHILITE: u32 = 5381u32; pub const EM_SETIMESTATUS: u32 = 216u32; pub const EM_SETLIMITTEXT: u32 = 197u32; pub const EM_SETMARGINS: u32 = 211u32; pub const EM_SETMODIFY: u32 = 185u32; pub const EM_SETPASSWORDCHAR: u32 = 204u32; pub const EM_SETREADONLY: u32 = 207u32; pub const EM_SETRECT: u32 = 179u32; pub const EM_SETRECTNP: u32 = 180u32; pub const EM_SETSEL: u32 = 177u32; pub const EM_SETTABSTOPS: u32 = 203u32; pub const EM_SETWORDBREAKPROC: u32 = 208u32; pub const EM_SHOWBALLOONTIP: u32 = 5379u32; pub const EM_TAKEFOCUS: u32 = 5384u32; pub const EM_UNDO: u32 = 199u32; pub type ENABLE_SCROLL_BAR_ARROWS = u32; pub const ESB_DISABLE_BOTH: ENABLE_SCROLL_BAR_ARROWS = 3u32; pub const ESB_DISABLE_DOWN: ENABLE_SCROLL_BAR_ARROWS = 2u32; pub const ESB_DISABLE_LEFT: ENABLE_SCROLL_BAR_ARROWS = 1u32; pub const ESB_DISABLE_LTUP: ENABLE_SCROLL_BAR_ARROWS = 1u32; pub const ESB_DISABLE_RIGHT: ENABLE_SCROLL_BAR_ARROWS = 2u32; pub const ESB_DISABLE_RTDN: ENABLE_SCROLL_BAR_ARROWS = 2u32; pub const ESB_DISABLE_UP: ENABLE_SCROLL_BAR_ARROWS = 1u32; pub const ESB_ENABLE_BOTH: ENABLE_SCROLL_BAR_ARROWS = 0u32; pub const ES_EX_ALLOWEOL_CR: i32 = 1i32; pub const ES_EX_ALLOWEOL_LF: i32 = 2i32; pub const ES_EX_CONVERT_EOL_ON_PASTE: i32 = 4i32; pub const ES_EX_ZOOMABLE: i32 = 16i32; pub const ETDT_DISABLE: u32 = 1u32; pub const ETDT_ENABLE: u32 = 2u32; pub const ETDT_USEAEROWIZARDTABTEXTURE: u32 = 8u32; pub const ETDT_USETABTEXTURE: u32 = 4u32; pub type FEEDBACK_TYPE = i32; pub const FEEDBACK_TOUCH_CONTACTVISUALIZATION: FEEDBACK_TYPE = 1i32; pub const FEEDBACK_PEN_BARRELVISUALIZATION: FEEDBACK_TYPE = 2i32; pub const FEEDBACK_PEN_TAP: FEEDBACK_TYPE = 3i32; pub const FEEDBACK_PEN_DOUBLETAP: FEEDBACK_TYPE = 4i32; pub const FEEDBACK_PEN_PRESSANDHOLD: FEEDBACK_TYPE = 5i32; pub const FEEDBACK_PEN_RIGHTTAP: FEEDBACK_TYPE = 6i32; pub const FEEDBACK_TOUCH_TAP: FEEDBACK_TYPE = 7i32; pub const FEEDBACK_TOUCH_DOUBLETAP: FEEDBACK_TYPE = 8i32; pub const FEEDBACK_TOUCH_PRESSANDHOLD: FEEDBACK_TYPE = 9i32; pub const FEEDBACK_TOUCH_RIGHTTAP: FEEDBACK_TYPE = 10i32; pub const FEEDBACK_GESTURE_PRESSANDTAP: FEEDBACK_TYPE = 11i32; pub const FEEDBACK_MAX: FEEDBACK_TYPE = -1i32; pub const FILEOPENORD: u32 = 1536u32; pub type FILLTYPE = i32; pub const FT_SOLID: FILLTYPE = 0i32; pub const FT_VERTGRADIENT: FILLTYPE = 1i32; pub const FT_HORZGRADIENT: FILLTYPE = 2i32; pub const FT_RADIALGRADIENT: FILLTYPE = 3i32; pub const FT_TILEIMAGE: FILLTYPE = 4i32; pub const FINDDLGORD: u32 = 1540u32; pub const FONTDLGORD: u32 = 1542u32; pub const FORMATDLGORD30: u32 = 1544u32; pub const FORMATDLGORD31: u32 = 1543u32; pub const FSB_ENCARTA_MODE: u32 = 1u32; pub const FSB_FLAT_MODE: u32 = 2u32; pub const FSB_REGULAR_MODE: u32 = 0u32; pub const GDTR_MAX: u32 = 2u32; pub const GDTR_MIN: u32 = 1u32; pub const GDT_ERROR: i32 = -1i32; pub const GDT_NONE: u32 = 1u32; pub const GDT_VALID: u32 = 0u32; pub type GET_THEME_BITMAP_FLAGS = u32; pub const GBF_DIRECT: GET_THEME_BITMAP_FLAGS = 1u32; pub const GBF_COPY: GET_THEME_BITMAP_FLAGS = 2u32; pub const GBF_VALIDBITS: GET_THEME_BITMAP_FLAGS = 3u32; pub type GLYPHFONTSIZINGTYPE = i32; pub const GFST_NONE: GLYPHFONTSIZINGTYPE = 0i32; pub const GFST_SIZE: GLYPHFONTSIZINGTYPE = 1i32; pub const GFST_DPI: GLYPHFONTSIZINGTYPE = 2i32; pub type GLYPHTYPE = i32; pub const GT_NONE: GLYPHTYPE = 0i32; pub const GT_IMAGEGLYPH: GLYPHTYPE = 1i32; pub const GT_FONTGLYPH: GLYPHTYPE = 2i32; pub const GMR_DAYSTATE: u32 = 1u32; pub const GMR_VISIBLE: u32 = 0u32; pub type GRIDCELLBACKGROUNDSTATES = i32; pub const MCGCB_SELECTED: GRIDCELLBACKGROUNDSTATES = 1i32; pub const MCGCB_HOT: GRIDCELLBACKGROUNDSTATES = 2i32; pub const MCGCB_SELECTEDHOT: GRIDCELLBACKGROUNDSTATES = 3i32; pub const MCGCB_SELECTEDNOTFOCUSED: GRIDCELLBACKGROUNDSTATES = 4i32; pub const MCGCB_TODAY: GRIDCELLBACKGROUNDSTATES = 5i32; pub const MCGCB_TODAYSELECTED: GRIDCELLBACKGROUNDSTATES = 6i32; pub type GRIDCELLSTATES = i32; pub const MCGC_HOT: GRIDCELLSTATES = 1i32; pub const MCGC_HASSTATE: GRIDCELLSTATES = 2i32; pub const MCGC_HASSTATEHOT: GRIDCELLSTATES = 3i32; pub const MCGC_TODAY: GRIDCELLSTATES = 4i32; pub const MCGC_TODAYSELECTED: GRIDCELLSTATES = 5i32; pub const MCGC_SELECTED: GRIDCELLSTATES = 6i32; pub const MCGC_SELECTEDHOT: GRIDCELLSTATES = 7i32; pub type GRIDCELLUPPERSTATES = i32; pub const MCGCU_HOT: GRIDCELLUPPERSTATES = 1i32; pub const MCGCU_HASSTATE: GRIDCELLUPPERSTATES = 2i32; pub const MCGCU_HASSTATEHOT: GRIDCELLUPPERSTATES = 3i32; pub const MCGCU_SELECTED: GRIDCELLUPPERSTATES = 4i32; pub const MCGCU_SELECTEDHOT: GRIDCELLUPPERSTATES = 5i32; pub type HALIGN = i32; pub const HA_LEFT: HALIGN = 0i32; pub const HA_CENTER: HALIGN = 1i32; pub const HA_RIGHT: HALIGN = 2i32; pub const HDFT_HASNOVALUE: u32 = 32768u32; pub const HDFT_ISDATE: u32 = 2u32; pub const HDFT_ISNUMBER: u32 = 1u32; pub const HDFT_ISSTRING: u32 = 0u32; pub const HDF_BITMAP: u32 = 8192u32; pub const HDF_BITMAP_ON_RIGHT: u32 = 4096u32; pub const HDF_CENTER: u32 = 2u32; pub const HDF_CHECKBOX: u32 = 64u32; pub const HDF_CHECKED: u32 = 128u32; pub const HDF_FIXEDWIDTH: u32 = 256u32; pub const HDF_IMAGE: u32 = 2048u32; pub const HDF_JUSTIFYMASK: u32 = 3u32; pub const HDF_LEFT: u32 = 0u32; pub const HDF_OWNERDRAW: u32 = 32768u32; pub const HDF_RIGHT: u32 = 1u32; pub const HDF_RTLREADING: u32 = 4u32; pub const HDF_SORTDOWN: u32 = 512u32; pub const HDF_SORTUP: u32 = 1024u32; pub const HDF_SPLITBUTTON: u32 = 16777216u32; pub const HDF_STRING: u32 = 16384u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct HDHITTESTINFO { pub pt: super::super::Foundation::POINT, pub flags: u32, pub iItem: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for HDHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for HDHITTESTINFO { fn clone(&self) -> Self { *self } } pub const HDIS_FOCUSED: u32 = 1u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct HDITEMA { pub mask: HDI_MASK, pub cxy: i32, pub pszText: super::super::Foundation::PSTR, pub hbm: super::super::Graphics::Gdi::HBITMAP, pub cchTextMax: i32, pub fmt: i32, pub lParam: super::super::Foundation::LPARAM, pub iImage: i32, pub iOrder: i32, pub r#type: u32, pub pvFilter: *mut ::core::ffi::c_void, pub state: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for HDITEMA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for HDITEMA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct HDITEMW { pub mask: HDI_MASK, pub cxy: i32, pub pszText: super::super::Foundation::PWSTR, pub hbm: super::super::Graphics::Gdi::HBITMAP, pub cchTextMax: i32, pub fmt: i32, pub lParam: super::super::Foundation::LPARAM, pub iImage: i32, pub iOrder: i32, pub r#type: u32, pub pvFilter: *mut ::core::ffi::c_void, pub state: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for HDITEMW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for HDITEMW { fn clone(&self) -> Self { *self } } pub type HDI_MASK = u32; pub const HDI_WIDTH: HDI_MASK = 1u32; pub const HDI_HEIGHT: HDI_MASK = 1u32; pub const HDI_TEXT: HDI_MASK = 2u32; pub const HDI_FORMAT: HDI_MASK = 4u32; pub const HDI_LPARAM: HDI_MASK = 8u32; pub const HDI_BITMAP: HDI_MASK = 16u32; pub const HDI_IMAGE: HDI_MASK = 32u32; pub const HDI_DI_SETITEM: HDI_MASK = 64u32; pub const HDI_ORDER: HDI_MASK = 128u32; pub const HDI_FILTER: HDI_MASK = 256u32; pub const HDI_STATE: HDI_MASK = 512u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub struct HDLAYOUT { pub prc: *mut super::super::Foundation::RECT, pub pwpos: *mut super::WindowsAndMessaging::WINDOWPOS, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for HDLAYOUT {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for HDLAYOUT { fn clone(&self) -> Self { *self } } pub const HDM_CLEARFILTER: u32 = 4632u32; pub const HDM_CREATEDRAGIMAGE: u32 = 4624u32; pub const HDM_DELETEITEM: u32 = 4610u32; pub const HDM_EDITFILTER: u32 = 4631u32; pub const HDM_FIRST: u32 = 4608u32; pub const HDM_GETBITMAPMARGIN: u32 = 4629u32; pub const HDM_GETFOCUSEDITEM: u32 = 4635u32; pub const HDM_GETIMAGELIST: u32 = 4617u32; pub const HDM_GETITEM: u32 = 4619u32; pub const HDM_GETITEMA: u32 = 4611u32; pub const HDM_GETITEMCOUNT: u32 = 4608u32; pub const HDM_GETITEMDROPDOWNRECT: u32 = 4633u32; pub const HDM_GETITEMRECT: u32 = 4615u32; pub const HDM_GETITEMW: u32 = 4619u32; pub const HDM_GETORDERARRAY: u32 = 4625u32; pub const HDM_GETOVERFLOWRECT: u32 = 4634u32; pub const HDM_GETUNICODEFORMAT: u32 = 8198u32; pub const HDM_HITTEST: u32 = 4614u32; pub const HDM_INSERTITEM: u32 = 4618u32; pub const HDM_INSERTITEMA: u32 = 4609u32; pub const HDM_INSERTITEMW: u32 = 4618u32; pub const HDM_LAYOUT: u32 = 4613u32; pub const HDM_ORDERTOINDEX: u32 = 4623u32; pub const HDM_SETBITMAPMARGIN: u32 = 4628u32; pub const HDM_SETFILTERCHANGETIMEOUT: u32 = 4630u32; pub const HDM_SETFOCUSEDITEM: u32 = 4636u32; pub const HDM_SETHOTDIVIDER: u32 = 4627u32; pub const HDM_SETIMAGELIST: u32 = 4616u32; pub const HDM_SETITEM: u32 = 4620u32; pub const HDM_SETITEMA: u32 = 4612u32; pub const HDM_SETITEMW: u32 = 4620u32; pub const HDM_SETORDERARRAY: u32 = 4626u32; pub const HDM_SETUNICODEFORMAT: u32 = 8197u32; pub type HDPA = isize; pub type HDSA = isize; pub const HDSIL_NORMAL: u32 = 0u32; pub const HDSIL_STATE: u32 = 1u32; pub const HDS_BUTTONS: u32 = 2u32; pub const HDS_CHECKBOXES: u32 = 1024u32; pub const HDS_DRAGDROP: u32 = 64u32; pub const HDS_FILTERBAR: u32 = 256u32; pub const HDS_FLAT: u32 = 512u32; pub const HDS_FULLDRAG: u32 = 128u32; pub const HDS_HIDDEN: u32 = 8u32; pub const HDS_HORZ: u32 = 0u32; pub const HDS_HOTTRACK: u32 = 4u32; pub const HDS_NOSIZING: u32 = 2048u32; pub const HDS_OVERFLOW: u32 = 4096u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct HD_TEXTFILTERA { pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for HD_TEXTFILTERA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for HD_TEXTFILTERA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct HD_TEXTFILTERW { pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for HD_TEXTFILTERW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for HD_TEXTFILTERW { fn clone(&self) -> Self { *self } } pub type HEADER_CONTROL_NOTIFICATION_BUTTON = u32; pub const HEADER_CONTROL_NOTIFICATION_BUTTON_LEFT: HEADER_CONTROL_NOTIFICATION_BUTTON = 0u32; pub const HEADER_CONTROL_NOTIFICATION_BUTTON_RIGHT: HEADER_CONTROL_NOTIFICATION_BUTTON = 1u32; pub const HEADER_CONTROL_NOTIFICATION_BUTTON_MIDDLE: HEADER_CONTROL_NOTIFICATION_BUTTON = 2u32; pub const HHT_ABOVE: u32 = 256u32; pub const HHT_BELOW: u32 = 512u32; pub const HHT_NOWHERE: u32 = 1u32; pub const HHT_ONDIVIDER: u32 = 4u32; pub const HHT_ONDIVOPEN: u32 = 8u32; pub const HHT_ONDROPDOWN: u32 = 8192u32; pub const HHT_ONFILTER: u32 = 16u32; pub const HHT_ONFILTERBUTTON: u32 = 32u32; pub const HHT_ONHEADER: u32 = 2u32; pub const HHT_ONITEMSTATEICON: u32 = 4096u32; pub const HHT_ONOVERFLOW: u32 = 16384u32; pub const HHT_TOLEFT: u32 = 2048u32; pub const HHT_TORIGHT: u32 = 1024u32; pub type HIMAGELIST = isize; pub const HIST_ADDTOFAVORITES: u32 = 3u32; pub const HIST_BACK: u32 = 0u32; pub const HIST_FAVORITES: u32 = 2u32; pub const HIST_FORWARD: u32 = 1u32; pub const HIST_VIEWTREE: u32 = 4u32; pub const HKCOMB_A: u32 = 8u32; pub const HKCOMB_C: u32 = 4u32; pub const HKCOMB_CA: u32 = 64u32; pub const HKCOMB_NONE: u32 = 1u32; pub const HKCOMB_S: u32 = 2u32; pub const HKCOMB_SA: u32 = 32u32; pub const HKCOMB_SC: u32 = 16u32; pub const HKCOMB_SCA: u32 = 128u32; pub const HKM_GETHOTKEY: u32 = 1026u32; pub const HKM_SETHOTKEY: u32 = 1025u32; pub const HKM_SETRULES: u32 = 1027u32; pub const HOTKEYF_ALT: u32 = 4u32; pub const HOTKEYF_CONTROL: u32 = 2u32; pub const HOTKEYF_EXT: u32 = 128u32; pub const HOTKEYF_SHIFT: u32 = 1u32; pub const HOVER_DEFAULT: u32 = 4294967295u32; pub type HPROPSHEETPAGE = isize; pub type HSYNTHETICPOINTERDEVICE = isize; pub type HTREEITEM = isize; pub const HTTB_BACKGROUNDSEG: u32 = 0u32; pub const HTTB_CAPTION: u32 = 4u32; pub const HTTB_FIXEDBORDER: u32 = 2u32; pub const HTTB_RESIZINGBORDER_BOTTOM: u32 = 128u32; pub const HTTB_RESIZINGBORDER_LEFT: u32 = 16u32; pub const HTTB_RESIZINGBORDER_RIGHT: u32 = 64u32; pub const HTTB_RESIZINGBORDER_TOP: u32 = 32u32; pub const HTTB_SIZINGTEMPLATE: u32 = 256u32; pub const HTTB_SYSTEMSIZINGMARGINS: u32 = 512u32; pub type HYPERLINKSTATES = i32; pub const HLS_NORMALTEXT: HYPERLINKSTATES = 1i32; pub const HLS_LINKTEXT: HYPERLINKSTATES = 2i32; pub type ICONEFFECT = i32; pub const ICE_NONE: ICONEFFECT = 0i32; pub const ICE_GLOW: ICONEFFECT = 1i32; pub const ICE_SHADOW: ICONEFFECT = 2i32; pub const ICE_PULSE: ICONEFFECT = 3i32; pub const ICE_ALPHA: ICONEFFECT = 4i32; pub const IDB_HIST_DISABLED: u32 = 14u32; pub const IDB_HIST_HOT: u32 = 13u32; pub const IDB_HIST_LARGE_COLOR: u32 = 9u32; pub const IDB_HIST_NORMAL: u32 = 12u32; pub const IDB_HIST_PRESSED: u32 = 15u32; pub const IDB_HIST_SMALL_COLOR: u32 = 8u32; pub const IDB_STD_LARGE_COLOR: u32 = 1u32; pub const IDB_STD_SMALL_COLOR: u32 = 0u32; pub const IDB_VIEW_LARGE_COLOR: u32 = 5u32; pub const IDB_VIEW_SMALL_COLOR: u32 = 4u32; pub const IDC_MANAGE_LINK: u32 = 1592u32; pub const ID_PSRESTARTWINDOWS: u32 = 2u32; pub type IImageList = *mut ::core::ffi::c_void; pub type IImageList2 = *mut ::core::ffi::c_void; pub const ILDI_PURGE: u32 = 1u32; pub const ILDI_QUERYACCESS: u32 = 8u32; pub const ILDI_RESETACCESS: u32 = 4u32; pub const ILDI_STANDBY: u32 = 2u32; pub const ILDRF_IMAGELOWQUALITY: u32 = 1u32; pub const ILDRF_OVERLAYLOWQUALITY: u32 = 16u32; pub const ILD_ASYNC: u32 = 32768u32; pub const ILD_BLEND25: u32 = 2u32; pub const ILD_DPISCALE: u32 = 16384u32; pub const ILD_IMAGE: u32 = 32u32; pub const ILD_OVERLAYMASK: u32 = 3840u32; pub const ILD_PRESERVEALPHA: u32 = 4096u32; pub const ILD_ROP: u32 = 64u32; pub const ILD_SCALE: u32 = 8192u32; pub const ILD_TRANSPARENT: u32 = 1u32; pub const ILFIP_ALWAYS: u32 = 0u32; pub const ILFIP_FROMSTANDBY: u32 = 1u32; pub const ILGOS_ALWAYS: u32 = 0u32; pub const ILGOS_FROMSTANDBY: u32 = 1u32; pub const ILGT_ASYNC: u32 = 1u32; pub const ILGT_NORMAL: u32 = 0u32; pub const ILP_DOWNLEVEL: u32 = 1u32; pub const ILP_NORMAL: u32 = 0u32; pub const ILR_DEFAULT: u32 = 0u32; pub const ILR_HORIZONTAL_CENTER: u32 = 1u32; pub const ILR_HORIZONTAL_LEFT: u32 = 0u32; pub const ILR_HORIZONTAL_RIGHT: u32 = 2u32; pub const ILR_SCALE_ASPECTRATIO: u32 = 256u32; pub const ILR_SCALE_CLIP: u32 = 0u32; pub const ILR_VERTICAL_BOTTOM: u32 = 32u32; pub const ILR_VERTICAL_CENTER: u32 = 16u32; pub const ILR_VERTICAL_TOP: u32 = 0u32; pub const ILS_ALPHA: u32 = 8u32; pub const ILS_GLOW: u32 = 1u32; pub const ILS_NORMAL: u32 = 0u32; pub const ILS_SATURATE: u32 = 4u32; pub const ILS_SHADOW: u32 = 2u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct IMAGEINFO { pub hbmImage: super::super::Graphics::Gdi::HBITMAP, pub hbmMask: super::super::Graphics::Gdi::HBITMAP, pub Unused1: i32, pub Unused2: i32, pub rcImage: super::super::Foundation::RECT, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for IMAGEINFO {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for IMAGEINFO { fn clone(&self) -> Self { *self } } pub type IMAGELAYOUT = i32; pub const IL_VERTICAL: IMAGELAYOUT = 0i32; pub const IL_HORIZONTAL: IMAGELAYOUT = 1i32; #[repr(C)] #[cfg(feature = "Win32_Graphics_Gdi")] pub struct IMAGELISTDRAWPARAMS { pub cbSize: u32, pub himl: HIMAGELIST, pub i: i32, pub hdcDst: super::super::Graphics::Gdi::HDC, pub x: i32, pub y: i32, pub cx: i32, pub cy: i32, pub xBitmap: i32, pub yBitmap: i32, pub rgbBk: u32, pub rgbFg: u32, pub fStyle: u32, pub dwRop: u32, pub fState: u32, pub Frame: u32, pub crEffect: u32, } #[cfg(feature = "Win32_Graphics_Gdi")] impl ::core::marker::Copy for IMAGELISTDRAWPARAMS {} #[cfg(feature = "Win32_Graphics_Gdi")] impl ::core::clone::Clone for IMAGELISTDRAWPARAMS { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct IMAGELISTSTATS { pub cbSize: u32, pub cAlloc: i32, pub cUsed: i32, pub cStandby: i32, } impl ::core::marker::Copy for IMAGELISTSTATS {} impl ::core::clone::Clone for IMAGELISTSTATS { fn clone(&self) -> Self { *self } } pub type IMAGELIST_CREATION_FLAGS = u32; pub const ILC_MASK: IMAGELIST_CREATION_FLAGS = 1u32; pub const ILC_COLOR: IMAGELIST_CREATION_FLAGS = 0u32; pub const ILC_COLORDDB: IMAGELIST_CREATION_FLAGS = 254u32; pub const ILC_COLOR4: IMAGELIST_CREATION_FLAGS = 4u32; pub const ILC_COLOR8: IMAGELIST_CREATION_FLAGS = 8u32; pub const ILC_COLOR16: IMAGELIST_CREATION_FLAGS = 16u32; pub const ILC_COLOR24: IMAGELIST_CREATION_FLAGS = 24u32; pub const ILC_COLOR32: IMAGELIST_CREATION_FLAGS = 32u32; pub const ILC_PALETTE: IMAGELIST_CREATION_FLAGS = 2048u32; pub const ILC_MIRROR: IMAGELIST_CREATION_FLAGS = 8192u32; pub const ILC_PERITEMMIRROR: IMAGELIST_CREATION_FLAGS = 32768u32; pub const ILC_ORIGINALSIZE: IMAGELIST_CREATION_FLAGS = 65536u32; pub const ILC_HIGHQUALITYSCALE: IMAGELIST_CREATION_FLAGS = 131072u32; pub type IMAGESELECTTYPE = i32; pub const IST_NONE: IMAGESELECTTYPE = 0i32; pub const IST_SIZE: IMAGESELECTTYPE = 1i32; pub const IST_DPI: IMAGESELECTTYPE = 2i32; pub type IMAGE_LIST_COPY_FLAGS = u32; pub const ILCF_MOVE: IMAGE_LIST_COPY_FLAGS = 0u32; pub const ILCF_SWAP: IMAGE_LIST_COPY_FLAGS = 1u32; pub type IMAGE_LIST_DRAW_STYLE = u32; pub const ILD_BLEND: IMAGE_LIST_DRAW_STYLE = 4u32; pub const ILD_BLEND50: IMAGE_LIST_DRAW_STYLE = 4u32; pub const ILD_FOCUS: IMAGE_LIST_DRAW_STYLE = 2u32; pub const ILD_MASK: IMAGE_LIST_DRAW_STYLE = 16u32; pub const ILD_NORMAL: IMAGE_LIST_DRAW_STYLE = 0u32; pub const ILD_SELECTED: IMAGE_LIST_DRAW_STYLE = 4u32; pub type IMAGE_LIST_ITEM_FLAGS = u32; pub const ILIF_ALPHA: IMAGE_LIST_ITEM_FLAGS = 1u32; pub const ILIF_LOWQUALITY: IMAGE_LIST_ITEM_FLAGS = 2u32; pub const INFOTIPSIZE: u32 = 1024u32; #[repr(C)] pub struct INITCOMMONCONTROLSEX { pub dwSize: u32, pub dwICC: INITCOMMONCONTROLSEX_ICC, } impl ::core::marker::Copy for INITCOMMONCONTROLSEX {} impl ::core::clone::Clone for INITCOMMONCONTROLSEX { fn clone(&self) -> Self { *self } } pub type INITCOMMONCONTROLSEX_ICC = u32; pub const ICC_ANIMATE_CLASS: INITCOMMONCONTROLSEX_ICC = 128u32; pub const ICC_BAR_CLASSES: INITCOMMONCONTROLSEX_ICC = 4u32; pub const ICC_COOL_CLASSES: INITCOMMONCONTROLSEX_ICC = 1024u32; pub const ICC_DATE_CLASSES: INITCOMMONCONTROLSEX_ICC = 256u32; pub const ICC_HOTKEY_CLASS: INITCOMMONCONTROLSEX_ICC = 64u32; pub const ICC_INTERNET_CLASSES: INITCOMMONCONTROLSEX_ICC = 2048u32; pub const ICC_LINK_CLASS: INITCOMMONCONTROLSEX_ICC = 32768u32; pub const ICC_LISTVIEW_CLASSES: INITCOMMONCONTROLSEX_ICC = 1u32; pub const ICC_NATIVEFNTCTL_CLASS: INITCOMMONCONTROLSEX_ICC = 8192u32; pub const ICC_PAGESCROLLER_CLASS: INITCOMMONCONTROLSEX_ICC = 4096u32; pub const ICC_PROGRESS_CLASS: INITCOMMONCONTROLSEX_ICC = 32u32; pub const ICC_STANDARD_CLASSES: INITCOMMONCONTROLSEX_ICC = 16384u32; pub const ICC_TAB_CLASSES: INITCOMMONCONTROLSEX_ICC = 8u32; pub const ICC_TREEVIEW_CLASSES: INITCOMMONCONTROLSEX_ICC = 2u32; pub const ICC_UPDOWN_CLASS: INITCOMMONCONTROLSEX_ICC = 16u32; pub const ICC_USEREX_CLASSES: INITCOMMONCONTROLSEX_ICC = 512u32; pub const ICC_WIN95_CLASSES: INITCOMMONCONTROLSEX_ICC = 255u32; #[repr(C)] pub struct INTLIST { pub iValueCount: i32, pub iValues: [i32; 402], } impl ::core::marker::Copy for INTLIST {} impl ::core::clone::Clone for INTLIST { fn clone(&self) -> Self { *self } } pub const INVALID_LINK_INDEX: i32 = -1i32; pub const IPM_CLEARADDRESS: u32 = 1124u32; pub const IPM_GETADDRESS: u32 = 1126u32; pub const IPM_ISBLANK: u32 = 1129u32; pub const IPM_SETADDRESS: u32 = 1125u32; pub const IPM_SETFOCUS: u32 = 1128u32; pub const IPM_SETRANGE: u32 = 1127u32; pub const I_IMAGECALLBACK: i32 = -1i32; pub const I_IMAGENONE: i32 = -2i32; pub const I_INDENTCALLBACK: i32 = -1i32; pub const ImageList: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 2085055394, data2: 689, data3: 18676, data4: [128, 72, 178, 70, 25, 221, 192, 88] }; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LHITTESTINFO { pub pt: super::super::Foundation::POINT, pub item: LITEM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LHITTESTINFO { fn clone(&self) -> Self { *self } } pub const LIF_ITEMID: u32 = 4u32; pub const LIF_ITEMINDEX: u32 = 1u32; pub const LIF_STATE: u32 = 2u32; pub const LIF_URL: u32 = 8u32; pub type LINKPARTS = i32; pub const LP_HYPERLINK: LINKPARTS = 1i32; pub const LIS_DEFAULTCOLORS: u32 = 16u32; pub const LIS_ENABLED: u32 = 2u32; pub const LIS_FOCUSED: u32 = 1u32; pub const LIS_HOTTRACK: u32 = 8u32; pub const LIS_VISITED: u32 = 4u32; #[repr(C)] pub struct LITEM { pub mask: u32, pub iLink: i32, pub state: u32, pub stateMask: u32, pub szID: [u16; 48], pub szUrl: [u16; 2084], } impl ::core::marker::Copy for LITEM {} impl ::core::clone::Clone for LITEM { fn clone(&self) -> Self { *self } } pub const LM_GETIDEALHEIGHT: u32 = 1793u32; pub const LM_GETIDEALSIZE: u32 = 1793u32; pub const LM_GETITEM: u32 = 1795u32; pub const LM_HITTEST: u32 = 1792u32; pub const LM_SETITEM: u32 = 1794u32; pub type LOGOFFBUTTONSSTATES = i32; pub const SPLS_NORMAL: LOGOFFBUTTONSSTATES = 1i32; pub const SPLS_HOT: LOGOFFBUTTONSSTATES = 2i32; pub const SPLS_PRESSED: LOGOFFBUTTONSSTATES = 3i32; #[cfg(feature = "Win32_Foundation")] pub type LPFNADDPROPSHEETPAGES = ::core::option::Option<unsafe extern "system" fn(param0: *mut ::core::ffi::c_void, param1: LPFNSVADDPROPSHEETPAGE, param2: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub type LPFNCCINFOA = ::core::option::Option<unsafe extern "system" fn(acci: *mut CCINFOA) -> u32>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub type LPFNCCINFOW = ::core::option::Option<unsafe extern "system" fn(acci: *mut CCINFOW) -> u32>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub type LPFNCCSIZETOTEXTA = ::core::option::Option<unsafe extern "system" fn(flstyle: u32, flextstyle: u32, hfont: super::super::Graphics::Gdi::HFONT, psztext: super::super::Foundation::PSTR) -> i32>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub type LPFNCCSIZETOTEXTW = ::core::option::Option<unsafe extern "system" fn(flstyle: u32, flextstyle: u32, hfont: super::super::Graphics::Gdi::HFONT, psztext: super::super::Foundation::PWSTR) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type LPFNCCSTYLEA = ::core::option::Option<unsafe extern "system" fn(hwndparent: super::super::Foundation::HWND, pccs: *mut CCSTYLEA) -> super::super::Foundation::BOOL>; #[cfg(feature = "Win32_Foundation")] pub type LPFNCCSTYLEW = ::core::option::Option<unsafe extern "system" fn(hwndparent: super::super::Foundation::HWND, pccs: *mut CCSTYLEW) -> super::super::Foundation::BOOL>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub type LPFNPSPCALLBACKA = ::core::option::Option<unsafe extern "system" fn(hwnd: super::super::Foundation::HWND, umsg: PSPCB_MESSAGE, ppsp: *mut PROPSHEETPAGEA) -> u32>; #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub type LPFNPSPCALLBACKW = ::core::option::Option<unsafe extern "system" fn(hwnd: super::super::Foundation::HWND, umsg: PSPCB_MESSAGE, ppsp: *mut PROPSHEETPAGEW) -> u32>; #[cfg(feature = "Win32_Foundation")] pub type LPFNSVADDPROPSHEETPAGE = ::core::option::Option<unsafe extern "system" fn(param0: HPROPSHEETPAGE, param1: super::super::Foundation::LPARAM) -> super::super::Foundation::BOOL>; pub const LVA_ALIGNLEFT: u32 = 1u32; pub const LVA_ALIGNTOP: u32 = 2u32; pub const LVA_DEFAULT: u32 = 0u32; pub const LVA_SNAPTOGRID: u32 = 5u32; pub const LVBKIF_FLAG_ALPHABLEND: u32 = 536870912u32; pub const LVBKIF_FLAG_TILEOFFSET: u32 = 256u32; pub const LVBKIF_SOURCE_HBITMAP: u32 = 1u32; pub const LVBKIF_SOURCE_MASK: u32 = 3u32; pub const LVBKIF_SOURCE_NONE: u32 = 0u32; pub const LVBKIF_SOURCE_URL: u32 = 2u32; pub const LVBKIF_STYLE_MASK: u32 = 16u32; pub const LVBKIF_STYLE_NORMAL: u32 = 0u32; pub const LVBKIF_STYLE_TILE: u32 = 16u32; pub const LVBKIF_TYPE_WATERMARK: u32 = 268435456u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct LVBKIMAGEA { pub ulFlags: u32, pub hbm: super::super::Graphics::Gdi::HBITMAP, pub pszImage: super::super::Foundation::PSTR, pub cchImageMax: u32, pub xOffsetPercent: i32, pub yOffsetPercent: i32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for LVBKIMAGEA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for LVBKIMAGEA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct LVBKIMAGEW { pub ulFlags: u32, pub hbm: super::super::Graphics::Gdi::HBITMAP, pub pszImage: super::super::Foundation::PWSTR, pub cchImageMax: u32, pub xOffsetPercent: i32, pub yOffsetPercent: i32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for LVBKIMAGEW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for LVBKIMAGEW { fn clone(&self) -> Self { *self } } pub const LVCDRF_NOGROUPFRAME: u32 = 131072u32; pub const LVCDRF_NOSELECT: u32 = 65536u32; pub const LVCFMT_FILL: u32 = 2097152u32; pub const LVCFMT_LINE_BREAK: u32 = 1048576u32; pub const LVCFMT_NO_TITLE: u32 = 8388608u32; pub const LVCFMT_WRAP: u32 = 4194304u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVCOLUMNA { pub mask: LVCOLUMNW_MASK, pub fmt: LVCOLUMNW_FORMAT, pub cx: i32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iSubItem: i32, pub iImage: i32, pub iOrder: i32, pub cxMin: i32, pub cxDefault: i32, pub cxIdeal: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVCOLUMNA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVCOLUMNA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVCOLUMNW { pub mask: LVCOLUMNW_MASK, pub fmt: LVCOLUMNW_FORMAT, pub cx: i32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iSubItem: i32, pub iImage: i32, pub iOrder: i32, pub cxMin: i32, pub cxDefault: i32, pub cxIdeal: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVCOLUMNW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVCOLUMNW { fn clone(&self) -> Self { *self } } pub type LVCOLUMNW_FORMAT = u32; pub const LVCFMT_LEFT: LVCOLUMNW_FORMAT = 0u32; pub const LVCFMT_RIGHT: LVCOLUMNW_FORMAT = 1u32; pub const LVCFMT_CENTER: LVCOLUMNW_FORMAT = 2u32; pub const LVCFMT_JUSTIFYMASK: LVCOLUMNW_FORMAT = 3u32; pub const LVCFMT_IMAGE: LVCOLUMNW_FORMAT = 2048u32; pub const LVCFMT_BITMAP_ON_RIGHT: LVCOLUMNW_FORMAT = 4096u32; pub const LVCFMT_COL_HAS_IMAGES: LVCOLUMNW_FORMAT = 32768u32; pub const LVCFMT_FIXED_WIDTH: LVCOLUMNW_FORMAT = 256u32; pub const LVCFMT_NO_DPI_SCALE: LVCOLUMNW_FORMAT = 262144u32; pub const LVCFMT_FIXED_RATIO: LVCOLUMNW_FORMAT = 524288u32; pub const LVCFMT_SPLITBUTTON: LVCOLUMNW_FORMAT = 16777216u32; pub type LVCOLUMNW_MASK = u32; pub const LVCF_FMT: LVCOLUMNW_MASK = 1u32; pub const LVCF_WIDTH: LVCOLUMNW_MASK = 2u32; pub const LVCF_TEXT: LVCOLUMNW_MASK = 4u32; pub const LVCF_SUBITEM: LVCOLUMNW_MASK = 8u32; pub const LVCF_IMAGE: LVCOLUMNW_MASK = 16u32; pub const LVCF_ORDER: LVCOLUMNW_MASK = 32u32; pub const LVCF_MINWIDTH: LVCOLUMNW_MASK = 64u32; pub const LVCF_DEFAULTWIDTH: LVCOLUMNW_MASK = 128u32; pub const LVCF_IDEALWIDTH: LVCOLUMNW_MASK = 256u32; pub const LVFF_ITEMCOUNT: u32 = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVFINDINFOA { pub flags: LVFINDINFOW_FLAGS, pub psz: super::super::Foundation::PSTR, pub lParam: super::super::Foundation::LPARAM, pub pt: super::super::Foundation::POINT, pub vkDirection: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVFINDINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVFINDINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVFINDINFOW { pub flags: LVFINDINFOW_FLAGS, pub psz: super::super::Foundation::PWSTR, pub lParam: super::super::Foundation::LPARAM, pub pt: super::super::Foundation::POINT, pub vkDirection: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVFINDINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVFINDINFOW { fn clone(&self) -> Self { *self } } pub type LVFINDINFOW_FLAGS = u32; pub const LVFI_PARAM: LVFINDINFOW_FLAGS = 1u32; pub const LVFI_PARTIAL: LVFINDINFOW_FLAGS = 8u32; pub const LVFI_STRING: LVFINDINFOW_FLAGS = 2u32; pub const LVFI_SUBSTRING: LVFINDINFOW_FLAGS = 4u32; pub const LVFI_WRAP: LVFINDINFOW_FLAGS = 32u32; pub const LVFI_NEARESTXY: LVFINDINFOW_FLAGS = 64u32; pub const LVFIS_FOCUSED: u32 = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVFOOTERINFO { pub mask: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub cItems: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVFOOTERINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVFOOTERINFO { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVFOOTERITEM { pub mask: LVFOOTERITEM_MASK, pub iItem: i32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub state: u32, pub stateMask: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVFOOTERITEM {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVFOOTERITEM { fn clone(&self) -> Self { *self } } pub type LVFOOTERITEM_MASK = u32; pub const LVFIF_TEXT: LVFOOTERITEM_MASK = 1u32; pub const LVFIF_STATE: LVFOOTERITEM_MASK = 2u32; pub const LVGA_FOOTER_CENTER: u32 = 16u32; pub const LVGA_FOOTER_LEFT: u32 = 8u32; pub const LVGA_FOOTER_RIGHT: u32 = 32u32; pub const LVGF_ALIGN: u32 = 8u32; pub const LVGF_DESCRIPTIONBOTTOM: u32 = 2048u32; pub const LVGF_DESCRIPTIONTOP: u32 = 1024u32; pub const LVGF_EXTENDEDIMAGE: u32 = 8192u32; pub const LVGF_GROUPID: u32 = 16u32; pub const LVGF_ITEMS: u32 = 16384u32; pub const LVGF_SUBSET: u32 = 32768u32; pub const LVGF_SUBSETITEMS: u32 = 65536u32; pub const LVGF_SUBTITLE: u32 = 256u32; pub const LVGF_TASK: u32 = 512u32; pub const LVGF_TITLEIMAGE: u32 = 4096u32; pub const LVGGR_GROUP: u32 = 0u32; pub const LVGGR_HEADER: u32 = 1u32; pub const LVGGR_LABEL: u32 = 2u32; pub const LVGGR_SUBSETLINK: u32 = 3u32; pub const LVGIT_UNFOLDED: u32 = 1u32; pub const LVGMF_BORDERCOLOR: u32 = 2u32; pub const LVGMF_BORDERSIZE: u32 = 1u32; pub const LVGMF_NONE: u32 = 0u32; pub const LVGMF_TEXTCOLOR: u32 = 4u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVGROUP { pub cbSize: u32, pub mask: LVGROUP_MASK, pub pszHeader: super::super::Foundation::PWSTR, pub cchHeader: i32, pub pszFooter: super::super::Foundation::PWSTR, pub cchFooter: i32, pub iGroupId: i32, pub stateMask: u32, pub state: u32, pub uAlign: u32, pub pszSubtitle: super::super::Foundation::PWSTR, pub cchSubtitle: u32, pub pszTask: super::super::Foundation::PWSTR, pub cchTask: u32, pub pszDescriptionTop: super::super::Foundation::PWSTR, pub cchDescriptionTop: u32, pub pszDescriptionBottom: super::super::Foundation::PWSTR, pub cchDescriptionBottom: u32, pub iTitleImage: i32, pub iExtendedImage: i32, pub iFirstItem: i32, pub cItems: u32, pub pszSubsetTitle: super::super::Foundation::PWSTR, pub cchSubsetTitle: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVGROUP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVGROUP { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct LVGROUPMETRICS { pub cbSize: u32, pub mask: u32, pub Left: u32, pub Top: u32, pub Right: u32, pub Bottom: u32, pub crLeft: u32, pub crTop: u32, pub crRight: u32, pub crBottom: u32, pub crHeader: u32, pub crFooter: u32, } impl ::core::marker::Copy for LVGROUPMETRICS {} impl ::core::clone::Clone for LVGROUPMETRICS { fn clone(&self) -> Self { *self } } pub type LVGROUP_MASK = u32; pub const LVGF_NONE: LVGROUP_MASK = 0u32; pub const LVGF_HEADER: LVGROUP_MASK = 1u32; pub const LVGF_FOOTER: LVGROUP_MASK = 2u32; pub const LVGF_STATE: LVGROUP_MASK = 4u32; pub const LVGS_COLLAPSED: u32 = 1u32; pub const LVGS_COLLAPSIBLE: u32 = 8u32; pub const LVGS_FOCUSED: u32 = 16u32; pub const LVGS_HIDDEN: u32 = 2u32; pub const LVGS_NOHEADER: u32 = 4u32; pub const LVGS_NORMAL: u32 = 0u32; pub const LVGS_SELECTED: u32 = 32u32; pub const LVGS_SUBSETED: u32 = 64u32; pub const LVGS_SUBSETLINKFOCUSED: u32 = 128u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVHITTESTINFO { pub pt: super::super::Foundation::POINT, pub flags: LVHITTESTINFO_FLAGS, pub iItem: i32, pub iSubItem: i32, pub iGroup: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVHITTESTINFO { fn clone(&self) -> Self { *self } } pub type LVHITTESTINFO_FLAGS = u32; pub const LVHT_ABOVE: LVHITTESTINFO_FLAGS = 8u32; pub const LVHT_BELOW: LVHITTESTINFO_FLAGS = 16u32; pub const LVHT_NOWHERE: LVHITTESTINFO_FLAGS = 1u32; pub const LVHT_ONITEMICON: LVHITTESTINFO_FLAGS = 2u32; pub const LVHT_ONITEMLABEL: LVHITTESTINFO_FLAGS = 4u32; pub const LVHT_ONITEMSTATEICON: LVHITTESTINFO_FLAGS = 8u32; pub const LVHT_TOLEFT: LVHITTESTINFO_FLAGS = 64u32; pub const LVHT_TORIGHT: LVHITTESTINFO_FLAGS = 32u32; pub const LVHT_EX_GROUP_HEADER: LVHITTESTINFO_FLAGS = 268435456u32; pub const LVHT_EX_GROUP_FOOTER: LVHITTESTINFO_FLAGS = 536870912u32; pub const LVHT_EX_GROUP_COLLAPSE: LVHITTESTINFO_FLAGS = 1073741824u32; pub const LVHT_EX_GROUP_BACKGROUND: LVHITTESTINFO_FLAGS = 2147483648u32; pub const LVHT_EX_GROUP_STATEICON: LVHITTESTINFO_FLAGS = 16777216u32; pub const LVHT_EX_GROUP_SUBSETLINK: LVHITTESTINFO_FLAGS = 33554432u32; pub const LVHT_EX_GROUP: LVHITTESTINFO_FLAGS = 4076863488u32; pub const LVHT_EX_ONCONTENTS: LVHITTESTINFO_FLAGS = 67108864u32; pub const LVHT_EX_FOOTER: LVHITTESTINFO_FLAGS = 134217728u32; pub const LVIF_COLFMT: u32 = 65536u32; pub const LVIF_COLUMNS: u32 = 512u32; pub const LVIF_DI_SETITEM: u32 = 4096u32; pub const LVIF_GROUPID: u32 = 256u32; pub const LVIF_IMAGE: u32 = 2u32; pub const LVIF_INDENT: u32 = 16u32; pub const LVIF_NORECOMPUTE: u32 = 2048u32; pub const LVIF_PARAM: u32 = 4u32; pub const LVIF_STATE: u32 = 8u32; pub const LVIF_TEXT: u32 = 1u32; pub const LVIM_AFTER: u32 = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVINSERTGROUPSORTED { pub pfnGroupCompare: PFNLVGROUPCOMPARE, pub pvData: *mut ::core::ffi::c_void, pub lvGroup: LVGROUP, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVINSERTGROUPSORTED {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVINSERTGROUPSORTED { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct LVINSERTMARK { pub cbSize: u32, pub dwFlags: u32, pub iItem: i32, pub dwReserved: u32, } impl ::core::marker::Copy for LVINSERTMARK {} impl ::core::clone::Clone for LVINSERTMARK { fn clone(&self) -> Self { *self } } pub const LVIR_BOUNDS: u32 = 0u32; pub const LVIR_ICON: u32 = 1u32; pub const LVIR_LABEL: u32 = 2u32; pub const LVIR_SELECTBOUNDS: u32 = 3u32; pub const LVIS_ACTIVATING: u32 = 32u32; pub const LVIS_CUT: u32 = 4u32; pub const LVIS_DROPHILITED: u32 = 8u32; pub const LVIS_FOCUSED: u32 = 1u32; pub const LVIS_GLOW: u32 = 16u32; pub const LVIS_OVERLAYMASK: u32 = 3840u32; pub const LVIS_SELECTED: u32 = 2u32; pub const LVIS_STATEIMAGEMASK: u32 = 61440u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVITEMA { pub mask: u32, pub iItem: i32, pub iSubItem: i32, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, pub iIndent: i32, pub iGroupId: LVITEMA_GROUP_ID, pub cColumns: u32, pub puColumns: *mut u32, pub piColFmt: *mut i32, pub iGroup: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVITEMA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVITEMA { fn clone(&self) -> Self { *self } } pub type LVITEMA_GROUP_ID = i32; pub const I_GROUPIDCALLBACK: LVITEMA_GROUP_ID = -1i32; pub const I_GROUPIDNONE: LVITEMA_GROUP_ID = -2i32; #[repr(C)] pub struct LVITEMINDEX { pub iItem: i32, pub iGroup: i32, } impl ::core::marker::Copy for LVITEMINDEX {} impl ::core::clone::Clone for LVITEMINDEX { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVITEMW { pub mask: u32, pub iItem: i32, pub iSubItem: i32, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, pub iIndent: i32, pub iGroupId: LVITEMA_GROUP_ID, pub cColumns: u32, pub puColumns: *mut u32, pub piColFmt: *mut i32, pub iGroup: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVITEMW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVITEMW { fn clone(&self) -> Self { *self } } pub const LVKF_ALT: u32 = 1u32; pub const LVKF_CONTROL: u32 = 2u32; pub const LVKF_SHIFT: u32 = 4u32; pub const LVM_APPROXIMATEVIEWRECT: u32 = 4160u32; pub const LVM_ARRANGE: u32 = 4118u32; pub const LVM_CANCELEDITLABEL: u32 = 4275u32; pub const LVM_CREATEDRAGIMAGE: u32 = 4129u32; pub const LVM_DELETEALLITEMS: u32 = 4105u32; pub const LVM_DELETECOLUMN: u32 = 4124u32; pub const LVM_DELETEITEM: u32 = 4104u32; pub const LVM_EDITLABEL: u32 = 4214u32; pub const LVM_EDITLABELA: u32 = 4119u32; pub const LVM_EDITLABELW: u32 = 4214u32; pub const LVM_ENABLEGROUPVIEW: u32 = 4253u32; pub const LVM_ENSUREVISIBLE: u32 = 4115u32; pub const LVM_FINDITEM: u32 = 4179u32; pub const LVM_FINDITEMA: u32 = 4109u32; pub const LVM_FINDITEMW: u32 = 4179u32; pub const LVM_FIRST: u32 = 4096u32; pub const LVM_GETBKCOLOR: u32 = 4096u32; pub const LVM_GETBKIMAGE: u32 = 4235u32; pub const LVM_GETBKIMAGEA: u32 = 4165u32; pub const LVM_GETBKIMAGEW: u32 = 4235u32; pub const LVM_GETCALLBACKMASK: u32 = 4106u32; pub const LVM_GETCOLUMN: u32 = 4191u32; pub const LVM_GETCOLUMNA: u32 = 4121u32; pub const LVM_GETCOLUMNORDERARRAY: u32 = 4155u32; pub const LVM_GETCOLUMNW: u32 = 4191u32; pub const LVM_GETCOLUMNWIDTH: u32 = 4125u32; pub const LVM_GETCOUNTPERPAGE: u32 = 4136u32; pub const LVM_GETEDITCONTROL: u32 = 4120u32; pub const LVM_GETEMPTYTEXT: u32 = 4300u32; pub const LVM_GETEXTENDEDLISTVIEWSTYLE: u32 = 4151u32; pub const LVM_GETFOCUSEDGROUP: u32 = 4189u32; pub const LVM_GETFOOTERINFO: u32 = 4302u32; pub const LVM_GETFOOTERITEM: u32 = 4304u32; pub const LVM_GETFOOTERITEMRECT: u32 = 4303u32; pub const LVM_GETFOOTERRECT: u32 = 4301u32; pub const LVM_GETGROUPCOUNT: u32 = 4248u32; pub const LVM_GETGROUPINFO: u32 = 4245u32; pub const LVM_GETGROUPINFOBYINDEX: u32 = 4249u32; pub const LVM_GETGROUPMETRICS: u32 = 4252u32; pub const LVM_GETGROUPRECT: u32 = 4194u32; pub const LVM_GETGROUPSTATE: u32 = 4188u32; pub const LVM_GETHEADER: u32 = 4127u32; pub const LVM_GETHOTCURSOR: u32 = 4159u32; pub const LVM_GETHOTITEM: u32 = 4157u32; pub const LVM_GETHOVERTIME: u32 = 4168u32; pub const LVM_GETIMAGELIST: u32 = 4098u32; pub const LVM_GETINSERTMARK: u32 = 4263u32; pub const LVM_GETINSERTMARKCOLOR: u32 = 4267u32; pub const LVM_GETINSERTMARKRECT: u32 = 4265u32; pub const LVM_GETISEARCHSTRING: u32 = 4213u32; pub const LVM_GETISEARCHSTRINGA: u32 = 4148u32; pub const LVM_GETISEARCHSTRINGW: u32 = 4213u32; pub const LVM_GETITEM: u32 = 4171u32; pub const LVM_GETITEMA: u32 = 4101u32; pub const LVM_GETITEMCOUNT: u32 = 4100u32; pub const LVM_GETITEMINDEXRECT: u32 = 4305u32; pub const LVM_GETITEMPOSITION: u32 = 4112u32; pub const LVM_GETITEMRECT: u32 = 4110u32; pub const LVM_GETITEMSPACING: u32 = 4147u32; pub const LVM_GETITEMSTATE: u32 = 4140u32; pub const LVM_GETITEMTEXT: u32 = 4211u32; pub const LVM_GETITEMTEXTA: u32 = 4141u32; pub const LVM_GETITEMTEXTW: u32 = 4211u32; pub const LVM_GETITEMW: u32 = 4171u32; pub const LVM_GETNEXTITEM: u32 = 4108u32; pub const LVM_GETNEXTITEMINDEX: u32 = 4307u32; pub const LVM_GETNUMBEROFWORKAREAS: u32 = 4169u32; pub const LVM_GETORIGIN: u32 = 4137u32; pub const LVM_GETOUTLINECOLOR: u32 = 4272u32; pub const LVM_GETSELECTEDCOLUMN: u32 = 4270u32; pub const LVM_GETSELECTEDCOUNT: u32 = 4146u32; pub const LVM_GETSELECTIONMARK: u32 = 4162u32; pub const LVM_GETSTRINGWIDTH: u32 = 4183u32; pub const LVM_GETSTRINGWIDTHA: u32 = 4113u32; pub const LVM_GETSTRINGWIDTHW: u32 = 4183u32; pub const LVM_GETSUBITEMRECT: u32 = 4152u32; pub const LVM_GETTEXTBKCOLOR: u32 = 4133u32; pub const LVM_GETTEXTCOLOR: u32 = 4131u32; pub const LVM_GETTILEINFO: u32 = 4261u32; pub const LVM_GETTILEVIEWINFO: u32 = 4259u32; pub const LVM_GETTOOLTIPS: u32 = 4174u32; pub const LVM_GETTOPINDEX: u32 = 4135u32; pub const LVM_GETUNICODEFORMAT: u32 = 8198u32; pub const LVM_GETVIEW: u32 = 4239u32; pub const LVM_GETVIEWRECT: u32 = 4130u32; pub const LVM_GETWORKAREAS: u32 = 4166u32; pub const LVM_HASGROUP: u32 = 4257u32; pub const LVM_HITTEST: u32 = 4114u32; pub const LVM_INSERTCOLUMNA: u32 = 4123u32; pub const LVM_INSERTCOLUMNW: u32 = 4193u32; pub const LVM_INSERTGROUP: u32 = 4241u32; pub const LVM_INSERTGROUPSORTED: u32 = 4255u32; pub const LVM_INSERTITEM: u32 = 4173u32; pub const LVM_INSERTITEMA: u32 = 4103u32; pub const LVM_INSERTITEMW: u32 = 4173u32; pub const LVM_INSERTMARKHITTEST: u32 = 4264u32; pub const LVM_ISGROUPVIEWENABLED: u32 = 4271u32; pub const LVM_ISITEMVISIBLE: u32 = 4278u32; pub const LVM_MAPIDTOINDEX: u32 = 4277u32; pub const LVM_MAPINDEXTOID: u32 = 4276u32; pub const LVM_MOVEGROUP: u32 = 4247u32; pub const LVM_MOVEITEMTOGROUP: u32 = 4250u32; pub const LVM_REDRAWITEMS: u32 = 4117u32; pub const LVM_REMOVEALLGROUPS: u32 = 4256u32; pub const LVM_REMOVEGROUP: u32 = 4246u32; pub const LVM_SCROLL: u32 = 4116u32; pub const LVM_SETBKCOLOR: u32 = 4097u32; pub const LVM_SETBKIMAGE: u32 = 4234u32; pub const LVM_SETBKIMAGEA: u32 = 4164u32; pub const LVM_SETBKIMAGEW: u32 = 4234u32; pub const LVM_SETCALLBACKMASK: u32 = 4107u32; pub const LVM_SETCOLUMN: u32 = 4192u32; pub const LVM_SETCOLUMNA: u32 = 4122u32; pub const LVM_SETCOLUMNORDERARRAY: u32 = 4154u32; pub const LVM_SETCOLUMNW: u32 = 4192u32; pub const LVM_SETCOLUMNWIDTH: u32 = 4126u32; pub const LVM_SETEXTENDEDLISTVIEWSTYLE: u32 = 4150u32; pub const LVM_SETGROUPINFO: u32 = 4243u32; pub const LVM_SETGROUPMETRICS: u32 = 4251u32; pub const LVM_SETHOTCURSOR: u32 = 4158u32; pub const LVM_SETHOTITEM: u32 = 4156u32; pub const LVM_SETHOVERTIME: u32 = 4167u32; pub const LVM_SETICONSPACING: u32 = 4149u32; pub const LVM_SETIMAGELIST: u32 = 4099u32; pub const LVM_SETINFOTIP: u32 = 4269u32; pub const LVM_SETINSERTMARK: u32 = 4262u32; pub const LVM_SETINSERTMARKCOLOR: u32 = 4266u32; pub const LVM_SETITEM: u32 = 4172u32; pub const LVM_SETITEMA: u32 = 4102u32; pub const LVM_SETITEMCOUNT: u32 = 4143u32; pub const LVM_SETITEMINDEXSTATE: u32 = 4306u32; pub const LVM_SETITEMPOSITION: u32 = 4111u32; pub const LVM_SETITEMPOSITION32: u32 = 4145u32; pub const LVM_SETITEMSTATE: u32 = 4139u32; pub const LVM_SETITEMTEXT: u32 = 4212u32; pub const LVM_SETITEMTEXTA: u32 = 4142u32; pub const LVM_SETITEMTEXTW: u32 = 4212u32; pub const LVM_SETITEMW: u32 = 4172u32; pub const LVM_SETOUTLINECOLOR: u32 = 4273u32; pub const LVM_SETSELECTEDCOLUMN: u32 = 4236u32; pub const LVM_SETSELECTIONMARK: u32 = 4163u32; pub const LVM_SETTEXTBKCOLOR: u32 = 4134u32; pub const LVM_SETTEXTCOLOR: u32 = 4132u32; pub const LVM_SETTILEINFO: u32 = 4260u32; pub const LVM_SETTILEVIEWINFO: u32 = 4258u32; pub const LVM_SETTOOLTIPS: u32 = 4170u32; pub const LVM_SETUNICODEFORMAT: u32 = 8197u32; pub const LVM_SETVIEW: u32 = 4238u32; pub const LVM_SETWORKAREAS: u32 = 4161u32; pub const LVM_SORTGROUPS: u32 = 4254u32; pub const LVM_SORTITEMS: u32 = 4144u32; pub const LVM_SORTITEMSEX: u32 = 4177u32; pub const LVM_SUBITEMHITTEST: u32 = 4153u32; pub const LVM_UPDATE: u32 = 4138u32; pub const LVNI_ABOVE: u32 = 256u32; pub const LVNI_ALL: u32 = 0u32; pub const LVNI_BELOW: u32 = 512u32; pub const LVNI_CUT: u32 = 4u32; pub const LVNI_DROPHILITED: u32 = 8u32; pub const LVNI_FOCUSED: u32 = 1u32; pub const LVNI_PREVIOUS: u32 = 32u32; pub const LVNI_SAMEGROUPONLY: u32 = 128u32; pub const LVNI_SELECTED: u32 = 2u32; pub const LVNI_TOLEFT: u32 = 1024u32; pub const LVNI_TORIGHT: u32 = 2048u32; pub const LVNI_VISIBLEONLY: u32 = 64u32; pub const LVNI_VISIBLEORDER: u32 = 16u32; pub const LVNSCH_DEFAULT: i32 = -1i32; pub const LVNSCH_ERROR: i32 = -2i32; pub const LVNSCH_IGNORE: i32 = -3i32; pub const LVSCW_AUTOSIZE: i32 = -1i32; pub const LVSCW_AUTOSIZE_USEHEADER: i32 = -2i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVSETINFOTIP { pub cbSize: u32, pub dwFlags: u32, pub pszText: super::super::Foundation::PWSTR, pub iItem: i32, pub iSubItem: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVSETINFOTIP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVSETINFOTIP { fn clone(&self) -> Self { *self } } pub const LVSICF_NOINVALIDATEALL: u32 = 1u32; pub const LVSICF_NOSCROLL: u32 = 2u32; pub const LVSIL_GROUPHEADER: u32 = 3u32; pub const LVSIL_NORMAL: u32 = 0u32; pub const LVSIL_SMALL: u32 = 1u32; pub const LVSIL_STATE: u32 = 2u32; pub const LVS_ALIGNLEFT: u32 = 2048u32; pub const LVS_ALIGNMASK: u32 = 3072u32; pub const LVS_ALIGNTOP: u32 = 0u32; pub const LVS_AUTOARRANGE: u32 = 256u32; pub const LVS_EDITLABELS: u32 = 512u32; pub const LVS_EX_AUTOAUTOARRANGE: u32 = 16777216u32; pub const LVS_EX_AUTOCHECKSELECT: u32 = 134217728u32; pub const LVS_EX_AUTOSIZECOLUMNS: u32 = 268435456u32; pub const LVS_EX_BORDERSELECT: u32 = 32768u32; pub const LVS_EX_CHECKBOXES: u32 = 4u32; pub const LVS_EX_COLUMNOVERFLOW: u32 = 2147483648u32; pub const LVS_EX_COLUMNSNAPPOINTS: u32 = 1073741824u32; pub const LVS_EX_DOUBLEBUFFER: u32 = 65536u32; pub const LVS_EX_FLATSB: u32 = 256u32; pub const LVS_EX_FULLROWSELECT: u32 = 32u32; pub const LVS_EX_GRIDLINES: u32 = 1u32; pub const LVS_EX_HEADERDRAGDROP: u32 = 16u32; pub const LVS_EX_HEADERINALLVIEWS: u32 = 33554432u32; pub const LVS_EX_HIDELABELS: u32 = 131072u32; pub const LVS_EX_INFOTIP: u32 = 1024u32; pub const LVS_EX_JUSTIFYCOLUMNS: u32 = 2097152u32; pub const LVS_EX_LABELTIP: u32 = 16384u32; pub const LVS_EX_MULTIWORKAREAS: u32 = 8192u32; pub const LVS_EX_ONECLICKACTIVATE: u32 = 64u32; pub const LVS_EX_REGIONAL: u32 = 512u32; pub const LVS_EX_SIMPLESELECT: u32 = 1048576u32; pub const LVS_EX_SINGLEROW: u32 = 262144u32; pub const LVS_EX_SNAPTOGRID: u32 = 524288u32; pub const LVS_EX_SUBITEMIMAGES: u32 = 2u32; pub const LVS_EX_TRACKSELECT: u32 = 8u32; pub const LVS_EX_TRANSPARENTBKGND: u32 = 4194304u32; pub const LVS_EX_TRANSPARENTSHADOWTEXT: u32 = 8388608u32; pub const LVS_EX_TWOCLICKACTIVATE: u32 = 128u32; pub const LVS_EX_UNDERLINECOLD: u32 = 4096u32; pub const LVS_EX_UNDERLINEHOT: u32 = 2048u32; pub const LVS_ICON: u32 = 0u32; pub const LVS_LIST: u32 = 3u32; pub const LVS_NOCOLUMNHEADER: u32 = 16384u32; pub const LVS_NOLABELWRAP: u32 = 128u32; pub const LVS_NOSCROLL: u32 = 8192u32; pub const LVS_NOSORTHEADER: u32 = 32768u32; pub const LVS_OWNERDATA: u32 = 4096u32; pub const LVS_OWNERDRAWFIXED: u32 = 1024u32; pub const LVS_REPORT: u32 = 1u32; pub const LVS_SHAREIMAGELISTS: u32 = 64u32; pub const LVS_SHOWSELALWAYS: u32 = 8u32; pub const LVS_SINGLESEL: u32 = 4u32; pub const LVS_SMALLICON: u32 = 2u32; pub const LVS_SORTASCENDING: u32 = 16u32; pub const LVS_SORTDESCENDING: u32 = 32u32; pub const LVS_TYPEMASK: u32 = 3u32; pub const LVS_TYPESTYLEMASK: u32 = 64512u32; #[repr(C)] pub struct LVTILEINFO { pub cbSize: u32, pub iItem: i32, pub cColumns: u32, pub puColumns: *mut u32, pub piColFmt: *mut i32, } impl ::core::marker::Copy for LVTILEINFO {} impl ::core::clone::Clone for LVTILEINFO { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct LVTILEVIEWINFO { pub cbSize: u32, pub dwMask: u32, pub dwFlags: LVTILEVIEWINFO_FLAGS, pub sizeTile: super::super::Foundation::SIZE, pub cLines: i32, pub rcLabelMargin: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for LVTILEVIEWINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for LVTILEVIEWINFO { fn clone(&self) -> Self { *self } } pub type LVTILEVIEWINFO_FLAGS = u32; pub const LVTVIF_EXTENDED: LVTILEVIEWINFO_FLAGS = 4u32; pub const LVTVIF_AUTOSIZE: u32 = 0u32; pub const LVTVIF_FIXEDHEIGHT: u32 = 2u32; pub const LVTVIF_FIXEDSIZE: u32 = 3u32; pub const LVTVIF_FIXEDWIDTH: u32 = 1u32; pub const LVTVIM_COLUMNS: u32 = 2u32; pub const LVTVIM_LABELMARGIN: u32 = 4u32; pub const LVTVIM_TILESIZE: u32 = 1u32; pub const LV_MAX_WORKAREAS: u32 = 16u32; pub const LV_VIEW_DETAILS: u32 = 1u32; pub const LV_VIEW_ICON: u32 = 0u32; pub const LV_VIEW_LIST: u32 = 3u32; pub const LV_VIEW_MAX: u32 = 4u32; pub const LV_VIEW_SMALLICON: u32 = 2u32; pub const LV_VIEW_TILE: u32 = 4u32; pub const LWS_IGNORERETURN: u32 = 2u32; pub const LWS_NOPREFIX: u32 = 4u32; pub const LWS_RIGHT: u32 = 32u32; pub const LWS_TRANSPARENT: u32 = 1u32; pub const LWS_USECUSTOMTEXT: u32 = 16u32; pub const LWS_USEVISUALSTYLE: u32 = 8u32; #[repr(C)] pub struct MARGINS { pub cxLeftWidth: i32, pub cxRightWidth: i32, pub cyTopHeight: i32, pub cyBottomHeight: i32, } impl ::core::marker::Copy for MARGINS {} impl ::core::clone::Clone for MARGINS { fn clone(&self) -> Self { *self } } pub type MARKUPTEXTSTATES = i32; pub const EMT_NORMALTEXT: MARKUPTEXTSTATES = 1i32; pub const EMT_LINKTEXT: MARKUPTEXTSTATES = 2i32; pub const MAXPROPPAGES: u32 = 100u32; pub const MAX_INTLIST_COUNT: u32 = 402u32; pub const MAX_LINKID_TEXT: u32 = 48u32; pub const MAX_THEMECOLOR: u32 = 64u32; pub const MAX_THEMESIZE: u32 = 64u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct MCGRIDINFO { pub cbSize: u32, pub dwPart: MCGRIDINFO_PART, pub dwFlags: MCGRIDINFO_FLAGS, pub iCalendar: i32, pub iRow: i32, pub iCol: i32, pub bSelected: super::super::Foundation::BOOL, pub stStart: super::super::Foundation::SYSTEMTIME, pub stEnd: super::super::Foundation::SYSTEMTIME, pub rc: super::super::Foundation::RECT, pub pszName: super::super::Foundation::PWSTR, pub cchName: usize, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for MCGRIDINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for MCGRIDINFO { fn clone(&self) -> Self { *self } } pub type MCGRIDINFO_FLAGS = u32; pub const MCGIF_DATE: MCGRIDINFO_FLAGS = 1u32; pub const MCGIF_RECT: MCGRIDINFO_FLAGS = 2u32; pub const MCGIF_NAME: MCGRIDINFO_FLAGS = 4u32; pub type MCGRIDINFO_PART = u32; pub const MCGIP_CALENDARCONTROL: MCGRIDINFO_PART = 0u32; pub const MCGIP_NEXT: MCGRIDINFO_PART = 1u32; pub const MCGIP_PREV: MCGRIDINFO_PART = 2u32; pub const MCGIP_FOOTER: MCGRIDINFO_PART = 3u32; pub const MCGIP_CALENDAR: MCGRIDINFO_PART = 4u32; pub const MCGIP_CALENDARHEADER: MCGRIDINFO_PART = 5u32; pub const MCGIP_CALENDARBODY: MCGRIDINFO_PART = 6u32; pub const MCGIP_CALENDARROW: MCGRIDINFO_PART = 7u32; pub const MCGIP_CALENDARCELL: MCGRIDINFO_PART = 8u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct MCHITTESTINFO { pub cbSize: u32, pub pt: super::super::Foundation::POINT, pub uHit: u32, pub st: super::super::Foundation::SYSTEMTIME, pub rc: super::super::Foundation::RECT, pub iOffset: i32, pub iRow: i32, pub iCol: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for MCHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for MCHITTESTINFO { fn clone(&self) -> Self { *self } } pub const MCHT_CALENDAR: u32 = 131072u32; pub const MCHT_CALENDARBK: u32 = 131072u32; pub const MCHT_CALENDARCONTROL: u32 = 1048576u32; pub const MCHT_NEXT: u32 = 16777216u32; pub const MCHT_NOWHERE: u32 = 0u32; pub const MCHT_PREV: u32 = 33554432u32; pub const MCHT_TITLE: u32 = 65536u32; pub const MCHT_TITLEBK: u32 = 65536u32; pub const MCHT_TODAYLINK: u32 = 196608u32; pub const MCMV_CENTURY: u32 = 3u32; pub const MCMV_DECADE: u32 = 2u32; pub const MCMV_MAX: u32 = 3u32; pub const MCMV_MONTH: u32 = 0u32; pub const MCMV_YEAR: u32 = 1u32; pub const MCM_FIRST: u32 = 4096u32; pub const MCM_GETCALENDARBORDER: u32 = 4127u32; pub const MCM_GETCALENDARCOUNT: u32 = 4119u32; pub const MCM_GETCALENDARGRIDINFO: u32 = 4120u32; pub const MCM_GETCALID: u32 = 4123u32; pub const MCM_GETCOLOR: u32 = 4107u32; pub const MCM_GETCURRENTVIEW: u32 = 4118u32; pub const MCM_GETCURSEL: u32 = 4097u32; pub const MCM_GETFIRSTDAYOFWEEK: u32 = 4112u32; pub const MCM_GETMAXSELCOUNT: u32 = 4099u32; pub const MCM_GETMAXTODAYWIDTH: u32 = 4117u32; pub const MCM_GETMINREQRECT: u32 = 4105u32; pub const MCM_GETMONTHDELTA: u32 = 4115u32; pub const MCM_GETMONTHRANGE: u32 = 4103u32; pub const MCM_GETRANGE: u32 = 4113u32; pub const MCM_GETSELRANGE: u32 = 4101u32; pub const MCM_GETTODAY: u32 = 4109u32; pub const MCM_GETUNICODEFORMAT: u32 = 8198u32; pub const MCM_HITTEST: u32 = 4110u32; pub const MCM_SETCALENDARBORDER: u32 = 4126u32; pub const MCM_SETCALID: u32 = 4124u32; pub const MCM_SETCOLOR: u32 = 4106u32; pub const MCM_SETCURRENTVIEW: u32 = 4128u32; pub const MCM_SETCURSEL: u32 = 4098u32; pub const MCM_SETDAYSTATE: u32 = 4104u32; pub const MCM_SETFIRSTDAYOFWEEK: u32 = 4111u32; pub const MCM_SETMAXSELCOUNT: u32 = 4100u32; pub const MCM_SETMONTHDELTA: u32 = 4116u32; pub const MCM_SETRANGE: u32 = 4114u32; pub const MCM_SETSELRANGE: u32 = 4102u32; pub const MCM_SETTODAY: u32 = 4108u32; pub const MCM_SETUNICODEFORMAT: u32 = 8197u32; pub const MCM_SIZERECTTOMIN: u32 = 4125u32; pub const MCSC_BACKGROUND: u32 = 0u32; pub const MCSC_MONTHBK: u32 = 4u32; pub const MCSC_TEXT: u32 = 1u32; pub const MCSC_TITLEBK: u32 = 2u32; pub const MCSC_TITLETEXT: u32 = 3u32; pub const MCSC_TRAILINGTEXT: u32 = 5u32; pub const MCS_DAYSTATE: u32 = 1u32; pub const MCS_MULTISELECT: u32 = 2u32; pub const MCS_NOSELCHANGEONNAV: u32 = 256u32; pub const MCS_NOTODAY: u32 = 16u32; pub const MCS_NOTODAYCIRCLE: u32 = 8u32; pub const MCS_NOTRAILINGDATES: u32 = 64u32; pub const MCS_SHORTDAYSOFWEEK: u32 = 128u32; pub const MCS_WEEKNUMBERS: u32 = 4u32; #[repr(C)] pub struct MEASUREITEMSTRUCT { pub CtlType: u32, pub CtlID: u32, pub itemID: u32, pub itemWidth: u32, pub itemHeight: u32, pub itemData: usize, } impl ::core::marker::Copy for MEASUREITEMSTRUCT {} impl ::core::clone::Clone for MEASUREITEMSTRUCT { fn clone(&self) -> Self { *self } } pub type MENUBANDPARTS = i32; pub const MDP_NEWAPPBUTTON: MENUBANDPARTS = 1i32; pub const MDP_SEPERATOR: MENUBANDPARTS = 2i32; pub type MENUBANDSTATES = i32; pub const MDS_NORMAL: MENUBANDSTATES = 1i32; pub const MDS_HOT: MENUBANDSTATES = 2i32; pub const MDS_PRESSED: MENUBANDSTATES = 3i32; pub const MDS_DISABLED: MENUBANDSTATES = 4i32; pub const MDS_CHECKED: MENUBANDSTATES = 5i32; pub const MDS_HOTCHECKED: MENUBANDSTATES = 6i32; pub type MONTHCALPARTS = i32; pub const MC_BACKGROUND: MONTHCALPARTS = 1i32; pub const MC_BORDERS: MONTHCALPARTS = 2i32; pub const MC_GRIDBACKGROUND: MONTHCALPARTS = 3i32; pub const MC_COLHEADERSPLITTER: MONTHCALPARTS = 4i32; pub const MC_GRIDCELLBACKGROUND: MONTHCALPARTS = 5i32; pub const MC_GRIDCELL: MONTHCALPARTS = 6i32; pub const MC_GRIDCELLUPPER: MONTHCALPARTS = 7i32; pub const MC_TRAILINGGRIDCELL: MONTHCALPARTS = 8i32; pub const MC_TRAILINGGRIDCELLUPPER: MONTHCALPARTS = 9i32; pub const MC_NAVNEXT: MONTHCALPARTS = 10i32; pub const MC_NAVPREV: MONTHCALPARTS = 11i32; pub type MOREPROGRAMSARROWBACKSTATES = i32; pub const SPSB_NORMAL: MOREPROGRAMSARROWBACKSTATES = 1i32; pub const SPSB_HOT: MOREPROGRAMSARROWBACKSTATES = 2i32; pub const SPSB_PRESSED: MOREPROGRAMSARROWBACKSTATES = 3i32; pub type MOREPROGRAMSARROWSTATES = i32; pub const SPS_NORMAL: MOREPROGRAMSARROWSTATES = 1i32; pub const SPS_HOT: MOREPROGRAMSARROWSTATES = 2i32; pub const SPS_PRESSED: MOREPROGRAMSARROWSTATES = 3i32; pub type MOREPROGRAMSTABSTATES = i32; pub const SPMPT_NORMAL: MOREPROGRAMSTABSTATES = 1i32; pub const SPMPT_HOT: MOREPROGRAMSTABSTATES = 2i32; pub const SPMPT_SELECTED: MOREPROGRAMSTABSTATES = 3i32; pub const SPMPT_DISABLED: MOREPROGRAMSTABSTATES = 4i32; pub const SPMPT_FOCUSED: MOREPROGRAMSTABSTATES = 5i32; pub const MSGF_COMMCTRL_BEGINDRAG: u32 = 16896u32; pub const MSGF_COMMCTRL_DRAGSELECT: u32 = 16898u32; pub const MSGF_COMMCTRL_SIZEHEADER: u32 = 16897u32; pub const MSGF_COMMCTRL_TOOLBARCUST: u32 = 16899u32; pub const MULTIFILEOPENORD: u32 = 1537u32; pub type NAVNEXTSTATES = i32; pub const MCNN_NORMAL: NAVNEXTSTATES = 1i32; pub const MCNN_HOT: NAVNEXTSTATES = 2i32; pub const MCNN_PRESSED: NAVNEXTSTATES = 3i32; pub const MCNN_DISABLED: NAVNEXTSTATES = 4i32; pub type NAVPREVSTATES = i32; pub const MCNP_NORMAL: NAVPREVSTATES = 1i32; pub const MCNP_HOT: NAVPREVSTATES = 2i32; pub const MCNP_PRESSED: NAVPREVSTATES = 3i32; pub const MCNP_DISABLED: NAVPREVSTATES = 4i32; pub const NEWFILEOPENORD: u32 = 1547u32; pub const NEWFILEOPENV2ORD: u32 = 1552u32; pub const NEWFILEOPENV3ORD: u32 = 1553u32; pub const NEWFORMATDLGWITHLINK: u32 = 1591u32; pub const NFS_ALL: u32 = 16u32; pub const NFS_BUTTON: u32 = 8u32; pub const NFS_EDIT: u32 = 1u32; pub const NFS_LISTCOMBO: u32 = 4u32; pub const NFS_STATIC: u32 = 2u32; pub const NFS_USEFONTASSOC: u32 = 32u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMBCDROPDOWN { pub hdr: NMHDR, pub rcButton: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMBCDROPDOWN {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMBCDROPDOWN { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMBCHOTITEM { pub hdr: NMHDR, pub dwFlags: NMTBHOTITEM_FLAGS, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMBCHOTITEM {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMBCHOTITEM { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCBEDRAGBEGINA { pub hdr: NMHDR, pub iItemid: i32, pub szText: [super::super::Foundation::CHAR; 260], } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCBEDRAGBEGINA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCBEDRAGBEGINA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCBEDRAGBEGINW { pub hdr: NMHDR, pub iItemid: i32, pub szText: [u16; 260], } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCBEDRAGBEGINW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCBEDRAGBEGINW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCBEENDEDITA { pub hdr: NMHDR, pub fChanged: super::super::Foundation::BOOL, pub iNewSelection: i32, pub szText: [super::super::Foundation::CHAR; 260], pub iWhy: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCBEENDEDITA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCBEENDEDITA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCBEENDEDITW { pub hdr: NMHDR, pub fChanged: super::super::Foundation::BOOL, pub iNewSelection: i32, pub szText: [u16; 260], pub iWhy: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCBEENDEDITW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCBEENDEDITW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCHAR { pub hdr: NMHDR, pub ch: u32, pub dwItemPrev: u32, pub dwItemNext: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCHAR {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCHAR { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCOMBOBOXEXA { pub hdr: NMHDR, pub ceItem: COMBOBOXEXITEMA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCOMBOBOXEXA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCOMBOBOXEXA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCOMBOBOXEXW { pub hdr: NMHDR, pub ceItem: COMBOBOXEXITEMW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCOMBOBOXEXW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCOMBOBOXEXW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMCUSTOMDRAW { pub hdr: NMHDR, pub dwDrawStage: NMCUSTOMDRAW_DRAW_STAGE, pub hdc: super::super::Graphics::Gdi::HDC, pub rc: super::super::Foundation::RECT, pub dwItemSpec: usize, pub uItemState: u32, pub lItemlParam: super::super::Foundation::LPARAM, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMCUSTOMDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMCUSTOMDRAW { fn clone(&self) -> Self { *self } } pub type NMCUSTOMDRAW_DRAW_STAGE = u32; pub const CDDS_POSTPAINT: NMCUSTOMDRAW_DRAW_STAGE = 2u32; pub const CDDS_PREERASE: NMCUSTOMDRAW_DRAW_STAGE = 3u32; pub const CDDS_PREPAINT: NMCUSTOMDRAW_DRAW_STAGE = 1u32; pub const CDDS_ITEMPOSTERASE: NMCUSTOMDRAW_DRAW_STAGE = 65540u32; pub const CDDS_ITEMPOSTPAINT: NMCUSTOMDRAW_DRAW_STAGE = 65538u32; pub const CDDS_ITEMPREERASE: NMCUSTOMDRAW_DRAW_STAGE = 65539u32; pub const CDDS_ITEMPREPAINT: NMCUSTOMDRAW_DRAW_STAGE = 65537u32; pub const CDDS_SUBITEM: NMCUSTOMDRAW_DRAW_STAGE = 131072u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMCUSTOMSPLITRECTINFO { pub hdr: NMHDR, pub rcClient: super::super::Foundation::RECT, pub rcButton: super::super::Foundation::RECT, pub rcSplit: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMCUSTOMSPLITRECTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMCUSTOMSPLITRECTINFO { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMCUSTOMTEXT { pub hdr: NMHDR, pub hDC: super::super::Graphics::Gdi::HDC, pub lpString: super::super::Foundation::PWSTR, pub nCount: i32, pub lpRect: *mut super::super::Foundation::RECT, pub uFormat: u32, pub fLink: super::super::Foundation::BOOL, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMCUSTOMTEXT {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMCUSTOMTEXT { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMECHANGE { pub nmhdr: NMHDR, pub dwFlags: u32, pub st: super::super::Foundation::SYSTEMTIME, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMECHANGE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMECHANGE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEFORMATA { pub nmhdr: NMHDR, pub pszFormat: super::super::Foundation::PSTR, pub st: super::super::Foundation::SYSTEMTIME, pub pszDisplay: super::super::Foundation::PSTR, pub szDisplay: [super::super::Foundation::CHAR; 64], } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEFORMATA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEFORMATA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEFORMATQUERYA { pub nmhdr: NMHDR, pub pszFormat: super::super::Foundation::PSTR, pub szMax: super::super::Foundation::SIZE, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEFORMATQUERYA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEFORMATQUERYA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEFORMATQUERYW { pub nmhdr: NMHDR, pub pszFormat: super::super::Foundation::PWSTR, pub szMax: super::super::Foundation::SIZE, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEFORMATQUERYW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEFORMATQUERYW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEFORMATW { pub nmhdr: NMHDR, pub pszFormat: super::super::Foundation::PWSTR, pub st: super::super::Foundation::SYSTEMTIME, pub pszDisplay: super::super::Foundation::PWSTR, pub szDisplay: [u16; 64], } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEFORMATW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEFORMATW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMESTRINGA { pub nmhdr: NMHDR, pub pszUserString: super::super::Foundation::PSTR, pub st: super::super::Foundation::SYSTEMTIME, pub dwFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMESTRINGA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMESTRINGA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMESTRINGW { pub nmhdr: NMHDR, pub pszUserString: super::super::Foundation::PWSTR, pub st: super::super::Foundation::SYSTEMTIME, pub dwFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMESTRINGW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMESTRINGW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEWMKEYDOWNA { pub nmhdr: NMHDR, pub nVirtKey: i32, pub pszFormat: super::super::Foundation::PSTR, pub st: super::super::Foundation::SYSTEMTIME, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEWMKEYDOWNA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEWMKEYDOWNA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDATETIMEWMKEYDOWNW { pub nmhdr: NMHDR, pub nVirtKey: i32, pub pszFormat: super::super::Foundation::PWSTR, pub st: super::super::Foundation::SYSTEMTIME, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDATETIMEWMKEYDOWNW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDATETIMEWMKEYDOWNW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMDAYSTATE { pub nmhdr: NMHDR, pub stStart: super::super::Foundation::SYSTEMTIME, pub cDayState: i32, pub prgDayState: *mut u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMDAYSTATE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMDAYSTATE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMHDDISPINFOA { pub hdr: NMHDR, pub iItem: i32, pub mask: HDI_MASK, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMHDDISPINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMHDDISPINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMHDDISPINFOW { pub hdr: NMHDR, pub iItem: i32, pub mask: HDI_MASK, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMHDDISPINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMHDDISPINFOW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMHDFILTERBTNCLICK { pub hdr: NMHDR, pub iItem: i32, pub rc: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMHDFILTERBTNCLICK {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMHDFILTERBTNCLICK { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMHDR { pub hwndFrom: super::super::Foundation::HWND, pub idFrom: usize, pub code: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMHDR {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMHDR { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMHEADERA { pub hdr: NMHDR, pub iItem: i32, pub iButton: HEADER_CONTROL_NOTIFICATION_BUTTON, pub pitem: *mut HDITEMA, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMHEADERA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMHEADERA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMHEADERW { pub hdr: NMHDR, pub iItem: i32, pub iButton: HEADER_CONTROL_NOTIFICATION_BUTTON, pub pitem: *mut HDITEMW, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMHEADERW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMHEADERW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMIPADDRESS { pub hdr: NMHDR, pub iField: i32, pub iValue: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMIPADDRESS {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMIPADDRESS { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMITEMACTIVATE { pub hdr: NMHDR, pub iItem: i32, pub iSubItem: i32, pub uNewState: u32, pub uOldState: u32, pub uChanged: u32, pub ptAction: super::super::Foundation::POINT, pub lParam: super::super::Foundation::LPARAM, pub uKeyFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMITEMACTIVATE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMITEMACTIVATE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMKEY { pub hdr: NMHDR, pub nVKey: u32, pub uFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMKEY {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMKEY { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLINK { pub hdr: NMHDR, pub item: LITEM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLINK {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLINK { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLISTVIEW { pub hdr: NMHDR, pub iItem: i32, pub iSubItem: i32, pub uNewState: u32, pub uOldState: u32, pub uChanged: u32, pub ptAction: super::super::Foundation::POINT, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLISTVIEW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLISTVIEW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVCACHEHINT { pub hdr: NMHDR, pub iFrom: i32, pub iTo: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVCACHEHINT {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVCACHEHINT { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMLVCUSTOMDRAW { pub nmcd: NMCUSTOMDRAW, pub clrText: u32, pub clrTextBk: u32, pub iSubItem: i32, pub dwItemType: NMLVCUSTOMDRAW_ITEM_TYPE, pub clrFace: u32, pub iIconEffect: i32, pub iIconPhase: i32, pub iPartId: i32, pub iStateId: i32, pub rcText: super::super::Foundation::RECT, pub uAlign: NMLVCUSTOMDRAW_ALIGN, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMLVCUSTOMDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMLVCUSTOMDRAW { fn clone(&self) -> Self { *self } } pub type NMLVCUSTOMDRAW_ALIGN = u32; pub const LVGA_HEADER_CENTER: NMLVCUSTOMDRAW_ALIGN = 2u32; pub const LVGA_HEADER_LEFT: NMLVCUSTOMDRAW_ALIGN = 1u32; pub const LVGA_HEADER_RIGHT: NMLVCUSTOMDRAW_ALIGN = 4u32; pub type NMLVCUSTOMDRAW_ITEM_TYPE = u32; pub const LVCDI_ITEM: NMLVCUSTOMDRAW_ITEM_TYPE = 0u32; pub const LVCDI_GROUP: NMLVCUSTOMDRAW_ITEM_TYPE = 1u32; pub const LVCDI_ITEMSLIST: NMLVCUSTOMDRAW_ITEM_TYPE = 2u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVDISPINFOA { pub hdr: NMHDR, pub item: LVITEMA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVDISPINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVDISPINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVDISPINFOW { pub hdr: NMHDR, pub item: LVITEMW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVDISPINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVDISPINFOW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVEMPTYMARKUP { pub hdr: NMHDR, pub dwFlags: NMLVEMPTYMARKUP_FLAGS, pub szMarkup: [u16; 2084], } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVEMPTYMARKUP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVEMPTYMARKUP { fn clone(&self) -> Self { *self } } pub type NMLVEMPTYMARKUP_FLAGS = u32; pub const EMF_CENTERED: NMLVEMPTYMARKUP_FLAGS = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVFINDITEMA { pub hdr: NMHDR, pub iStart: i32, pub lvfi: LVFINDINFOA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVFINDITEMA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVFINDITEMA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVFINDITEMW { pub hdr: NMHDR, pub iStart: i32, pub lvfi: LVFINDINFOW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVFINDITEMW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVFINDITEMW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVGETINFOTIPA { pub hdr: NMHDR, pub dwFlags: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iItem: i32, pub iSubItem: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVGETINFOTIPA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVGETINFOTIPA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVGETINFOTIPW { pub hdr: NMHDR, pub dwFlags: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iItem: i32, pub iSubItem: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVGETINFOTIPW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVGETINFOTIPW { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(feature = "Win32_Foundation")] pub struct NMLVKEYDOWN { pub hdr: NMHDR, pub wVKey: u16, pub flags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVKEYDOWN {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVKEYDOWN { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVLINK { pub hdr: NMHDR, pub link: LITEM, pub iItem: i32, pub iSubItem: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVLINK {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVLINK { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVODSTATECHANGE { pub hdr: NMHDR, pub iFrom: i32, pub iTo: i32, pub uNewState: u32, pub uOldState: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVODSTATECHANGE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVODSTATECHANGE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMLVSCROLL { pub hdr: NMHDR, pub dx: i32, pub dy: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMLVSCROLL {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMLVSCROLL { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMMOUSE { pub hdr: NMHDR, pub dwItemSpec: usize, pub dwItemData: usize, pub pt: super::super::Foundation::POINT, pub dwHitInfo: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMMOUSE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMMOUSE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMOBJECTNOTIFY { pub hdr: NMHDR, pub iItem: i32, pub piid: *mut ::windows_sys::core::GUID, pub pObject: *mut ::core::ffi::c_void, pub hResult: ::windows_sys::core::HRESULT, pub dwFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMOBJECTNOTIFY {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMOBJECTNOTIFY { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMPGCALCSIZE { pub hdr: NMHDR, pub dwFlag: NMPGCALCSIZE_FLAGS, pub iWidth: i32, pub iHeight: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMPGCALCSIZE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMPGCALCSIZE { fn clone(&self) -> Self { *self } } pub type NMPGCALCSIZE_FLAGS = u32; pub const PGF_CALCHEIGHT: NMPGCALCSIZE_FLAGS = 2u32; pub const PGF_CALCWIDTH: NMPGCALCSIZE_FLAGS = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMPGHOTITEM { pub hdr: NMHDR, pub idOld: i32, pub idNew: i32, pub dwFlags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMPGHOTITEM {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMPGHOTITEM { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(feature = "Win32_Foundation")] pub struct NMPGSCROLL { pub hdr: NMHDR, pub fwKeys: NMPGSCROLL_KEYS, pub rcParent: super::super::Foundation::RECT, pub iDir: NMPGSCROLL_DIR, pub iXpos: i32, pub iYpos: i32, pub iScroll: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMPGSCROLL {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMPGSCROLL { fn clone(&self) -> Self { *self } } pub type NMPGSCROLL_DIR = u32; pub const PGF_SCROLLDOWN: NMPGSCROLL_DIR = 2u32; pub const PGF_SCROLLLEFT: NMPGSCROLL_DIR = 4u32; pub const PGF_SCROLLRIGHT: NMPGSCROLL_DIR = 8u32; pub const PGF_SCROLLUP: NMPGSCROLL_DIR = 1u32; pub type NMPGSCROLL_KEYS = u16; pub const PGK_NONE: NMPGSCROLL_KEYS = 0u16; pub const PGK_SHIFT: NMPGSCROLL_KEYS = 1u16; pub const PGK_CONTROL: NMPGSCROLL_KEYS = 2u16; pub const PGK_MENU: NMPGSCROLL_KEYS = 4u16; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMRBAUTOSIZE { pub hdr: NMHDR, pub fChanged: super::super::Foundation::BOOL, pub rcTarget: super::super::Foundation::RECT, pub rcActual: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMRBAUTOSIZE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMRBAUTOSIZE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMREBAR { pub hdr: NMHDR, pub dwMask: NMREBAR_MASK_FLAGS, pub uBand: u32, pub fStyle: u32, pub wID: u32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMREBAR {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMREBAR { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMREBARAUTOBREAK { pub hdr: NMHDR, pub uBand: u32, pub wID: u32, pub lParam: super::super::Foundation::LPARAM, pub uMsg: u32, pub fStyleCurrent: u32, pub fAutoBreak: super::super::Foundation::BOOL, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMREBARAUTOBREAK {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMREBARAUTOBREAK { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMREBARCHEVRON { pub hdr: NMHDR, pub uBand: u32, pub wID: u32, pub lParam: super::super::Foundation::LPARAM, pub rc: super::super::Foundation::RECT, pub lParamNM: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMREBARCHEVRON {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMREBARCHEVRON { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMREBARCHILDSIZE { pub hdr: NMHDR, pub uBand: u32, pub wID: u32, pub rcChild: super::super::Foundation::RECT, pub rcBand: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMREBARCHILDSIZE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMREBARCHILDSIZE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMREBARSPLITTER { pub hdr: NMHDR, pub rcSizing: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMREBARSPLITTER {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMREBARSPLITTER { fn clone(&self) -> Self { *self } } pub type NMREBAR_MASK_FLAGS = u32; pub const RBNM_ID: NMREBAR_MASK_FLAGS = 1u32; pub const RBNM_LPARAM: NMREBAR_MASK_FLAGS = 4u32; pub const RBNM_STYLE: NMREBAR_MASK_FLAGS = 2u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMSEARCHWEB { pub hdr: NMHDR, pub entrypoint: EC_SEARCHWEB_ENTRYPOINT, pub hasQueryText: super::super::Foundation::BOOL, pub invokeSucceeded: super::super::Foundation::BOOL, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMSEARCHWEB {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMSEARCHWEB { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMSELCHANGE { pub nmhdr: NMHDR, pub stSelStart: super::super::Foundation::SYSTEMTIME, pub stSelEnd: super::super::Foundation::SYSTEMTIME, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMSELCHANGE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMSELCHANGE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMTBCUSTOMDRAW { pub nmcd: NMCUSTOMDRAW, pub hbrMonoDither: super::super::Graphics::Gdi::HBRUSH, pub hbrLines: super::super::Graphics::Gdi::HBRUSH, pub hpenLines: super::super::Graphics::Gdi::HPEN, pub clrText: u32, pub clrMark: u32, pub clrTextHighlight: u32, pub clrBtnFace: u32, pub clrBtnHighlight: u32, pub clrHighlightHotTrack: u32, pub rcText: super::super::Foundation::RECT, pub nStringBkMode: i32, pub nHLStringBkMode: i32, pub iListGap: i32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMTBCUSTOMDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMTBCUSTOMDRAW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBDISPINFOA { pub hdr: NMHDR, pub dwMask: NMTBDISPINFOW_MASK, pub idCommand: i32, pub lParam: usize, pub iImage: i32, pub pszText: super::super::Foundation::PSTR, pub cchText: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBDISPINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBDISPINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBDISPINFOW { pub hdr: NMHDR, pub dwMask: NMTBDISPINFOW_MASK, pub idCommand: i32, pub lParam: usize, pub iImage: i32, pub pszText: super::super::Foundation::PWSTR, pub cchText: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBDISPINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBDISPINFOW { fn clone(&self) -> Self { *self } } pub type NMTBDISPINFOW_MASK = u32; pub const TBNF_IMAGE: NMTBDISPINFOW_MASK = 1u32; pub const TBNF_TEXT: NMTBDISPINFOW_MASK = 2u32; pub const TBNF_DI_SETITEM: NMTBDISPINFOW_MASK = 268435456u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBGETINFOTIPA { pub hdr: NMHDR, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iItem: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBGETINFOTIPA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBGETINFOTIPA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBGETINFOTIPW { pub hdr: NMHDR, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iItem: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBGETINFOTIPW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBGETINFOTIPW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBHOTITEM { pub hdr: NMHDR, pub idOld: i32, pub idNew: i32, pub dwFlags: NMTBHOTITEM_FLAGS, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBHOTITEM {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBHOTITEM { fn clone(&self) -> Self { *self } } pub type NMTBHOTITEM_FLAGS = u32; pub const HICF_ACCELERATOR: NMTBHOTITEM_FLAGS = 4u32; pub const HICF_ARROWKEYS: NMTBHOTITEM_FLAGS = 2u32; pub const HICF_DUPACCEL: NMTBHOTITEM_FLAGS = 8u32; pub const HICF_ENTERING: NMTBHOTITEM_FLAGS = 16u32; pub const HICF_LEAVING: NMTBHOTITEM_FLAGS = 32u32; pub const HICF_LMOUSE: NMTBHOTITEM_FLAGS = 128u32; pub const HICF_MOUSE: NMTBHOTITEM_FLAGS = 1u32; pub const HICF_OTHER: NMTBHOTITEM_FLAGS = 0u32; pub const HICF_RESELECT: NMTBHOTITEM_FLAGS = 64u32; pub const HICF_TOGGLEDROPDOWN: NMTBHOTITEM_FLAGS = 256u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBRESTORE { pub hdr: NMHDR, pub pData: *mut u32, pub pCurrent: *mut u32, pub cbData: u32, pub iItem: i32, pub cButtons: i32, pub cbBytesPerRecord: i32, pub tbButton: TBBUTTON, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBRESTORE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBRESTORE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTBSAVE { pub hdr: NMHDR, pub pData: *mut u32, pub pCurrent: *mut u32, pub cbData: u32, pub iItem: i32, pub cButtons: i32, pub tbButton: TBBUTTON, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTBSAVE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTBSAVE { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(feature = "Win32_Foundation")] pub struct NMTCKEYDOWN { pub hdr: NMHDR, pub wVKey: u16, pub flags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTCKEYDOWN {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTCKEYDOWN { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTOOLBARA { pub hdr: NMHDR, pub iItem: i32, pub tbButton: TBBUTTON, pub cchText: i32, pub pszText: super::super::Foundation::PSTR, pub rcButton: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTOOLBARA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTOOLBARA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTOOLBARW { pub hdr: NMHDR, pub iItem: i32, pub tbButton: TBBUTTON, pub cchText: i32, pub pszText: super::super::Foundation::PWSTR, pub rcButton: super::super::Foundation::RECT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTOOLBARW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTOOLBARW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTOOLTIPSCREATED { pub hdr: NMHDR, pub hwndToolTips: super::super::Foundation::HWND, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTOOLTIPSCREATED {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTOOLTIPSCREATED { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTRBTHUMBPOSCHANGING { pub hdr: NMHDR, pub dwPos: u32, pub nReason: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTRBTHUMBPOSCHANGING {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTRBTHUMBPOSCHANGING { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTREEVIEWA { pub hdr: NMHDR, pub action: u32, pub itemOld: TVITEMA, pub itemNew: TVITEMA, pub ptDrag: super::super::Foundation::POINT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTREEVIEWA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTREEVIEWA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTREEVIEWW { pub hdr: NMHDR, pub action: u32, pub itemOld: TVITEMW, pub itemNew: TVITEMW, pub ptDrag: super::super::Foundation::POINT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTREEVIEWW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTREEVIEWW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMTTCUSTOMDRAW { pub nmcd: NMCUSTOMDRAW, pub uDrawFlags: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMTTCUSTOMDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMTTCUSTOMDRAW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTTDISPINFOA { pub hdr: NMHDR, pub lpszText: super::super::Foundation::PSTR, pub szText: [super::super::Foundation::CHAR; 80], pub hinst: super::super::Foundation::HINSTANCE, pub uFlags: u32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTTDISPINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTTDISPINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTTDISPINFOW { pub hdr: NMHDR, pub lpszText: super::super::Foundation::PWSTR, pub szText: [u16; 80], pub hinst: super::super::Foundation::HINSTANCE, pub uFlags: u32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTTDISPINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTTDISPINFOW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMTVASYNCDRAW { pub hdr: NMHDR, pub pimldp: *mut IMAGELISTDRAWPARAMS, pub hr: ::windows_sys::core::HRESULT, pub hItem: HTREEITEM, pub lParam: super::super::Foundation::LPARAM, pub dwRetFlags: u32, pub iRetImageIndex: i32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMTVASYNCDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMTVASYNCDRAW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct NMTVCUSTOMDRAW { pub nmcd: NMCUSTOMDRAW, pub clrText: u32, pub clrTextBk: u32, pub iLevel: i32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for NMTVCUSTOMDRAW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for NMTVCUSTOMDRAW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVDISPINFOA { pub hdr: NMHDR, pub item: TVITEMA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVDISPINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVDISPINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVDISPINFOEXA { pub hdr: NMHDR, pub item: TVITEMEXA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVDISPINFOEXA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVDISPINFOEXA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVDISPINFOEXW { pub hdr: NMHDR, pub item: TVITEMEXW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVDISPINFOEXW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVDISPINFOEXW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVDISPINFOW { pub hdr: NMHDR, pub item: TVITEMW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVDISPINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVDISPINFOW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVGETINFOTIPA { pub hdr: NMHDR, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub hItem: HTREEITEM, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVGETINFOTIPA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVGETINFOTIPA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVGETINFOTIPW { pub hdr: NMHDR, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub hItem: HTREEITEM, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVGETINFOTIPW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVGETINFOTIPW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVITEMCHANGE { pub hdr: NMHDR, pub uChanged: u32, pub hItem: HTREEITEM, pub uStateNew: u32, pub uStateOld: u32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVITEMCHANGE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVITEMCHANGE { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(feature = "Win32_Foundation")] pub struct NMTVKEYDOWN { pub hdr: NMHDR, pub wVKey: u16, pub flags: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVKEYDOWN {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVKEYDOWN { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMTVSTATEIMAGECHANGING { pub hdr: NMHDR, pub hti: HTREEITEM, pub iOldStateImageIndex: i32, pub iNewStateImageIndex: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMTVSTATEIMAGECHANGING {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMTVSTATEIMAGECHANGING { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMUPDOWN { pub hdr: NMHDR, pub iPos: i32, pub iDelta: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMUPDOWN {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMUPDOWN { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct NMVIEWCHANGE { pub nmhdr: NMHDR, pub dwOldView: u32, pub dwNewView: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for NMVIEWCHANGE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for NMVIEWCHANGE { fn clone(&self) -> Self { *self } } pub const NM_GETCUSTOMSPLITRECT: u32 = 4294966049u32; pub const ODT_HEADER: u32 = 100u32; pub type OFFSETTYPE = i32; pub const OT_TOPLEFT: OFFSETTYPE = 0i32; pub const OT_TOPRIGHT: OFFSETTYPE = 1i32; pub const OT_TOPMIDDLE: OFFSETTYPE = 2i32; pub const OT_BOTTOMLEFT: OFFSETTYPE = 3i32; pub const OT_BOTTOMRIGHT: OFFSETTYPE = 4i32; pub const OT_BOTTOMMIDDLE: OFFSETTYPE = 5i32; pub const OT_MIDDLELEFT: OFFSETTYPE = 6i32; pub const OT_MIDDLERIGHT: OFFSETTYPE = 7i32; pub const OT_LEFTOFCAPTION: OFFSETTYPE = 8i32; pub const OT_RIGHTOFCAPTION: OFFSETTYPE = 9i32; pub const OT_LEFTOFLASTBUTTON: OFFSETTYPE = 10i32; pub const OT_RIGHTOFLASTBUTTON: OFFSETTYPE = 11i32; pub const OT_ABOVELASTBUTTON: OFFSETTYPE = 12i32; pub const OT_BELOWLASTBUTTON: OFFSETTYPE = 13i32; pub type OPENBOXSTATES = i32; pub const SPOB_NORMAL: OPENBOXSTATES = 1i32; pub const SPOB_HOT: OPENBOXSTATES = 2i32; pub const SPOB_SELECTED: OPENBOXSTATES = 3i32; pub const SPOB_DISABLED: OPENBOXSTATES = 4i32; pub const SPOB_FOCUSED: OPENBOXSTATES = 5i32; pub type OPEN_THEME_DATA_FLAGS = u32; pub const OTD_FORCE_RECT_SIZING: OPEN_THEME_DATA_FLAGS = 1u32; pub const OTD_NONCLIENT: OPEN_THEME_DATA_FLAGS = 2u32; pub type PAGEPARTS = i32; pub const PGRP_UP: PAGEPARTS = 1i32; pub const PGRP_DOWN: PAGEPARTS = 2i32; pub const PGRP_UPHORZ: PAGEPARTS = 3i32; pub const PGRP_DOWNHORZ: PAGEPARTS = 4i32; pub const PAGESETUPDLGORD: u32 = 1546u32; pub const PAGESETUPDLGORDMOTIF: u32 = 1550u32; pub const PBM_DELTAPOS: u32 = 1027u32; pub const PBM_GETBARCOLOR: u32 = 1039u32; pub const PBM_GETBKCOLOR: u32 = 1038u32; pub const PBM_GETPOS: u32 = 1032u32; pub const PBM_GETRANGE: u32 = 1031u32; pub const PBM_GETSTATE: u32 = 1041u32; pub const PBM_GETSTEP: u32 = 1037u32; pub const PBM_SETBARCOLOR: u32 = 1033u32; pub const PBM_SETBKCOLOR: u32 = 8193u32; pub const PBM_SETMARQUEE: u32 = 1034u32; pub const PBM_SETPOS: u32 = 1026u32; pub const PBM_SETRANGE: u32 = 1025u32; pub const PBM_SETRANGE32: u32 = 1030u32; pub const PBM_SETSTATE: u32 = 1040u32; pub const PBM_SETSTEP: u32 = 1028u32; pub const PBM_STEPIT: u32 = 1029u32; #[repr(C)] pub struct PBRANGE { pub iLow: i32, pub iHigh: i32, } impl ::core::marker::Copy for PBRANGE {} impl ::core::clone::Clone for PBRANGE { fn clone(&self) -> Self { *self } } pub const PBST_ERROR: u32 = 2u32; pub const PBST_NORMAL: u32 = 1u32; pub const PBST_PAUSED: u32 = 3u32; pub const PBS_MARQUEE: u32 = 8u32; pub const PBS_SMOOTH: u32 = 1u32; pub const PBS_SMOOTHREVERSE: u32 = 16u32; pub const PBS_VERTICAL: u32 = 4u32; #[cfg(feature = "Win32_Foundation")] pub type PFNDACOMPARE = ::core::option::Option<unsafe extern "system" fn(p1: *const ::core::ffi::c_void, p2: *const ::core::ffi::c_void, lparam: super::super::Foundation::LPARAM) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type PFNDACOMPARECONST = ::core::option::Option<unsafe extern "system" fn(p1: *const ::core::ffi::c_void, p2: *const ::core::ffi::c_void, lparam: super::super::Foundation::LPARAM) -> i32>; pub type PFNDAENUMCALLBACK = ::core::option::Option<unsafe extern "system" fn(p: *const ::core::ffi::c_void, pdata: *const ::core::ffi::c_void) -> i32>; pub type PFNDAENUMCALLBACKCONST = ::core::option::Option<unsafe extern "system" fn(p: *const ::core::ffi::c_void, pdata: *const ::core::ffi::c_void) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type PFNDPAMERGE = ::core::option::Option<unsafe extern "system" fn(umsg: DPAMM_MESSAGE, pvdest: *const ::core::ffi::c_void, pvsrc: *const ::core::ffi::c_void, lparam: super::super::Foundation::LPARAM) -> *mut ::core::ffi::c_void>; #[cfg(feature = "Win32_Foundation")] pub type PFNDPAMERGECONST = ::core::option::Option<unsafe extern "system" fn(umsg: DPAMM_MESSAGE, pvdest: *const ::core::ffi::c_void, pvsrc: *const ::core::ffi::c_void, lparam: super::super::Foundation::LPARAM) -> *mut ::core::ffi::c_void>; #[cfg(feature = "Win32_System_Com")] pub type PFNDPASTREAM = ::core::option::Option<unsafe extern "system" fn(pinfo: *const DPASTREAMINFO, pstream: super::super::System::Com::IStream, pvinstdata: *const ::core::ffi::c_void) -> ::windows_sys::core::HRESULT>; #[cfg(feature = "Win32_Foundation")] pub type PFNLVCOMPARE = ::core::option::Option<unsafe extern "system" fn(param0: super::super::Foundation::LPARAM, param1: super::super::Foundation::LPARAM, param2: super::super::Foundation::LPARAM) -> i32>; pub type PFNLVGROUPCOMPARE = ::core::option::Option<unsafe extern "system" fn(param0: i32, param1: i32, param2: *mut ::core::ffi::c_void) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type PFNPROPSHEETCALLBACK = ::core::option::Option<unsafe extern "system" fn(param0: super::super::Foundation::HWND, param1: u32, param2: super::super::Foundation::LPARAM) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type PFNTVCOMPARE = ::core::option::Option<unsafe extern "system" fn(lparam1: super::super::Foundation::LPARAM, lparam2: super::super::Foundation::LPARAM, lparamsort: super::super::Foundation::LPARAM) -> i32>; #[cfg(feature = "Win32_Foundation")] pub type PFTASKDIALOGCALLBACK = ::core::option::Option<unsafe extern "system" fn(hwnd: super::super::Foundation::HWND, msg: u32, wparam: super::super::Foundation::WPARAM, lparam: super::super::Foundation::LPARAM, lprefdata: isize) -> ::windows_sys::core::HRESULT>; pub const PGB_BOTTOMORRIGHT: u32 = 1u32; pub const PGB_TOPORLEFT: u32 = 0u32; pub const PGF_DEPRESSED: u32 = 4u32; pub const PGF_GRAYED: u32 = 2u32; pub const PGF_HOT: u32 = 8u32; pub const PGF_INVISIBLE: u32 = 0u32; pub const PGF_NORMAL: u32 = 1u32; pub const PGM_FIRST: u32 = 5120u32; pub const PGM_FORWARDMOUSE: u32 = 5123u32; pub const PGM_GETBKCOLOR: u32 = 5125u32; pub const PGM_GETBORDER: u32 = 5127u32; pub const PGM_GETBUTTONSIZE: u32 = 5131u32; pub const PGM_GETBUTTONSTATE: u32 = 5132u32; pub const PGM_GETDROPTARGET: u32 = 8196u32; pub const PGM_GETPOS: u32 = 5129u32; pub const PGM_RECALCSIZE: u32 = 5122u32; pub const PGM_SETBKCOLOR: u32 = 5124u32; pub const PGM_SETBORDER: u32 = 5126u32; pub const PGM_SETBUTTONSIZE: u32 = 5130u32; pub const PGM_SETCHILD: u32 = 5121u32; pub const PGM_SETPOS: u32 = 5128u32; pub const PGM_SETSCROLLINFO: u32 = 5133u32; pub const PGS_AUTOSCROLL: u32 = 2u32; pub const PGS_DRAGNDROP: u32 = 4u32; pub const PGS_HORZ: u32 = 1u32; pub const PGS_VERT: u32 = 0u32; #[repr(C)] pub struct POINTER_DEVICE_CURSOR_INFO { pub cursorId: u32, pub cursor: POINTER_DEVICE_CURSOR_TYPE, } impl ::core::marker::Copy for POINTER_DEVICE_CURSOR_INFO {} impl ::core::clone::Clone for POINTER_DEVICE_CURSOR_INFO { fn clone(&self) -> Self { *self } } pub type POINTER_DEVICE_CURSOR_TYPE = i32; pub const POINTER_DEVICE_CURSOR_TYPE_UNKNOWN: POINTER_DEVICE_CURSOR_TYPE = 0i32; pub const POINTER_DEVICE_CURSOR_TYPE_TIP: POINTER_DEVICE_CURSOR_TYPE = 1i32; pub const POINTER_DEVICE_CURSOR_TYPE_ERASER: POINTER_DEVICE_CURSOR_TYPE = 2i32; pub const POINTER_DEVICE_CURSOR_TYPE_MAX: POINTER_DEVICE_CURSOR_TYPE = -1i32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct POINTER_DEVICE_INFO { pub displayOrientation: u32, pub device: super::super::Foundation::HANDLE, pub pointerDeviceType: POINTER_DEVICE_TYPE, pub monitor: super::super::Graphics::Gdi::HMONITOR, pub startingCursorId: u32, pub maxActiveContacts: u16, pub productString: [u16; 520], } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for POINTER_DEVICE_INFO {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for POINTER_DEVICE_INFO { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct POINTER_DEVICE_PROPERTY { pub logicalMin: i32, pub logicalMax: i32, pub physicalMin: i32, pub physicalMax: i32, pub unit: u32, pub unitExponent: u32, pub usagePageId: u16, pub usageId: u16, } impl ::core::marker::Copy for POINTER_DEVICE_PROPERTY {} impl ::core::clone::Clone for POINTER_DEVICE_PROPERTY { fn clone(&self) -> Self { *self } } pub type POINTER_DEVICE_TYPE = i32; pub const POINTER_DEVICE_TYPE_INTEGRATED_PEN: POINTER_DEVICE_TYPE = 1i32; pub const POINTER_DEVICE_TYPE_EXTERNAL_PEN: POINTER_DEVICE_TYPE = 2i32; pub const POINTER_DEVICE_TYPE_TOUCH: POINTER_DEVICE_TYPE = 3i32; pub const POINTER_DEVICE_TYPE_TOUCH_PAD: POINTER_DEVICE_TYPE = 4i32; pub const POINTER_DEVICE_TYPE_MAX: POINTER_DEVICE_TYPE = -1i32; pub type POINTER_FEEDBACK_MODE = i32; pub const POINTER_FEEDBACK_DEFAULT: POINTER_FEEDBACK_MODE = 1i32; pub const POINTER_FEEDBACK_INDIRECT: POINTER_FEEDBACK_MODE = 2i32; pub const POINTER_FEEDBACK_NONE: POINTER_FEEDBACK_MODE = 3i32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] pub struct POINTER_TYPE_INFO { pub r#type: super::WindowsAndMessaging::POINTER_INPUT_TYPE, pub Anonymous: POINTER_TYPE_INFO_0, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for POINTER_TYPE_INFO {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for POINTER_TYPE_INFO { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] pub union POINTER_TYPE_INFO_0 { pub touchInfo: super::Input::Pointer::POINTER_TOUCH_INFO, pub penInfo: super::Input::Pointer::POINTER_PEN_INFO, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for POINTER_TYPE_INFO_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for POINTER_TYPE_INFO_0 { fn clone(&self) -> Self { *self } } pub const PRINTDLGEXORD: u32 = 1549u32; pub const PRINTDLGORD: u32 = 1538u32; pub const PRNSETUPDLGORD: u32 = 1539u32; pub type PROPERTYORIGIN = i32; pub const PO_STATE: PROPERTYORIGIN = 0i32; pub const PO_PART: PROPERTYORIGIN = 1i32; pub const PO_CLASS: PROPERTYORIGIN = 2i32; pub const PO_GLOBAL: PROPERTYORIGIN = 3i32; pub const PO_NOTFOUND: PROPERTYORIGIN = 4i32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETHEADERA_V1 { pub dwSize: u32, pub dwFlags: u32, pub hwndParent: super::super::Foundation::HWND, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETHEADERA_V1_0, pub pszCaption: super::super::Foundation::PSTR, pub nPages: u32, pub Anonymous2: PROPSHEETHEADERA_V1_1, pub Anonymous3: PROPSHEETHEADERA_V1_2, pub pfnCallback: PFNPROPSHEETCALLBACK, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V1_0 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V1_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V1_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V1_1 { pub nStartPage: u32, pub pStartPage: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V1_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V1_2 { pub ppsp: *mut PROPSHEETPAGEA, pub phpage: *mut HPROPSHEETPAGE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V1_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V1_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETHEADERA_V2 { pub dwSize: u32, pub dwFlags: u32, pub hwndParent: super::super::Foundation::HWND, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETHEADERA_V2_0, pub pszCaption: super::super::Foundation::PSTR, pub nPages: u32, pub Anonymous2: PROPSHEETHEADERA_V2_1, pub Anonymous3: PROPSHEETHEADERA_V2_2, pub pfnCallback: PFNPROPSHEETCALLBACK, pub Anonymous4: PROPSHEETHEADERA_V2_3, pub hplWatermark: super::super::Graphics::Gdi::HPALETTE, pub Anonymous5: PROPSHEETHEADERA_V2_4, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V2_0 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V2_1 { pub nStartPage: u32, pub pStartPage: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V2_2 { pub ppsp: *mut PROPSHEETPAGEA, pub phpage: *mut HPROPSHEETPAGE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V2_3 { pub hbmWatermark: super::super::Graphics::Gdi::HBITMAP, pub pszbmWatermark: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2_3 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2_3 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERA_V2_4 { pub hbmHeader: super::super::Graphics::Gdi::HBITMAP, pub pszbmHeader: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERA_V2_4 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERA_V2_4 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETHEADERW_V1 { pub dwSize: u32, pub dwFlags: u32, pub hwndParent: super::super::Foundation::HWND, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETHEADERW_V1_0, pub pszCaption: super::super::Foundation::PWSTR, pub nPages: u32, pub Anonymous2: PROPSHEETHEADERW_V1_1, pub Anonymous3: PROPSHEETHEADERW_V1_2, pub pfnCallback: PFNPROPSHEETCALLBACK, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V1_0 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V1_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V1_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V1_1 { pub nStartPage: u32, pub pStartPage: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V1_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V1_2 { pub ppsp: *mut PROPSHEETPAGEW, pub phpage: *mut HPROPSHEETPAGE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V1_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V1_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETHEADERW_V2 { pub dwSize: u32, pub dwFlags: u32, pub hwndParent: super::super::Foundation::HWND, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETHEADERW_V2_0, pub pszCaption: super::super::Foundation::PWSTR, pub nPages: u32, pub Anonymous2: PROPSHEETHEADERW_V2_1, pub Anonymous3: PROPSHEETHEADERW_V2_2, pub pfnCallback: PFNPROPSHEETCALLBACK, pub Anonymous4: PROPSHEETHEADERW_V2_3, pub hplWatermark: super::super::Graphics::Gdi::HPALETTE, pub Anonymous5: PROPSHEETHEADERW_V2_4, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V2_0 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V2_1 { pub nStartPage: u32, pub pStartPage: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V2_2 { pub ppsp: *mut PROPSHEETPAGEW, pub phpage: *mut HPROPSHEETPAGE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V2_3 { pub hbmWatermark: super::super::Graphics::Gdi::HBITMAP, pub pszbmWatermark: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2_3 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2_3 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETHEADERW_V2_4 { pub hbmHeader: super::super::Graphics::Gdi::HBITMAP, pub pszbmHeader: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETHEADERW_V2_4 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETHEADERW_V2_4 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEA { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEA_0, pub Anonymous2: PROPSHEETPAGEA_1, pub pszTitle: super::super::Foundation::PSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKA, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PSTR, pub pszHeaderSubTitle: super::super::Foundation::PSTR, pub hActCtx: super::super::Foundation::HANDLE, pub Anonymous3: PROPSHEETPAGEA_2, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_0 { pub pszTemplate: super::super::Foundation::PSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_2 { pub hbmHeader: super::super::Graphics::Gdi::HBITMAP, pub pszbmHeader: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEA_V1 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEA_V1_0, pub Anonymous2: PROPSHEETPAGEA_V1_1, pub pszTitle: super::super::Foundation::PSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKA, pub pcRefParent: *mut u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V1_0 { pub pszTemplate: super::super::Foundation::PSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V1_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V1_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V1_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V1_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEA_V2 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEA_V2_0, pub Anonymous2: PROPSHEETPAGEA_V2_1, pub pszTitle: super::super::Foundation::PSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKA, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PSTR, pub pszHeaderSubTitle: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V2_0 { pub pszTemplate: super::super::Foundation::PSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V2_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V2_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V2_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V2_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V2_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEA_V3 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEA_V3_0, pub Anonymous2: PROPSHEETPAGEA_V3_1, pub pszTitle: super::super::Foundation::PSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKA, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PSTR, pub pszHeaderSubTitle: super::super::Foundation::PSTR, pub hActCtx: super::super::Foundation::HANDLE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V3 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V3 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V3_0 { pub pszTemplate: super::super::Foundation::PSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V3_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V3_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEA_V3_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEA_V3_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEA_V3_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEW { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEW_0, pub Anonymous2: PROPSHEETPAGEW_1, pub pszTitle: super::super::Foundation::PWSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKW, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PWSTR, pub pszHeaderSubTitle: super::super::Foundation::PWSTR, pub hActCtx: super::super::Foundation::HANDLE, pub Anonymous3: PROPSHEETPAGEW_2, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_0 { pub pszTemplate: super::super::Foundation::PWSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_2 { pub hbmHeader: super::super::Graphics::Gdi::HBITMAP, pub pszbmHeader: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEW_V1 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEW_V1_0, pub Anonymous2: PROPSHEETPAGEW_V1_1, pub pszTitle: super::super::Foundation::PWSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKW, pub pcRefParent: *mut u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V1_0 { pub pszTemplate: super::super::Foundation::PWSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V1_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V1_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V1_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V1_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V1_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEW_V2 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEW_V2_0, pub Anonymous2: PROPSHEETPAGEW_V2_1, pub pszTitle: super::super::Foundation::PWSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKW, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PWSTR, pub pszHeaderSubTitle: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V2 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V2 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V2_0 { pub pszTemplate: super::super::Foundation::PWSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V2_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V2_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V2_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V2_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V2_1 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub struct PROPSHEETPAGEW_V3 { pub dwSize: u32, pub dwFlags: u32, pub hInstance: super::super::Foundation::HINSTANCE, pub Anonymous1: PROPSHEETPAGEW_V3_0, pub Anonymous2: PROPSHEETPAGEW_V3_1, pub pszTitle: super::super::Foundation::PWSTR, pub pfnDlgProc: super::WindowsAndMessaging::DLGPROC, pub lParam: super::super::Foundation::LPARAM, pub pfnCallback: LPFNPSPCALLBACKW, pub pcRefParent: *mut u32, pub pszHeaderTitle: super::super::Foundation::PWSTR, pub pszHeaderSubTitle: super::super::Foundation::PWSTR, pub hActCtx: super::super::Foundation::HANDLE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V3 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V3 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V3_0 { pub pszTemplate: super::super::Foundation::PWSTR, pub pResource: *mut super::WindowsAndMessaging::DLGTEMPLATE, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V3_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V3_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] pub union PROPSHEETPAGEW_V3_1 { pub hIcon: super::WindowsAndMessaging::HICON, pub pszIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for PROPSHEETPAGEW_V3_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for PROPSHEETPAGEW_V3_1 { fn clone(&self) -> Self { *self } } pub const PROP_LG_CXDLG: u32 = 252u32; pub const PROP_LG_CYDLG: u32 = 218u32; pub const PROP_MED_CXDLG: u32 = 227u32; pub const PROP_MED_CYDLG: u32 = 215u32; pub const PROP_SM_CXDLG: u32 = 212u32; pub const PROP_SM_CYDLG: u32 = 188u32; pub const PSBTN_APPLYNOW: u32 = 4u32; pub const PSBTN_BACK: u32 = 0u32; pub const PSBTN_CANCEL: u32 = 5u32; pub const PSBTN_FINISH: u32 = 2u32; pub const PSBTN_HELP: u32 = 6u32; pub const PSBTN_MAX: u32 = 6u32; pub const PSBTN_NEXT: u32 = 1u32; pub const PSBTN_OK: u32 = 3u32; pub const PSCB_BUTTONPRESSED: u32 = 3u32; pub const PSCB_INITIALIZED: u32 = 1u32; pub const PSCB_PRECREATE: u32 = 2u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct PSHNOTIFY { pub hdr: NMHDR, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for PSHNOTIFY {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for PSHNOTIFY { fn clone(&self) -> Self { *self } } pub const PSH_AEROWIZARD: u32 = 16384u32; pub const PSH_DEFAULT: u32 = 0u32; pub const PSH_HASHELP: u32 = 512u32; pub const PSH_HEADER: u32 = 524288u32; pub const PSH_HEADERBITMAP: u32 = 134217728u32; pub const PSH_MODELESS: u32 = 1024u32; pub const PSH_NOAPPLYNOW: u32 = 128u32; pub const PSH_NOCONTEXTHELP: u32 = 33554432u32; pub const PSH_NOMARGIN: u32 = 268435456u32; pub const PSH_PROPSHEETPAGE: u32 = 8u32; pub const PSH_PROPTITLE: u32 = 1u32; pub const PSH_RESIZABLE: u32 = 67108864u32; pub const PSH_RTLREADING: u32 = 2048u32; pub const PSH_STRETCHWATERMARK: u32 = 262144u32; pub const PSH_USECALLBACK: u32 = 256u32; pub const PSH_USEHBMHEADER: u32 = 1048576u32; pub const PSH_USEHBMWATERMARK: u32 = 65536u32; pub const PSH_USEHICON: u32 = 2u32; pub const PSH_USEHPLWATERMARK: u32 = 131072u32; pub const PSH_USEICONID: u32 = 4u32; pub const PSH_USEPAGELANG: u32 = 2097152u32; pub const PSH_USEPSTARTPAGE: u32 = 64u32; pub const PSH_WATERMARK: u32 = 32768u32; pub const PSH_WIZARD: u32 = 32u32; pub const PSH_WIZARD97: u32 = 8192u32; pub const PSH_WIZARDCONTEXTHELP: u32 = 4096u32; pub const PSH_WIZARDHASFINISH: u32 = 16u32; pub const PSH_WIZARD_LITE: u32 = 4194304u32; pub const PSM_ADDPAGE: u32 = 1127u32; pub const PSM_APPLY: u32 = 1134u32; pub const PSM_CANCELTOCLOSE: u32 = 1131u32; pub const PSM_CHANGED: u32 = 1128u32; pub const PSM_ENABLEWIZBUTTONS: u32 = 1163u32; pub const PSM_GETCURRENTPAGEHWND: u32 = 1142u32; pub const PSM_GETRESULT: u32 = 1159u32; pub const PSM_GETTABCONTROL: u32 = 1140u32; pub const PSM_HWNDTOINDEX: u32 = 1153u32; pub const PSM_IDTOINDEX: u32 = 1157u32; pub const PSM_INDEXTOHWND: u32 = 1154u32; pub const PSM_INDEXTOID: u32 = 1158u32; pub const PSM_INDEXTOPAGE: u32 = 1156u32; pub const PSM_INSERTPAGE: u32 = 1143u32; pub const PSM_ISDIALOGMESSAGE: u32 = 1141u32; pub const PSM_PAGETOINDEX: u32 = 1155u32; pub const PSM_PRESSBUTTON: u32 = 1137u32; pub const PSM_QUERYSIBLINGS: u32 = 1132u32; pub const PSM_REBOOTSYSTEM: u32 = 1130u32; pub const PSM_RECALCPAGESIZES: u32 = 1160u32; pub const PSM_REMOVEPAGE: u32 = 1126u32; pub const PSM_RESTARTWINDOWS: u32 = 1129u32; pub const PSM_SETBUTTONTEXT: u32 = 1164u32; pub const PSM_SETBUTTONTEXTW: u32 = 1164u32; pub const PSM_SETCURSEL: u32 = 1125u32; pub const PSM_SETCURSELID: u32 = 1138u32; pub const PSM_SETFINISHTEXT: u32 = 1145u32; pub const PSM_SETFINISHTEXTA: u32 = 1139u32; pub const PSM_SETFINISHTEXTW: u32 = 1145u32; pub const PSM_SETHEADERSUBTITLE: u32 = 1152u32; pub const PSM_SETHEADERSUBTITLEA: u32 = 1151u32; pub const PSM_SETHEADERSUBTITLEW: u32 = 1152u32; pub const PSM_SETHEADERTITLE: u32 = 1150u32; pub const PSM_SETHEADERTITLEA: u32 = 1149u32; pub const PSM_SETHEADERTITLEW: u32 = 1150u32; pub const PSM_SETNEXTTEXT: u32 = 1161u32; pub const PSM_SETNEXTTEXTW: u32 = 1161u32; pub const PSM_SETTITLE: u32 = 1144u32; pub const PSM_SETTITLEA: u32 = 1135u32; pub const PSM_SETTITLEW: u32 = 1144u32; pub const PSM_SETWIZBUTTONS: u32 = 1136u32; pub const PSM_SHOWWIZBUTTONS: u32 = 1162u32; pub const PSM_UNCHANGED: u32 = 1133u32; pub const PSNRET_INVALID: u32 = 1u32; pub const PSNRET_INVALID_NOCHANGEPAGE: u32 = 2u32; pub const PSNRET_MESSAGEHANDLED: u32 = 3u32; pub const PSNRET_NOERROR: u32 = 0u32; pub type PSPCB_MESSAGE = u32; pub const PSPCB_ADDREF: PSPCB_MESSAGE = 0u32; pub const PSPCB_CREATE: PSPCB_MESSAGE = 2u32; pub const PSPCB_RELEASE: PSPCB_MESSAGE = 1u32; pub const PSPCB_SI_INITDIALOG: PSPCB_MESSAGE = 1025u32; pub const PSP_DEFAULT: u32 = 0u32; pub const PSP_DLGINDIRECT: u32 = 1u32; pub const PSP_HASHELP: u32 = 32u32; pub const PSP_HIDEHEADER: u32 = 2048u32; pub const PSP_PREMATURE: u32 = 1024u32; pub const PSP_RTLREADING: u32 = 16u32; pub const PSP_USECALLBACK: u32 = 128u32; pub const PSP_USEFUSIONCONTEXT: u32 = 16384u32; pub const PSP_USEHEADERSUBTITLE: u32 = 8192u32; pub const PSP_USEHEADERTITLE: u32 = 4096u32; pub const PSP_USEHICON: u32 = 2u32; pub const PSP_USEICONID: u32 = 4u32; pub const PSP_USEREFPARENT: u32 = 64u32; pub const PSP_USETITLE: u32 = 8u32; pub const PSWIZBF_ELEVATIONREQUIRED: u32 = 1u32; pub const PSWIZB_BACK: u32 = 1u32; pub const PSWIZB_CANCEL: u32 = 16u32; pub const PSWIZB_DISABLEDFINISH: u32 = 8u32; pub const PSWIZB_FINISH: u32 = 4u32; pub const PSWIZB_NEXT: u32 = 2u32; pub const PSWIZB_RESTORE: u32 = 1u32; pub const PSWIZB_SHOW: u32 = 0u32; pub const RBAB_ADDBAND: u32 = 2u32; pub const RBAB_AUTOSIZE: u32 = 1u32; pub const RBBIM_BACKGROUND: u32 = 128u32; pub const RBBIM_CHEVRONLOCATION: u32 = 4096u32; pub const RBBIM_CHEVRONSTATE: u32 = 8192u32; pub const RBBIM_CHILD: u32 = 16u32; pub const RBBIM_CHILDSIZE: u32 = 32u32; pub const RBBIM_COLORS: u32 = 2u32; pub const RBBIM_HEADERSIZE: u32 = 2048u32; pub const RBBIM_ID: u32 = 256u32; pub const RBBIM_IDEALSIZE: u32 = 512u32; pub const RBBIM_IMAGE: u32 = 8u32; pub const RBBIM_LPARAM: u32 = 1024u32; pub const RBBIM_SIZE: u32 = 64u32; pub const RBBIM_STYLE: u32 = 1u32; pub const RBBIM_TEXT: u32 = 4u32; pub const RBBS_BREAK: u32 = 1u32; pub const RBBS_CHILDEDGE: u32 = 4u32; pub const RBBS_FIXEDBMP: u32 = 32u32; pub const RBBS_FIXEDSIZE: u32 = 2u32; pub const RBBS_GRIPPERALWAYS: u32 = 128u32; pub const RBBS_HIDDEN: u32 = 8u32; pub const RBBS_HIDETITLE: u32 = 1024u32; pub const RBBS_NOGRIPPER: u32 = 256u32; pub const RBBS_NOVERT: u32 = 16u32; pub const RBBS_TOPALIGN: u32 = 2048u32; pub const RBBS_USECHEVRON: u32 = 512u32; pub const RBBS_VARIABLEHEIGHT: u32 = 64u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct RBHITTESTINFO { pub pt: super::super::Foundation::POINT, pub flags: u32, pub iBand: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for RBHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for RBHITTESTINFO { fn clone(&self) -> Self { *self } } pub const RBHT_CAPTION: u32 = 2u32; pub const RBHT_CHEVRON: u32 = 8u32; pub const RBHT_CLIENT: u32 = 3u32; pub const RBHT_GRABBER: u32 = 4u32; pub const RBHT_NOWHERE: u32 = 1u32; pub const RBHT_SPLITTER: u32 = 16u32; pub const RBIM_IMAGELIST: u32 = 1u32; pub const RBSTR_CHANGERECT: u32 = 1u32; pub const RBS_AUTOSIZE: u32 = 8192u32; pub const RBS_BANDBORDERS: u32 = 1024u32; pub const RBS_DBLCLKTOGGLE: u32 = 32768u32; pub const RBS_FIXEDORDER: u32 = 2048u32; pub const RBS_REGISTERDROP: u32 = 4096u32; pub const RBS_TOOLTIPS: u32 = 256u32; pub const RBS_VARHEIGHT: u32 = 512u32; pub const RBS_VERTICALGRIPPER: u32 = 16384u32; pub const RB_BEGINDRAG: u32 = 1048u32; pub const RB_DELETEBAND: u32 = 1026u32; pub const RB_DRAGMOVE: u32 = 1050u32; pub const RB_ENDDRAG: u32 = 1049u32; pub const RB_GETBANDBORDERS: u32 = 1058u32; pub const RB_GETBANDCOUNT: u32 = 1036u32; pub const RB_GETBANDINFO: u32 = 1052u32; pub const RB_GETBANDINFOA: u32 = 1053u32; pub const RB_GETBANDINFOW: u32 = 1052u32; pub const RB_GETBANDMARGINS: u32 = 1064u32; pub const RB_GETBARHEIGHT: u32 = 1051u32; pub const RB_GETBARINFO: u32 = 1027u32; pub const RB_GETBKCOLOR: u32 = 1044u32; pub const RB_GETCOLORSCHEME: u32 = 8195u32; pub const RB_GETDROPTARGET: u32 = 8196u32; pub const RB_GETEXTENDEDSTYLE: u32 = 1066u32; pub const RB_GETPALETTE: u32 = 1062u32; pub const RB_GETRECT: u32 = 1033u32; pub const RB_GETROWCOUNT: u32 = 1037u32; pub const RB_GETROWHEIGHT: u32 = 1038u32; pub const RB_GETTEXTCOLOR: u32 = 1046u32; pub const RB_GETTOOLTIPS: u32 = 1041u32; pub const RB_GETUNICODEFORMAT: u32 = 8198u32; pub const RB_HITTEST: u32 = 1032u32; pub const RB_IDTOINDEX: u32 = 1040u32; pub const RB_INSERTBAND: u32 = 1034u32; pub const RB_INSERTBANDA: u32 = 1025u32; pub const RB_INSERTBANDW: u32 = 1034u32; pub const RB_MAXIMIZEBAND: u32 = 1055u32; pub const RB_MINIMIZEBAND: u32 = 1054u32; pub const RB_MOVEBAND: u32 = 1063u32; pub const RB_PUSHCHEVRON: u32 = 1067u32; pub const RB_SETBANDINFO: u32 = 1035u32; pub const RB_SETBANDINFOA: u32 = 1030u32; pub const RB_SETBANDINFOW: u32 = 1035u32; pub const RB_SETBANDWIDTH: u32 = 1068u32; pub const RB_SETBARINFO: u32 = 1028u32; pub const RB_SETBKCOLOR: u32 = 1043u32; pub const RB_SETCOLORSCHEME: u32 = 8194u32; pub const RB_SETEXTENDEDSTYLE: u32 = 1065u32; pub const RB_SETPALETTE: u32 = 1061u32; pub const RB_SETPARENT: u32 = 1031u32; pub const RB_SETTEXTCOLOR: u32 = 1045u32; pub const RB_SETTOOLTIPS: u32 = 1042u32; pub const RB_SETUNICODEFORMAT: u32 = 8197u32; pub const RB_SETWINDOWTHEME: u32 = 8203u32; pub const RB_SHOWBAND: u32 = 1059u32; pub const RB_SIZETORECT: u32 = 1047u32; #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct REBARBANDINFOA { pub cbSize: u32, pub fMask: u32, pub fStyle: u32, pub clrFore: u32, pub clrBack: u32, pub lpText: super::super::Foundation::PSTR, pub cch: u32, pub iImage: i32, pub hwndChild: super::super::Foundation::HWND, pub cxMinChild: u32, pub cyMinChild: u32, pub cx: u32, pub hbmBack: super::super::Graphics::Gdi::HBITMAP, pub wID: u32, pub cyChild: u32, pub cyMaxChild: u32, pub cyIntegral: u32, pub cxIdeal: u32, pub lParam: super::super::Foundation::LPARAM, pub cxHeader: u32, pub rcChevronLocation: super::super::Foundation::RECT, pub uChevronState: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for REBARBANDINFOA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for REBARBANDINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] pub struct REBARBANDINFOW { pub cbSize: u32, pub fMask: u32, pub fStyle: u32, pub clrFore: u32, pub clrBack: u32, pub lpText: super::super::Foundation::PWSTR, pub cch: u32, pub iImage: i32, pub hwndChild: super::super::Foundation::HWND, pub cxMinChild: u32, pub cyMinChild: u32, pub cx: u32, pub hbmBack: super::super::Graphics::Gdi::HBITMAP, pub wID: u32, pub cyChild: u32, pub cyMaxChild: u32, pub cyIntegral: u32, pub cxIdeal: u32, pub lParam: super::super::Foundation::LPARAM, pub cxHeader: u32, pub rcChevronLocation: super::super::Foundation::RECT, pub uChevronState: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::marker::Copy for REBARBANDINFOW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi"))] impl ::core::clone::Clone for REBARBANDINFOW { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct REBARINFO { pub cbSize: u32, pub fMask: u32, pub himl: HIMAGELIST, } impl ::core::marker::Copy for REBARINFO {} impl ::core::clone::Clone for REBARINFO { fn clone(&self) -> Self { *self } } pub const REPLACEDLGORD: u32 = 1541u32; pub const RUNDLGORD: u32 = 1545u32; pub const SBARS_SIZEGRIP: u32 = 256u32; pub const SBARS_TOOLTIPS: u32 = 2048u32; pub const SBT_NOBORDERS: u32 = 256u32; pub const SBT_NOTABPARSING: u32 = 2048u32; pub const SBT_OWNERDRAW: u32 = 4096u32; pub const SBT_POPOUT: u32 = 512u32; pub const SBT_RTLREADING: u32 = 1024u32; pub const SBT_TOOLTIPS: u32 = 2048u32; pub const SB_GETBORDERS: u32 = 1031u32; pub const SB_GETICON: u32 = 1044u32; pub const SB_GETPARTS: u32 = 1030u32; pub const SB_GETRECT: u32 = 1034u32; pub const SB_GETTEXT: u32 = 1037u32; pub const SB_GETTEXTA: u32 = 1026u32; pub const SB_GETTEXTLENGTH: u32 = 1036u32; pub const SB_GETTEXTLENGTHA: u32 = 1027u32; pub const SB_GETTEXTLENGTHW: u32 = 1036u32; pub const SB_GETTEXTW: u32 = 1037u32; pub const SB_GETTIPTEXTA: u32 = 1042u32; pub const SB_GETTIPTEXTW: u32 = 1043u32; pub const SB_GETUNICODEFORMAT: u32 = 8198u32; pub const SB_ISSIMPLE: u32 = 1038u32; pub const SB_SETBKCOLOR: u32 = 8193u32; pub const SB_SETICON: u32 = 1039u32; pub const SB_SETMINHEIGHT: u32 = 1032u32; pub const SB_SETPARTS: u32 = 1028u32; pub const SB_SETTEXT: u32 = 1035u32; pub const SB_SETTEXTA: u32 = 1025u32; pub const SB_SETTEXTW: u32 = 1035u32; pub const SB_SETTIPTEXTA: u32 = 1040u32; pub const SB_SETTIPTEXTW: u32 = 1041u32; pub const SB_SETUNICODEFORMAT: u32 = 8197u32; pub const SB_SIMPLE: u32 = 1033u32; pub const SB_SIMPLEID: u32 = 255u32; pub type SIZINGTYPE = i32; pub const ST_TRUESIZE: SIZINGTYPE = 0i32; pub const ST_STRETCH: SIZINGTYPE = 1i32; pub const ST_TILE: SIZINGTYPE = 2i32; pub type SOFTWAREEXPLORERSTATES = i32; pub const SPSE_NORMAL: SOFTWAREEXPLORERSTATES = 1i32; pub const SPSE_HOT: SOFTWAREEXPLORERSTATES = 2i32; pub const SPSE_SELECTED: SOFTWAREEXPLORERSTATES = 3i32; pub const SPSE_DISABLED: SOFTWAREEXPLORERSTATES = 4i32; pub const SPSE_FOCUSED: SOFTWAREEXPLORERSTATES = 5i32; pub type STARTPANELPARTS = i32; pub const SPP_USERPANE: STARTPANELPARTS = 1i32; pub const SPP_MOREPROGRAMS: STARTPANELPARTS = 2i32; pub const SPP_MOREPROGRAMSARROW: STARTPANELPARTS = 3i32; pub const SPP_PROGLIST: STARTPANELPARTS = 4i32; pub const SPP_PROGLISTSEPARATOR: STARTPANELPARTS = 5i32; pub const SPP_PLACESLIST: STARTPANELPARTS = 6i32; pub const SPP_PLACESLISTSEPARATOR: STARTPANELPARTS = 7i32; pub const SPP_LOGOFF: STARTPANELPARTS = 8i32; pub const SPP_LOGOFFBUTTONS: STARTPANELPARTS = 9i32; pub const SPP_USERPICTURE: STARTPANELPARTS = 10i32; pub const SPP_PREVIEW: STARTPANELPARTS = 11i32; pub const SPP_MOREPROGRAMSTAB: STARTPANELPARTS = 12i32; pub const SPP_NSCHOST: STARTPANELPARTS = 13i32; pub const SPP_SOFTWAREEXPLORER: STARTPANELPARTS = 14i32; pub const SPP_OPENBOX: STARTPANELPARTS = 15i32; pub const SPP_SEARCHVIEW: STARTPANELPARTS = 16i32; pub const SPP_MOREPROGRAMSARROWBACK: STARTPANELPARTS = 17i32; pub const SPP_TOPMATCH: STARTPANELPARTS = 18i32; pub const SPP_LOGOFFSPLITBUTTONDROPDOWN: STARTPANELPARTS = 19i32; pub type STATICPARTS = i32; pub const STAT_TEXT: STATICPARTS = 1i32; pub const STD_COPY: u32 = 1u32; pub const STD_CUT: u32 = 0u32; pub const STD_DELETE: u32 = 5u32; pub const STD_FILENEW: u32 = 6u32; pub const STD_FILEOPEN: u32 = 7u32; pub const STD_FILESAVE: u32 = 8u32; pub const STD_FIND: u32 = 12u32; pub const STD_HELP: u32 = 11u32; pub const STD_PASTE: u32 = 2u32; pub const STD_PRINT: u32 = 14u32; pub const STD_PRINTPRE: u32 = 9u32; pub const STD_PROPERTIES: u32 = 10u32; pub const STD_REDOW: u32 = 4u32; pub const STD_REPLACE: u32 = 13u32; pub const STD_UNDO: u32 = 3u32; pub type TASKBANDPARTS = i32; pub const TDP_GROUPCOUNT: TASKBANDPARTS = 1i32; pub const TDP_FLASHBUTTON: TASKBANDPARTS = 2i32; pub const TDP_FLASHBUTTONGROUPMENU: TASKBANDPARTS = 3i32; pub type TASKBARPARTS = i32; pub const TBP_BACKGROUNDBOTTOM: TASKBARPARTS = 1i32; pub const TBP_BACKGROUNDRIGHT: TASKBARPARTS = 2i32; pub const TBP_BACKGROUNDTOP: TASKBARPARTS = 3i32; pub const TBP_BACKGROUNDLEFT: TASKBARPARTS = 4i32; pub const TBP_SIZINGBARBOTTOM: TASKBARPARTS = 5i32; pub const TBP_SIZINGBARRIGHT: TASKBARPARTS = 6i32; pub const TBP_SIZINGBARTOP: TASKBARPARTS = 7i32; pub const TBP_SIZINGBARLEFT: TASKBARPARTS = 8i32; #[repr(C, packed(1))] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub struct TASKDIALOGCONFIG { pub cbSize: u32, pub hwndParent: super::super::Foundation::HWND, pub hInstance: super::super::Foundation::HINSTANCE, pub dwFlags: TASKDIALOG_FLAGS, pub dwCommonButtons: TASKDIALOG_COMMON_BUTTON_FLAGS, pub pszWindowTitle: super::super::Foundation::PWSTR, pub Anonymous1: TASKDIALOGCONFIG_0, pub pszMainInstruction: super::super::Foundation::PWSTR, pub pszContent: super::super::Foundation::PWSTR, pub cButtons: u32, pub pButtons: *mut TASKDIALOG_BUTTON, pub nDefaultButton: i32, pub cRadioButtons: u32, pub pRadioButtons: *mut TASKDIALOG_BUTTON, pub nDefaultRadioButton: i32, pub pszVerificationText: super::super::Foundation::PWSTR, pub pszExpandedInformation: super::super::Foundation::PWSTR, pub pszExpandedControlText: super::super::Foundation::PWSTR, pub pszCollapsedControlText: super::super::Foundation::PWSTR, pub Anonymous2: TASKDIALOGCONFIG_1, pub pszFooter: super::super::Foundation::PWSTR, pub pfCallback: PFTASKDIALOGCALLBACK, pub lpCallbackData: isize, pub cxWidth: u32, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for TASKDIALOGCONFIG {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for TASKDIALOGCONFIG { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub union TASKDIALOGCONFIG_0 { pub hMainIcon: super::WindowsAndMessaging::HICON, pub pszMainIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for TASKDIALOGCONFIG_0 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for TASKDIALOGCONFIG_0 { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] pub union TASKDIALOGCONFIG_1 { pub hFooterIcon: super::WindowsAndMessaging::HICON, pub pszFooterIcon: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::marker::Copy for TASKDIALOGCONFIG_1 {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_WindowsAndMessaging"))] impl ::core::clone::Clone for TASKDIALOGCONFIG_1 { fn clone(&self) -> Self { *self } } #[repr(C, packed(1))] #[cfg(feature = "Win32_Foundation")] pub struct TASKDIALOG_BUTTON { pub nButtonID: i32, pub pszButtonText: super::super::Foundation::PWSTR, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TASKDIALOG_BUTTON {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TASKDIALOG_BUTTON { fn clone(&self) -> Self { *self } } pub type TASKDIALOG_COMMON_BUTTON_FLAGS = i32; pub const TDCBF_OK_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 1i32; pub const TDCBF_YES_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 2i32; pub const TDCBF_NO_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 4i32; pub const TDCBF_CANCEL_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 8i32; pub const TDCBF_RETRY_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 16i32; pub const TDCBF_CLOSE_BUTTON: TASKDIALOG_COMMON_BUTTON_FLAGS = 32i32; pub type TASKDIALOG_ELEMENTS = i32; pub const TDE_CONTENT: TASKDIALOG_ELEMENTS = 0i32; pub const TDE_EXPANDED_INFORMATION: TASKDIALOG_ELEMENTS = 1i32; pub const TDE_FOOTER: TASKDIALOG_ELEMENTS = 2i32; pub const TDE_MAIN_INSTRUCTION: TASKDIALOG_ELEMENTS = 3i32; pub type TASKDIALOG_FLAGS = i32; pub const TDF_ENABLE_HYPERLINKS: TASKDIALOG_FLAGS = 1i32; pub const TDF_USE_HICON_MAIN: TASKDIALOG_FLAGS = 2i32; pub const TDF_USE_HICON_FOOTER: TASKDIALOG_FLAGS = 4i32; pub const TDF_ALLOW_DIALOG_CANCELLATION: TASKDIALOG_FLAGS = 8i32; pub const TDF_USE_COMMAND_LINKS: TASKDIALOG_FLAGS = 16i32; pub const TDF_USE_COMMAND_LINKS_NO_ICON: TASKDIALOG_FLAGS = 32i32; pub const TDF_EXPAND_FOOTER_AREA: TASKDIALOG_FLAGS = 64i32; pub const TDF_EXPANDED_BY_DEFAULT: TASKDIALOG_FLAGS = 128i32; pub const TDF_VERIFICATION_FLAG_CHECKED: TASKDIALOG_FLAGS = 256i32; pub const TDF_SHOW_PROGRESS_BAR: TASKDIALOG_FLAGS = 512i32; pub const TDF_SHOW_MARQUEE_PROGRESS_BAR: TASKDIALOG_FLAGS = 1024i32; pub const TDF_CALLBACK_TIMER: TASKDIALOG_FLAGS = 2048i32; pub const TDF_POSITION_RELATIVE_TO_WINDOW: TASKDIALOG_FLAGS = 4096i32; pub const TDF_RTL_LAYOUT: TASKDIALOG_FLAGS = 8192i32; pub const TDF_NO_DEFAULT_RADIO_BUTTON: TASKDIALOG_FLAGS = 16384i32; pub const TDF_CAN_BE_MINIMIZED: TASKDIALOG_FLAGS = 32768i32; pub const TDF_NO_SET_FOREGROUND: TASKDIALOG_FLAGS = 65536i32; pub const TDF_SIZE_TO_CONTENT: TASKDIALOG_FLAGS = 16777216i32; pub type TASKDIALOG_ICON_ELEMENTS = i32; pub const TDIE_ICON_MAIN: TASKDIALOG_ICON_ELEMENTS = 0i32; pub const TDIE_ICON_FOOTER: TASKDIALOG_ICON_ELEMENTS = 1i32; pub type TASKDIALOG_MESSAGES = i32; pub const TDM_NAVIGATE_PAGE: TASKDIALOG_MESSAGES = 1125i32; pub const TDM_CLICK_BUTTON: TASKDIALOG_MESSAGES = 1126i32; pub const TDM_SET_MARQUEE_PROGRESS_BAR: TASKDIALOG_MESSAGES = 1127i32; pub const TDM_SET_PROGRESS_BAR_STATE: TASKDIALOG_MESSAGES = 1128i32; pub const TDM_SET_PROGRESS_BAR_RANGE: TASKDIALOG_MESSAGES = 1129i32; pub const TDM_SET_PROGRESS_BAR_POS: TASKDIALOG_MESSAGES = 1130i32; pub const TDM_SET_PROGRESS_BAR_MARQUEE: TASKDIALOG_MESSAGES = 1131i32; pub const TDM_SET_ELEMENT_TEXT: TASKDIALOG_MESSAGES = 1132i32; pub const TDM_CLICK_RADIO_BUTTON: TASKDIALOG_MESSAGES = 1134i32; pub const TDM_ENABLE_BUTTON: TASKDIALOG_MESSAGES = 1135i32; pub const TDM_ENABLE_RADIO_BUTTON: TASKDIALOG_MESSAGES = 1136i32; pub const TDM_CLICK_VERIFICATION: TASKDIALOG_MESSAGES = 1137i32; pub const TDM_UPDATE_ELEMENT_TEXT: TASKDIALOG_MESSAGES = 1138i32; pub const TDM_SET_BUTTON_ELEVATION_REQUIRED_STATE: TASKDIALOG_MESSAGES = 1139i32; pub const TDM_UPDATE_ICON: TASKDIALOG_MESSAGES = 1140i32; pub type TASKDIALOG_NOTIFICATIONS = i32; pub const TDN_CREATED: TASKDIALOG_NOTIFICATIONS = 0i32; pub const TDN_NAVIGATED: TASKDIALOG_NOTIFICATIONS = 1i32; pub const TDN_BUTTON_CLICKED: TASKDIALOG_NOTIFICATIONS = 2i32; pub const TDN_HYPERLINK_CLICKED: TASKDIALOG_NOTIFICATIONS = 3i32; pub const TDN_TIMER: TASKDIALOG_NOTIFICATIONS = 4i32; pub const TDN_DESTROYED: TASKDIALOG_NOTIFICATIONS = 5i32; pub const TDN_RADIO_BUTTON_CLICKED: TASKDIALOG_NOTIFICATIONS = 6i32; pub const TDN_DIALOG_CONSTRUCTED: TASKDIALOG_NOTIFICATIONS = 7i32; pub const TDN_VERIFICATION_CLICKED: TASKDIALOG_NOTIFICATIONS = 8i32; pub const TDN_HELP: TASKDIALOG_NOTIFICATIONS = 9i32; pub const TDN_EXPANDO_BUTTON_CLICKED: TASKDIALOG_NOTIFICATIONS = 10i32; #[repr(C)] pub struct TA_CUBIC_BEZIER { pub header: TA_TIMINGFUNCTION, pub rX0: f32, pub rY0: f32, pub rX1: f32, pub rY1: f32, } impl ::core::marker::Copy for TA_CUBIC_BEZIER {} impl ::core::clone::Clone for TA_CUBIC_BEZIER { fn clone(&self) -> Self { *self } } pub type TA_PROPERTY = i32; pub const TAP_FLAGS: TA_PROPERTY = 0i32; pub const TAP_TRANSFORMCOUNT: TA_PROPERTY = 1i32; pub const TAP_STAGGERDELAY: TA_PROPERTY = 2i32; pub const TAP_STAGGERDELAYCAP: TA_PROPERTY = 3i32; pub const TAP_STAGGERDELAYFACTOR: TA_PROPERTY = 4i32; pub const TAP_ZORDER: TA_PROPERTY = 5i32; pub type TA_PROPERTY_FLAG = u32; pub const TAPF_NONE: TA_PROPERTY_FLAG = 0u32; pub const TAPF_HASSTAGGER: TA_PROPERTY_FLAG = 1u32; pub const TAPF_ISRTLAWARE: TA_PROPERTY_FLAG = 2u32; pub const TAPF_ALLOWCOLLECTION: TA_PROPERTY_FLAG = 4u32; pub const TAPF_HASBACKGROUND: TA_PROPERTY_FLAG = 8u32; pub const TAPF_HASPERSPECTIVE: TA_PROPERTY_FLAG = 16u32; #[repr(C)] pub struct TA_TIMINGFUNCTION { pub eTimingFunctionType: TA_TIMINGFUNCTION_TYPE, } impl ::core::marker::Copy for TA_TIMINGFUNCTION {} impl ::core::clone::Clone for TA_TIMINGFUNCTION { fn clone(&self) -> Self { *self } } pub type TA_TIMINGFUNCTION_TYPE = i32; pub const TTFT_UNDEFINED: TA_TIMINGFUNCTION_TYPE = 0i32; pub const TTFT_CUBIC_BEZIER: TA_TIMINGFUNCTION_TYPE = 1i32; #[repr(C)] pub struct TA_TRANSFORM { pub eTransformType: TA_TRANSFORM_TYPE, pub dwTimingFunctionId: u32, pub dwStartTime: u32, pub dwDurationTime: u32, pub eFlags: TA_TRANSFORM_FLAG, } impl ::core::marker::Copy for TA_TRANSFORM {} impl ::core::clone::Clone for TA_TRANSFORM { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct TA_TRANSFORM_2D { pub header: TA_TRANSFORM, pub rX: f32, pub rY: f32, pub rInitialX: f32, pub rInitialY: f32, pub rOriginX: f32, pub rOriginY: f32, } impl ::core::marker::Copy for TA_TRANSFORM_2D {} impl ::core::clone::Clone for TA_TRANSFORM_2D { fn clone(&self) -> Self { *self } } #[repr(C)] pub struct TA_TRANSFORM_CLIP { pub header: TA_TRANSFORM, pub rLeft: f32, pub rTop: f32, pub rRight: f32, pub rBottom: f32, pub rInitialLeft: f32, pub rInitialTop: f32, pub rInitialRight: f32, pub rInitialBottom: f32, } impl ::core::marker::Copy for TA_TRANSFORM_CLIP {} impl ::core::clone::Clone for TA_TRANSFORM_CLIP { fn clone(&self) -> Self { *self } } pub type TA_TRANSFORM_FLAG = i32; pub const TATF_NONE: TA_TRANSFORM_FLAG = 0i32; pub const TATF_TARGETVALUES_USER: TA_TRANSFORM_FLAG = 1i32; pub const TATF_HASINITIALVALUES: TA_TRANSFORM_FLAG = 2i32; pub const TATF_HASORIGINVALUES: TA_TRANSFORM_FLAG = 4i32; #[repr(C)] pub struct TA_TRANSFORM_OPACITY { pub header: TA_TRANSFORM, pub rOpacity: f32, pub rInitialOpacity: f32, } impl ::core::marker::Copy for TA_TRANSFORM_OPACITY {} impl ::core::clone::Clone for TA_TRANSFORM_OPACITY { fn clone(&self) -> Self { *self } } pub type TA_TRANSFORM_TYPE = i32; pub const TATT_TRANSLATE_2D: TA_TRANSFORM_TYPE = 0i32; pub const TATT_SCALE_2D: TA_TRANSFORM_TYPE = 1i32; pub const TATT_OPACITY: TA_TRANSFORM_TYPE = 2i32; pub const TATT_CLIP: TA_TRANSFORM_TYPE = 3i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TBADDBITMAP { pub hInst: super::super::Foundation::HINSTANCE, pub nID: usize, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TBADDBITMAP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TBADDBITMAP { fn clone(&self) -> Self { *self } } pub const TBBF_LARGE: u32 = 1u32; #[repr(C)] #[cfg(any(target_arch = "x86_64", target_arch = "aarch64",))] pub struct TBBUTTON { pub iBitmap: i32, pub idCommand: i32, pub fsState: u8, pub fsStyle: u8, pub bReserved: [u8; 6], pub dwData: usize, pub iString: isize, } #[cfg(any(target_arch = "x86_64", target_arch = "aarch64",))] impl ::core::marker::Copy for TBBUTTON {} #[cfg(any(target_arch = "x86_64", target_arch = "aarch64",))] impl ::core::clone::Clone for TBBUTTON { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(any(target_arch = "x86",))] pub struct TBBUTTON { pub iBitmap: i32, pub idCommand: i32, pub fsState: u8, pub fsStyle: u8, pub bReserved: [u8; 2], pub dwData: usize, pub iString: isize, } #[cfg(any(target_arch = "x86",))] impl ::core::marker::Copy for TBBUTTON {} #[cfg(any(target_arch = "x86",))] impl ::core::clone::Clone for TBBUTTON { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TBBUTTONINFOA { pub cbSize: u32, pub dwMask: TBBUTTONINFOW_MASK, pub idCommand: i32, pub iImage: i32, pub fsState: u8, pub fsStyle: u8, pub cx: u16, pub lParam: usize, pub pszText: super::super::Foundation::PSTR, pub cchText: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TBBUTTONINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TBBUTTONINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TBBUTTONINFOW { pub cbSize: u32, pub dwMask: TBBUTTONINFOW_MASK, pub idCommand: i32, pub iImage: i32, pub fsState: u8, pub fsStyle: u8, pub cx: u16, pub lParam: usize, pub pszText: super::super::Foundation::PWSTR, pub cchText: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TBBUTTONINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TBBUTTONINFOW { fn clone(&self) -> Self { *self } } pub type TBBUTTONINFOW_MASK = u32; pub const TBIF_BYINDEX: TBBUTTONINFOW_MASK = 2147483648u32; pub const TBIF_COMMAND: TBBUTTONINFOW_MASK = 32u32; pub const TBIF_IMAGE: TBBUTTONINFOW_MASK = 1u32; pub const TBIF_LPARAM: TBBUTTONINFOW_MASK = 16u32; pub const TBIF_SIZE: TBBUTTONINFOW_MASK = 64u32; pub const TBIF_STATE: TBBUTTONINFOW_MASK = 4u32; pub const TBIF_STYLE: TBBUTTONINFOW_MASK = 8u32; pub const TBIF_TEXT: TBBUTTONINFOW_MASK = 2u32; pub const TBCDRF_BLENDICON: u32 = 2097152u32; pub const TBCDRF_HILITEHOTTRACK: u32 = 131072u32; pub const TBCDRF_NOBACKGROUND: u32 = 4194304u32; pub const TBCDRF_NOEDGES: u32 = 65536u32; pub const TBCDRF_NOETCHEDEFFECT: u32 = 1048576u32; pub const TBCDRF_NOMARK: u32 = 524288u32; pub const TBCDRF_NOOFFSET: u32 = 262144u32; pub const TBCDRF_USECDCOLORS: u32 = 8388608u32; pub const TBCD_CHANNEL: u32 = 3u32; pub const TBCD_THUMB: u32 = 2u32; pub const TBCD_TICS: u32 = 1u32; pub const TBDDRET_DEFAULT: u32 = 0u32; pub const TBDDRET_NODEFAULT: u32 = 1u32; pub const TBDDRET_TREATPRESSED: u32 = 2u32; #[repr(C)] pub struct TBINSERTMARK { pub iButton: i32, pub dwFlags: TBINSERTMARK_FLAGS, } impl ::core::marker::Copy for TBINSERTMARK {} impl ::core::clone::Clone for TBINSERTMARK { fn clone(&self) -> Self { *self } } pub type TBINSERTMARK_FLAGS = u32; pub const TBIMHT_NONE: TBINSERTMARK_FLAGS = 0u32; pub const TBIMHT_AFTER: TBINSERTMARK_FLAGS = 1u32; pub const TBIMHT_BACKGROUND: TBINSERTMARK_FLAGS = 2u32; #[repr(C)] pub struct TBMETRICS { pub cbSize: u32, pub dwMask: u32, pub cxPad: i32, pub cyPad: i32, pub cxBarPad: i32, pub cyBarPad: i32, pub cxButtonSpacing: i32, pub cyButtonSpacing: i32, } impl ::core::marker::Copy for TBMETRICS {} impl ::core::clone::Clone for TBMETRICS { fn clone(&self) -> Self { *self } } pub const TBMF_BARPAD: u32 = 2u32; pub const TBMF_BUTTONSPACING: u32 = 4u32; pub const TBMF_PAD: u32 = 1u32; pub const TBM_CLEARSEL: u32 = 1043u32; pub const TBM_CLEARTICS: u32 = 1033u32; pub const TBM_GETBUDDY: u32 = 1057u32; pub const TBM_GETCHANNELRECT: u32 = 1050u32; pub const TBM_GETLINESIZE: u32 = 1048u32; pub const TBM_GETNUMTICS: u32 = 1040u32; pub const TBM_GETPAGESIZE: u32 = 1046u32; pub const TBM_GETPTICS: u32 = 1038u32; pub const TBM_GETRANGEMAX: u32 = 1026u32; pub const TBM_GETRANGEMIN: u32 = 1025u32; pub const TBM_GETSELEND: u32 = 1042u32; pub const TBM_GETSELSTART: u32 = 1041u32; pub const TBM_GETTHUMBLENGTH: u32 = 1052u32; pub const TBM_GETTHUMBRECT: u32 = 1049u32; pub const TBM_GETTIC: u32 = 1027u32; pub const TBM_GETTICPOS: u32 = 1039u32; pub const TBM_GETTOOLTIPS: u32 = 1054u32; pub const TBM_GETUNICODEFORMAT: u32 = 8198u32; pub const TBM_SETBUDDY: u32 = 1056u32; pub const TBM_SETLINESIZE: u32 = 1047u32; pub const TBM_SETPAGESIZE: u32 = 1045u32; pub const TBM_SETPOS: u32 = 1029u32; pub const TBM_SETPOSNOTIFY: u32 = 1058u32; pub const TBM_SETRANGE: u32 = 1030u32; pub const TBM_SETRANGEMAX: u32 = 1032u32; pub const TBM_SETRANGEMIN: u32 = 1031u32; pub const TBM_SETSEL: u32 = 1034u32; pub const TBM_SETSELEND: u32 = 1036u32; pub const TBM_SETSELSTART: u32 = 1035u32; pub const TBM_SETTHUMBLENGTH: u32 = 1051u32; pub const TBM_SETTIC: u32 = 1028u32; pub const TBM_SETTICFREQ: u32 = 1044u32; pub const TBM_SETTIPSIDE: u32 = 1055u32; pub const TBM_SETTOOLTIPS: u32 = 1053u32; pub const TBM_SETUNICODEFORMAT: u32 = 8197u32; pub const TBNRF_ENDCUSTOMIZE: u32 = 2u32; pub const TBNRF_HIDEHELP: u32 = 1u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TBREPLACEBITMAP { pub hInstOld: super::super::Foundation::HINSTANCE, pub nIDOld: usize, pub hInstNew: super::super::Foundation::HINSTANCE, pub nIDNew: usize, pub nButtons: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TBREPLACEBITMAP {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TBREPLACEBITMAP { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] pub struct TBSAVEPARAMSA { pub hkr: super::super::System::Registry::HKEY, pub pszSubKey: super::super::Foundation::PSTR, pub pszValueName: super::super::Foundation::PSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] impl ::core::marker::Copy for TBSAVEPARAMSA {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] impl ::core::clone::Clone for TBSAVEPARAMSA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] pub struct TBSAVEPARAMSW { pub hkr: super::super::System::Registry::HKEY, pub pszSubKey: super::super::Foundation::PWSTR, pub pszValueName: super::super::Foundation::PWSTR, } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] impl ::core::marker::Copy for TBSAVEPARAMSW {} #[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Registry"))] impl ::core::clone::Clone for TBSAVEPARAMSW { fn clone(&self) -> Self { *self } } pub const TBSTATE_CHECKED: u32 = 1u32; pub const TBSTATE_ELLIPSES: u32 = 64u32; pub const TBSTATE_ENABLED: u32 = 4u32; pub const TBSTATE_HIDDEN: u32 = 8u32; pub const TBSTATE_INDETERMINATE: u32 = 16u32; pub const TBSTATE_MARKED: u32 = 128u32; pub const TBSTATE_PRESSED: u32 = 2u32; pub const TBSTATE_WRAP: u32 = 32u32; pub const TBSTYLE_ALTDRAG: u32 = 1024u32; pub const TBSTYLE_AUTOSIZE: u32 = 16u32; pub const TBSTYLE_BUTTON: u32 = 0u32; pub const TBSTYLE_CHECK: u32 = 2u32; pub const TBSTYLE_CUSTOMERASE: u32 = 8192u32; pub const TBSTYLE_DROPDOWN: u32 = 8u32; pub const TBSTYLE_EX_DOUBLEBUFFER: u32 = 128u32; pub const TBSTYLE_EX_DRAWDDARROWS: u32 = 1u32; pub const TBSTYLE_EX_HIDECLIPPEDBUTTONS: u32 = 16u32; pub const TBSTYLE_EX_MIXEDBUTTONS: u32 = 8u32; pub const TBSTYLE_EX_MULTICOLUMN: u32 = 2u32; pub const TBSTYLE_EX_VERTICAL: u32 = 4u32; pub const TBSTYLE_FLAT: u32 = 2048u32; pub const TBSTYLE_GROUP: u32 = 4u32; pub const TBSTYLE_LIST: u32 = 4096u32; pub const TBSTYLE_NOPREFIX: u32 = 32u32; pub const TBSTYLE_REGISTERDROP: u32 = 16384u32; pub const TBSTYLE_SEP: u32 = 1u32; pub const TBSTYLE_TOOLTIPS: u32 = 256u32; pub const TBSTYLE_TRANSPARENT: u32 = 32768u32; pub const TBSTYLE_WRAPABLE: u32 = 512u32; pub const TBS_AUTOTICKS: u32 = 1u32; pub const TBS_BOTH: u32 = 8u32; pub const TBS_BOTTOM: u32 = 0u32; pub const TBS_DOWNISLEFT: u32 = 1024u32; pub const TBS_ENABLESELRANGE: u32 = 32u32; pub const TBS_FIXEDLENGTH: u32 = 64u32; pub const TBS_HORZ: u32 = 0u32; pub const TBS_LEFT: u32 = 4u32; pub const TBS_NOTHUMB: u32 = 128u32; pub const TBS_NOTICKS: u32 = 16u32; pub const TBS_NOTIFYBEFOREMOVE: u32 = 2048u32; pub const TBS_REVERSED: u32 = 512u32; pub const TBS_RIGHT: u32 = 0u32; pub const TBS_TOOLTIPS: u32 = 256u32; pub const TBS_TOP: u32 = 4u32; pub const TBS_TRANSPARENTBKGND: u32 = 4096u32; pub const TBS_VERT: u32 = 2u32; pub const TBTS_BOTTOM: u32 = 2u32; pub const TBTS_LEFT: u32 = 1u32; pub const TBTS_RIGHT: u32 = 3u32; pub const TBTS_TOP: u32 = 0u32; pub const TB_ADDBITMAP: u32 = 1043u32; pub const TB_ADDBUTTONS: u32 = 1092u32; pub const TB_ADDBUTTONSA: u32 = 1044u32; pub const TB_ADDBUTTONSW: u32 = 1092u32; pub const TB_ADDSTRING: u32 = 1101u32; pub const TB_ADDSTRINGA: u32 = 1052u32; pub const TB_ADDSTRINGW: u32 = 1101u32; pub const TB_AUTOSIZE: u32 = 1057u32; pub const TB_BOTTOM: u32 = 7u32; pub const TB_BUTTONCOUNT: u32 = 1048u32; pub const TB_BUTTONSTRUCTSIZE: u32 = 1054u32; pub const TB_CHANGEBITMAP: u32 = 1067u32; pub const TB_CHECKBUTTON: u32 = 1026u32; pub const TB_COMMANDTOINDEX: u32 = 1049u32; pub const TB_CUSTOMIZE: u32 = 1051u32; pub const TB_DELETEBUTTON: u32 = 1046u32; pub const TB_ENABLEBUTTON: u32 = 1025u32; pub const TB_ENDTRACK: u32 = 8u32; pub const TB_GETANCHORHIGHLIGHT: u32 = 1098u32; pub const TB_GETBITMAP: u32 = 1068u32; pub const TB_GETBITMAPFLAGS: u32 = 1065u32; pub const TB_GETBUTTON: u32 = 1047u32; pub const TB_GETBUTTONINFO: u32 = 1087u32; pub const TB_GETBUTTONINFOA: u32 = 1089u32; pub const TB_GETBUTTONINFOW: u32 = 1087u32; pub const TB_GETBUTTONSIZE: u32 = 1082u32; pub const TB_GETBUTTONTEXT: u32 = 1099u32; pub const TB_GETBUTTONTEXTA: u32 = 1069u32; pub const TB_GETBUTTONTEXTW: u32 = 1099u32; pub const TB_GETCOLORSCHEME: u32 = 8195u32; pub const TB_GETDISABLEDIMAGELIST: u32 = 1079u32; pub const TB_GETEXTENDEDSTYLE: u32 = 1109u32; pub const TB_GETHOTIMAGELIST: u32 = 1077u32; pub const TB_GETHOTITEM: u32 = 1095u32; pub const TB_GETIDEALSIZE: u32 = 1123u32; pub const TB_GETIMAGELIST: u32 = 1073u32; pub const TB_GETIMAGELISTCOUNT: u32 = 1122u32; pub const TB_GETINSERTMARK: u32 = 1103u32; pub const TB_GETINSERTMARKCOLOR: u32 = 1113u32; pub const TB_GETITEMDROPDOWNRECT: u32 = 1127u32; pub const TB_GETITEMRECT: u32 = 1053u32; pub const TB_GETMAXSIZE: u32 = 1107u32; pub const TB_GETMETRICS: u32 = 1125u32; pub const TB_GETOBJECT: u32 = 1086u32; pub const TB_GETPADDING: u32 = 1110u32; pub const TB_GETPRESSEDIMAGELIST: u32 = 1129u32; pub const TB_GETRECT: u32 = 1075u32; pub const TB_GETROWS: u32 = 1064u32; pub const TB_GETSTATE: u32 = 1042u32; pub const TB_GETSTRING: u32 = 1115u32; pub const TB_GETSTRINGA: u32 = 1116u32; pub const TB_GETSTRINGW: u32 = 1115u32; pub const TB_GETSTYLE: u32 = 1081u32; pub const TB_GETTEXTROWS: u32 = 1085u32; pub const TB_GETTOOLTIPS: u32 = 1059u32; pub const TB_GETUNICODEFORMAT: u32 = 8198u32; pub const TB_HASACCELERATOR: u32 = 1119u32; pub const TB_HIDEBUTTON: u32 = 1028u32; pub const TB_HITTEST: u32 = 1093u32; pub const TB_INDETERMINATE: u32 = 1029u32; pub const TB_INSERTBUTTON: u32 = 1091u32; pub const TB_INSERTBUTTONA: u32 = 1045u32; pub const TB_INSERTBUTTONW: u32 = 1091u32; pub const TB_INSERTMARKHITTEST: u32 = 1105u32; pub const TB_ISBUTTONCHECKED: u32 = 1034u32; pub const TB_ISBUTTONENABLED: u32 = 1033u32; pub const TB_ISBUTTONHIDDEN: u32 = 1036u32; pub const TB_ISBUTTONHIGHLIGHTED: u32 = 1038u32; pub const TB_ISBUTTONINDETERMINATE: u32 = 1037u32; pub const TB_ISBUTTONPRESSED: u32 = 1035u32; pub const TB_LINEDOWN: u32 = 1u32; pub const TB_LINEUP: u32 = 0u32; pub const TB_LOADIMAGES: u32 = 1074u32; pub const TB_MAPACCELERATOR: u32 = 1114u32; pub const TB_MAPACCELERATORA: u32 = 1102u32; pub const TB_MAPACCELERATORW: u32 = 1114u32; pub const TB_MARKBUTTON: u32 = 1030u32; pub const TB_MOVEBUTTON: u32 = 1106u32; pub const TB_PAGEDOWN: u32 = 3u32; pub const TB_PAGEUP: u32 = 2u32; pub const TB_PRESSBUTTON: u32 = 1027u32; pub const TB_REPLACEBITMAP: u32 = 1070u32; pub const TB_SAVERESTORE: u32 = 1100u32; pub const TB_SAVERESTOREA: u32 = 1050u32; pub const TB_SAVERESTOREW: u32 = 1100u32; pub const TB_SETANCHORHIGHLIGHT: u32 = 1097u32; pub const TB_SETBITMAPSIZE: u32 = 1056u32; pub const TB_SETBOUNDINGSIZE: u32 = 1117u32; pub const TB_SETBUTTONINFO: u32 = 1088u32; pub const TB_SETBUTTONINFOA: u32 = 1090u32; pub const TB_SETBUTTONINFOW: u32 = 1088u32; pub const TB_SETBUTTONSIZE: u32 = 1055u32; pub const TB_SETBUTTONWIDTH: u32 = 1083u32; pub const TB_SETCMDID: u32 = 1066u32; pub const TB_SETCOLORSCHEME: u32 = 8194u32; pub const TB_SETDISABLEDIMAGELIST: u32 = 1078u32; pub const TB_SETDRAWTEXTFLAGS: u32 = 1094u32; pub const TB_SETEXTENDEDSTYLE: u32 = 1108u32; pub const TB_SETHOTIMAGELIST: u32 = 1076u32; pub const TB_SETHOTITEM: u32 = 1096u32; pub const TB_SETHOTITEM2: u32 = 1118u32; pub const TB_SETIMAGELIST: u32 = 1072u32; pub const TB_SETINDENT: u32 = 1071u32; pub const TB_SETINSERTMARK: u32 = 1104u32; pub const TB_SETINSERTMARKCOLOR: u32 = 1112u32; pub const TB_SETLISTGAP: u32 = 1120u32; pub const TB_SETMAXTEXTROWS: u32 = 1084u32; pub const TB_SETMETRICS: u32 = 1126u32; pub const TB_SETPADDING: u32 = 1111u32; pub const TB_SETPARENT: u32 = 1061u32; pub const TB_SETPRESSEDIMAGELIST: u32 = 1128u32; pub const TB_SETROWS: u32 = 1063u32; pub const TB_SETSTATE: u32 = 1041u32; pub const TB_SETSTYLE: u32 = 1080u32; pub const TB_SETTOOLTIPS: u32 = 1060u32; pub const TB_SETUNICODEFORMAT: u32 = 8197u32; pub const TB_SETWINDOWTHEME: u32 = 8203u32; pub const TB_THUMBPOSITION: u32 = 4u32; pub const TB_THUMBTRACK: u32 = 5u32; pub const TB_TOP: u32 = 6u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TCHITTESTINFO { pub pt: super::super::Foundation::POINT, pub flags: TCHITTESTINFO_FLAGS, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TCHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TCHITTESTINFO { fn clone(&self) -> Self { *self } } pub type TCHITTESTINFO_FLAGS = u32; pub const TCHT_NOWHERE: TCHITTESTINFO_FLAGS = 1u32; pub const TCHT_ONITEM: TCHITTESTINFO_FLAGS = 6u32; pub const TCHT_ONITEMICON: TCHITTESTINFO_FLAGS = 2u32; pub const TCHT_ONITEMLABEL: TCHITTESTINFO_FLAGS = 4u32; pub const TCIS_BUTTONPRESSED: u32 = 1u32; pub const TCIS_HIGHLIGHTED: u32 = 2u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TCITEMA { pub mask: TCITEMHEADERA_MASK, pub dwState: u32, pub dwStateMask: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TCITEMA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TCITEMA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TCITEMHEADERA { pub mask: TCITEMHEADERA_MASK, pub lpReserved1: u32, pub lpReserved2: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TCITEMHEADERA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TCITEMHEADERA { fn clone(&self) -> Self { *self } } pub type TCITEMHEADERA_MASK = u32; pub const TCIF_IMAGE: TCITEMHEADERA_MASK = 2u32; pub const TCIF_RTLREADING: TCITEMHEADERA_MASK = 4u32; pub const TCIF_TEXT: TCITEMHEADERA_MASK = 1u32; pub const TCIF_PARAM: TCITEMHEADERA_MASK = 8u32; pub const TCIF_STATE: TCITEMHEADERA_MASK = 16u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TCITEMHEADERW { pub mask: TCITEMHEADERA_MASK, pub lpReserved1: u32, pub lpReserved2: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TCITEMHEADERW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TCITEMHEADERW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TCITEMW { pub mask: TCITEMHEADERA_MASK, pub dwState: u32, pub dwStateMask: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TCITEMW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TCITEMW { fn clone(&self) -> Self { *self } } pub const TCM_ADJUSTRECT: u32 = 4904u32; pub const TCM_DELETEALLITEMS: u32 = 4873u32; pub const TCM_DELETEITEM: u32 = 4872u32; pub const TCM_DESELECTALL: u32 = 4914u32; pub const TCM_FIRST: u32 = 4864u32; pub const TCM_GETCURFOCUS: u32 = 4911u32; pub const TCM_GETCURSEL: u32 = 4875u32; pub const TCM_GETEXTENDEDSTYLE: u32 = 4917u32; pub const TCM_GETIMAGELIST: u32 = 4866u32; pub const TCM_GETITEM: u32 = 4924u32; pub const TCM_GETITEMA: u32 = 4869u32; pub const TCM_GETITEMCOUNT: u32 = 4868u32; pub const TCM_GETITEMRECT: u32 = 4874u32; pub const TCM_GETITEMW: u32 = 4924u32; pub const TCM_GETROWCOUNT: u32 = 4908u32; pub const TCM_GETTOOLTIPS: u32 = 4909u32; pub const TCM_GETUNICODEFORMAT: u32 = 8198u32; pub const TCM_HIGHLIGHTITEM: u32 = 4915u32; pub const TCM_HITTEST: u32 = 4877u32; pub const TCM_INSERTITEM: u32 = 4926u32; pub const TCM_INSERTITEMA: u32 = 4871u32; pub const TCM_INSERTITEMW: u32 = 4926u32; pub const TCM_REMOVEIMAGE: u32 = 4906u32; pub const TCM_SETCURFOCUS: u32 = 4912u32; pub const TCM_SETCURSEL: u32 = 4876u32; pub const TCM_SETEXTENDEDSTYLE: u32 = 4916u32; pub const TCM_SETIMAGELIST: u32 = 4867u32; pub const TCM_SETITEM: u32 = 4925u32; pub const TCM_SETITEMA: u32 = 4870u32; pub const TCM_SETITEMEXTRA: u32 = 4878u32; pub const TCM_SETITEMSIZE: u32 = 4905u32; pub const TCM_SETITEMW: u32 = 4925u32; pub const TCM_SETMINTABWIDTH: u32 = 4913u32; pub const TCM_SETPADDING: u32 = 4907u32; pub const TCM_SETTOOLTIPS: u32 = 4910u32; pub const TCM_SETUNICODEFORMAT: u32 = 8197u32; pub const TCS_BOTTOM: u32 = 2u32; pub const TCS_BUTTONS: u32 = 256u32; pub const TCS_EX_FLATSEPARATORS: u32 = 1u32; pub const TCS_EX_REGISTERDROP: u32 = 2u32; pub const TCS_FIXEDWIDTH: u32 = 1024u32; pub const TCS_FLATBUTTONS: u32 = 8u32; pub const TCS_FOCUSNEVER: u32 = 32768u32; pub const TCS_FOCUSONBUTTONDOWN: u32 = 4096u32; pub const TCS_FORCEICONLEFT: u32 = 16u32; pub const TCS_FORCELABELLEFT: u32 = 32u32; pub const TCS_HOTTRACK: u32 = 64u32; pub const TCS_MULTILINE: u32 = 512u32; pub const TCS_MULTISELECT: u32 = 4u32; pub const TCS_OWNERDRAWFIXED: u32 = 8192u32; pub const TCS_RAGGEDRIGHT: u32 = 2048u32; pub const TCS_RIGHT: u32 = 2u32; pub const TCS_RIGHTJUSTIFY: u32 = 0u32; pub const TCS_SCROLLOPPOSITE: u32 = 1u32; pub const TCS_SINGLELINE: u32 = 0u32; pub const TCS_TABS: u32 = 0u32; pub const TCS_TOOLTIPS: u32 = 16384u32; pub const TCS_VERTICAL: u32 = 128u32; pub type TEXTSHADOWTYPE = i32; pub const TST_NONE: TEXTSHADOWTYPE = 0i32; pub const TST_SINGLE: TEXTSHADOWTYPE = 1i32; pub const TST_CONTINUOUS: TEXTSHADOWTYPE = 2i32; pub type THEMESIZE = i32; pub const TS_MIN: THEMESIZE = 0i32; pub const TS_TRUE: THEMESIZE = 1i32; pub const TS_DRAW: THEMESIZE = 2i32; pub type THEME_PROPERTY_SYMBOL_ID = u32; pub const TMT_RESERVEDLOW: THEME_PROPERTY_SYMBOL_ID = 0u32; pub const TMT_RESERVEDHIGH: THEME_PROPERTY_SYMBOL_ID = 7999u32; pub const TMT_DIBDATA: THEME_PROPERTY_SYMBOL_ID = 2u32; pub const TMT_GLYPHDIBDATA: THEME_PROPERTY_SYMBOL_ID = 8u32; pub const TMT_ENUM: THEME_PROPERTY_SYMBOL_ID = 200u32; pub const TMT_STRING: THEME_PROPERTY_SYMBOL_ID = 201u32; pub const TMT_INT: THEME_PROPERTY_SYMBOL_ID = 202u32; pub const TMT_BOOL: THEME_PROPERTY_SYMBOL_ID = 203u32; pub const TMT_COLOR: THEME_PROPERTY_SYMBOL_ID = 204u32; pub const TMT_MARGINS: THEME_PROPERTY_SYMBOL_ID = 205u32; pub const TMT_FILENAME: THEME_PROPERTY_SYMBOL_ID = 206u32; pub const TMT_SIZE: THEME_PROPERTY_SYMBOL_ID = 207u32; pub const TMT_POSITION: THEME_PROPERTY_SYMBOL_ID = 208u32; pub const TMT_RECT: THEME_PROPERTY_SYMBOL_ID = 209u32; pub const TMT_FONT: THEME_PROPERTY_SYMBOL_ID = 210u32; pub const TMT_INTLIST: THEME_PROPERTY_SYMBOL_ID = 211u32; pub const TMT_HBITMAP: THEME_PROPERTY_SYMBOL_ID = 212u32; pub const TMT_DISKSTREAM: THEME_PROPERTY_SYMBOL_ID = 213u32; pub const TMT_STREAM: THEME_PROPERTY_SYMBOL_ID = 214u32; pub const TMT_BITMAPREF: THEME_PROPERTY_SYMBOL_ID = 215u32; pub const TMT_FLOAT: THEME_PROPERTY_SYMBOL_ID = 216u32; pub const TMT_FLOATLIST: THEME_PROPERTY_SYMBOL_ID = 217u32; pub const TMT_COLORSCHEMES: THEME_PROPERTY_SYMBOL_ID = 401u32; pub const TMT_SIZES: THEME_PROPERTY_SYMBOL_ID = 402u32; pub const TMT_CHARSET: THEME_PROPERTY_SYMBOL_ID = 403u32; pub const TMT_NAME: THEME_PROPERTY_SYMBOL_ID = 600u32; pub const TMT_DISPLAYNAME: THEME_PROPERTY_SYMBOL_ID = 601u32; pub const TMT_TOOLTIP: THEME_PROPERTY_SYMBOL_ID = 602u32; pub const TMT_COMPANY: THEME_PROPERTY_SYMBOL_ID = 603u32; pub const TMT_AUTHOR: THEME_PROPERTY_SYMBOL_ID = 604u32; pub const TMT_COPYRIGHT: THEME_PROPERTY_SYMBOL_ID = 605u32; pub const TMT_URL: THEME_PROPERTY_SYMBOL_ID = 606u32; pub const TMT_VERSION: THEME_PROPERTY_SYMBOL_ID = 607u32; pub const TMT_DESCRIPTION: THEME_PROPERTY_SYMBOL_ID = 608u32; pub const TMT_FIRST_RCSTRING_NAME: THEME_PROPERTY_SYMBOL_ID = 601u32; pub const TMT_LAST_RCSTRING_NAME: THEME_PROPERTY_SYMBOL_ID = 608u32; pub const TMT_CAPTIONFONT: THEME_PROPERTY_SYMBOL_ID = 801u32; pub const TMT_SMALLCAPTIONFONT: THEME_PROPERTY_SYMBOL_ID = 802u32; pub const TMT_MENUFONT: THEME_PROPERTY_SYMBOL_ID = 803u32; pub const TMT_STATUSFONT: THEME_PROPERTY_SYMBOL_ID = 804u32; pub const TMT_MSGBOXFONT: THEME_PROPERTY_SYMBOL_ID = 805u32; pub const TMT_ICONTITLEFONT: THEME_PROPERTY_SYMBOL_ID = 806u32; pub const TMT_HEADING1FONT: THEME_PROPERTY_SYMBOL_ID = 807u32; pub const TMT_HEADING2FONT: THEME_PROPERTY_SYMBOL_ID = 808u32; pub const TMT_BODYFONT: THEME_PROPERTY_SYMBOL_ID = 809u32; pub const TMT_FIRSTFONT: THEME_PROPERTY_SYMBOL_ID = 801u32; pub const TMT_LASTFONT: THEME_PROPERTY_SYMBOL_ID = 809u32; pub const TMT_FLATMENUS: THEME_PROPERTY_SYMBOL_ID = 1001u32; pub const TMT_FIRSTBOOL: THEME_PROPERTY_SYMBOL_ID = 1001u32; pub const TMT_LASTBOOL: THEME_PROPERTY_SYMBOL_ID = 1001u32; pub const TMT_SIZINGBORDERWIDTH: THEME_PROPERTY_SYMBOL_ID = 1201u32; pub const TMT_SCROLLBARWIDTH: THEME_PROPERTY_SYMBOL_ID = 1202u32; pub const TMT_SCROLLBARHEIGHT: THEME_PROPERTY_SYMBOL_ID = 1203u32; pub const TMT_CAPTIONBARWIDTH: THEME_PROPERTY_SYMBOL_ID = 1204u32; pub const TMT_CAPTIONBARHEIGHT: THEME_PROPERTY_SYMBOL_ID = 1205u32; pub const TMT_SMCAPTIONBARWIDTH: THEME_PROPERTY_SYMBOL_ID = 1206u32; pub const TMT_SMCAPTIONBARHEIGHT: THEME_PROPERTY_SYMBOL_ID = 1207u32; pub const TMT_MENUBARWIDTH: THEME_PROPERTY_SYMBOL_ID = 1208u32; pub const TMT_MENUBARHEIGHT: THEME_PROPERTY_SYMBOL_ID = 1209u32; pub const TMT_PADDEDBORDERWIDTH: THEME_PROPERTY_SYMBOL_ID = 1210u32; pub const TMT_FIRSTSIZE: THEME_PROPERTY_SYMBOL_ID = 1201u32; pub const TMT_LASTSIZE: THEME_PROPERTY_SYMBOL_ID = 1210u32; pub const TMT_MINCOLORDEPTH: THEME_PROPERTY_SYMBOL_ID = 1301u32; pub const TMT_FIRSTINT: THEME_PROPERTY_SYMBOL_ID = 1301u32; pub const TMT_LASTINT: THEME_PROPERTY_SYMBOL_ID = 1301u32; pub const TMT_CSSNAME: THEME_PROPERTY_SYMBOL_ID = 1401u32; pub const TMT_XMLNAME: THEME_PROPERTY_SYMBOL_ID = 1402u32; pub const TMT_LASTUPDATED: THEME_PROPERTY_SYMBOL_ID = 1403u32; pub const TMT_ALIAS: THEME_PROPERTY_SYMBOL_ID = 1404u32; pub const TMT_FIRSTSTRING: THEME_PROPERTY_SYMBOL_ID = 1401u32; pub const TMT_LASTSTRING: THEME_PROPERTY_SYMBOL_ID = 1404u32; pub const TMT_SCROLLBAR: THEME_PROPERTY_SYMBOL_ID = 1601u32; pub const TMT_BACKGROUND: THEME_PROPERTY_SYMBOL_ID = 1602u32; pub const TMT_ACTIVECAPTION: THEME_PROPERTY_SYMBOL_ID = 1603u32; pub const TMT_INACTIVECAPTION: THEME_PROPERTY_SYMBOL_ID = 1604u32; pub const TMT_MENU: THEME_PROPERTY_SYMBOL_ID = 1605u32; pub const TMT_WINDOW: THEME_PROPERTY_SYMBOL_ID = 1606u32; pub const TMT_WINDOWFRAME: THEME_PROPERTY_SYMBOL_ID = 1607u32; pub const TMT_MENUTEXT: THEME_PROPERTY_SYMBOL_ID = 1608u32; pub const TMT_WINDOWTEXT: THEME_PROPERTY_SYMBOL_ID = 1609u32; pub const TMT_CAPTIONTEXT: THEME_PROPERTY_SYMBOL_ID = 1610u32; pub const TMT_ACTIVEBORDER: THEME_PROPERTY_SYMBOL_ID = 1611u32; pub const TMT_INACTIVEBORDER: THEME_PROPERTY_SYMBOL_ID = 1612u32; pub const TMT_APPWORKSPACE: THEME_PROPERTY_SYMBOL_ID = 1613u32; pub const TMT_HIGHLIGHT: THEME_PROPERTY_SYMBOL_ID = 1614u32; pub const TMT_HIGHLIGHTTEXT: THEME_PROPERTY_SYMBOL_ID = 1615u32; pub const TMT_BTNFACE: THEME_PROPERTY_SYMBOL_ID = 1616u32; pub const TMT_BTNSHADOW: THEME_PROPERTY_SYMBOL_ID = 1617u32; pub const TMT_GRAYTEXT: THEME_PROPERTY_SYMBOL_ID = 1618u32; pub const TMT_BTNTEXT: THEME_PROPERTY_SYMBOL_ID = 1619u32; pub const TMT_INACTIVECAPTIONTEXT: THEME_PROPERTY_SYMBOL_ID = 1620u32; pub const TMT_BTNHIGHLIGHT: THEME_PROPERTY_SYMBOL_ID = 1621u32; pub const TMT_DKSHADOW3D: THEME_PROPERTY_SYMBOL_ID = 1622u32; pub const TMT_LIGHT3D: THEME_PROPERTY_SYMBOL_ID = 1623u32; pub const TMT_INFOTEXT: THEME_PROPERTY_SYMBOL_ID = 1624u32; pub const TMT_INFOBK: THEME_PROPERTY_SYMBOL_ID = 1625u32; pub const TMT_BUTTONALTERNATEFACE: THEME_PROPERTY_SYMBOL_ID = 1626u32; pub const TMT_HOTTRACKING: THEME_PROPERTY_SYMBOL_ID = 1627u32; pub const TMT_GRADIENTACTIVECAPTION: THEME_PROPERTY_SYMBOL_ID = 1628u32; pub const TMT_GRADIENTINACTIVECAPTION: THEME_PROPERTY_SYMBOL_ID = 1629u32; pub const TMT_MENUHILIGHT: THEME_PROPERTY_SYMBOL_ID = 1630u32; pub const TMT_MENUBAR: THEME_PROPERTY_SYMBOL_ID = 1631u32; pub const TMT_FIRSTCOLOR: THEME_PROPERTY_SYMBOL_ID = 1601u32; pub const TMT_LASTCOLOR: THEME_PROPERTY_SYMBOL_ID = 1631u32; pub const TMT_FROMHUE1: THEME_PROPERTY_SYMBOL_ID = 1801u32; pub const TMT_FROMHUE2: THEME_PROPERTY_SYMBOL_ID = 1802u32; pub const TMT_FROMHUE3: THEME_PROPERTY_SYMBOL_ID = 1803u32; pub const TMT_FROMHUE4: THEME_PROPERTY_SYMBOL_ID = 1804u32; pub const TMT_FROMHUE5: THEME_PROPERTY_SYMBOL_ID = 1805u32; pub const TMT_TOHUE1: THEME_PROPERTY_SYMBOL_ID = 1806u32; pub const TMT_TOHUE2: THEME_PROPERTY_SYMBOL_ID = 1807u32; pub const TMT_TOHUE3: THEME_PROPERTY_SYMBOL_ID = 1808u32; pub const TMT_TOHUE4: THEME_PROPERTY_SYMBOL_ID = 1809u32; pub const TMT_TOHUE5: THEME_PROPERTY_SYMBOL_ID = 1810u32; pub const TMT_FROMCOLOR1: THEME_PROPERTY_SYMBOL_ID = 2001u32; pub const TMT_FROMCOLOR2: THEME_PROPERTY_SYMBOL_ID = 2002u32; pub const TMT_FROMCOLOR3: THEME_PROPERTY_SYMBOL_ID = 2003u32; pub const TMT_FROMCOLOR4: THEME_PROPERTY_SYMBOL_ID = 2004u32; pub const TMT_FROMCOLOR5: THEME_PROPERTY_SYMBOL_ID = 2005u32; pub const TMT_TOCOLOR1: THEME_PROPERTY_SYMBOL_ID = 2006u32; pub const TMT_TOCOLOR2: THEME_PROPERTY_SYMBOL_ID = 2007u32; pub const TMT_TOCOLOR3: THEME_PROPERTY_SYMBOL_ID = 2008u32; pub const TMT_TOCOLOR4: THEME_PROPERTY_SYMBOL_ID = 2009u32; pub const TMT_TOCOLOR5: THEME_PROPERTY_SYMBOL_ID = 2010u32; pub const TMT_TRANSPARENT: THEME_PROPERTY_SYMBOL_ID = 2201u32; pub const TMT_AUTOSIZE: THEME_PROPERTY_SYMBOL_ID = 2202u32; pub const TMT_BORDERONLY: THEME_PROPERTY_SYMBOL_ID = 2203u32; pub const TMT_COMPOSITED: THEME_PROPERTY_SYMBOL_ID = 2204u32; pub const TMT_BGFILL: THEME_PROPERTY_SYMBOL_ID = 2205u32; pub const TMT_GLYPHTRANSPARENT: THEME_PROPERTY_SYMBOL_ID = 2206u32; pub const TMT_GLYPHONLY: THEME_PROPERTY_SYMBOL_ID = 2207u32; pub const TMT_ALWAYSSHOWSIZINGBAR: THEME_PROPERTY_SYMBOL_ID = 2208u32; pub const TMT_MIRRORIMAGE: THEME_PROPERTY_SYMBOL_ID = 2209u32; pub const TMT_UNIFORMSIZING: THEME_PROPERTY_SYMBOL_ID = 2210u32; pub const TMT_INTEGRALSIZING: THEME_PROPERTY_SYMBOL_ID = 2211u32; pub const TMT_SOURCEGROW: THEME_PROPERTY_SYMBOL_ID = 2212u32; pub const TMT_SOURCESHRINK: THEME_PROPERTY_SYMBOL_ID = 2213u32; pub const TMT_DRAWBORDERS: THEME_PROPERTY_SYMBOL_ID = 2214u32; pub const TMT_NOETCHEDEFFECT: THEME_PROPERTY_SYMBOL_ID = 2215u32; pub const TMT_TEXTAPPLYOVERLAY: THEME_PROPERTY_SYMBOL_ID = 2216u32; pub const TMT_TEXTGLOW: THEME_PROPERTY_SYMBOL_ID = 2217u32; pub const TMT_TEXTITALIC: THEME_PROPERTY_SYMBOL_ID = 2218u32; pub const TMT_COMPOSITEDOPAQUE: THEME_PROPERTY_SYMBOL_ID = 2219u32; pub const TMT_LOCALIZEDMIRRORIMAGE: THEME_PROPERTY_SYMBOL_ID = 2220u32; pub const TMT_IMAGECOUNT: THEME_PROPERTY_SYMBOL_ID = 2401u32; pub const TMT_ALPHALEVEL: THEME_PROPERTY_SYMBOL_ID = 2402u32; pub const TMT_BORDERSIZE: THEME_PROPERTY_SYMBOL_ID = 2403u32; pub const TMT_ROUNDCORNERWIDTH: THEME_PROPERTY_SYMBOL_ID = 2404u32; pub const TMT_ROUNDCORNERHEIGHT: THEME_PROPERTY_SYMBOL_ID = 2405u32; pub const TMT_GRADIENTRATIO1: THEME_PROPERTY_SYMBOL_ID = 2406u32; pub const TMT_GRADIENTRATIO2: THEME_PROPERTY_SYMBOL_ID = 2407u32; pub const TMT_GRADIENTRATIO3: THEME_PROPERTY_SYMBOL_ID = 2408u32; pub const TMT_GRADIENTRATIO4: THEME_PROPERTY_SYMBOL_ID = 2409u32; pub const TMT_GRADIENTRATIO5: THEME_PROPERTY_SYMBOL_ID = 2410u32; pub const TMT_PROGRESSCHUNKSIZE: THEME_PROPERTY_SYMBOL_ID = 2411u32; pub const TMT_PROGRESSSPACESIZE: THEME_PROPERTY_SYMBOL_ID = 2412u32; pub const TMT_SATURATION: THEME_PROPERTY_SYMBOL_ID = 2413u32; pub const TMT_TEXTBORDERSIZE: THEME_PROPERTY_SYMBOL_ID = 2414u32; pub const TMT_ALPHATHRESHOLD: THEME_PROPERTY_SYMBOL_ID = 2415u32; pub const TMT_WIDTH: THEME_PROPERTY_SYMBOL_ID = 2416u32; pub const TMT_HEIGHT: THEME_PROPERTY_SYMBOL_ID = 2417u32; pub const TMT_GLYPHINDEX: THEME_PROPERTY_SYMBOL_ID = 2418u32; pub const TMT_TRUESIZESTRETCHMARK: THEME_PROPERTY_SYMBOL_ID = 2419u32; pub const TMT_MINDPI1: THEME_PROPERTY_SYMBOL_ID = 2420u32; pub const TMT_MINDPI2: THEME_PROPERTY_SYMBOL_ID = 2421u32; pub const TMT_MINDPI3: THEME_PROPERTY_SYMBOL_ID = 2422u32; pub const TMT_MINDPI4: THEME_PROPERTY_SYMBOL_ID = 2423u32; pub const TMT_MINDPI5: THEME_PROPERTY_SYMBOL_ID = 2424u32; pub const TMT_TEXTGLOWSIZE: THEME_PROPERTY_SYMBOL_ID = 2425u32; pub const TMT_FRAMESPERSECOND: THEME_PROPERTY_SYMBOL_ID = 2426u32; pub const TMT_PIXELSPERFRAME: THEME_PROPERTY_SYMBOL_ID = 2427u32; pub const TMT_ANIMATIONDELAY: THEME_PROPERTY_SYMBOL_ID = 2428u32; pub const TMT_GLOWINTENSITY: THEME_PROPERTY_SYMBOL_ID = 2429u32; pub const TMT_OPACITY: THEME_PROPERTY_SYMBOL_ID = 2430u32; pub const TMT_COLORIZATIONCOLOR: THEME_PROPERTY_SYMBOL_ID = 2431u32; pub const TMT_COLORIZATIONOPACITY: THEME_PROPERTY_SYMBOL_ID = 2432u32; pub const TMT_MINDPI6: THEME_PROPERTY_SYMBOL_ID = 2433u32; pub const TMT_MINDPI7: THEME_PROPERTY_SYMBOL_ID = 2434u32; pub const TMT_GLYPHFONT: THEME_PROPERTY_SYMBOL_ID = 2601u32; pub const TMT_IMAGEFILE: THEME_PROPERTY_SYMBOL_ID = 3001u32; pub const TMT_IMAGEFILE1: THEME_PROPERTY_SYMBOL_ID = 3002u32; pub const TMT_IMAGEFILE2: THEME_PROPERTY_SYMBOL_ID = 3003u32; pub const TMT_IMAGEFILE3: THEME_PROPERTY_SYMBOL_ID = 3004u32; pub const TMT_IMAGEFILE4: THEME_PROPERTY_SYMBOL_ID = 3005u32; pub const TMT_IMAGEFILE5: THEME_PROPERTY_SYMBOL_ID = 3006u32; pub const TMT_GLYPHIMAGEFILE: THEME_PROPERTY_SYMBOL_ID = 3008u32; pub const TMT_IMAGEFILE6: THEME_PROPERTY_SYMBOL_ID = 3009u32; pub const TMT_IMAGEFILE7: THEME_PROPERTY_SYMBOL_ID = 3010u32; pub const TMT_TEXT: THEME_PROPERTY_SYMBOL_ID = 3201u32; pub const TMT_CLASSICVALUE: THEME_PROPERTY_SYMBOL_ID = 3202u32; pub const TMT_OFFSET: THEME_PROPERTY_SYMBOL_ID = 3401u32; pub const TMT_TEXTSHADOWOFFSET: THEME_PROPERTY_SYMBOL_ID = 3402u32; pub const TMT_MINSIZE: THEME_PROPERTY_SYMBOL_ID = 3403u32; pub const TMT_MINSIZE1: THEME_PROPERTY_SYMBOL_ID = 3404u32; pub const TMT_MINSIZE2: THEME_PROPERTY_SYMBOL_ID = 3405u32; pub const TMT_MINSIZE3: THEME_PROPERTY_SYMBOL_ID = 3406u32; pub const TMT_MINSIZE4: THEME_PROPERTY_SYMBOL_ID = 3407u32; pub const TMT_MINSIZE5: THEME_PROPERTY_SYMBOL_ID = 3408u32; pub const TMT_NORMALSIZE: THEME_PROPERTY_SYMBOL_ID = 3409u32; pub const TMT_MINSIZE6: THEME_PROPERTY_SYMBOL_ID = 3410u32; pub const TMT_MINSIZE7: THEME_PROPERTY_SYMBOL_ID = 3411u32; pub const TMT_SIZINGMARGINS: THEME_PROPERTY_SYMBOL_ID = 3601u32; pub const TMT_CONTENTMARGINS: THEME_PROPERTY_SYMBOL_ID = 3602u32; pub const TMT_CAPTIONMARGINS: THEME_PROPERTY_SYMBOL_ID = 3603u32; pub const TMT_BORDERCOLOR: THEME_PROPERTY_SYMBOL_ID = 3801u32; pub const TMT_FILLCOLOR: THEME_PROPERTY_SYMBOL_ID = 3802u32; pub const TMT_TEXTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3803u32; pub const TMT_EDGELIGHTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3804u32; pub const TMT_EDGEHIGHLIGHTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3805u32; pub const TMT_EDGESHADOWCOLOR: THEME_PROPERTY_SYMBOL_ID = 3806u32; pub const TMT_EDGEDKSHADOWCOLOR: THEME_PROPERTY_SYMBOL_ID = 3807u32; pub const TMT_EDGEFILLCOLOR: THEME_PROPERTY_SYMBOL_ID = 3808u32; pub const TMT_TRANSPARENTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3809u32; pub const TMT_GRADIENTCOLOR1: THEME_PROPERTY_SYMBOL_ID = 3810u32; pub const TMT_GRADIENTCOLOR2: THEME_PROPERTY_SYMBOL_ID = 3811u32; pub const TMT_GRADIENTCOLOR3: THEME_PROPERTY_SYMBOL_ID = 3812u32; pub const TMT_GRADIENTCOLOR4: THEME_PROPERTY_SYMBOL_ID = 3813u32; pub const TMT_GRADIENTCOLOR5: THEME_PROPERTY_SYMBOL_ID = 3814u32; pub const TMT_SHADOWCOLOR: THEME_PROPERTY_SYMBOL_ID = 3815u32; pub const TMT_GLOWCOLOR: THEME_PROPERTY_SYMBOL_ID = 3816u32; pub const TMT_TEXTBORDERCOLOR: THEME_PROPERTY_SYMBOL_ID = 3817u32; pub const TMT_TEXTSHADOWCOLOR: THEME_PROPERTY_SYMBOL_ID = 3818u32; pub const TMT_GLYPHTEXTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3819u32; pub const TMT_GLYPHTRANSPARENTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3820u32; pub const TMT_FILLCOLORHINT: THEME_PROPERTY_SYMBOL_ID = 3821u32; pub const TMT_BORDERCOLORHINT: THEME_PROPERTY_SYMBOL_ID = 3822u32; pub const TMT_ACCENTCOLORHINT: THEME_PROPERTY_SYMBOL_ID = 3823u32; pub const TMT_TEXTCOLORHINT: THEME_PROPERTY_SYMBOL_ID = 3824u32; pub const TMT_HEADING1TEXTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3825u32; pub const TMT_HEADING2TEXTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3826u32; pub const TMT_BODYTEXTCOLOR: THEME_PROPERTY_SYMBOL_ID = 3827u32; pub const TMT_BGTYPE: THEME_PROPERTY_SYMBOL_ID = 4001u32; pub const TMT_BORDERTYPE: THEME_PROPERTY_SYMBOL_ID = 4002u32; pub const TMT_FILLTYPE: THEME_PROPERTY_SYMBOL_ID = 4003u32; pub const TMT_SIZINGTYPE: THEME_PROPERTY_SYMBOL_ID = 4004u32; pub const TMT_HALIGN: THEME_PROPERTY_SYMBOL_ID = 4005u32; pub const TMT_CONTENTALIGNMENT: THEME_PROPERTY_SYMBOL_ID = 4006u32; pub const TMT_VALIGN: THEME_PROPERTY_SYMBOL_ID = 4007u32; pub const TMT_OFFSETTYPE: THEME_PROPERTY_SYMBOL_ID = 4008u32; pub const TMT_ICONEFFECT: THEME_PROPERTY_SYMBOL_ID = 4009u32; pub const TMT_TEXTSHADOWTYPE: THEME_PROPERTY_SYMBOL_ID = 4010u32; pub const TMT_IMAGELAYOUT: THEME_PROPERTY_SYMBOL_ID = 4011u32; pub const TMT_GLYPHTYPE: THEME_PROPERTY_SYMBOL_ID = 4012u32; pub const TMT_IMAGESELECTTYPE: THEME_PROPERTY_SYMBOL_ID = 4013u32; pub const TMT_GLYPHFONTSIZINGTYPE: THEME_PROPERTY_SYMBOL_ID = 4014u32; pub const TMT_TRUESIZESCALINGTYPE: THEME_PROPERTY_SYMBOL_ID = 4015u32; pub const TMT_USERPICTURE: THEME_PROPERTY_SYMBOL_ID = 5001u32; pub const TMT_DEFAULTPANESIZE: THEME_PROPERTY_SYMBOL_ID = 5002u32; pub const TMT_BLENDCOLOR: THEME_PROPERTY_SYMBOL_ID = 5003u32; pub const TMT_CUSTOMSPLITRECT: THEME_PROPERTY_SYMBOL_ID = 5004u32; pub const TMT_ANIMATIONBUTTONRECT: THEME_PROPERTY_SYMBOL_ID = 5005u32; pub const TMT_ANIMATIONDURATION: THEME_PROPERTY_SYMBOL_ID = 5006u32; pub const TMT_TRANSITIONDURATIONS: THEME_PROPERTY_SYMBOL_ID = 6000u32; pub const TMT_SCALEDBACKGROUND: THEME_PROPERTY_SYMBOL_ID = 7001u32; pub const TMT_ATLASIMAGE: THEME_PROPERTY_SYMBOL_ID = 8000u32; pub const TMT_ATLASINPUTIMAGE: THEME_PROPERTY_SYMBOL_ID = 8001u32; pub const TMT_ATLASRECT: THEME_PROPERTY_SYMBOL_ID = 8002u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TOUCH_HIT_TESTING_INPUT { pub pointerId: u32, pub point: super::super::Foundation::POINT, pub boundingBox: super::super::Foundation::RECT, pub nonOccludedBoundingBox: super::super::Foundation::RECT, pub orientation: u32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TOUCH_HIT_TESTING_INPUT {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TOUCH_HIT_TESTING_INPUT { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TOUCH_HIT_TESTING_PROXIMITY_EVALUATION { pub score: u16, pub adjustedPoint: super::super::Foundation::POINT, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TOUCH_HIT_TESTING_PROXIMITY_EVALUATION {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TOUCH_HIT_TESTING_PROXIMITY_EVALUATION { fn clone(&self) -> Self { *self } } pub type TRAILINGGRIDCELLSTATES = i32; pub const MCTGC_HOT: TRAILINGGRIDCELLSTATES = 1i32; pub const MCTGC_HASSTATE: TRAILINGGRIDCELLSTATES = 2i32; pub const MCTGC_HASSTATEHOT: TRAILINGGRIDCELLSTATES = 3i32; pub const MCTGC_TODAY: TRAILINGGRIDCELLSTATES = 4i32; pub const MCTGC_TODAYSELECTED: TRAILINGGRIDCELLSTATES = 5i32; pub const MCTGC_SELECTED: TRAILINGGRIDCELLSTATES = 6i32; pub const MCTGC_SELECTEDHOT: TRAILINGGRIDCELLSTATES = 7i32; pub type TRAILINGGRIDCELLUPPERSTATES = i32; pub const MCTGCU_HOT: TRAILINGGRIDCELLUPPERSTATES = 1i32; pub const MCTGCU_HASSTATE: TRAILINGGRIDCELLUPPERSTATES = 2i32; pub const MCTGCU_HASSTATEHOT: TRAILINGGRIDCELLUPPERSTATES = 3i32; pub const MCTGCU_SELECTED: TRAILINGGRIDCELLUPPERSTATES = 4i32; pub const MCTGCU_SELECTEDHOT: TRAILINGGRIDCELLUPPERSTATES = 5i32; pub type TRAYNOTIFYPARTS = i32; pub const TNP_BACKGROUND: TRAYNOTIFYPARTS = 1i32; pub const TNP_ANIMBACKGROUND: TRAYNOTIFYPARTS = 2i32; pub type TRUESIZESCALINGTYPE = i32; pub const TSST_NONE: TRUESIZESCALINGTYPE = 0i32; pub const TSST_SIZE: TRUESIZESCALINGTYPE = 1i32; pub const TSST_DPI: TRUESIZESCALINGTYPE = 2i32; pub const TTDT_AUTOMATIC: u32 = 0u32; pub const TTDT_AUTOPOP: u32 = 2u32; pub const TTDT_INITIAL: u32 = 3u32; pub const TTDT_RESHOW: u32 = 1u32; pub const TTF_DI_SETITEM: u32 = 32768u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TTGETTITLE { pub dwSize: u32, pub uTitleBitmap: u32, pub cch: u32, pub pszTitle: super::super::Foundation::PWSTR, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TTGETTITLE {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TTGETTITLE { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TTHITTESTINFOA { pub hwnd: super::super::Foundation::HWND, pub pt: super::super::Foundation::POINT, pub ti: TTTOOLINFOA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TTHITTESTINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TTHITTESTINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TTHITTESTINFOW { pub hwnd: super::super::Foundation::HWND, pub pt: super::super::Foundation::POINT, pub ti: TTTOOLINFOW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TTHITTESTINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TTHITTESTINFOW { fn clone(&self) -> Self { *self } } pub const TTM_ACTIVATE: u32 = 1025u32; pub const TTM_ADDTOOL: u32 = 1074u32; pub const TTM_ADDTOOLA: u32 = 1028u32; pub const TTM_ADDTOOLW: u32 = 1074u32; pub const TTM_ADJUSTRECT: u32 = 1055u32; pub const TTM_DELTOOL: u32 = 1075u32; pub const TTM_DELTOOLA: u32 = 1029u32; pub const TTM_DELTOOLW: u32 = 1075u32; pub const TTM_ENUMTOOLS: u32 = 1082u32; pub const TTM_ENUMTOOLSA: u32 = 1038u32; pub const TTM_ENUMTOOLSW: u32 = 1082u32; pub const TTM_GETBUBBLESIZE: u32 = 1054u32; pub const TTM_GETCURRENTTOOL: u32 = 1083u32; pub const TTM_GETCURRENTTOOLA: u32 = 1039u32; pub const TTM_GETCURRENTTOOLW: u32 = 1083u32; pub const TTM_GETDELAYTIME: u32 = 1045u32; pub const TTM_GETMARGIN: u32 = 1051u32; pub const TTM_GETMAXTIPWIDTH: u32 = 1049u32; pub const TTM_GETTEXT: u32 = 1080u32; pub const TTM_GETTEXTA: u32 = 1035u32; pub const TTM_GETTEXTW: u32 = 1080u32; pub const TTM_GETTIPBKCOLOR: u32 = 1046u32; pub const TTM_GETTIPTEXTCOLOR: u32 = 1047u32; pub const TTM_GETTITLE: u32 = 1059u32; pub const TTM_GETTOOLCOUNT: u32 = 1037u32; pub const TTM_GETTOOLINFO: u32 = 1077u32; pub const TTM_GETTOOLINFOA: u32 = 1032u32; pub const TTM_GETTOOLINFOW: u32 = 1077u32; pub const TTM_HITTEST: u32 = 1079u32; pub const TTM_HITTESTA: u32 = 1034u32; pub const TTM_HITTESTW: u32 = 1079u32; pub const TTM_NEWTOOLRECT: u32 = 1076u32; pub const TTM_NEWTOOLRECTA: u32 = 1030u32; pub const TTM_NEWTOOLRECTW: u32 = 1076u32; pub const TTM_POP: u32 = 1052u32; pub const TTM_POPUP: u32 = 1058u32; pub const TTM_RELAYEVENT: u32 = 1031u32; pub const TTM_SETDELAYTIME: u32 = 1027u32; pub const TTM_SETMARGIN: u32 = 1050u32; pub const TTM_SETMAXTIPWIDTH: u32 = 1048u32; pub const TTM_SETTIPBKCOLOR: u32 = 1043u32; pub const TTM_SETTIPTEXTCOLOR: u32 = 1044u32; pub const TTM_SETTITLE: u32 = 1057u32; pub const TTM_SETTITLEA: u32 = 1056u32; pub const TTM_SETTITLEW: u32 = 1057u32; pub const TTM_SETTOOLINFO: u32 = 1078u32; pub const TTM_SETTOOLINFOA: u32 = 1033u32; pub const TTM_SETTOOLINFOW: u32 = 1078u32; pub const TTM_SETWINDOWTHEME: u32 = 8203u32; pub const TTM_TRACKACTIVATE: u32 = 1041u32; pub const TTM_TRACKPOSITION: u32 = 1042u32; pub const TTM_UPDATE: u32 = 1053u32; pub const TTM_UPDATETIPTEXT: u32 = 1081u32; pub const TTM_UPDATETIPTEXTA: u32 = 1036u32; pub const TTM_UPDATETIPTEXTW: u32 = 1081u32; pub const TTM_WINDOWFROMPOINT: u32 = 1040u32; pub const TTS_ALWAYSTIP: u32 = 1u32; pub const TTS_BALLOON: u32 = 64u32; pub const TTS_CLOSE: u32 = 128u32; pub const TTS_NOANIMATE: u32 = 16u32; pub const TTS_NOFADE: u32 = 32u32; pub const TTS_NOPREFIX: u32 = 2u32; pub const TTS_USEVISUALSTYLE: u32 = 256u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TTTOOLINFOA { pub cbSize: u32, pub uFlags: TTTOOLINFO_FLAGS, pub hwnd: super::super::Foundation::HWND, pub uId: usize, pub rect: super::super::Foundation::RECT, pub hinst: super::super::Foundation::HINSTANCE, pub lpszText: super::super::Foundation::PSTR, pub lParam: super::super::Foundation::LPARAM, pub lpReserved: *mut ::core::ffi::c_void, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TTTOOLINFOA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TTTOOLINFOA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TTTOOLINFOW { pub cbSize: u32, pub uFlags: TTTOOLINFO_FLAGS, pub hwnd: super::super::Foundation::HWND, pub uId: usize, pub rect: super::super::Foundation::RECT, pub hinst: super::super::Foundation::HINSTANCE, pub lpszText: super::super::Foundation::PWSTR, pub lParam: super::super::Foundation::LPARAM, pub lpReserved: *mut ::core::ffi::c_void, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TTTOOLINFOW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TTTOOLINFOW { fn clone(&self) -> Self { *self } } pub type TTTOOLINFO_FLAGS = u32; pub const TTF_ABSOLUTE: TTTOOLINFO_FLAGS = 128u32; pub const TTF_CENTERTIP: TTTOOLINFO_FLAGS = 2u32; pub const TTF_IDISHWND: TTTOOLINFO_FLAGS = 1u32; pub const TTF_PARSELINKS: TTTOOLINFO_FLAGS = 4096u32; pub const TTF_RTLREADING: TTTOOLINFO_FLAGS = 4u32; pub const TTF_SUBCLASS: TTTOOLINFO_FLAGS = 16u32; pub const TTF_TRACK: TTTOOLINFO_FLAGS = 32u32; pub const TTF_TRANSPARENT: TTTOOLINFO_FLAGS = 256u32; pub const TVCDRF_NOIMAGES: u32 = 65536u32; pub const TVC_BYKEYBOARD: u32 = 2u32; pub const TVC_BYMOUSE: u32 = 1u32; pub const TVC_UNKNOWN: u32 = 0u32; pub const TVE_COLLAPSE: u32 = 1u32; pub const TVE_COLLAPSERESET: u32 = 32768u32; pub const TVE_EXPAND: u32 = 2u32; pub const TVE_EXPANDPARTIAL: u32 = 16384u32; pub const TVE_TOGGLE: u32 = 3u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVGETITEMPARTRECTINFO { pub hti: HTREEITEM, pub prc: *mut super::super::Foundation::RECT, pub partID: TVITEMPART, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVGETITEMPARTRECTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVGETITEMPARTRECTINFO { fn clone(&self) -> Self { *self } } pub const TVGN_CARET: u32 = 9u32; pub const TVGN_CHILD: u32 = 4u32; pub const TVGN_DROPHILITE: u32 = 8u32; pub const TVGN_FIRSTVISIBLE: u32 = 5u32; pub const TVGN_LASTVISIBLE: u32 = 10u32; pub const TVGN_NEXT: u32 = 1u32; pub const TVGN_NEXTSELECTED: u32 = 11u32; pub const TVGN_NEXTVISIBLE: u32 = 6u32; pub const TVGN_PARENT: u32 = 3u32; pub const TVGN_PREVIOUS: u32 = 2u32; pub const TVGN_PREVIOUSVISIBLE: u32 = 7u32; pub const TVGN_ROOT: u32 = 0u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVHITTESTINFO { pub pt: super::super::Foundation::POINT, pub flags: TVHITTESTINFO_FLAGS, pub hItem: HTREEITEM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVHITTESTINFO {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVHITTESTINFO { fn clone(&self) -> Self { *self } } pub type TVHITTESTINFO_FLAGS = u32; pub const TVHT_ABOVE: TVHITTESTINFO_FLAGS = 256u32; pub const TVHT_BELOW: TVHITTESTINFO_FLAGS = 512u32; pub const TVHT_NOWHERE: TVHITTESTINFO_FLAGS = 1u32; pub const TVHT_ONITEM: TVHITTESTINFO_FLAGS = 70u32; pub const TVHT_ONITEMBUTTON: TVHITTESTINFO_FLAGS = 16u32; pub const TVHT_ONITEMICON: TVHITTESTINFO_FLAGS = 2u32; pub const TVHT_ONITEMINDENT: TVHITTESTINFO_FLAGS = 8u32; pub const TVHT_ONITEMLABEL: TVHITTESTINFO_FLAGS = 4u32; pub const TVHT_ONITEMRIGHT: TVHITTESTINFO_FLAGS = 32u32; pub const TVHT_ONITEMSTATEICON: TVHITTESTINFO_FLAGS = 64u32; pub const TVHT_TOLEFT: TVHITTESTINFO_FLAGS = 2048u32; pub const TVHT_TORIGHT: TVHITTESTINFO_FLAGS = 1024u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVINSERTSTRUCTA { pub hParent: HTREEITEM, pub hInsertAfter: HTREEITEM, pub Anonymous: TVINSERTSTRUCTA_0, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVINSERTSTRUCTA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVINSERTSTRUCTA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub union TVINSERTSTRUCTA_0 { pub itemex: TVITEMEXA, pub item: TVITEMA, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVINSERTSTRUCTA_0 {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVINSERTSTRUCTA_0 { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVINSERTSTRUCTW { pub hParent: HTREEITEM, pub hInsertAfter: HTREEITEM, pub Anonymous: TVINSERTSTRUCTW_0, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVINSERTSTRUCTW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVINSERTSTRUCTW { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub union TVINSERTSTRUCTW_0 { pub itemex: TVITEMEXW, pub item: TVITEMW, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVINSERTSTRUCTW_0 {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVINSERTSTRUCTW_0 { fn clone(&self) -> Self { *self } } pub const TVIS_BOLD: u32 = 16u32; pub const TVIS_CUT: u32 = 4u32; pub const TVIS_DROPHILITED: u32 = 8u32; pub const TVIS_EXPANDED: u32 = 32u32; pub const TVIS_EXPANDEDONCE: u32 = 64u32; pub const TVIS_EXPANDPARTIAL: u32 = 128u32; pub const TVIS_EX_ALL: u32 = 2u32; pub const TVIS_EX_DISABLED: u32 = 2u32; pub const TVIS_EX_FLAT: u32 = 1u32; pub const TVIS_OVERLAYMASK: u32 = 3840u32; pub const TVIS_SELECTED: u32 = 2u32; pub const TVIS_STATEIMAGEMASK: u32 = 61440u32; pub const TVIS_USERMASK: u32 = 61440u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVITEMA { pub mask: TVITEM_MASK, pub hItem: HTREEITEM, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub cChildren: TVITEMEXW_CHILDREN, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVITEMA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVITEMA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVITEMEXA { pub mask: TVITEM_MASK, pub hItem: HTREEITEM, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub cChildren: TVITEMEXW_CHILDREN, pub lParam: super::super::Foundation::LPARAM, pub iIntegral: i32, pub uStateEx: u32, pub hwnd: super::super::Foundation::HWND, pub iExpandedImage: i32, pub iReserved: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVITEMEXA {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVITEMEXA { fn clone(&self) -> Self { *self } } #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVITEMEXW { pub mask: TVITEM_MASK, pub hItem: HTREEITEM, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub cChildren: TVITEMEXW_CHILDREN, pub lParam: super::super::Foundation::LPARAM, pub iIntegral: i32, pub uStateEx: u32, pub hwnd: super::super::Foundation::HWND, pub iExpandedImage: i32, pub iReserved: i32, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVITEMEXW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVITEMEXW { fn clone(&self) -> Self { *self } } pub type TVITEMEXW_CHILDREN = i32; pub const I_ZERO: TVITEMEXW_CHILDREN = 0i32; pub const I_ONE_OR_MORE: TVITEMEXW_CHILDREN = 1i32; pub const I_CHILDRENCALLBACK: TVITEMEXW_CHILDREN = -1i32; pub const I_CHILDRENAUTO: TVITEMEXW_CHILDREN = -2i32; pub type TVITEMPART = i32; pub const TVGIPR_BUTTON: TVITEMPART = 1i32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVITEMW { pub mask: TVITEM_MASK, pub hItem: HTREEITEM, pub state: u32, pub stateMask: u32, pub pszText: super::super::Foundation::PWSTR, pub cchTextMax: i32, pub iImage: i32, pub iSelectedImage: i32, pub cChildren: TVITEMEXW_CHILDREN, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVITEMW {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVITEMW { fn clone(&self) -> Self { *self } } pub type TVITEM_MASK = u32; pub const TVIF_CHILDREN: TVITEM_MASK = 64u32; pub const TVIF_DI_SETITEM: TVITEM_MASK = 4096u32; pub const TVIF_HANDLE: TVITEM_MASK = 16u32; pub const TVIF_IMAGE: TVITEM_MASK = 2u32; pub const TVIF_PARAM: TVITEM_MASK = 4u32; pub const TVIF_SELECTEDIMAGE: TVITEM_MASK = 32u32; pub const TVIF_STATE: TVITEM_MASK = 8u32; pub const TVIF_TEXT: TVITEM_MASK = 1u32; pub const TVIF_EXPANDEDIMAGE: TVITEM_MASK = 512u32; pub const TVIF_INTEGRAL: TVITEM_MASK = 128u32; pub const TVIF_STATEEX: TVITEM_MASK = 256u32; pub const TVI_FIRST: HTREEITEM = -65535i32 as _; pub const TVI_LAST: HTREEITEM = -65534i32 as _; pub const TVI_ROOT: HTREEITEM = -65536i32 as _; pub const TVI_SORT: HTREEITEM = -65533i32 as _; pub const TVM_CREATEDRAGIMAGE: u32 = 4370u32; pub const TVM_DELETEITEM: u32 = 4353u32; pub const TVM_EDITLABEL: u32 = 4417u32; pub const TVM_EDITLABELA: u32 = 4366u32; pub const TVM_EDITLABELW: u32 = 4417u32; pub const TVM_ENDEDITLABELNOW: u32 = 4374u32; pub const TVM_ENSUREVISIBLE: u32 = 4372u32; pub const TVM_EXPAND: u32 = 4354u32; pub const TVM_GETBKCOLOR: u32 = 4383u32; pub const TVM_GETCOUNT: u32 = 4357u32; pub const TVM_GETEDITCONTROL: u32 = 4367u32; pub const TVM_GETEXTENDEDSTYLE: u32 = 4397u32; pub const TVM_GETIMAGELIST: u32 = 4360u32; pub const TVM_GETINDENT: u32 = 4358u32; pub const TVM_GETINSERTMARKCOLOR: u32 = 4390u32; pub const TVM_GETISEARCHSTRING: u32 = 4416u32; pub const TVM_GETISEARCHSTRINGA: u32 = 4375u32; pub const TVM_GETISEARCHSTRINGW: u32 = 4416u32; pub const TVM_GETITEM: u32 = 4414u32; pub const TVM_GETITEMA: u32 = 4364u32; pub const TVM_GETITEMHEIGHT: u32 = 4380u32; pub const TVM_GETITEMPARTRECT: u32 = 4424u32; pub const TVM_GETITEMRECT: u32 = 4356u32; pub const TVM_GETITEMSTATE: u32 = 4391u32; pub const TVM_GETITEMW: u32 = 4414u32; pub const TVM_GETLINECOLOR: u32 = 4393u32; pub const TVM_GETNEXTITEM: u32 = 4362u32; pub const TVM_GETSCROLLTIME: u32 = 4386u32; pub const TVM_GETSELECTEDCOUNT: u32 = 4422u32; pub const TVM_GETTEXTCOLOR: u32 = 4384u32; pub const TVM_GETTOOLTIPS: u32 = 4377u32; pub const TVM_GETUNICODEFORMAT: u32 = 8198u32; pub const TVM_GETVISIBLECOUNT: u32 = 4368u32; pub const TVM_HITTEST: u32 = 4369u32; pub const TVM_INSERTITEM: u32 = 4402u32; pub const TVM_INSERTITEMA: u32 = 4352u32; pub const TVM_INSERTITEMW: u32 = 4402u32; pub const TVM_MAPACCIDTOHTREEITEM: u32 = 4394u32; pub const TVM_MAPHTREEITEMTOACCID: u32 = 4395u32; pub const TVM_SELECTITEM: u32 = 4363u32; pub const TVM_SETAUTOSCROLLINFO: u32 = 4411u32; pub const TVM_SETBKCOLOR: u32 = 4381u32; pub const TVM_SETBORDER: u32 = 4387u32; pub const TVM_SETEXTENDEDSTYLE: u32 = 4396u32; pub const TVM_SETHOT: u32 = 4410u32; pub const TVM_SETIMAGELIST: u32 = 4361u32; pub const TVM_SETINDENT: u32 = 4359u32; pub const TVM_SETINSERTMARK: u32 = 4378u32; pub const TVM_SETINSERTMARKCOLOR: u32 = 4389u32; pub const TVM_SETITEM: u32 = 4415u32; pub const TVM_SETITEMA: u32 = 4365u32; pub const TVM_SETITEMHEIGHT: u32 = 4379u32; pub const TVM_SETITEMW: u32 = 4415u32; pub const TVM_SETLINECOLOR: u32 = 4392u32; pub const TVM_SETSCROLLTIME: u32 = 4385u32; pub const TVM_SETTEXTCOLOR: u32 = 4382u32; pub const TVM_SETTOOLTIPS: u32 = 4376u32; pub const TVM_SETUNICODEFORMAT: u32 = 8197u32; pub const TVM_SHOWINFOTIP: u32 = 4423u32; pub const TVM_SORTCHILDREN: u32 = 4371u32; pub const TVM_SORTCHILDRENCB: u32 = 4373u32; pub const TVNRET_DEFAULT: u32 = 0u32; pub const TVNRET_SKIPNEW: u32 = 2u32; pub const TVNRET_SKIPOLD: u32 = 1u32; pub const TVSBF_XBORDER: u32 = 1u32; pub const TVSBF_YBORDER: u32 = 2u32; pub const TVSIL_NORMAL: u32 = 0u32; pub const TVSIL_STATE: u32 = 2u32; pub const TVSI_NOSINGLEEXPAND: u32 = 32768u32; #[repr(C)] #[cfg(feature = "Win32_Foundation")] pub struct TVSORTCB { pub hParent: HTREEITEM, pub lpfnCompare: PFNTVCOMPARE, pub lParam: super::super::Foundation::LPARAM, } #[cfg(feature = "Win32_Foundation")] impl ::core::marker::Copy for TVSORTCB {} #[cfg(feature = "Win32_Foundation")] impl ::core::clone::Clone for TVSORTCB { fn clone(&self) -> Self { *self } } pub const TVS_CHECKBOXES: u32 = 256u32; pub const TVS_DISABLEDRAGDROP: u32 = 16u32; pub const TVS_EDITLABELS: u32 = 8u32; pub const TVS_EX_AUTOHSCROLL: u32 = 32u32; pub const TVS_EX_DIMMEDCHECKBOXES: u32 = 512u32; pub const TVS_EX_DOUBLEBUFFER: u32 = 4u32; pub const TVS_EX_DRAWIMAGEASYNC: u32 = 1024u32; pub const TVS_EX_EXCLUSIONCHECKBOXES: u32 = 256u32; pub const TVS_EX_FADEINOUTEXPANDOS: u32 = 64u32; pub const TVS_EX_MULTISELECT: u32 = 2u32; pub const TVS_EX_NOINDENTSTATE: u32 = 8u32; pub const TVS_EX_NOSINGLECOLLAPSE: u32 = 1u32; pub const TVS_EX_PARTIALCHECKBOXES: u32 = 128u32; pub const TVS_EX_RICHTOOLTIP: u32 = 16u32; pub const TVS_FULLROWSELECT: u32 = 4096u32; pub const TVS_HASBUTTONS: u32 = 1u32; pub const TVS_HASLINES: u32 = 2u32; pub const TVS_INFOTIP: u32 = 2048u32; pub const TVS_LINESATROOT: u32 = 4u32; pub const TVS_NOHSCROLL: u32 = 32768u32; pub const TVS_NONEVENHEIGHT: u32 = 16384u32; pub const TVS_NOSCROLL: u32 = 8192u32; pub const TVS_NOTOOLTIPS: u32 = 128u32; pub const TVS_RTLREADING: u32 = 64u32; pub const TVS_SHOWSELALWAYS: u32 = 32u32; pub const TVS_SINGLEEXPAND: u32 = 1024u32; pub const TVS_TRACKSELECT: u32 = 512u32; pub const TV_FIRST: u32 = 4352u32; #[repr(C)] pub struct UDACCEL { pub nSec: u32, pub nInc: u32, } impl ::core::marker::Copy for UDACCEL {} impl ::core::clone::Clone for UDACCEL { fn clone(&self) -> Self { *self } } pub const UDM_GETACCEL: u32 = 1132u32; pub const UDM_GETBASE: u32 = 1134u32; pub const UDM_GETBUDDY: u32 = 1130u32; pub const UDM_GETPOS: u32 = 1128u32; pub const UDM_GETPOS32: u32 = 1138u32; pub const UDM_GETRANGE: u32 = 1126u32; pub const UDM_GETRANGE32: u32 = 1136u32; pub const UDM_GETUNICODEFORMAT: u32 = 8198u32; pub const UDM_SETACCEL: u32 = 1131u32; pub const UDM_SETBASE: u32 = 1133u32; pub const UDM_SETBUDDY: u32 = 1129u32; pub const UDM_SETPOS: u32 = 1127u32; pub const UDM_SETPOS32: u32 = 1137u32; pub const UDM_SETRANGE: u32 = 1125u32; pub const UDM_SETRANGE32: u32 = 1135u32; pub const UDM_SETUNICODEFORMAT: u32 = 8197u32; pub const UDS_ALIGNLEFT: u32 = 8u32; pub const UDS_ALIGNRIGHT: u32 = 4u32; pub const UDS_ARROWKEYS: u32 = 32u32; pub const UDS_AUTOBUDDY: u32 = 16u32; pub const UDS_HORZ: u32 = 64u32; pub const UDS_HOTTRACK: u32 = 256u32; pub const UDS_NOTHOUSANDS: u32 = 128u32; pub const UDS_SETBUDDYINT: u32 = 2u32; pub const UDS_WRAP: u32 = 1u32; pub const UD_MAXVAL: u32 = 32767u32; #[repr(C)] pub struct USAGE_PROPERTIES { pub level: u16, pub page: u16, pub usage: u16, pub logicalMinimum: i32, pub logicalMaximum: i32, pub unit: u16, pub exponent: u16, pub count: u8, pub physicalMinimum: i32, pub physicalMaximum: i32, } impl ::core::marker::Copy for USAGE_PROPERTIES {} impl ::core::clone::Clone for USAGE_PROPERTIES { fn clone(&self) -> Self { *self } } pub type VALIGN = i32; pub const VA_TOP: VALIGN = 0i32; pub const VA_CENTER: VALIGN = 1i32; pub const VA_BOTTOM: VALIGN = 2i32; pub const VIEW_DETAILS: u32 = 3u32; pub const VIEW_LARGEICONS: u32 = 0u32; pub const VIEW_LIST: u32 = 2u32; pub const VIEW_NETCONNECT: u32 = 9u32; pub const VIEW_NETDISCONNECT: u32 = 10u32; pub const VIEW_NEWFOLDER: u32 = 11u32; pub const VIEW_PARENTFOLDER: u32 = 8u32; pub const VIEW_SMALLICONS: u32 = 1u32; pub const VIEW_SORTDATE: u32 = 6u32; pub const VIEW_SORTNAME: u32 = 4u32; pub const VIEW_SORTSIZE: u32 = 5u32; pub const VIEW_SORTTYPE: u32 = 7u32; pub const VIEW_VIEWMENU: u32 = 12u32; pub type WINDOWTHEMEATTRIBUTETYPE = i32; pub const WTA_NONCLIENT: WINDOWTHEMEATTRIBUTETYPE = 1i32; pub const WIZ_BODYCX: u32 = 184u32; pub const WIZ_BODYX: u32 = 92u32; pub const WIZ_CXBMP: u32 = 80u32; pub const WIZ_CXDLG: u32 = 276u32; pub const WIZ_CYDLG: u32 = 140u32; pub const WM_CTLCOLOR: u32 = 25u32; pub const WM_MOUSEHOVER: u32 = 673u32; pub const WM_MOUSELEAVE: u32 = 675u32; pub type WORD_BREAK_ACTION = u32; pub const WB_CLASSIFY: WORD_BREAK_ACTION = 3u32; pub const WB_ISDELIMITER: WORD_BREAK_ACTION = 2u32; pub const WB_LEFT: WORD_BREAK_ACTION = 0u32; pub const WB_LEFTBREAK: WORD_BREAK_ACTION = 6u32; pub const WB_MOVEWORDLEFT: WORD_BREAK_ACTION = 4u32; pub const WB_MOVEWORDRIGHT: WORD_BREAK_ACTION = 5u32; pub const WB_RIGHT: WORD_BREAK_ACTION = 1u32; pub const WB_RIGHTBREAK: WORD_BREAK_ACTION = 7u32; pub type WSB_PROP = i32; pub const WSB_PROP_CXHSCROLL: WSB_PROP = 2i32; pub const WSB_PROP_CXHTHUMB: WSB_PROP = 16i32; pub const WSB_PROP_CXVSCROLL: WSB_PROP = 8i32; pub const WSB_PROP_CYHSCROLL: WSB_PROP = 4i32; pub const WSB_PROP_CYVSCROLL: WSB_PROP = 1i32; pub const WSB_PROP_CYVTHUMB: WSB_PROP = 32i32; pub const WSB_PROP_HBKGCOLOR: WSB_PROP = 128i32; pub const WSB_PROP_HSTYLE: WSB_PROP = 512i32; pub const WSB_PROP_PALETTE: WSB_PROP = 2048i32; pub const WSB_PROP_VBKGCOLOR: WSB_PROP = 64i32; pub const WSB_PROP_VSTYLE: WSB_PROP = 256i32; pub const WSB_PROP_WINSTYLE: WSB_PROP = 1024i32; pub const WSB_PROP_MASK: i32 = 4095i32; #[repr(C)] pub struct WTA_OPTIONS { pub dwFlags: u32, pub dwMask: u32, } impl ::core::marker::Copy for WTA_OPTIONS {} impl ::core::clone::Clone for WTA_OPTIONS { fn clone(&self) -> Self { *self } } pub const WTNCA_NODRAWCAPTION: u32 = 1u32; pub const WTNCA_NODRAWICON: u32 = 2u32; pub const WTNCA_NOMIRRORHELP: u32 = 8u32; pub const WTNCA_NOSYSMENU: u32 = 4u32; pub type _LI_METRIC = i32; pub const LIM_SMALL: _LI_METRIC = 0i32; pub const LIM_LARGE: _LI_METRIC = 1i32;
use chrono::{Date, Datelike, NaiveDate, Utc}; use futures::stream::TryStreamExt; use mongodb::bson::doc; use serde::{Deserialize, Serialize}; use serenity::{ client::Context, framework::standard::{macros::command, Args, CommandResult, Delimiter}, model::channel::Message, prelude::{RwLock, TypeMapKey}, }; use std::{collections::HashMap, env, sync::Arc}; use crate::TodayDate; pub struct BirthdaysDb; impl TypeMapKey for BirthdaysDb { type Value = Arc<RwLock<HashMap<u64, String>>>; } #[derive(Debug, Serialize, Deserialize)] struct Birthday { dob: String, discord_id: String, } #[derive(Debug, Serialize, Deserialize)] struct BirthdayFlag { year: i32, month: u32, day: u32, } #[command] #[owners_only] pub async fn update_db(ctx: &Context, _msg: &Message) -> CommandResult { database_update(ctx).await?; Ok(()) } #[command] #[owners_only] pub async fn add_birthday(ctx: &Context, msg: &Message) -> CommandResult { let mut args = Args::new(&msg.content, &[Delimiter::Single(' ')]); args.advance(); if let Ok(discord_id) = args.parse::<String>() { args.advance(); if let Ok(dob) = args.parse::<String>() { let connection_string = env::var("DB_CONNECTION_STRING").expect("Database connection string not found"); let data_for_insertion = Birthday { discord_id, dob }; { let client = mongodb::Client::with_uri_str(connection_string).await?; let db = client.database("discord-bot"); let birthdays = db.collection::<Birthday>("birthdays"); birthdays.insert_one(data_for_insertion, None).await?; } } else { msg.reply(&ctx.http, "Need to specify dob for adding an entry") .await?; } } else { msg.reply(&ctx.http, "Need to specify discord_id for adding an entry") .await?; } Ok(()) } #[command] #[owners_only] pub async fn delete_birthday(ctx: &Context, msg: &Message) -> CommandResult { let mut args = Args::new(&msg.content, &[Delimiter::Single(' ')]); args.advance(); if let Ok(query) = args.parse::<String>() { let connection_string = env::var("DB_CONNECTION_STRING").expect("Database connection string not found"); { let client = mongodb::Client::with_uri_str(connection_string).await?; let db = client.database("discord-bot"); let birthdays = db.collection::<Birthday>("birthdays"); match birthdays .delete_many(doc! {"discord_id": query}, None) .await { Ok(deleted_entries) => { msg.reply( &ctx.http, format!( "Deleted {} entries matching your query", deleted_entries.deleted_count ), ) .await?; } Err(why) => { msg.reply( &ctx.http, format!("There was an error processing your querry:\n{:?}", why), ) .await?; } } } } else { msg.reply( &ctx.http, "Need to specify discord_id for deleting an entry", ) .await?; } Ok(()) } #[command] #[owners_only] pub async fn print_db(ctx: &Context, _msg: &Message) -> CommandResult { let birthdays_local = { let data_read = ctx.data.read().await; data_read .get::<BirthdaysDb>() .expect("Expected a BirthdaysDb") .clone() .read() .await .clone() }; println!("{:?}", birthdays_local); Ok(()) } // utility function for updating db pub async fn database_update(ctx: &Context) -> CommandResult { let connection_string = env::var("DB_CONNECTION_STRING").expect("Database connection string not found"); let mut birthdays_dict: HashMap<u64, String> = HashMap::new(); { let client = mongodb::Client::with_uri_str(connection_string).await?; let db = client.database("discord-bot"); let birthdays = db.collection::<Birthday>("birthdays"); let birthdays_flag = db.collection::<BirthdayFlag>("birthdays_flag"); let filter = doc! {}; let mut cursor = birthdays.find(doc! {}, None).await?; // fill local dictionary from birthdayDb while let Some(birthday) = &cursor.try_next().await? { birthdays_dict.insert(birthday.discord_id.parse().unwrap(), birthday.dob.clone()); } let mut cursor = birthdays_flag.find(filter, None).await?; // set TodayDate global to what's in the database if let Some(birthday_flag) = &cursor.try_next().await? { let date = Date::<Utc>::from_utc( NaiveDate::from_ymd(birthday_flag.year, birthday_flag.month, birthday_flag.day), Utc, ); let date_lock = { let data_write = ctx.data.read().await; data_write .get::<TodayDate>() .expect("Expected a TodayDate") .clone() }; { let mut flag_date_write = date_lock.write().await; *flag_date_write = date; } } } let data_lock = { let data_write = ctx.data.read().await; data_write .get::<BirthdaysDb>() .expect("Expected a BirthdaysDb") .clone() }; // read all birthdays to memory { let mut birthdays_db = data_lock.write().await; *birthdays_db = birthdays_dict; } Ok(()) } pub async fn update_flag(ctx: &Context, date: Date<Utc>) -> CommandResult { let date_lock = { let data_write = ctx.data.read().await; data_write .get::<TodayDate>() .expect("Expected a TodayDate") .clone() }; // set flag to today's date { let mut flag_date_write = date_lock.write().await; *flag_date_write = date; } // update DB entry let connection_string = env::var("DB_CONNECTION_STRING").expect("Database connection string not found"); { let client = mongodb::Client::with_uri_str(connection_string).await?; let db = client.database("discord-bot"); let birthdays_flag = db.collection::<BirthdayFlag>("birthdays_flag"); let (year, month, day); year = date.year(); month = date.month(); day = date.day(); // delete the old date birthdays_flag.delete_many(doc! {}, None).await?; birthdays_flag .insert_one(BirthdayFlag { year, month, day }, None) .await?; } Ok(()) } // check if someone's birthday is today and notify users pub async fn notify_users(ctx: &Context, msg: &Message) { let channel = std::env::var("GENERAL_CHANNEL") .expect("Failed to lookup general-channel id") .parse::<u64>() .unwrap(); let mut birthdays = { let data_read = ctx.data.read().await; let birthdays_lock = data_read .get::<BirthdaysDb>() .expect("expected a BirthdaysDb") .clone(); let birthdays = birthdays_lock.read().await; birthdays.clone() }; let query = { let date = msg.timestamp.date(); format!("{}/{}", date.day(), date.month()) }; birthdays.retain(|_, dob| dob == &query); if !birthdays.is_empty() { let mut message = String::new(); message += &format!("Today's ({}) the birthday of:", msg.timestamp.date()); for (id, _) in birthdays { message += &format!("\n<@!{}>", id); } message += "\n🎂HAPPY BIRTHDAY TO THEM🎂"; let channel = ctx .cache .guild_channel(channel) .await .expect("Channel with that ID isnt found"); channel .say(&ctx.http, message) .await .expect("Failed to send message"); } }
#[doc = "Reader of register SWIER2"] pub type R = crate::R<u32, super::SWIER2>; #[doc = "Writer for register SWIER2"] pub type W = crate::W<u32, super::SWIER2>; #[doc = "Register SWIER2 `reset()`'s with value 0"] impl crate::ResetValue for super::SWIER2 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `SWI35`"] pub type SWI35_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SWI35`"] pub struct SWI35_W<'a> { w: &'a mut W, } impl<'a> SWI35_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Reader of field `SWI36`"] pub type SWI36_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SWI36`"] pub struct SWI36_W<'a> { w: &'a mut W, } impl<'a> SWI36_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); self.w } } #[doc = "Reader of field `SWI37`"] pub type SWI37_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SWI37`"] pub struct SWI37_W<'a> { w: &'a mut W, } impl<'a> SWI37_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); self.w } } #[doc = "Reader of field `SWI38`"] pub type SWI38_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SWI38`"] pub struct SWI38_W<'a> { w: &'a mut W, } impl<'a> SWI38_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); self.w } } impl R { #[doc = "Bit 3 - SWI35"] #[inline(always)] pub fn swi35(&self) -> SWI35_R { SWI35_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bit 4 - SWI36"] #[inline(always)] pub fn swi36(&self) -> SWI36_R { SWI36_R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 5 - SWI37"] #[inline(always)] pub fn swi37(&self) -> SWI37_R { SWI37_R::new(((self.bits >> 5) & 0x01) != 0) } #[doc = "Bit 6 - SWI38"] #[inline(always)] pub fn swi38(&self) -> SWI38_R { SWI38_R::new(((self.bits >> 6) & 0x01) != 0) } } impl W { #[doc = "Bit 3 - SWI35"] #[inline(always)] pub fn swi35(&mut self) -> SWI35_W { SWI35_W { w: self } } #[doc = "Bit 4 - SWI36"] #[inline(always)] pub fn swi36(&mut self) -> SWI36_W { SWI36_W { w: self } } #[doc = "Bit 5 - SWI37"] #[inline(always)] pub fn swi37(&mut self) -> SWI37_W { SWI37_W { w: self } } #[doc = "Bit 6 - SWI38"] #[inline(always)] pub fn swi38(&mut self) -> SWI38_W { SWI38_W { w: self } } }
use crate::voting::substrate::rpc::{ combine_decrypted_shares, combine_pk_shares, create_vote, get_tally, set_vote_phase, store_question, }; use crypto::helper::Helper; use pallet_mixnet::types::{Topic, VotePhase}; use std::str::FromStr; use substrate_subxt::Client; use substrate_subxt::{ClientBuilder, Error, NodeTemplateRuntime}; async fn init() -> Result<Client<NodeTemplateRuntime>, Error> { env_logger::init(); let url = "ws://127.0.0.1:9944"; let client = ClientBuilder::<NodeTemplateRuntime>::new() .set_url(url) .build() .await?; Ok(client) } pub async fn setup_vote(vote_title: String, topic_question: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create the vote let (params, _, _) = Helper::setup_lg_system(); let vote_id = vote_title.as_bytes().to_vec(); let vote_title = vote_title.as_bytes().to_vec(); // create the question let topic_id = topic_question.as_bytes().to_vec(); let topic_question = topic_question.as_bytes().to_vec(); let topic: Topic = (topic_id.clone(), topic_question); let topics = vec![topic]; // setup the vote let create_vote_response = create_vote( &client, params.into(), vote_title, vote_id.clone(), topics, 75, ) .await?; println!( "create_vote_response: {:?}", create_vote_response.events[0].variant ); // // DON'T USE THIS IN PRODUCTION ONLY FOR DEV PURPOSES // // setup the public key // let public_key_response = store_public_key(&client, vote_id.clone(), pk.clone().into()).await?; // println!( // "public_key_response: {:?}", // public_key_response.events[0].variant // ); Ok(()) } pub async fn setup_question(vote: String, question: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create the question + input parameters let vote_id = vote.as_bytes().to_vec(); let topic_id = question.as_bytes().to_vec(); let topic_question = question.as_bytes().to_vec(); let topic: Topic = (topic_id.clone(), topic_question); // store question let response = store_question(&client, vote_id, topic, 75).await?; println!("response: {:?}", response.events[0].variant); Ok(()) } pub async fn change_vote_phase(vote: String, vote_phase: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create input parameters let vote_id = vote.as_bytes().to_vec(); let vote_phase = VotePhase::from_str(&vote_phase).expect("only valid VotePhase values should be parsed!"); // update vote phase to Voting let response = set_vote_phase(&client, vote_id.clone(), vote_phase).await?; println!("response: {:?}", response.events[0].variant); Ok(()) } pub async fn combine_public_key_shares(vote: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create input parameters let vote_id = vote.as_bytes().to_vec(); // update vote phase to Voting let response = combine_pk_shares(&client, vote_id.clone()).await?; println!("response: {:?}", response.events[0].variant); Ok(()) } pub async fn tally_question(vote: String, question: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create input parameters let vote_id = vote.as_bytes().to_vec(); let topic_id = question.as_bytes().to_vec(); // update vote phase to Voting let response = combine_decrypted_shares(&client, vote_id, topic_id).await?; println!( "response: {:?}, data: {:?}", response.events[0].variant, response.events[0] ); Ok(()) } pub async fn get_result(question: String) -> Result<(), Error> { // init substrate client let client = init().await?; // create input parameters let topic_id = question.as_bytes().to_vec(); // update vote phase to Voting let result = get_tally(&client, topic_id).await?; println!("The result of the question: {:?} is...", question); for (vote, count) in result { println!("\tVote: {:?}, Count: {:?}", vote, count); } Ok(()) }
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[cfg(feature = "Win32_Foundation")] #[inline] pub unsafe fn CeipIsOptedIn() -> super::super::super::Foundation::BOOL { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CeipIsOptedIn() -> super::super::super::Foundation::BOOL; } ::core::mem::transmute(CeipIsOptedIn()) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); }
use futures::future::join; use serde::{Deserialize, Serialize}; use crate::{format_string, Error}; #[cfg(feature = "cli")] use clap::{CommandFactory, Parser}; #[cfg(feature = "cli")] use tokio::io::{stdout, AsyncWriteExt}; use crate::{ config::Config, latitude::Latitude, longitude::Longitude, weather_api::WeatherLocation, ApiStringType, StringType, }; #[cfg(feature = "cli")] use crate::weather_api::WeatherApi; /// Utility to retreive and format weather data from openweathermap.org /// /// Please specify one of `zipcode(country_code)`, `city_name`, or `lat` and /// `lon`. #[cfg(feature = "cli")] #[derive(Parser, Default, Serialize, Deserialize)] pub struct WeatherOpts { /// Zipcode (optional) #[clap(short, long)] zipcode: Option<u64>, /// Country Code (optional), if not specified `us` will be assumed #[clap(short, long)] country_code: Option<StringType>, /// City Name (optional) #[clap(long)] city_name: Option<StringType>, /// Latitude (must also specify Longitude) #[clap(long)] lat: Option<Latitude>, /// Longitude (must also specify Latitude) #[clap(long)] lon: Option<Longitude>, /// Api key (optional but either this or API_KEY environment variable must /// exist) #[clap(short = 'k', long)] api_key: Option<ApiStringType>, /// Print forecast #[serde(default)] #[clap(short, long)] forecast: bool, } #[cfg(feature = "cli")] impl WeatherOpts { /// Parse options from stdin, requires `Config` instance. /// # Errors /// /// Returns error if call to retreive weather data fails or if write to /// stdout fails pub async fn parse_opts(config: &Config) -> Result<(), Error> { let mut opts = Self::parse(); opts.apply_defaults(config); let mut stdout = stdout(); for output in opts.run_opts(config).await? { stdout.write_all(output.as_bytes()).await?; } Ok(()) } /// # Errors /// Return Error if api key cannot be found #[cfg(feature = "cli")] fn get_api(&self, config: &Config) -> Result<WeatherApi, Error> { let api_key = self .api_key .as_deref() .ok_or_else(|| Error::InvalidInputError(format_string!("invalid api key")))?; Ok(WeatherApi::new( api_key, &config.api_endpoint, &config.api_path, &config.geo_path, )) } /// Extract options from `WeatherOpts` and apply to `WeatherApi` /// # Errors /// Returns Error if clap help output fails pub fn get_location(&self) -> Result<WeatherLocation, Error> { let loc = if let Some(zipcode) = self.zipcode { if let Some(country_code) = &self.country_code { WeatherLocation::from_zipcode_country_code_str(zipcode, country_code) } else { WeatherLocation::from_zipcode(zipcode) } } else if let Some(city_name) = &self.city_name { WeatherLocation::from_city_name(city_name) } else { if let Some(lat) = self.lat { if let Some(lon) = self.lon { return Ok(WeatherLocation::from_lat_lon(lat, lon)); } } return Err(Error::InvalidInputError(format_string!( "\nERROR: You must specify at least one option\n" ))); }; Ok(loc) } /// # Errors /// /// Returns error if call to retreive weather data fails async fn run_opts(&self, config: &Config) -> Result<Vec<StringType>, Error> { let api = self.get_api(config)?; let loc = self.get_location()?; let data = api.get_weather_data(&loc); let (data, forecast) = if self.forecast { let forecast = api.get_weather_forecast(&loc); let (data, forecast) = join(data, forecast).await; (data?, Some(forecast?)) } else { (data.await?, None) }; let mut output = vec![data.get_current_conditions()]; if let Some(forecast) = forecast { output.extend(forecast.get_forecast()); } Ok(output) } fn apply_defaults(&mut self, config: &Config) { if self.api_key.is_none() { self.api_key = config.api_key.clone(); } if self.zipcode.is_none() && self.country_code.is_none() && self.city_name.is_none() && (self.lat.is_none() || self.lon.is_none()) { self.zipcode = config.zipcode; self.country_code = config.country_code.clone(); self.city_name = config.city_name.clone(); if config.lat.is_some() && config.lon.is_some() { self.lat = config.lat; self.lon = config.lon; } } } #[must_use] pub fn api_help_msg() -> StringType { format_string!("{}", Self::command().render_help()) } } #[cfg(test)] mod test { use isocountry::CountryCode; use log::info; use std::{convert::TryFrom, env::set_var}; use crate::{ config::{Config, TestEnvs}, latitude::Latitude, longitude::Longitude, weather_api::WeatherLocation, Error, }; #[cfg(feature = "cli")] use crate::weather_opts::WeatherOpts; #[cfg(feature = "cli")] #[test] fn test_get_api() -> Result<(), Error> { let _env = TestEnvs::new(&["API_KEY", "API_ENDPOINT", "ZIPCODE", "API_PATH"]); set_var("API_KEY", "1234567"); set_var("API_ENDPOINT", "test.local1"); set_var("ZIPCODE", "8675309"); set_var("API_PATH", "weather/"); let config = Config::init_config(None)?; drop(_env); let mut opts = WeatherOpts::default(); opts.apply_defaults(&config); let api = opts.get_api(&config)?; assert_eq!( format!("{api:?}"), "WeatherApi(key=1234567,endpoint=test.local1)".to_string() ); let loc = opts.get_location()?; assert_eq!( format!("{loc:?}"), "ZipCode { zipcode: 8675309, country_code: None }".to_string() ); Ok(()) } #[test] fn test_apply_defaults() -> Result<(), Error> { let _env = TestEnvs::new(&["API_KEY", "API_ENDPOINT", "LAT", "LON", "API_PATH"]); set_var("API_KEY", "1234567"); set_var("API_ENDPOINT", "test.local1"); set_var("LAT", "10.1"); set_var("LON", "11.1"); set_var("API_PATH", "weather/"); let config = Config::init_config(None)?; drop(_env); let mut opts = WeatherOpts::default(); opts.apply_defaults(&config); assert_eq!(opts.lat, Some(Latitude::try_from(10.1)?)); assert_eq!(opts.lon, Some(Longitude::try_from(11.1)?)); Ok(()) } #[cfg(feature = "cli")] #[tokio::test] async fn test_run_opts() -> Result<(), Error> { let _env = TestEnvs::new(&["API_KEY", "API_ENDPOINT", "ZIPCODE", "API_PATH"]); let config = Config::init_config(None)?; drop(_env); let mut opts = WeatherOpts::default(); opts.zipcode = Some(55427); opts.apply_defaults(&config); let output = opts.run_opts(&config).await?; assert_eq!(output.len(), 1); println!("{}", output[0]); assert!( output[0].contains("Current conditions Golden Valley US") || output[0].contains("Current conditions Minneapolis US") ); opts.forecast = true; let output = opts.run_opts(&config).await?; assert!(output.len() == 7 || output.len() == 8); info!("{:#?}", output); assert!(output[1].contains("Forecast:")); assert!(output[2].contains("High:")); assert!(output[2].contains("Low:")); Ok(()) } #[test] fn test_api_help_msg() -> Result<(), Error> { let msg = WeatherOpts::api_help_msg(); assert!(msg.len() > 0); Ok(()) } #[test] fn test_get_location() -> Result<(), Error> { let mut opts = WeatherOpts::default(); opts.zipcode = Some(55427); opts.country_code = Some("US".into()); let loc = opts.get_location()?; assert_eq!( loc, WeatherLocation::ZipCode { zipcode: 55427, country_code: CountryCode::for_alpha2("US").ok(), } ); let mut opts = WeatherOpts::default(); opts.city_name = Some("Pittsburgh".into()); let loc = opts.get_location()?; assert_eq!(loc, WeatherLocation::CityName("Pittsburgh".into())); let mut opts = WeatherOpts::default(); opts.lat = Latitude::try_from(11.1).ok(); opts.lon = Longitude::try_from(12.2).ok(); let loc = opts.get_location()?; assert_eq!( loc, WeatherLocation::LatLon { latitude: Latitude::try_from(11.1)?, longitude: Longitude::try_from(12.2)? } ); let opts = WeatherOpts::default(); assert!(opts.get_location().is_err()); Ok(()) } }
#![recursion_limit = "1024"] #[macro_use] extern crate quick_error; #[cfg(windows)] pub mod windows; #[cfg(windows)] pub use windows::*; #[cfg(target_os = "linux")] pub mod linux; #[cfg(target_os = "linux")] pub use linux::*; #[cfg(target_os = "emscripten")] pub mod emscripten; #[cfg(target_os = "emscripten")] pub use emscripten::*; #[cfg(target_os = "emscripten")] #[macro_use] extern crate stdweb; #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub mod wasm; #[cfg(all(target_arch = "wasm32", target_os = "unknown"))] pub use wasm::*; #[cfg( not( any( windows, target_os = "linux", target_os = "emscripten", all(target_arch = "wasm32", target_os = "unknown") ) ) )] pub mod other; #[cfg( not( any( windows, target_os = "linux", target_os = "emscripten", all(target_arch = "wasm32", target_os = "unknown") ) ) )] pub use other::*;
// Copyright 2021 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. //! Test arrow-grpc API of metasrv use std::collections::HashSet; use common_base::base::tokio; use common_base::base::Stoppable; use common_meta_client::MetaGrpcClient; use common_meta_kvapi::kvapi::KVApi; use common_meta_kvapi::kvapi::UpsertKVReply; use common_meta_kvapi::kvapi::UpsertKVReq; use common_meta_types::MatchSeq; use common_meta_types::Operation; use common_meta_types::SeqV; use databend_meta::init_meta_ut; use pretty_assertions::assert_eq; use tokio::time::Duration; use tracing::debug; use tracing::info; use crate::tests::service::MetaSrvTestContext; use crate::tests::start_metasrv_with_context; #[async_entry::test(worker_threads = 3, init = "init_meta_ut!()", tracing_span = "debug")] async fn test_restart() -> anyhow::Result<()> { // Fix: Issue 1134 https://github.com/datafuselabs/databend/issues/1134 // - Start a metasrv server. // - create db and create table // - restart // - Test read the db and read the table. let (mut tc, addr) = crate::tests::start_metasrv().await?; let client = MetaGrpcClient::try_create( vec![addr.clone()], "root", "xxx", None, Some(Duration::from_secs(10)), None, )?; info!("--- upsert kv"); { let res = client .upsert_kv(UpsertKVReq::new( "foo", MatchSeq::GE(0), Operation::Update(b"bar".to_vec()), None, )) .await; debug!("set kv res: {:?}", res); let res = res?; assert_eq!( UpsertKVReply::new( None, Some(SeqV { seq: 1, meta: None, data: b"bar".to_vec(), }) ), res, "upsert kv" ); } info!("--- get kv"); { let res = client.get_kv("foo").await; debug!("get kv res: {:?}", res); let res = res?; assert_eq!( Some(SeqV { seq: 1, meta: None, data: b"bar".to_vec(), }), res, "get kv" ); } info!("--- stop metasrv"); { let mut srv = tc.grpc_srv.take().unwrap(); srv.stop(None).await?; drop(client); tokio::time::sleep(Duration::from_millis(1000)).await; crate::tests::start_metasrv_with_context(&mut tc).await?; } tokio::time::sleep(Duration::from_millis(10_000)).await; // try to reconnect the restarted server. let client = MetaGrpcClient::try_create( vec![addr], "root", "xxx", None, Some(Duration::from_secs(10)), None, )?; info!("--- get kv"); { let res = client.get_kv("foo").await; debug!("get kv res: {:?}", res); let res = res?; assert_eq!( Some(SeqV { seq: 1, meta: None, data: b"bar".to_vec() }), res, "get kv" ); } Ok(()) } #[async_entry::test(worker_threads = 3, init = "init_meta_ut!()", tracing_span = "debug")] async fn test_retry_join() -> anyhow::Result<()> { // - Start 2 metasrv. // - Join node-1 to node-0 // - Test metasrv retry cluster case let mut tc0 = MetaSrvTestContext::new(0); start_metasrv_with_context(&mut tc0).await?; let bad_addr = "127.0.0.1:1".to_string(); // first test join has only bad_addr case, MUST return JoinClusterFail { let mut tc1 = MetaSrvTestContext::new(1); tc1.config.raft_config.single = false; tc1.config.raft_config.join = vec![bad_addr.clone()]; let ret = start_metasrv_with_context(&mut tc1).await; let expect = format!( "fail to join {} cluster via {:?}", 1, tc1.config.raft_config.join ); match ret { Ok(_) => panic!("must return JoinClusterFail"), Err(e) => { assert!(e.to_string().starts_with(&expect)); } } } // second test join has bad_addr and tc0 addr case, MUST return success { let mut tc1 = MetaSrvTestContext::new(1); tc1.config.raft_config.single = false; tc1.config.raft_config.join = vec![ bad_addr, tc0.config.raft_config.raft_api_addr().await?.to_string(), ]; let ret = start_metasrv_with_context(&mut tc1).await; match ret { Ok(_) => Ok(()), Err(e) => { panic!("must JoinCluster success: {:?}", e); } } } } #[async_entry::test(worker_threads = 3, init = "init_meta_ut!()", tracing_span = "debug")] async fn test_join() -> anyhow::Result<()> { // - Start 2 metasrv. // - Join node-1 to node-0 // - Test metasrv api let mut tc0 = MetaSrvTestContext::new(0); let mut tc1 = MetaSrvTestContext::new(1); tc1.config.raft_config.single = false; tc1.config.raft_config.join = vec![tc0.config.raft_config.raft_api_addr().await?.to_string()]; start_metasrv_with_context(&mut tc0).await?; start_metasrv_with_context(&mut tc1).await?; let addr0 = tc0.config.grpc_api_address.clone(); let addr1 = tc1.config.grpc_api_address.clone(); let client0 = MetaGrpcClient::try_create( vec![addr0], "root", "xxx", None, Some(Duration::from_secs(10)), None, )?; let client1 = MetaGrpcClient::try_create( vec![addr1], "root", "xxx", None, Some(Duration::from_secs(10)), None, )?; let clients = vec![client0, client1]; info!("--- upsert kv to every nodes"); { for (i, cli) in clients.iter().enumerate() { let k = format!("join-{}", i); let res = cli .upsert_kv(UpsertKVReq::new( k.as_str(), MatchSeq::GE(0), Operation::Update(k.clone().into_bytes()), None, )) .await; debug!("set kv res: {:?}", res); let res = res?; assert_eq!( UpsertKVReply::new( None, Some(SeqV { seq: 1 + i as u64, meta: None, data: k.into_bytes(), }) ), res, "upsert kv to node {}", i ); } } tokio::time::sleep(Duration::from_millis(1000)).await; info!("--- get every kv from every node"); { for (icli, cli) in clients.iter().enumerate() { for i in 0..2 { let k = format!("join-{}", i); let res = cli.get_kv(k.as_str()).await; debug!("get kv {} from {}-th node,res: {:?}", k, icli, res); let res = res?; assert_eq!(k.into_bytes(), res.unwrap().data); } } } Ok(()) } #[async_entry::test(worker_threads = 3, init = "init_meta_ut!()", tracing_span = "debug")] async fn test_auto_sync_addr() -> anyhow::Result<()> { // - Start 3 metasrv. // - Join node-1, node-2 to node-0 // - Test meta client auto sync node endpoints // - Terminal one node and check auto sync again // - Restart terminated node and rejoin to meta cluster // - Test auto sync again. let mut tc0 = MetaSrvTestContext::new(0); let mut tc1 = MetaSrvTestContext::new(1); let mut tc2 = MetaSrvTestContext::new(2); tc1.config.raft_config.single = false; tc1.config.raft_config.join = vec![tc0.config.raft_config.raft_api_addr().await?.to_string()]; tc2.config.raft_config.single = false; tc2.config.raft_config.join = vec![tc0.config.raft_config.raft_api_addr().await?.to_string()]; start_metasrv_with_context(&mut tc0).await?; start_metasrv_with_context(&mut tc1).await?; start_metasrv_with_context(&mut tc2).await?; let addr0 = tc0.config.grpc_api_address.clone(); let addr1 = tc1.config.grpc_api_address.clone(); let addr2 = tc2.config.grpc_api_address.clone(); let client = MetaGrpcClient::try_create( vec![addr1.clone()], "root", "xxx", None, Some(Duration::from_secs(5)), None, )?; let addrs = HashSet::from([addr0, addr1, addr2]); info!("--- upsert kv cluster"); { let k = "join-k".to_string(); let res = client .upsert_kv(UpsertKVReq::new( k.as_str(), MatchSeq::GE(0), Operation::Update(k.clone().into_bytes()), None, )) .await; debug!("set kv res: {:?}", res); let res = res?; assert_eq!( UpsertKVReply::new( None, Some(SeqV { seq: 1_u64, meta: None, data: k.into_bytes(), }) ), res, "upsert kv to cluster", ); } tokio::time::sleep(Duration::from_millis(1000)).await; info!("--- get kv from cluster"); { let k = "join-k".to_string(); let res = client.get_kv(k.as_str()).await; debug!("get kv {} from cluster, res: {:?}", k, res); let res = res?; assert_eq!(k.into_bytes(), res.unwrap().data); } info!("--- check endpoints are equal"); { tokio::time::sleep(Duration::from_secs(20)).await; let res = client.get_cached_endpoints().await?; let res: HashSet<String> = HashSet::from_iter(res.into_iter()); assert_eq!(addrs, res, "endpoints should be equal"); } info!("--- endpoints should changed when node is down"); { let g = tc1.grpc_srv.as_ref().unwrap(); let meta_node = g.get_meta_node(); let old_term = meta_node.raft.metrics().borrow().current_term; let mut srv = tc0.grpc_srv.take().unwrap(); srv.stop(None).await?; // wait for leader observed // if tc0 is old leader, then we need to check both current_leader is some and current_term > old_term // if tc0 isn't old leader, then we need do nothing. let leader_id = meta_node.get_leader().await?; if leader_id == Some(0) { let metrics = meta_node .raft .wait(Some(Duration::from_millis(30_000))) .metrics( |m| m.current_leader.is_some() && m.current_term > old_term, "a leader is observed", ) .await?; debug!("got leader, metrics: {metrics:?}"); } let res = client.get_cached_endpoints().await?; let res: HashSet<String> = HashSet::from_iter(res.into_iter()); assert_eq!(3, res.len()); } info!("--- endpoints should changed when add node"); { let mut tc3 = MetaSrvTestContext::new(3); tc3.config.raft_config.single = false; tc3.config.raft_config.join = vec![ tc1.config.raft_config.raft_api_addr().await?.to_string(), tc2.config.raft_config.raft_api_addr().await?.to_string(), ]; start_metasrv_with_context(&mut tc3).await?; let g = tc3.grpc_srv.as_ref().unwrap(); let meta_node = g.get_meta_node(); let metrics = meta_node .raft .wait(Some(Duration::from_millis(30_000))) .metrics(|m| m.current_leader.is_some(), "a leader is observed") .await?; debug!("got leader, metrics: {metrics:?}"); let addr3 = tc3.config.grpc_api_address.clone(); let mut i = 0; let mut res = vec![]; while i < 15 { res = client.get_cached_endpoints().await?; if res.contains(&addr3) { break; } else { i += 1; tokio::time::sleep(Duration::from_secs(1)).await; } } assert!( res.contains(&addr3), "endpoints should contains new addr when add node" ); // still can get kv from cluster let k = "join-k".to_string(); let res = client.get_kv(k.as_str()).await; let res = res?; assert_eq!(k.into_bytes(), res.unwrap().data); } // TODO(ariesdevil): remove node from cluster then get endpoints // info!("--- endpoints should changed after remove node"); Ok(()) }
use tdn::prelude::start; use tdn_permission::PermissionlessGroup; use tdn_types::message::{GroupReceiveMessage, ReceiveMessage}; fn main() { smol::block_on(async { let mut group = PermissionlessGroup::default(); let (_peer_addr, send, recv) = start().await.unwrap(); while let Ok(message) = recv.recv().await { match message { ReceiveMessage::Group(GroupReceiveMessage::PeerJoin(peer, addr, data)) => { group.join(peer, addr, data, send.clone()).await; } ReceiveMessage::Group(GroupReceiveMessage::PeerJoinResult(peer, is_ok, result)) => { group.join_result(peer, is_ok, result); } ReceiveMessage::Group(GroupReceiveMessage::PeerLeave(peer)) => { group.leave(&peer); } _ => { println!("recv: {:?}", message); } } } }); }
use chrono::NaiveDate; use teloxide::utils::command::BotCommand; use crate::database::period::Period; #[derive(BotCommand)] #[command(rename = "lowercase", description = "These commands are supported:")] pub enum Command { #[command(description = "Display help text.")] Help, #[command(description = "Create a new challenge", parse_with = "split")] CreateNewChallenge { name: String, start: NaiveDate, end: NaiveDate, }, #[command(description = "Add a new task", parse_with = "split")] AddTask { challenge_name: String, task_name: String, count: i32, period: Period, }, #[command(description = "Sign up for reminders", parse_with = "split")] Signup, #[command( description = "Deshittify the day by asking me all the stuff i havent actually done yet", parse_with = "split" )] SendPoll, SendUpdates, }
// https://leetcode.com/problems/decompress-run-length-encoded-list/submissions/ impl Solution { pub fn decompress_rl_elist(nums: Vec<i32>) -> Vec<i32> { let mut ans: Vec<i32> = Vec::new(); for i in 0..nums.len()/2 { for j in 0..nums[i*2] { ans.push(nums[i*2 + 1]); } } ans } }
#[doc = "Reader of register MPCBB2_VCTR9"] pub type R = crate::R<u32, super::MPCBB2_VCTR9>; #[doc = "Writer for register MPCBB2_VCTR9"] pub type W = crate::W<u32, super::MPCBB2_VCTR9>; #[doc = "Register MPCBB2_VCTR9 `reset()`'s with value 0"] impl crate::ResetValue for super::MPCBB2_VCTR9 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `B288`"] pub type B288_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B288`"] pub struct B288_W<'a> { w: &'a mut W, } impl<'a> B288_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); self.w } } #[doc = "Reader of field `B289`"] pub type B289_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B289`"] pub struct B289_W<'a> { w: &'a mut W, } impl<'a> B289_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); self.w } } #[doc = "Reader of field `B290`"] pub type B290_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B290`"] pub struct B290_W<'a> { w: &'a mut W, } impl<'a> B290_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); self.w } } #[doc = "Reader of field `B291`"] pub type B291_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B291`"] pub struct B291_W<'a> { w: &'a mut W, } impl<'a> B291_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Reader of field `B292`"] pub type B292_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B292`"] pub struct B292_W<'a> { w: &'a mut W, } impl<'a> B292_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); self.w } } #[doc = "Reader of field `B293`"] pub type B293_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B293`"] pub struct B293_W<'a> { w: &'a mut W, } impl<'a> B293_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); self.w } } #[doc = "Reader of field `B294`"] pub type B294_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B294`"] pub struct B294_W<'a> { w: &'a mut W, } impl<'a> B294_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6); self.w } } #[doc = "Reader of field `B295`"] pub type B295_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B295`"] pub struct B295_W<'a> { w: &'a mut W, } impl<'a> B295_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7); self.w } } #[doc = "Reader of field `B296`"] pub type B296_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B296`"] pub struct B296_W<'a> { w: &'a mut W, } impl<'a> B296_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8); self.w } } #[doc = "Reader of field `B297`"] pub type B297_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B297`"] pub struct B297_W<'a> { w: &'a mut W, } impl<'a> B297_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9); self.w } } #[doc = "Reader of field `B298`"] pub type B298_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B298`"] pub struct B298_W<'a> { w: &'a mut W, } impl<'a> B298_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); self.w } } #[doc = "Reader of field `B299`"] pub type B299_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B299`"] pub struct B299_W<'a> { w: &'a mut W, } impl<'a> B299_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); self.w } } #[doc = "Reader of field `B300`"] pub type B300_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B300`"] pub struct B300_W<'a> { w: &'a mut W, } impl<'a> B300_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); self.w } } #[doc = "Reader of field `B301`"] pub type B301_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B301`"] pub struct B301_W<'a> { w: &'a mut W, } impl<'a> B301_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13); self.w } } #[doc = "Reader of field `B302`"] pub type B302_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B302`"] pub struct B302_W<'a> { w: &'a mut W, } impl<'a> B302_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14); self.w } } #[doc = "Reader of field `B303`"] pub type B303_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B303`"] pub struct B303_W<'a> { w: &'a mut W, } impl<'a> B303_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15); self.w } } #[doc = "Reader of field `B304`"] pub type B304_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B304`"] pub struct B304_W<'a> { w: &'a mut W, } impl<'a> B304_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16); self.w } } #[doc = "Reader of field `B305`"] pub type B305_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B305`"] pub struct B305_W<'a> { w: &'a mut W, } impl<'a> B305_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17); self.w } } #[doc = "Reader of field `B306`"] pub type B306_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B306`"] pub struct B306_W<'a> { w: &'a mut W, } impl<'a> B306_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18); self.w } } #[doc = "Reader of field `B307`"] pub type B307_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B307`"] pub struct B307_W<'a> { w: &'a mut W, } impl<'a> B307_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 19)) | (((value as u32) & 0x01) << 19); self.w } } #[doc = "Reader of field `B308`"] pub type B308_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B308`"] pub struct B308_W<'a> { w: &'a mut W, } impl<'a> B308_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20); self.w } } #[doc = "Reader of field `B309`"] pub type B309_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B309`"] pub struct B309_W<'a> { w: &'a mut W, } impl<'a> B309_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21); self.w } } #[doc = "Reader of field `B310`"] pub type B310_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B310`"] pub struct B310_W<'a> { w: &'a mut W, } impl<'a> B310_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22); self.w } } #[doc = "Reader of field `B311`"] pub type B311_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B311`"] pub struct B311_W<'a> { w: &'a mut W, } impl<'a> B311_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23); self.w } } #[doc = "Reader of field `B312`"] pub type B312_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B312`"] pub struct B312_W<'a> { w: &'a mut W, } impl<'a> B312_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24); self.w } } #[doc = "Reader of field `B313`"] pub type B313_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B313`"] pub struct B313_W<'a> { w: &'a mut W, } impl<'a> B313_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25); self.w } } #[doc = "Reader of field `B314`"] pub type B314_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B314`"] pub struct B314_W<'a> { w: &'a mut W, } impl<'a> B314_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26); self.w } } #[doc = "Reader of field `B315`"] pub type B315_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B315`"] pub struct B315_W<'a> { w: &'a mut W, } impl<'a> B315_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 27)) | (((value as u32) & 0x01) << 27); self.w } } #[doc = "Reader of field `B316`"] pub type B316_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B316`"] pub struct B316_W<'a> { w: &'a mut W, } impl<'a> B316_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 28)) | (((value as u32) & 0x01) << 28); self.w } } #[doc = "Reader of field `B317`"] pub type B317_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B317`"] pub struct B317_W<'a> { w: &'a mut W, } impl<'a> B317_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 29)) | (((value as u32) & 0x01) << 29); self.w } } #[doc = "Reader of field `B318`"] pub type B318_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B318`"] pub struct B318_W<'a> { w: &'a mut W, } impl<'a> B318_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 30)) | (((value as u32) & 0x01) << 30); self.w } } #[doc = "Reader of field `B319`"] pub type B319_R = crate::R<bool, bool>; #[doc = "Write proxy for field `B319`"] pub struct B319_W<'a> { w: &'a mut W, } impl<'a> B319_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31); self.w } } impl R { #[doc = "Bit 0 - B288"] #[inline(always)] pub fn b288(&self) -> B288_R { B288_R::new((self.bits & 0x01) != 0) } #[doc = "Bit 1 - B289"] #[inline(always)] pub fn b289(&self) -> B289_R { B289_R::new(((self.bits >> 1) & 0x01) != 0) } #[doc = "Bit 2 - B290"] #[inline(always)] pub fn b290(&self) -> B290_R { B290_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - B291"] #[inline(always)] pub fn b291(&self) -> B291_R { B291_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bit 4 - B292"] #[inline(always)] pub fn b292(&self) -> B292_R { B292_R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 5 - B293"] #[inline(always)] pub fn b293(&self) -> B293_R { B293_R::new(((self.bits >> 5) & 0x01) != 0) } #[doc = "Bit 6 - B294"] #[inline(always)] pub fn b294(&self) -> B294_R { B294_R::new(((self.bits >> 6) & 0x01) != 0) } #[doc = "Bit 7 - B295"] #[inline(always)] pub fn b295(&self) -> B295_R { B295_R::new(((self.bits >> 7) & 0x01) != 0) } #[doc = "Bit 8 - B296"] #[inline(always)] pub fn b296(&self) -> B296_R { B296_R::new(((self.bits >> 8) & 0x01) != 0) } #[doc = "Bit 9 - B297"] #[inline(always)] pub fn b297(&self) -> B297_R { B297_R::new(((self.bits >> 9) & 0x01) != 0) } #[doc = "Bit 10 - B298"] #[inline(always)] pub fn b298(&self) -> B298_R { B298_R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bit 11 - B299"] #[inline(always)] pub fn b299(&self) -> B299_R { B299_R::new(((self.bits >> 11) & 0x01) != 0) } #[doc = "Bit 12 - B300"] #[inline(always)] pub fn b300(&self) -> B300_R { B300_R::new(((self.bits >> 12) & 0x01) != 0) } #[doc = "Bit 13 - B301"] #[inline(always)] pub fn b301(&self) -> B301_R { B301_R::new(((self.bits >> 13) & 0x01) != 0) } #[doc = "Bit 14 - B302"] #[inline(always)] pub fn b302(&self) -> B302_R { B302_R::new(((self.bits >> 14) & 0x01) != 0) } #[doc = "Bit 15 - B303"] #[inline(always)] pub fn b303(&self) -> B303_R { B303_R::new(((self.bits >> 15) & 0x01) != 0) } #[doc = "Bit 16 - B304"] #[inline(always)] pub fn b304(&self) -> B304_R { B304_R::new(((self.bits >> 16) & 0x01) != 0) } #[doc = "Bit 17 - B305"] #[inline(always)] pub fn b305(&self) -> B305_R { B305_R::new(((self.bits >> 17) & 0x01) != 0) } #[doc = "Bit 18 - B306"] #[inline(always)] pub fn b306(&self) -> B306_R { B306_R::new(((self.bits >> 18) & 0x01) != 0) } #[doc = "Bit 19 - B307"] #[inline(always)] pub fn b307(&self) -> B307_R { B307_R::new(((self.bits >> 19) & 0x01) != 0) } #[doc = "Bit 20 - B308"] #[inline(always)] pub fn b308(&self) -> B308_R { B308_R::new(((self.bits >> 20) & 0x01) != 0) } #[doc = "Bit 21 - B309"] #[inline(always)] pub fn b309(&self) -> B309_R { B309_R::new(((self.bits >> 21) & 0x01) != 0) } #[doc = "Bit 22 - B310"] #[inline(always)] pub fn b310(&self) -> B310_R { B310_R::new(((self.bits >> 22) & 0x01) != 0) } #[doc = "Bit 23 - B311"] #[inline(always)] pub fn b311(&self) -> B311_R { B311_R::new(((self.bits >> 23) & 0x01) != 0) } #[doc = "Bit 24 - B312"] #[inline(always)] pub fn b312(&self) -> B312_R { B312_R::new(((self.bits >> 24) & 0x01) != 0) } #[doc = "Bit 25 - B313"] #[inline(always)] pub fn b313(&self) -> B313_R { B313_R::new(((self.bits >> 25) & 0x01) != 0) } #[doc = "Bit 26 - B314"] #[inline(always)] pub fn b314(&self) -> B314_R { B314_R::new(((self.bits >> 26) & 0x01) != 0) } #[doc = "Bit 27 - B315"] #[inline(always)] pub fn b315(&self) -> B315_R { B315_R::new(((self.bits >> 27) & 0x01) != 0) } #[doc = "Bit 28 - B316"] #[inline(always)] pub fn b316(&self) -> B316_R { B316_R::new(((self.bits >> 28) & 0x01) != 0) } #[doc = "Bit 29 - B317"] #[inline(always)] pub fn b317(&self) -> B317_R { B317_R::new(((self.bits >> 29) & 0x01) != 0) } #[doc = "Bit 30 - B318"] #[inline(always)] pub fn b318(&self) -> B318_R { B318_R::new(((self.bits >> 30) & 0x01) != 0) } #[doc = "Bit 31 - B319"] #[inline(always)] pub fn b319(&self) -> B319_R { B319_R::new(((self.bits >> 31) & 0x01) != 0) } } impl W { #[doc = "Bit 0 - B288"] #[inline(always)] pub fn b288(&mut self) -> B288_W { B288_W { w: self } } #[doc = "Bit 1 - B289"] #[inline(always)] pub fn b289(&mut self) -> B289_W { B289_W { w: self } } #[doc = "Bit 2 - B290"] #[inline(always)] pub fn b290(&mut self) -> B290_W { B290_W { w: self } } #[doc = "Bit 3 - B291"] #[inline(always)] pub fn b291(&mut self) -> B291_W { B291_W { w: self } } #[doc = "Bit 4 - B292"] #[inline(always)] pub fn b292(&mut self) -> B292_W { B292_W { w: self } } #[doc = "Bit 5 - B293"] #[inline(always)] pub fn b293(&mut self) -> B293_W { B293_W { w: self } } #[doc = "Bit 6 - B294"] #[inline(always)] pub fn b294(&mut self) -> B294_W { B294_W { w: self } } #[doc = "Bit 7 - B295"] #[inline(always)] pub fn b295(&mut self) -> B295_W { B295_W { w: self } } #[doc = "Bit 8 - B296"] #[inline(always)] pub fn b296(&mut self) -> B296_W { B296_W { w: self } } #[doc = "Bit 9 - B297"] #[inline(always)] pub fn b297(&mut self) -> B297_W { B297_W { w: self } } #[doc = "Bit 10 - B298"] #[inline(always)] pub fn b298(&mut self) -> B298_W { B298_W { w: self } } #[doc = "Bit 11 - B299"] #[inline(always)] pub fn b299(&mut self) -> B299_W { B299_W { w: self } } #[doc = "Bit 12 - B300"] #[inline(always)] pub fn b300(&mut self) -> B300_W { B300_W { w: self } } #[doc = "Bit 13 - B301"] #[inline(always)] pub fn b301(&mut self) -> B301_W { B301_W { w: self } } #[doc = "Bit 14 - B302"] #[inline(always)] pub fn b302(&mut self) -> B302_W { B302_W { w: self } } #[doc = "Bit 15 - B303"] #[inline(always)] pub fn b303(&mut self) -> B303_W { B303_W { w: self } } #[doc = "Bit 16 - B304"] #[inline(always)] pub fn b304(&mut self) -> B304_W { B304_W { w: self } } #[doc = "Bit 17 - B305"] #[inline(always)] pub fn b305(&mut self) -> B305_W { B305_W { w: self } } #[doc = "Bit 18 - B306"] #[inline(always)] pub fn b306(&mut self) -> B306_W { B306_W { w: self } } #[doc = "Bit 19 - B307"] #[inline(always)] pub fn b307(&mut self) -> B307_W { B307_W { w: self } } #[doc = "Bit 20 - B308"] #[inline(always)] pub fn b308(&mut self) -> B308_W { B308_W { w: self } } #[doc = "Bit 21 - B309"] #[inline(always)] pub fn b309(&mut self) -> B309_W { B309_W { w: self } } #[doc = "Bit 22 - B310"] #[inline(always)] pub fn b310(&mut self) -> B310_W { B310_W { w: self } } #[doc = "Bit 23 - B311"] #[inline(always)] pub fn b311(&mut self) -> B311_W { B311_W { w: self } } #[doc = "Bit 24 - B312"] #[inline(always)] pub fn b312(&mut self) -> B312_W { B312_W { w: self } } #[doc = "Bit 25 - B313"] #[inline(always)] pub fn b313(&mut self) -> B313_W { B313_W { w: self } } #[doc = "Bit 26 - B314"] #[inline(always)] pub fn b314(&mut self) -> B314_W { B314_W { w: self } } #[doc = "Bit 27 - B315"] #[inline(always)] pub fn b315(&mut self) -> B315_W { B315_W { w: self } } #[doc = "Bit 28 - B316"] #[inline(always)] pub fn b316(&mut self) -> B316_W { B316_W { w: self } } #[doc = "Bit 29 - B317"] #[inline(always)] pub fn b317(&mut self) -> B317_W { B317_W { w: self } } #[doc = "Bit 30 - B318"] #[inline(always)] pub fn b318(&mut self) -> B318_W { B318_W { w: self } } #[doc = "Bit 31 - B319"] #[inline(always)] pub fn b319(&mut self) -> B319_W { B319_W { w: self } } }
//! Represents the `source` array table in the package manifest. use std::collections::BTreeSet; use std::path::PathBuf; use serde::{Deserialize, Serialize}; /// External fetchable source that can be cached in the store. /// /// TODO: Change to `Uri` once https://github.com/hyperium/http/pull/274 gets merged. #[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] #[serde(untagged)] pub enum Source { Git, Path { path: PathBuf, hash: String }, Uri { uri: String, hash: String }, } /// Represents the `source` array table in the package manifest. #[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd, Deserialize, Serialize)] pub struct Sources(BTreeSet<Source>); impl Sources { /// Creates a new empty `Sources` table. pub fn new() -> Self { Sources(BTreeSet::new()) } /// Inserts a new [`Source`] into the table. /// /// [`Source`]: ./enum.Source.html #[inline] pub fn insert(&mut self, source: Source) { self.0.insert(source); } /// Returns whether the table is empty. #[inline] pub fn is_empty(&self) -> bool { self.0.is_empty() } /// Iterates over each [`Source`] in the table. /// /// [`Source`]: ./enum.Source.html #[inline] pub fn iter(&self) -> impl Iterator<Item = &Source> { self.0.iter() } }
use liblumen_alloc::erts::exception; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::Term; /// `band/2` infix operator. #[native_implemented::function(erlang:band/2)] pub fn result( process: &Process, left_integer: Term, right_integer: Term, ) -> exception::Result<Term> { bitwise_infix_operator!(left_integer, right_integer, process, bitand) }
use super::derived_state::*; use super::super::error::*; use gluon::{RootedThread, Compiler}; use gluon::compiler_pipeline::{CompileValue, Executable}; use gluon::vm::api::{VmType, Getable}; use gluon::base::ast::{SpannedExpr}; use gluon::base::symbol::{Symbol}; use futures::*; use std::mem; use std::sync::*; use std::marker::PhantomData; /// /// The state of a computing script /// enum ComputingScriptState<Item> { /// Script is running and will produce a simple result GeneratingResult(Box<dyn Future<Item=Item, Error=gluon::Error>+Send>), /// Script has completed (has run and no longer depends on anything from the namespace) Finished } /// /// A stream that pulls results from a computing script /// pub struct ComputingScriptStream<Item> { /// The current state of the computing script state: ComputingScriptState<Item>, /// The root thread that we'll spawn from when we need to run root: Arc<RootedThread>, /// The compiler that created the script compiler: Arc<Mutex<Compiler>>, /// We don't actually store any item of the specified data type item: PhantomData<Item> } impl<Item> ComputingScriptStream<Item> where for<'vm> DerivedState<'vm, Item>: VmType, Item: for<'vm, 'value> Getable<'vm, 'value> + VmType + Send + 'static { /// /// Creates a new computing thread that reads from the specified symbol /// pub fn new(root_thread: Arc<RootedThread>, script: CompileValue<SpannedExpr<Symbol>>, compiler: Compiler) -> FloScriptResult<ComputingScriptStream<Item>> { let symbol_type = Item::make_type(&*root_thread); let derived_state_type = DerivedState::<Item>::make_type(&*root_thread); let mut compiler = compiler; let initial_state = if script.typ == symbol_type { // Computed expression with no dependencies let root_copy = Arc::clone(&root_thread); let thread = root_thread.new_thread().expect("script thread"); let future_result = script.run_expr(&mut compiler, thread, "", "", ()) .map(move |result| Item::from_value(&*root_copy, result.value.get_variant())); ComputingScriptState::GeneratingResult(Box::new(future_result)) } else if script.typ == derived_state_type { // Computed expression with dependencies ComputingScriptState::Finished } else { // Not a valid type return Err(FloScriptError::IncorrectType); }; Ok(ComputingScriptStream { root: root_thread, compiler: Arc::new(Mutex::new(compiler)), state: initial_state, item: PhantomData }) } } impl<'vm, Item> ComputingScriptStream<Item> where Item: for<'value> Getable<'vm, 'value> + VmType + Send + 'static { /// /// Given a script in the 'GeneratingResult' state, /// fn poll_for_simple_result(mut future_result: Box<dyn Future<Item=Item, Error=gluon::Error>+Send>) -> (ComputingScriptState<Item>, Poll<Option<Item>, ()>) { use self::ComputingScriptState::*; match future_result.poll() { Ok(Async::NotReady) => (GeneratingResult(future_result), Ok(Async::NotReady)), Ok(Async::Ready(result)) => (Finished, Ok(Async::Ready(Some(result)))), Err(_err) => (Finished, Err(())) } } } impl<'vm, Item> Stream for ComputingScriptStream<Item> where Item: for<'value> Getable<'vm, 'value> + VmType + Send + 'static { type Item = Item; type Error = (); fn poll(&mut self) -> Poll<Option<Item>, ()> { use self::ComputingScriptState::*; // Steal the current state of the stream (we'll wind up in the finished state if there's a panic or something) let mut current_state = Finished; mem::swap(&mut current_state, &mut self.state); // Dispatch the next action based on the current script state let (new_state, result) = match current_state { GeneratingResult(future_result) => Self::poll_for_simple_result(future_result), Finished => (Finished, Ok(Async::Ready(None))) }; // Update to the new state self.state = new_state; result } }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { failure::{format_err, Error}, fuchsia_async as fasync, helper::*, net_types::ip::IpVersion, std::net::UdpSocket, }; const PACKET_COUNT: usize = 10; const PAYLOAD_SIZE: usize = 100; // octets. fn main() -> Result<(), Error> { static TEST_NAME: &str = "basic_integration"; let mut env = TestEnvironment::new(fasync::Executor::new()?, TEST_NAME)?; // Example integration tests of basic packet sniffing functionality. // TODO(CONN-168): Add more comprehensive tests. test_case!(bad_args_test, &mut env); test_case!(receive_one_of_many_test, &mut env, EndpointType::RX); // Repeat for capturing on TX endpoint. test_case!(receive_one_of_many_test, &mut env, EndpointType::TX); Ok(()) } // A simple test of bad arguments where packet capture exits immediately. fn bad_args_test(env: &mut TestEnvironment) -> Result<(), Error> { // Empty arguments. let mut output = env.run_test_case_no_packets(vec![])?; assert!(output.ok().is_err()); // Bad device. output = env.run_test_case_no_packets(vec!["..".into()])?; assert!(output.ok().is_err()); // Device should be last. let mut argsv: Vec<String> = env.new_args(EndpointType::RX).into(); argsv.push("-v".into()); output = env.run_test_case_no_packets(argsv)?; assert!(output.ok().is_err()); // Unknown argument. let args = env.new_args(EndpointType::RX).insert_arg("-x".into()); output = env.run_test_case_no_packets(args.into())?; assert!(output.ok().is_err()); Ok(()) } // Tests that packet headers are captured and output. // Only one correct packet is necessary for the test to pass fn receive_one_of_many_test( env: &mut TestEnvironment, capture_ep: EndpointType, ) -> Result<(), Error> { let args = env .new_args(capture_ep) .insert_packet_count(PACKET_COUNT) .insert_write_to_dumpfile(DEFAULT_DUMPFILE); let socket_tx = UdpSocket::bind(EndpointType::TX.default_socket_addr(IpVersion::V4))?; let output = env.run_test_case( args.into(), send_udp_packets( socket_tx, EndpointType::RX.default_socket_addr(IpVersion::V4), PAYLOAD_SIZE, PACKET_COUNT, ), DEFAULT_DUMPFILE, )?; output.ok()?; let output_stdout = output_string(&output.stdout); // Obtained headers. let packets: Vec<String> = output_stdout.lines().map(String::from).collect(); assert_eq!(packets.len(), PACKET_COUNT); // Expected data. let headers = [ "IP4", EndpointType::TX.default_ip_addr_str(IpVersion::V4), EndpointType::RX.default_ip_addr_str(IpVersion::V4), &EndpointType::TX.default_port().to_string(), &EndpointType::RX.default_port().to_string(), "UDP", &(20 + 8 + PAYLOAD_SIZE).to_string(), // IP + UDP headers + payload octets in length. ]; for packet in packets { match check_all_substrs(&packet, &headers) { Ok(()) => return Ok(()), _ => continue, } } Err(format_err!("Matching packet not found in packet_data_test!")) }
//给定一个非负整数 num。对于 0 ≤ i ≤ num 范围中的每个数字 i ,计算其二进制数中的 1 的数目并将它们作为数组返回。 // // 示例 1: // // 输入: 2 //输出: [0,1,1] // // 示例 2: // // 输入: 5 //输出: [0,1,1,2,1,2] // // 进阶: // // // 给出时间复杂度为O(n*sizeof(integer))的解答非常容易。但你可以在线性时间O(n)内用一趟扫描做到吗? // 要求算法的空间复杂度为O(n)。 // 你能进一步完善解法吗?要求在C++或任何其他语言中不使用任何内置函数(如 C++ 中的 __builtin_popcount)来执行此操作。 // // Related Topics 位运算 动态规划 //leetcode submit region begin(Prohibit modification and deletion) impl Solution { pub fn count_bits(num: i32) -> Vec<i32> { let num = num as usize; let mut result = vec![0; num + 1]; result[0] = 0; for i in 1..=num { result[i] = result[i / 2] + (i & 1) as i32; } return result; } } //leetcode submit region end(Prohibit modification and deletion) struct Solution {} fn main() { let vec = Solution::count_bits(2); dbg!(vec); }
use std::fmt; use std::cmp::Ordering; pub struct BinaryHeap<T> { heap: Vec<T>, } #[derive(Clone, Copy, Default)] pub struct PriorityTuple<T> { priority: u32, pub value: T, } impl<T> PartialOrd for PriorityTuple<T> { fn partial_cmp(&self, other: &PriorityTuple<T>) -> Option<Ordering> { Some(self.priority.cmp(&other.priority)) } } impl<T> PartialEq for PriorityTuple<T> { fn eq(&self, other: &PriorityTuple<T>) -> bool { self.priority == other.priority } } impl<T> fmt::Display for PriorityTuple<T> where T: PartialOrd + Copy + fmt::Display + fmt::Debug { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "Priority: {}, Value: {}", self.priority, self.value) } } impl<T> PriorityTuple<T> { pub fn new(priority: u32, value: T) -> PriorityTuple<T> { PriorityTuple { priority, value, } } } #[allow(dead_code)] impl<T> BinaryHeap<T> where T: Default + Copy + PartialOrd + fmt::Display { pub fn new() -> BinaryHeap<T> { BinaryHeap { heap: Vec::new(), } } fn get_left(&self, i: usize) -> Option<T> { self.heap.get(2*i+1).cloned() } fn get_right(&self, i: usize) -> Option<T> { self.heap.get(2*i+2).cloned() } fn get_left_index(&self, i: usize) -> usize { 2*i+1 as usize } fn get_right_index(&self, i: usize) -> usize { 2*i+2 as usize } fn get_parent(&self, i: usize) -> T { if i==0 { panic!("Cannot get parent of root node"); } self.heap.get((i-1)/2).unwrap().clone() } fn get_parent_index(&self, i: usize) -> usize { (i-1)/2 as usize } pub fn insert(&mut self, value: T) { self.heap.push(value); let i = self.heap.len()-1; self.bubble_up(i); } fn bubble_up(&mut self, i: usize) { if i == 0 { return; } let parent_i = self.get_parent_index(i); //min-heap (minimum val at root) if self.get_parent(i) < self.heap[i] { self.bubble_up(parent_i); return; } self.heap.swap(i, parent_i); } pub fn extract(&mut self) -> Option<T> { //If the heap is empty, return None if self.heap.len() == 0 { return None; } //Move the lowest node on the tree to the top let last = self.heap.len()-1; self.heap.swap(0, last); //Save and remove the extracted value let value = self.heap.pop().unwrap(); //Percolate down from root to re-Heapify self.percolate_down(0); return Some(value); } fn percolate_down(&mut self, i: usize) { let mut smallest = i; //println!("I am {}", self.heap[smallest]); if let Some(left_val) = self.get_left(i) { //println!("My left child is {}", left_val); if self.heap[smallest] > left_val { smallest = self.get_left_index(i); } } if let Some(right_val) = self.get_right(i) { //println!("My right child is {}", right_val); if self.heap[smallest] > right_val { smallest = self.get_right_index(i); } } if smallest != i { //println!("Swapping with {}", self.heap[smallest]); self.heap.swap(i, smallest); self.percolate_down(smallest); } } pub fn get_heap(&self) -> Vec<T> { self.heap.clone() } pub fn is_empty(&self) -> bool { self.heap.len() == 0 } pub fn contains(&self, key: T) -> bool { self.heap.contains(key) } } impl<T> fmt::Display for BinaryHeap<T> where T: PartialOrd + Copy + fmt::Display + fmt::Debug { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.heap) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_insert() { let mut bin: BinaryHeap<u32> = BinaryHeap::new(); bin.insert(1); bin.insert(5); bin.insert(10); bin.insert(3); bin.insert(2); bin.insert(6); bin.insert(7); bin.insert(20); assert_eq!(bin.heap,vec![1, 2, 6, 5, 3, 10, 7, 20]); } #[test] fn test_extract() { //Build a heap let mut bin: BinaryHeap<u32> = BinaryHeap::new(); bin.insert(1); bin.insert(5); bin.insert(10); bin.insert(3); bin.insert(2); bin.insert(6); bin.insert(7); bin.insert(20); assert_eq!(bin.get_heap(),vec![1, 2, 6, 5, 3, 10, 7, 20]); //Extract let val = bin.extract(); assert!(val.is_some()); assert_eq!(val.unwrap(), 1); assert_eq!(bin.get_heap(),vec![2, 3, 6, 5, 20, 10, 7]); //Extract again let val = bin.extract(); assert!(val.is_some()); assert_eq!(val.unwrap(), 2); assert_eq!(bin.get_heap(),vec![3, 5, 6, 7, 20, 10]); } }
use crate::cpu::Cpu; use crate::opcode::addressing_mode::AddressMode; use crate::opcode::Operation; use crate::opcode::*; use std::string::ToString; pub struct Branch { branch_type: BranchType, /// Offset to branch to on success. offset: i8, } /// The type of branch operation. enum BranchType { /// (B)ranch on (c)arry (s)et. Bcs, /// (B)ranch on (c)arry (c)lear. Bcc, /// (B)ranch on (n)ot (e)qual. Bne, /// Branch on (e)qual. Beq, /// (B)ranch on (mi)nus. Bmi, /// (B)ranch on (pl)us. Bpl, /// (B)ranch on o(v)erflow (s)et. Bvs, /// (B)ranch on o(v)erflow (c)lear. Bvc, } impl BranchType { /// Convert from the opcode to branch type enum. pub fn from_opcode(opcode: u8) -> Option<BranchType> { match opcode { 0x10 => Some(BranchType::Bpl), 0x30 => Some(BranchType::Bmi), 0x50 => Some(BranchType::Bvc), 0x70 => Some(BranchType::Bvs), 0xB0 => Some(BranchType::Bcs), 0x90 => Some(BranchType::Bcc), 0xD0 => Some(BranchType::Bne), 0xF0 => Some(BranchType::Beq), _ => None, } } /// Convert from BranchType to opcode. pub fn to_opcode(&self) -> u8 { match self { BranchType::Bpl => 0x10, BranchType::Bmi => 0x30, BranchType::Bvc => 0x50, BranchType::Bvs => 0x70, BranchType::Bcs => 0xB0, BranchType::Bcc => 0x90, BranchType::Bne => 0xD0, BranchType::Beq => 0xF0, } } } impl ToString for BranchType { fn to_string(&self) -> String { match &self { BranchType::Bcs => "BCS", BranchType::Bcc => "BCC", BranchType::Beq => "BEQ", BranchType::Bne => "BNE", BranchType::Bmi => "BMI", BranchType::Bpl => "BPL", BranchType::Bvs => "BVS", BranchType::Bvc => "BVC", } .to_string() } } impl Branch { /// Number of bytes in branch operation. const BYTE_COUNT: u16 = 2; /// Create a new branch from an opcode. pub fn new(opcode: u8, cpu: &Cpu) -> Option<Self> { let offset = cpu.memory[(cpu.program_counter + 1) as usize] as i8; let branch_type = BranchType::from_opcode(opcode)?; Some(Branch { branch_type, offset, }) } /// Specalitve computation of branch value. fn branch_value(&self, cpu: &Cpu) -> u16 { cpu.program_counter + Self::BYTE_COUNT + self.offset as u16 } } impl Operation for Branch { fn execute(&self, cpu: &mut Cpu) { cpu.program_counter += Self::BYTE_COUNT; cpu.cycles += 2; let should_branch = match self.branch_type { BranchType::Bcs => cpu.status.carry, BranchType::Bcc => !cpu.status.carry, BranchType::Beq => cpu.status.zero, BranchType::Bne => !cpu.status.zero, BranchType::Bmi => cpu.status.negative, BranchType::Bpl => !cpu.status.negative, BranchType::Bvs => cpu.status.overflow, BranchType::Bvc => !cpu.status.overflow, }; if should_branch { let addr = AddressMode::Relative { offset: self.offset, } .to_addr(cpu) .unwrap(); let next_instruction_addr = cpu.program_counter; cpu.program_counter = addr; cpu.cycles += 1; if is_on_different_pages(next_instruction_addr, cpu.program_counter) { cpu.cycles += 1; } } } fn dump(&self, cpu: &Cpu) -> String { format!( "{:02X} {:02X} {} ${:04X} ", self.branch_type.to_opcode(), self.offset, self.branch_type.to_string(), self.branch_value(cpu), ) } }
use std::env; fn main(){ let args: Vec<String> = env::args().collect(); let nom = &args[1]; let auteur = &args[2]; let version = &args[3]; println!("Lancement du module {} créé par {} en version {}", nom, auteur, version); }
/// Insert sort pub fn sort<T: Ord + Clone>(list: &Vec<T>) -> Vec<T> { let mut sorted = list.clone(); for cursor in 1..sorted.len() { let value = sorted[cursor].clone(); let mut place = cursor; while place > 0 && sorted[place - 1] > value { sorted[place] = sorted[place - 1].clone(); place -= 1; } sorted[place] = value; } return sorted; }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use fidl::endpoints::ServiceMarker; use fidl_fuchsia_cobalt::LoggerFactoryMarker; use fidl_fuchsia_fonts::ProviderMarker; use fidl_fuchsia_ledger_cloud::CloudProviderMarker; use fidl_fuchsia_logger::LogSinkMarker; use fidl_fuchsia_sys::EnvironmentControllerProxy; use fidl_fuchsia_tracing_provider::RegistryMarker; use fidl_fuchsia_ui_input::ImeServiceMarker; use fidl_fuchsia_ui_scenic::ScenicMarker; use fidl_fuchsia_vulkan_loader::LoaderMarker; use fuchsia_component::{ client::{App as LaunchedApp, LaunchOptions}, fuchsia_single_component_package_url, server::{ServiceFs, ServiceObj}, }; use fuchsia_syslog::fx_log_err; use std::sync::Arc; const SESSIONMGR_URI: &str = fuchsia_single_component_package_url!("sessionmgr"); const FLAG_USE_CLOUD_PROVIDER_FROM_ENV: &str = "--use_cloud_provider_from_environment"; pub fn make_replica_env( replica_id: &str, cloud_provider_app: Arc<LaunchedApp>, ) -> Result< (ServiceFs<ServiceObj<'static, ()>>, EnvironmentControllerProxy, LaunchedApp), failure::Error, > { // Configure disk directory. let data_origin = format!("/data/voila/{}", replica_id); std::fs::create_dir_all(data_origin.clone())?; let mut launch_options = LaunchOptions::new(); launch_options.add_dir_to_namespace("/data".to_string(), std::fs::File::open(data_origin)?)?; let mut fs = ServiceFs::new(); fs.add_service_at(CloudProviderMarker::NAME, move |chan| { cloud_provider_app .pass_to_service::<CloudProviderMarker>(chan) .unwrap_or_else(|e| fx_log_err!("failed to pass cloud provider request {:?}", e)); None }) .add_proxy_service::<LogSinkMarker, _>() .add_proxy_service::<LoggerFactoryMarker, _>() .add_proxy_service::<ScenicMarker, _>() .add_proxy_service::<ImeServiceMarker, _>() .add_proxy_service::<LoaderMarker, _>() .add_proxy_service::<ProviderMarker, _>() .add_proxy_service::<RegistryMarker, _>(); let (environment_ctrl, app) = fs.launch_component_in_nested_environment_with_options( SESSIONMGR_URI.to_string(), Some(vec![FLAG_USE_CLOUD_PROVIDER_FROM_ENV.to_string()]), launch_options, replica_id, )?; Ok((fs, environment_ctrl, app)) }
use seed::{prelude::*, *}; use seed::web_sys::console; use serde::{Serialize, Deserialize}; // ------ ------ // Init // ------ ------ fn init(_: Url, orders: &mut impl Orders<Msg>) -> Model { orders.send_msg(Msg::FetchData); Model::default() } // ------ ------ // Model // ------ ------ #[derive(Default)] struct Model { change: Option<Change>, } #[derive(Debug, Deserialize, Serialize)] struct Change { diff: String, } // ------ ------ // Update // ------ ------ enum Msg { DataFetched(Change), FetchData, } fn update(msg: Msg, model: &mut Model, orders: &mut impl Orders<Msg>) { match msg { Msg::FetchData => { orders.skip(); orders.perform_cmd( async { let url = "/public/sample.diff"; let response = fetch(url).await.expect("fetch failed"); let change = response .check_status() .expect("check_status failed") .json() .await .expect("deserialization failed"); Msg::DataFetched(change) }); } Msg::DataFetched(change) => { model.change = Some(change); orders.after_next_render(|_| { console::time_end_with_label("rendering"); }); }, } } fn unified_diff(diff: &str) -> Node<Msg> { // let mut current_ofile = "".to_string(); // let mut current_nfile = "".to_string(); let mut arr = vec![]; let mut oline = 0; let mut nline = 0; for value in diff.split("\n") { if value.starts_with("@") { continue; } if value.starts_with("+++") { continue; } if value.starts_with("---") { continue; } // if value.starts_with("index") { // if let [idx, ff, rest] = value.split(" ").collect::<Vec<_>>().as_slice() { // if let [o, n] = ff.split("..").collect::<Vec<_>>().as_slice() { // current_ofile = o.to_string(); // current_nfile = n.to_string(); // } // } // continue; // } if value.starts_with("diff --git") { if let [_d, _g, a, b] = value.split(" ").collect::<Vec<_>>().as_slice() { oline = 1; nline = 1; arr.push(tr![ C!["head"], td![attrs!(At::ColSpan=> 3), pre![""]] ]); arr.push(tr![ C!["head"], td![ attrs!(At::ColSpan=> 3), pre![format!("{} -> {}", &a[2..], &b[2..])] ] ]); arr.push(tr![ C!["head"], td![attrs!(At::ColSpan=> 3), pre![""]] ]); continue; } } if value.starts_with(" ") { arr.push(code_line( "", Some(oline), Some(nline), &value[1..], )); oline += 1; nline += 1; } else if value.starts_with("+") { arr.push(code_line("addition", None, Some(nline), &value[1..])); nline += 1; } else if value.starts_with("-") { arr.push(code_line("removal", Some(oline), None, &value[1..])); oline += 1; } } table![tbody![arr]] } fn code_line(cls: &str, oline: Option<i32>, nline: Option<i32>, value: &str) -> Node<Msg> { tr![ C![cls], td![C!["linenr"], pre![oline],], td![C!["linenr"], pre![nline],], td![C!["code"], pre![value],] ] } // ------ ------ // View // ------ ------ fn view(model: &Model) -> Node<Msg> { if let Some(change) = &model.change { log!("view with `change` invoked"); console::time_with_label("diffing"); let diff_html = unified_diff(&change.diff); console::time_end_with_label("diffing"); console::time_with_label("rendering"); diff_html } else { div!["No diff"] } } // ------ ------ // Start // ------ ------ #[wasm_bindgen(start)] pub fn start() { App::start("app", init, update, view); }
pub use VkImageViewCreateFlags::*; #[repr(u32)] #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum VkImageViewCreateFlags { VK_IMAGE_VIEW_CREATE_FRAGMENT_DENSITY_MAP_DYNAMIC_BIT_EXT = 0x0000_0001, } use crate::SetupVkFlags; #[repr(C)] #[derive(Clone, Copy, Eq, PartialEq, Hash)] pub struct VkImageViewCreateFlagBits(u32); SetupVkFlags!(VkImageViewCreateFlags, VkImageViewCreateFlagBits);
pub(crate) mod async_buf_read; pub(crate) mod async_read; pub(crate) mod async_seek; pub(crate) mod async_write; pub(crate) mod sink; pub(crate) mod stream;
use std::path::{PathBuf}; pub struct Pathfinder { pub root: PathBuf, } impl Pathfinder { /// Get the root directory. pub fn root_dir(&self) -> PathBuf { self.root.clone() } /// Get the backup directory. pub fn backup_dir(&self) -> PathBuf { self.root.join("_renom").join("Backup") } /// Get the staging directory. pub fn staging_dir(&self) -> PathBuf { self.root.join("_renom").join("Staging") } /// Get the config directory. pub fn config_dir(&self) -> PathBuf { self.root.join("Config") } /// Get the source directory. pub fn source_dir(&self) -> PathBuf { self.root.join("Source") } /// Get the source project subdirectory. pub fn source_proj_dir(&self, proj_name: &str) -> PathBuf { self.source_dir().join(proj_name) } } #[cfg(test)] mod tests { use super::*; #[test] fn test_root() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot"), }; assert_eq!(pathfinder.root_dir(), PathBuf::from("TestRoot\\")); } #[test] fn test_backup_dir() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot\\"), }; assert_eq!(pathfinder.backup_dir(), PathBuf::from("TestRoot\\_renom\\Backup")); } #[test] fn test_staging_dir() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot\\"), }; assert_eq!( pathfinder.staging_dir(), PathBuf::from("TestRoot\\_renom\\Staging") ); } #[test] fn test_config_dir() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot\\"), }; assert_eq!(pathfinder.config_dir(), PathBuf::from("TestRoot\\Config")); } #[test] fn test_source_dir() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot\\"), }; assert_eq!(pathfinder.source_dir(), PathBuf::from("TestRoot\\Source")); } #[test] fn test_source_proj_dir() { let pathfinder = Pathfinder { root: PathBuf::from("TestRoot\\"), }; assert_eq!(pathfinder.source_proj_dir("TestProject"), PathBuf::from("TestRoot\\Source\\TestProject")); } }
use expansion_policy::ExpansionPolicy; use node_pool::NodePool; use pqueue::PriorityQueue; use qcell::{TLCell, TLCellOwner}; pub mod domains; pub mod pqueue; pub mod util; pub mod expansion_policy; pub mod node_pool; #[derive(Debug, Copy, Clone)] pub struct SearchNode<VertexId> { search_num: usize, pqueue_location: usize, pub expansions: usize, pub id: VertexId, pub parent: Option<VertexId>, pub g: f64, pub lb: f64, } #[derive(Debug, Copy, Clone, PartialEq)] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Edge<VertexId> { pub destination: VertexId, pub cost: f64, } pub enum SearchCellMarker {} pub type Cell<T> = TLCell<SearchCellMarker, T>; pub type Owner = TLCellOwner<SearchCellMarker>; pub fn astar<VertexId>( pool: &mut impl NodePool<VertexId>, owner: &mut Owner, expansion_policy: &mut impl ExpansionPolicy<VertexId>, h: impl FnMut(VertexId) -> f64, source: VertexId, goal: VertexId, ) where VertexId: Copy + Eq, { unsafe { // SAFETY: Since SafeNodePool and SafeExpansionPolicy always do bounds checks, so all vertex // IDs are in-bounds for the purposes of safety. astar_unchecked( &mut SafeNodePool(pool), owner, &mut SafeExpansionPolicy(expansion_policy), h, source, goal, ) } } /// SAFETY: The caller must ensure that the following invariants hold: /// - `source` must be in-bounds of the expansion policy. /// - `expansion_policy` must always produce edges whose destinations are in-bounds of the /// expansion policy. /// - If a vertex ID is in-bounds of the expansion policy, then it must be in-bounds of the node /// pool. #[inline(never)] pub unsafe fn astar_unchecked<VertexId>( pool: &mut impl NodePool<VertexId>, owner: &mut Owner, expansion_policy: &mut impl ExpansionPolicy<VertexId>, mut h: impl FnMut(VertexId) -> f64, source: VertexId, goal: VertexId, ) where VertexId: Copy + Eq, { pool.reset(owner); let mut queue = PriorityQueue::new(); let mut edges = vec![]; let source = pool.generate_unchecked(source, owner); owner.rw(source).g = 0.0; owner.rw(source).lb = 0.0; queue.decrease_key(source, owner); while let Some(node) = queue.pop(owner) { let n = owner.rw(node); n.expansions += 1; if n.id == goal { break; } expansion_policy.expand_unchecked(n, &mut edges); let parent_g = n.g; let parent_id = n.id; for edge in edges.drain(..) { let g = parent_g + edge.cost; let node = pool.generate_unchecked(edge.destination, owner); let n = owner.rw(node); if g < n.g { n.g = g; n.lb = g + h(n.id); n.parent = Some(parent_id); queue.decrease_key(node, owner); } } } } struct SafeNodePool<'a, N>(&'a mut N); impl<V, N: NodePool<V>> NodePool<V> for SafeNodePool<'_, N> { fn reset(&mut self, owner: &mut Owner) { self.0.reset(owner) } fn generate(&self, id: V, owner: &mut Owner) -> &Cell<SearchNode<V>> { self.0.generate(id, owner) } } struct SafeExpansionPolicy<'a, E>(&'a mut E); impl<V, E: ExpansionPolicy<V>> ExpansionPolicy<V> for SafeExpansionPolicy<'_, E> { fn expand(&mut self, node: &SearchNode<V>, edges: &mut Vec<Edge<V>>) { self.0.expand(node, edges) } }
//! server of Blockchain #![allow(warnings, unused)] use super::*; use crate::block::*; use crate::transaction::*; use crate::utxoset::*; use bincode::{deserialize, serialize}; use failure::format_err; use serde::{Deserialize, Serialize}; use std::collections::{HashMap, HashSet}; use std::io::prelude::*; use std::net::{TcpListener, TcpStream}; use std::sync::*; use std::thread; use std::time::Duration; use crate::blockchain::*; #[derive(Serialize, Deserialize, Debug, Clone)] enum Message { Addr(Vec<String>), Version(Versionmsg), Tx(Txmsg), GetData(GetDatamsg), GetBlock(GetBlocksmsg), Inv(Invmsg), Block(Blockmsg), } #[derive(Serialize, Deserialize, Debug, Clone)] struct Blockmsg { addr_from: String, block: Block, chain: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] struct GetBlocksmsg { addr_from: String, chain: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] struct GetDatamsg { addr_from: String, kind: String, id: String, chain: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] struct Invmsg { addr_from: String, kind: String, items: Vec<String>, chain: i32, } #[derive(Serialize, Deserialize, Debug, Clone)] struct Txmsg { addr_from: String, transaction: Transaction, chain: i32, } #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] struct Versionmsg { addr_from: String, version: i32, best_height: i32, chain: i32, } pub struct Server { node_address: String, mining_address: String, inner: Arc<Mutex<ServerInner>>, } struct ServerInner { known_nodes: HashSet<String>, utxo: UTXOSet, blocks_in_transit: Vec<String>, mempool: HashMap<String, Transaction>, utxo1: UTXOSet, } const KNOWN_NODE1: &str = "localhost:3000"; const CMD_LEN: usize = 12; const VERSION: i32 = 1; impl Server { pub fn new(port: &str, miner_address: &str,utxo: UTXOSet,utxo1: UTXOSet) -> Result<Server> { let mut node_set = HashSet::new(); node_set.insert(String::from(KNOWN_NODE1)); Ok(Server { node_address: String::from("localhost:") + port, mining_address: miner_address.to_string(), inner: Arc::new(Mutex::new(ServerInner { known_nodes: node_set, utxo, blocks_in_transit: Vec::new(), mempool: HashMap::new(), utxo1, })), }) } pub fn start_server(&self,chain: i32) -> Result<()> { let server1 = Server { node_address: self.node_address.clone(), mining_address: self.mining_address.clone(), inner: Arc::clone(&self.inner), }; let server2 = Server { node_address: self.node_address.clone(), mining_address: self.mining_address.clone(), inner: Arc::clone(&self.inner), }; println!( "Started server at {}, minning address: {}", &self.node_address, &self.mining_address ); //sync thread::spawn(move || { println!( "Started chain 1 check"); thread::sleep(Duration::from_millis(1000)); server2.send_version(KNOWN_NODE1,1) }); thread::spawn(move || { println!( "Started chain 2 check"); thread::sleep(Duration::from_millis(1000)); server1.send_version(KNOWN_NODE1,2) }); // end let listener = TcpListener::bind(&self.node_address).unwrap(); println!("Default chain: {}",chain); println!("Default chain is just a number used so function arguments are not empty!"); println!("Node listen..."); for stream in listener.incoming() { let stream = stream?; let server1 = Server { node_address: self.node_address.clone(), mining_address: self.mining_address.clone(), inner: Arc::clone(&self.inner), }; let server2 = Server { node_address: self.node_address.clone(), mining_address: self.mining_address.clone(), inner: Arc::clone(&self.inner), }; thread::spawn(move || server1.handle_connection(stream,1)); } Ok(()) } pub fn send_transaction(tx: &Transaction, utxo: UTXOSet, chain: i32, utxo1: UTXOSet) -> Result<()> { let server = Server::new("7000", "",utxo,utxo1)?; server.send_tx(KNOWN_NODE1, tx, chain)?; Ok(()) } /* ------------------- inner halp functions ----------------------------------*/ fn remove_node(&self, addr: &str) { self.inner.lock().unwrap().known_nodes.remove(addr); } fn add_nodes(&self, addr: &str) { self.inner .lock() .unwrap() .known_nodes .insert(String::from(addr)); } fn get_known_nodes(&self) -> HashSet<String> { self.inner.lock().unwrap().known_nodes.clone() } fn node_is_known(&self, addr: &str) -> bool { self.inner.lock().unwrap().known_nodes.get(addr).is_some() } fn replace_in_transit(&self, hashs: Vec<String>) { let bit = &mut self.inner.lock().unwrap().blocks_in_transit; bit.clone_from(&hashs); } fn get_in_transit(&self) -> Vec<String> { self.inner.lock().unwrap().blocks_in_transit.clone() } fn get_mempool_tx(&self, addr: &str) -> Option<Transaction> { match self.inner.lock().unwrap().mempool.get(addr) { Some(tx) => Some(tx.clone()), None => None, } } fn get_mempool(&self) -> HashMap<String, Transaction> { self.inner.lock().unwrap().mempool.clone() } fn insert_mempool(&self, tx: Transaction) { self.inner.lock().unwrap().mempool.insert(tx.id.clone(), tx); } fn clear_mempool(&self) { self.inner.lock().unwrap().mempool.clear() } fn get_best_height(&self,chain: i32) -> Result<i32> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.get_best_height1() } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.get_best_height1() }_ => panic!("Unknown chain index!") } } fn get_hash_other(&self,chain: i32) -> Result<String> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.get_block_other(1) } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.get_block_other(2) }_ => panic!("Unknown chain index!") } } fn get_block_hashs(&self,chain: i32) -> Vec<String> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.get_block_hashs() } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.get_block_hashs() }_ => panic!("Unknown chain index!") } } fn get_block(&self, block_hash: &str,chain: i32) -> Result<Block> { self.inner .lock() .unwrap() .utxo .blockchain .get_block(block_hash,chain) } fn verify_tx(&self, tx: &Transaction) -> Result<bool> { self.inner .lock() .unwrap() .utxo .blockchain .verify_transacton(tx) } fn add_block(&self, block: Block,chain: i32) -> Result<()> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.add_block(block) } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.add_block(block) }_ => panic!("Unknown chain index!") } } fn mine_block_other(&self, txs: Vec<Transaction,>,chain: i32,last: String) -> Result<Block> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.mine_block_server(txs, chain,last) } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.mine_block_server(txs, chain,last) }_ => panic!("Unknown chain index!") } } fn utxo_reindex(&self,chain: i32) -> Result<()> { match chain { 1 =>{ self.inner.lock().unwrap().utxo.reindex() } 2 =>{ self.inner.lock().unwrap().utxo1.reindex() }_ => panic!("Unknown chain index!") } } /* -----------------------------------------------------*/ fn send_data(&self, addr: &str, data: &[u8],chain: i32) -> Result<()> { if addr == &self.node_address { return Ok(()); } let mut stream = match TcpStream::connect(addr) { Ok(s) => s, Err(_) => { self.remove_node(addr); return Ok(()); } }; stream.write(data)?; println!("data send successfully"); Ok(()) } fn request_blocks(&self,chain: i32) -> Result<()> { for node in self.get_known_nodes() { self.send_get_blocks(&node,chain)? } Ok(()) } fn send_block(&self, addr: &str, b: &Block, chain: i32) -> Result<()> { println!("send block data to: {} block hash: {}", addr, b.get_hash()); let data = Blockmsg { addr_from: self.node_address.clone(), block: b.clone(), chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("block"), data))?; self.send_data(addr, &data,chain) } fn send_addr(&self, addr: &str,chain: i32) -> Result<()> { println!("send address info to: {}", addr); let nodes = self.get_known_nodes(); let data = serialize(&(cmd_to_bytes("addr"), nodes))?; self.send_data(addr, &data,chain) } fn send_inv(&self, addr: &str, kind: &str, items: Vec<String>,chain: i32) -> Result<()> { println!( "send inv message to: {} kind: {} data: {:?}", addr, kind, items ); let data = Invmsg { addr_from: self.node_address.clone(), kind: kind.to_string(), items, chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("inv"), data))?; self.send_data(addr, &data,chain) } fn send_get_blocks(&self, addr: &str,chain: i32) -> Result<()> { println!("send get blocks message to: {}", addr); let data = GetBlocksmsg { addr_from: self.node_address.clone(), chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("getblocks"), data))?; self.send_data(addr, &data,chain) } fn send_get_data(&self, addr: &str, kind: &str, id: &str,chain: i32) -> Result<()> { println!( "send get data message to: {} kind: {} id: {}", addr, kind, id ); let data = GetDatamsg { addr_from: self.node_address.clone(), kind: kind.to_string(), id: id.to_string(), chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("getdata"), data))?; self.send_data(addr, &data,chain) } pub fn send_tx(&self, addr: &str, tx: &Transaction, chain: i32) -> Result<()> { println!("send tx to: {} txid: {}", addr, &tx.id); let data = Txmsg { addr_from: self.node_address.clone(), transaction: tx.clone(), chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("tx"), data))?; self.send_data(addr, &data, chain) } fn send_version(&self, addr: &str,chain: i32) -> Result<()> { println!("send version info to: {}", addr); let data = Versionmsg { addr_from: self.node_address.clone(), best_height: self.get_best_height(chain)?, version: VERSION, chain: chain.clone(), }; let data = serialize(&(cmd_to_bytes("version"), data))?; self.send_data(addr, &data,chain) } fn handle_version(&self, msg: Versionmsg,chain: i32) -> Result<()> { println!("receive version msg: {:#?}", msg); let my_best_height = self.get_best_height(msg.chain)?; if my_best_height < msg.best_height { self.send_get_blocks(&msg.addr_from,msg.chain)?; println!("Syncing"); } else if my_best_height > msg.best_height { self.send_version(&msg.addr_from,msg.chain)?; println!("Im longer chain"); } self.send_addr(&msg.addr_from,msg.chain)?; if !self.node_is_known(&msg.addr_from) { self.add_nodes(&msg.addr_from); } println!("Synced"); Ok(()) } fn handle_addr(&self, msg: Vec<String>, chain: i32) -> Result<()> { println!("receive address msg: {:#?}", msg); for node in msg { self.add_nodes(&node); } //self.request_blocks()?; Ok(()) } fn handle_block(&self, msg: Blockmsg,chain: i32) -> Result<()> { println!( "receive block msg: {}, {}", msg.addr_from, msg.block.get_hash() ); println!("1"); self.add_block(msg.block,msg.chain)?; println!("2"); let mut in_transit = self.get_in_transit(); if in_transit.len() > 0 { let block_hash = &in_transit[0]; self.send_get_data(&msg.addr_from, "block", block_hash,msg.chain)?; in_transit.remove(0); self.replace_in_transit(in_transit); } else { self.utxo_reindex(msg.chain)?; } println!("3"); Ok(()) } fn handle_inv(&self, msg: Invmsg,chain: i32) -> Result<()> { println!("receive inv msg: {:#?}", msg); if msg.kind == "block" { let block_hash = &msg.items[0]; self.send_get_data(&msg.addr_from, "block", block_hash,msg.chain)?; let mut new_in_transit = Vec::new(); for b in &msg.items { if b != block_hash { new_in_transit.push(b.clone()); } } self.replace_in_transit(new_in_transit); } else if msg.kind == "tx" { let txid = &msg.items[0]; match self.get_mempool_tx(txid) { Some(tx) => { if tx.id.is_empty() { self.send_get_data(&msg.addr_from, "tx", txid,msg.chain)? } } None => self.send_get_data(&msg.addr_from, "tx", txid,msg.chain)?, } } Ok(()) } fn handle_get_blocks(&self, msg: GetBlocksmsg,chain: i32) -> Result<()> { println!("receive get blocks msg: {:#?}", msg); let block_hashs = self.get_block_hashs(msg.chain); self.send_inv(&msg.addr_from, "block", block_hashs,msg.chain)?; Ok(()) } fn handle_get_data(&self, msg: GetDatamsg,chain: i32) -> Result<()> { println!("receive get data msg: {:#?}", msg); if msg.kind == "block" { println!("Kind: Block"); let block = match msg.chain { 1 =>{ self.inner.lock().unwrap().utxo.blockchain.get_block(&msg.id,msg.chain)? } 2 =>{ self.inner.lock().unwrap().utxo1.blockchain.get_block(&msg.id,msg.chain)? }_ => panic!("Unknown chain index!") }; println!("Kind: Block1"); self.send_block(&msg.addr_from, &block,msg.chain)?; } else if msg.kind == "tx" { let tx = self.get_mempool_tx(&msg.id).unwrap(); self.send_tx(&msg.addr_from, &tx,msg.chain)?; } Ok(()) } fn handle_tx(&self, msg: Txmsg, chain: i32) -> Result<()> { println!("receive tx msg: {} {}, chain: {}", msg.addr_from, &msg.transaction.id, msg.chain); self.insert_mempool(msg.transaction.clone()); let known_nodes = self.get_known_nodes(); if self.node_address == KNOWN_NODE1 { for node in known_nodes { if node != self.node_address && node != msg.addr_from { println!("Sending inv to other nodes"); self.send_inv(&node, "tx", vec![msg.transaction.id.clone()],msg.chain)?; } } } else { let mut mempool = self.get_mempool(); println!("Current mempool: {:#?}", &mempool); if mempool.len() >= 1 && !self.mining_address.is_empty() { loop { println!("Should start mine"); let mut txs = Vec::new(); for (_, tx) in &mempool { if self.verify_tx(tx)? { txs.push(tx.clone()); } } if txs.is_empty() { return Ok(()); } let cbtx = Transaction::new_coinbase(self.mining_address.clone(), String::new())?; txs.push(cbtx); for tx in &txs { mempool.remove(&tx.id); } let last1 = match msg.chain { 1 => {self.get_hash_other(2)} 2 => {self.get_hash_other(1)} _ => panic!("Unknown chain index!") }; let last2 = last1.unwrap().to_string(); let new_block = self.mine_block_other(txs,msg.chain,last2)?; self.utxo_reindex(msg.chain)?; for node in self.get_known_nodes() { if node != self.node_address { self.send_inv(&node, "block", vec![new_block.get_hash()],msg.chain)?; } } if mempool.len() == 0 { break; } } self.clear_mempool(); } } Ok(()) } fn handle_connection(&self, mut stream: TcpStream, chain: i32) -> Result<()> { let mut buffer = Vec::new(); let count = stream.read_to_end(&mut buffer)?; println!("Accept request: length {}", count); let cmd = bytes_to_cmd(&buffer)?; match cmd { Message::Addr(data) => self.handle_addr(data,chain)?, Message::Block(data) => self.handle_block(data,chain)?, Message::Inv(data) => self.handle_inv(data,chain)?, Message::GetBlock(data) => self.handle_get_blocks(data,chain)?, Message::GetData(data) => self.handle_get_data(data,chain)?, Message::Tx(data) => self.handle_tx(data,chain)?, Message::Version(data) => self.handle_version(data,chain)?, } Ok(()) } } fn cmd_to_bytes(cmd: &str) -> [u8; CMD_LEN] { let mut data = [0; CMD_LEN]; for (i, d) in cmd.as_bytes().iter().enumerate() { data[i] = *d; } data } fn bytes_to_cmd(bytes: &[u8]) -> Result<Message> { let mut cmd = Vec::new(); let cmd_bytes = &bytes[..CMD_LEN]; let data = &bytes[CMD_LEN..]; for b in cmd_bytes { if 0 as u8 != *b { cmd.push(*b); } } println!("cmd: {}", String::from_utf8(cmd.clone())?); if cmd == "addr".as_bytes() { let data: Vec<String> = deserialize(data)?; Ok(Message::Addr(data)) } else if cmd == "block".as_bytes() { let data: Blockmsg = deserialize(data)?; Ok(Message::Block(data)) } else if cmd == "inv".as_bytes() { let data: Invmsg = deserialize(data)?; Ok(Message::Inv(data)) } else if cmd == "getblocks".as_bytes() { let data: GetBlocksmsg = deserialize(data)?; Ok(Message::GetBlock(data)) } else if cmd == "getdata".as_bytes() { let data: GetDatamsg = deserialize(data)?; Ok(Message::GetData(data)) } else if cmd == "tx".as_bytes() { let data: Txmsg = deserialize(data)?; Ok(Message::Tx(data)) } else if cmd == "version".as_bytes() { let data: Versionmsg = deserialize(data)?; Ok(Message::Version(data)) } else { Err(format_err!("Unknown command in the server")) } } #[cfg(test)] mod test { use super::*; use crate::wallets::*; #[test] fn test_cmd() { } }
extern crate argparse; use std::process::exit; use argparse::{ArgumentParser, StoreTrue, Store}; struct Options { verbose: bool, name: String, } fn main() { let mut options = Options { verbose: false, name: "World".to_string(), }; { let mut ap = ArgumentParser::new(); ap.set_description("Greet somebody."); ap.refer(&mut options.verbose) .add_option(&["-v", "--verbose"], StoreTrue, "Be verbose"); ap.refer(&mut options.name) .add_option(&["--name"], Store, "Name for the greeting"); match ap.parse_args() { Ok(()) => {} Err(x) => { exit(x); } } } if options.verbose { println!("name is {}", options.name); } println!("Hello {}!", options.name); }
// Copyright 2019. The Tari Project // // Redistribution and use in source and binary forms, with or without modification, are permitted provided that the // following conditions are met: // // 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following // disclaimer. // // 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the // following disclaimer in the documentation and/or other materials provided with the distribution. // // 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote // products derived from this software without specific prior written permission. // // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, // WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE // USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. use crate::{ chain_storage::{db_transaction::DbKey, MmrTree}, validation::ValidationError, }; use tari_mmr::{error::MerkleMountainRangeError, MerkleProofError}; use thiserror::Error; #[derive(Debug, Clone, Error, PartialEq)] pub enum ChainStorageError { #[error("Access to the underlying storage mechanism failed:{0}")] AccessError(String), #[error( "The database may be corrupted or otherwise be in an inconsistent state. Please check logs to try and \ identify the issue:{0}" )] CorruptedDatabase(String), #[error("A given input could not be spent because it was not in the UTXO set")] UnspendableInput, #[error("A problem occurred trying to move a STXO back into the UTXO pool during a re-org.")] UnspendError, #[error( "An unexpected result type was received for the given database request. This suggests that there is an \ internal error or bug of sorts: {0}" )] UnexpectedResult(String), #[error("You tried to execute an invalid Database operation:{0}")] InvalidOperation(String), #[error("There appears to be a critical error on the back end:{0}. Check the logs for more information.")] CriticalError(String), #[error("Cannot return data for requests older than the current pruning horizon")] BeyondPruningHorizon, #[error("A parameter to the request was invalid")] InvalidQuery(String), #[error("The requested value '{0}' was not found in the database")] ValueNotFound(DbKey), #[error("MMR error: {source}")] MerkleMountainRangeError { #[from] source: MerkleMountainRangeError, }, #[error("Merkle proof error: {source}")] MerkleProofError { #[from] source: MerkleProofError, }, #[error("Validation error:{source}")] ValidationError { #[from] source: ValidationError, }, #[error("The MMR root for {0} in the provided block header did not match the MMR root in the database")] MismatchedMmrRoot(MmrTree), #[error("An invalid block was submitted to the database")] InvalidBlock, #[error("Blocking task spawn error:{0}")] BlockingTaskSpawnError(String), #[error("A request was out of range")] OutOfRange, }
use std::convert::TryInto; use anyhow::*; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::*; use crate::runtime::context::*; /// `delete_element/2` #[native_implemented::function(erlang:delete_element/2)] pub fn result(process: &Process, index: Term, tuple: Term) -> exception::Result<Term> { let initial_inner_tuple = term_try_into_tuple!(tuple)?; let initial_len = initial_inner_tuple.len(); if initial_len > 0 { let index_one_based: OneBasedIndex = index .try_into() .with_context(|| term_is_not_in_one_based_range(index, initial_len))?; let index_zero_based: usize = index_one_based.into(); if index_zero_based < initial_len { let mut new_elements_vec = initial_inner_tuple[..].to_vec(); new_elements_vec.remove(index_zero_based); let smaller_tuple = process.tuple_from_slice(&new_elements_vec); Ok(smaller_tuple) } else { Err(TryIntoIntegerError::OutOfRange) .with_context(|| term_is_not_in_one_based_range(index, initial_len)) .map_err(From::from) } } else { Err(anyhow!("tuple ({}) is empty", tuple).into()) } }
use super::ema::ema_func; use super::ema::rma_func; use super::sma::{declare_ma_var, wma_func}; use super::tr::tr_func; use super::VarResult; use crate::ast::stat_expr_types::VarIndex; use crate::ast::syntax_type::{FunctionType, FunctionTypes, SimpleSyntaxType, SyntaxType}; use crate::helper::err_msgs::*; use crate::helper::str_replace; use crate::helper::{ ensure_srcs, float_abs, float_max2, move_element, pine_ref_to_bool, pine_ref_to_f64, pine_ref_to_f64_series, pine_ref_to_i64, require_param, series_index, }; use crate::runtime::context::{downcast_ctx, Ctx}; use crate::runtime::InputSrc; use crate::types::{ downcast_pf_ref, int2float, Arithmetic, Callable, CallableCreator, CallableFactory, Evaluate, EvaluateVal, Float, Int, ParamCollectCall, PineRef, RefData, RuntimeErr, Series, SeriesCall, Tuple, }; use std::mem; use std::rc::Rc; #[derive(Debug, Clone, PartialEq)] pub struct KcVal<'a> { closes: Series<'a, Float>, smooth1: Series<'a, Float>, smooth2: Series<'a, Float>, asmooth1: Series<'a, Float>, asmooth2: Series<'a, Float>, } impl<'a> KcVal<'a> { pub fn new() -> KcVal<'a> { KcVal { closes: Series::new(), smooth1: Series::new(), smooth2: Series::new(), asmooth1: Series::new(), asmooth2: Series::new(), } } fn process_tsi( &mut self, _ctx: &mut dyn Ctx<'a>, mut param: Vec<Option<PineRef<'a>>>, _func_type: FunctionType<'a>, ) -> Result<Float, RuntimeErr> { move_tuplet!((source, short, long) = param); let short = require_param("short", pine_ref_to_i64(short))?; let long = require_param("long", pine_ref_to_i64(long))?; // Double Smoothed PC // ------------------ // PC = Current Price minus Prior Price // First Smoothing = 25-period EMA of PC // Second Smoothing = 13-period EMA of 25-period EMA of PC let close = pine_ref_to_f64(source); let pc = close.minus(self.closes.index_value(1)?); let s1val = ema_func(pc, long, self.smooth1.index_value(1)?)?; let s2val = ema_func(s1val, short, self.smooth2.index_value(1)?)?; // Double Smoothed Absolute PC // --------------------------- // Absolute Price Change |PC| = Absolute Value of Current Price minus Prior Price // First Smoothing = 25-period EMA of |PC| // Second Smoothing = 13-period EMA of 25-period EMA of |PC| let apc = float_abs(close.minus(self.closes.index_value(1)?)); let as1val = ema_func(apc, long, self.asmooth1.index_value(1)?)?; let as2val = ema_func(as1val, short, self.asmooth2.index_value(1)?)?; // TSI = (Double Smoothed PC / Double Smoothed Absolute PC) let tsi = s2val.div(as2val); self.closes.update_commit(close); self.smooth1.update_commit(s1val); self.smooth2.update_commit(s2val); self.asmooth1.update_commit(as1val); self.asmooth2.update_commit(as2val); Ok(tsi) } } impl<'a> SeriesCall<'a> for KcVal<'a> { fn step( &mut self, _ctx: &mut dyn Ctx<'a>, param: Vec<Option<PineRef<'a>>>, _func_type: FunctionType<'a>, ) -> Result<PineRef<'a>, RuntimeErr> { let res = self.process_tsi(_ctx, param, _func_type)?; Ok(PineRef::new_rc(Series::from(res))) } fn back(&mut self, _context: &mut dyn Ctx<'a>) -> Result<(), RuntimeErr> { self.closes.roll_back(); self.smooth1.roll_back(); self.smooth2.roll_back(); self.asmooth1.roll_back(); self.asmooth2.roll_back(); Ok(()) } fn copy(&self) -> Box<dyn SeriesCall<'a> + 'a> { Box::new(self.clone()) } } pub fn declare_var<'a>() -> VarResult<'a> { let value = PineRef::new(CallableFactory::new(|| { Callable::new(None, Some(Box::new(KcVal::new()))) })); let func_type = FunctionTypes(vec![FunctionType::new(( vec![ ("source", SyntaxType::float_series()), ("short_length", SyntaxType::int()), ("long_length", SyntaxType::int()), ], SyntaxType::float_series(), ))]); let syntax_type = SyntaxType::Function(Rc::new(func_type)); VarResult::new(value, syntax_type, "tsi") } #[cfg(test)] mod tests { use super::*; use crate::ast::syntax_type::SyntaxType; use crate::runtime::VarOperate; use crate::runtime::{AnySeries, NoneCallback}; use crate::types::Series; use crate::{LibInfo, PineParser, PineRunner}; // use crate::libs::{floor, exp, }; #[test] fn rsi_int_test() { let lib_info = LibInfo::new( vec![declare_var()], vec![("close", SyntaxType::float_series())], ); let src = "m = tsi(close, 2, 2)\n"; let blk = PineParser::new(src, &lib_info).parse_blk().unwrap(); let mut runner = PineRunner::new(&lib_info, &blk, &NoneCallback()); runner .run( &vec![( "close", AnySeries::from_float_vec(vec![Some(20f64), Some(10f64)]), )], None, ) .unwrap(); assert_eq!( runner.get_context().move_var(VarIndex::new(0, 0)), Some(PineRef::new(Series::from_vec(vec![None, Some(-1.0)]))) ); } }
#[doc = "Reader of register APB1_FZR1"] pub type R = crate::R<u32, super::APB1_FZR1>; #[doc = "Writer for register APB1_FZR1"] pub type W = crate::W<u32, super::APB1_FZR1>; #[doc = "Register APB1_FZR1 `reset()`'s with value 0"] impl crate::ResetValue for super::APB1_FZR1 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `DBG_TIMER2_STOP`"] pub type DBG_TIMER2_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIMER2_STOP`"] pub struct DBG_TIMER2_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIMER2_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); self.w } } #[doc = "Reader of field `DBG_TIM3_STOP`"] pub type DBG_TIM3_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIM3_STOP`"] pub struct DBG_TIM3_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIM3_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1); self.w } } #[doc = "Reader of field `DBG_TIM4_STOP`"] pub type DBG_TIM4_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIM4_STOP`"] pub struct DBG_TIM4_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIM4_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); self.w } } #[doc = "Reader of field `DBG_TIM5_STOP`"] pub type DBG_TIM5_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIM5_STOP`"] pub struct DBG_TIM5_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIM5_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Reader of field `DBG_TIMER6_STOP`"] pub type DBG_TIMER6_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIMER6_STOP`"] pub struct DBG_TIMER6_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIMER6_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4); self.w } } #[doc = "Reader of field `DBG_TIM7_STOP`"] pub type DBG_TIM7_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_TIM7_STOP`"] pub struct DBG_TIM7_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_TIM7_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5); self.w } } #[doc = "Reader of field `DBG_RTC_STOP`"] pub type DBG_RTC_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_RTC_STOP`"] pub struct DBG_RTC_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_RTC_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10); self.w } } #[doc = "Reader of field `DBG_WWDG_STOP`"] pub type DBG_WWDG_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_WWDG_STOP`"] pub struct DBG_WWDG_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_WWDG_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); self.w } } #[doc = "Reader of field `DBG_IWDG_STOP`"] pub type DBG_IWDG_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_IWDG_STOP`"] pub struct DBG_IWDG_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_IWDG_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12); self.w } } #[doc = "Reader of field `DBG_I2C1_STOP`"] pub type DBG_I2C1_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_I2C1_STOP`"] pub struct DBG_I2C1_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_I2C1_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21); self.w } } #[doc = "Reader of field `DBG_I2C2_STOP`"] pub type DBG_I2C2_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_I2C2_STOP`"] pub struct DBG_I2C2_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_I2C2_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22); self.w } } #[doc = "Reader of field `DBG_I2C3_STOP`"] pub type DBG_I2C3_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_I2C3_STOP`"] pub struct DBG_I2C3_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_I2C3_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23); self.w } } #[doc = "Reader of field `DBG_CAN_STOP`"] pub type DBG_CAN_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_CAN_STOP`"] pub struct DBG_CAN_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_CAN_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25); self.w } } #[doc = "Reader of field `DBG_LPTIMER_STOP`"] pub type DBG_LPTIMER_STOP_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBG_LPTIMER_STOP`"] pub struct DBG_LPTIMER_STOP_W<'a> { w: &'a mut W, } impl<'a> DBG_LPTIMER_STOP_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31); self.w } } impl R { #[doc = "Bit 0 - Debug Timer 2 stopped when Core is halted"] #[inline(always)] pub fn dbg_timer2_stop(&self) -> DBG_TIMER2_STOP_R { DBG_TIMER2_STOP_R::new((self.bits & 0x01) != 0) } #[doc = "Bit 1 - TIM3 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim3_stop(&self) -> DBG_TIM3_STOP_R { DBG_TIM3_STOP_R::new(((self.bits >> 1) & 0x01) != 0) } #[doc = "Bit 2 - TIM4 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim4_stop(&self) -> DBG_TIM4_STOP_R { DBG_TIM4_STOP_R::new(((self.bits >> 2) & 0x01) != 0) } #[doc = "Bit 3 - TIM5 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim5_stop(&self) -> DBG_TIM5_STOP_R { DBG_TIM5_STOP_R::new(((self.bits >> 3) & 0x01) != 0) } #[doc = "Bit 4 - Debug Timer 6 stopped when Core is halted"] #[inline(always)] pub fn dbg_timer6_stop(&self) -> DBG_TIMER6_STOP_R { DBG_TIMER6_STOP_R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 5 - TIM7 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim7_stop(&self) -> DBG_TIM7_STOP_R { DBG_TIM7_STOP_R::new(((self.bits >> 5) & 0x01) != 0) } #[doc = "Bit 10 - Debug RTC stopped when Core is halted"] #[inline(always)] pub fn dbg_rtc_stop(&self) -> DBG_RTC_STOP_R { DBG_RTC_STOP_R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bit 11 - Debug Window Wachdog stopped when Core is halted"] #[inline(always)] pub fn dbg_wwdg_stop(&self) -> DBG_WWDG_STOP_R { DBG_WWDG_STOP_R::new(((self.bits >> 11) & 0x01) != 0) } #[doc = "Bit 12 - Debug Independent Wachdog stopped when Core is halted"] #[inline(always)] pub fn dbg_iwdg_stop(&self) -> DBG_IWDG_STOP_R { DBG_IWDG_STOP_R::new(((self.bits >> 12) & 0x01) != 0) } #[doc = "Bit 21 - I2C1 SMBUS timeout mode stopped when core is halted"] #[inline(always)] pub fn dbg_i2c1_stop(&self) -> DBG_I2C1_STOP_R { DBG_I2C1_STOP_R::new(((self.bits >> 21) & 0x01) != 0) } #[doc = "Bit 22 - I2C2 SMBUS timeout mode stopped when core is halted"] #[inline(always)] pub fn dbg_i2c2_stop(&self) -> DBG_I2C2_STOP_R { DBG_I2C2_STOP_R::new(((self.bits >> 22) & 0x01) != 0) } #[doc = "Bit 23 - I2C3 SMBUS timeout counter stopped when core is halted"] #[inline(always)] pub fn dbg_i2c3_stop(&self) -> DBG_I2C3_STOP_R { DBG_I2C3_STOP_R::new(((self.bits >> 23) & 0x01) != 0) } #[doc = "Bit 25 - bxCAN stopped when core is halted"] #[inline(always)] pub fn dbg_can_stop(&self) -> DBG_CAN_STOP_R { DBG_CAN_STOP_R::new(((self.bits >> 25) & 0x01) != 0) } #[doc = "Bit 31 - LPTIM1 counter stopped when core is halted"] #[inline(always)] pub fn dbg_lptimer_stop(&self) -> DBG_LPTIMER_STOP_R { DBG_LPTIMER_STOP_R::new(((self.bits >> 31) & 0x01) != 0) } } impl W { #[doc = "Bit 0 - Debug Timer 2 stopped when Core is halted"] #[inline(always)] pub fn dbg_timer2_stop(&mut self) -> DBG_TIMER2_STOP_W { DBG_TIMER2_STOP_W { w: self } } #[doc = "Bit 1 - TIM3 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim3_stop(&mut self) -> DBG_TIM3_STOP_W { DBG_TIM3_STOP_W { w: self } } #[doc = "Bit 2 - TIM4 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim4_stop(&mut self) -> DBG_TIM4_STOP_W { DBG_TIM4_STOP_W { w: self } } #[doc = "Bit 3 - TIM5 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim5_stop(&mut self) -> DBG_TIM5_STOP_W { DBG_TIM5_STOP_W { w: self } } #[doc = "Bit 4 - Debug Timer 6 stopped when Core is halted"] #[inline(always)] pub fn dbg_timer6_stop(&mut self) -> DBG_TIMER6_STOP_W { DBG_TIMER6_STOP_W { w: self } } #[doc = "Bit 5 - TIM7 counter stopped when core is halted"] #[inline(always)] pub fn dbg_tim7_stop(&mut self) -> DBG_TIM7_STOP_W { DBG_TIM7_STOP_W { w: self } } #[doc = "Bit 10 - Debug RTC stopped when Core is halted"] #[inline(always)] pub fn dbg_rtc_stop(&mut self) -> DBG_RTC_STOP_W { DBG_RTC_STOP_W { w: self } } #[doc = "Bit 11 - Debug Window Wachdog stopped when Core is halted"] #[inline(always)] pub fn dbg_wwdg_stop(&mut self) -> DBG_WWDG_STOP_W { DBG_WWDG_STOP_W { w: self } } #[doc = "Bit 12 - Debug Independent Wachdog stopped when Core is halted"] #[inline(always)] pub fn dbg_iwdg_stop(&mut self) -> DBG_IWDG_STOP_W { DBG_IWDG_STOP_W { w: self } } #[doc = "Bit 21 - I2C1 SMBUS timeout mode stopped when core is halted"] #[inline(always)] pub fn dbg_i2c1_stop(&mut self) -> DBG_I2C1_STOP_W { DBG_I2C1_STOP_W { w: self } } #[doc = "Bit 22 - I2C2 SMBUS timeout mode stopped when core is halted"] #[inline(always)] pub fn dbg_i2c2_stop(&mut self) -> DBG_I2C2_STOP_W { DBG_I2C2_STOP_W { w: self } } #[doc = "Bit 23 - I2C3 SMBUS timeout counter stopped when core is halted"] #[inline(always)] pub fn dbg_i2c3_stop(&mut self) -> DBG_I2C3_STOP_W { DBG_I2C3_STOP_W { w: self } } #[doc = "Bit 25 - bxCAN stopped when core is halted"] #[inline(always)] pub fn dbg_can_stop(&mut self) -> DBG_CAN_STOP_W { DBG_CAN_STOP_W { w: self } } #[doc = "Bit 31 - LPTIM1 counter stopped when core is halted"] #[inline(always)] pub fn dbg_lptimer_stop(&mut self) -> DBG_LPTIMER_STOP_W { DBG_LPTIMER_STOP_W { w: self } } }
use std::collections::HashMap; use std::io; use example_interface::{ClientState, Color, ConnectionId, MousePos}; use futures_util::SinkExt; use nanoserde::{DeJson, SerJson}; use rand::{thread_rng, Rng}; use std::sync::atomic::{AtomicU32, Ordering}; use tokio::net::{TcpListener, TcpStream}; use tokio::select; use tokio::stream::StreamExt; use tokio::sync::{broadcast, mpsc, oneshot}; use tokio::task::spawn; use tokio_tungstenite::tungstenite::Message; use tokio_tungstenite::{self, accept_async, tungstenite}; mod example_interface; static NEXT_ID: AtomicU32 = AtomicU32::new(1); impl Color { fn random() -> Self { let mut rng = thread_rng(); Color { r: rng.gen_range(0., 1.), g: rng.gen_range(0., 1.), b: rng.gen_range(0., 1.), } } } #[derive(Debug)] struct ClientEvent { id: ConnectionId, kind: ClientEventKind, } #[derive(Debug)] enum ClientEventKind { NewConnection(MousePos, Color, oneshot::Sender<Vec<ClientState>>), Update(MousePos), Disconnection, } async fn distribute(mut rx: mpsc::Receiver<ClientEvent>, tx: broadcast::Sender<ClientState>) { let mut data: HashMap<ConnectionId, ClientState> = HashMap::new(); loop { match rx.next().await { None => break, Some(ClientEvent { id, kind: ClientEventKind::NewConnection(pos, color, initial_tx), }) => { println!( "Districute handling new connection id: {:?} color: {:?}", id, color ); initial_tx .send(data.values().map(|x| x.clone()).collect()) .unwrap(); let new_state = ClientState { id, color, pos }; data.insert(id, new_state.clone()); tx.send(new_state).unwrap(); } Some(ClientEvent { id, kind: ClientEventKind::Update(pos), }) => { let v = data.get_mut(&id).unwrap(); v.pos = pos; tx.send(v.clone()).unwrap(); } Some(ClientEvent { id, kind: ClientEventKind::Disconnection, }) => { data.remove(&id); } } } } fn deserialize_msg(msg: Message) -> Option<MousePos> { match msg { Message::Text(s) => Some(MousePos::deserialize_json(&s).unwrap()), Message::Close(cf) => { println!("Close frame: {:?}", cf); None } _ => panic!("Unsupported message type. {:?}", msg), } } async fn process_rx( id: ConnectionId, rx_update: Option<tungstenite::Result<Message>>, distribute_tx: &mut mpsc::Sender<ClientEvent>, ) -> bool { match rx_update { Some(Ok(rx_update)) => { if let Some(pos) = deserialize_msg(rx_update) { distribute_tx .send(ClientEvent { id, kind: ClientEventKind::Update(pos), }) .await .unwrap(); } true } Some(Err(rx_err)) => { println!("Connnection {:?} closed with error {}", id, rx_err); distribute_tx .send(ClientEvent { id, kind: ClientEventKind::Disconnection, }) .await .unwrap(); false } None => { println!("Connnection {:?} closed cleanly", id); distribute_tx .send(ClientEvent { id, kind: ClientEventKind::Disconnection, }) .await .unwrap(); false } } } async fn process_socket( socket: TcpStream, mut distribute_tx: mpsc::Sender<ClientEvent>, mut distribute_rx: broadcast::Receiver<ClientState>, ) { let id = ConnectionId(NEXT_ID.fetch_add(1, Ordering::AcqRel)); let color = Color::random(); println!("New connection id: {:?} color: {:?}", id, color); let mut ws = accept_async(socket).await.unwrap(); let initial = ws.next().await.unwrap().unwrap(); let pos = deserialize_msg(initial).unwrap(); let (tx, rx) = oneshot::channel(); distribute_tx .send(ClientEvent { id, kind: ClientEventKind::NewConnection(pos, color, tx), }) .await .unwrap(); for datum in rx.await.unwrap() { ws.send(Message::Text(datum.serialize_json())) .await .unwrap(); } loop { select! { rx_update = ws.next() => { if !process_rx(id, rx_update, &mut distribute_tx).await { break; } } tx_update = distribute_rx.next() => { match tx_update { Some(x) => ws.send(Message::Text(x.unwrap().serialize_json())).await.unwrap(), None => break, }; } } } } #[tokio::main] async fn main() -> io::Result<()> { let mut listener = TcpListener::bind("0.0.0.0:8080").await?; let (ingress_tx, ingress_rx) = mpsc::channel(10); let (egress_tx, egress_rx) = broadcast::channel(10); drop(egress_rx); let egress_tx2 = egress_tx.clone(); spawn(distribute(ingress_rx, egress_tx)); println!("Running"); loop { let (socket, _) = listener.accept().await?; spawn(process_socket( socket, ingress_tx.clone(), egress_tx2.subscribe(), )); } }
use serde::{Deserialize, Serialize}; #[repr(C)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub enum MismatchType { None, Access, FileName, FileSize, } #[repr(C)] #[derive(Serialize, Deserialize, Debug, Clone, PartialEq)] pub struct RuleErrorMsg { pub expected: String, pub actual: String, pub mismatch_type: MismatchType, pub msg: String, pub items: Vec<String>, pub rule_index: usize, } impl RuleErrorMsg { pub fn new(mismatch_type: MismatchType, index: usize) -> RuleErrorMsg { RuleErrorMsg { expected: "".to_string(), actual: "".to_string(), mismatch_type, msg: "".to_string(), items: vec![], rule_index: index } } } impl Default for RuleErrorMsg { fn default() -> Self { RuleErrorMsg { expected: "".to_string(), actual: "".to_string(), mismatch_type: MismatchType::None, msg: "".to_string(), items: vec![], rule_index: 0 } } }
#[doc = r"Register block"] #[repr(C)] pub struct RegisterBlock { #[doc = "0x00 - Hibernation RTC Counter"] pub rtcc: RTCC, #[doc = "0x04 - Hibernation RTC Match 0"] pub rtcm0: RTCM0, _reserved2: [u8; 4usize], #[doc = "0x0c - Hibernation RTC Load"] pub rtcld: RTCLD, #[doc = "0x10 - Hibernation Control"] pub ctl: CTL, #[doc = "0x14 - Hibernation Interrupt Mask"] pub im: IM, #[doc = "0x18 - Hibernation Raw Interrupt Status"] pub ris: RIS, #[doc = "0x1c - Hibernation Masked Interrupt Status"] pub mis: MIS, #[doc = "0x20 - Hibernation Interrupt Clear"] pub ic: IC, #[doc = "0x24 - Hibernation RTC Trim"] pub rtct: RTCT, #[doc = "0x28 - Hibernation RTC Sub Seconds"] pub rtcss: RTCSS, #[doc = "0x2c - Hibernation IO Configuration"] pub io: IO, #[doc = "0x30 - Hibernation Data"] pub data: DATA, _reserved12: [u8; 716usize], #[doc = "0x300 - Hibernation Calendar Control"] pub calctl: CALCTL, _reserved13: [u8; 12usize], #[doc = "0x310 - Hibernation Calendar 0"] pub cal0: CAL0, #[doc = "0x314 - Hibernation Calendar 1"] pub cal1: CAL1, _reserved15: [u8; 8usize], #[doc = "0x320 - Hibernation Calendar Load 0"] pub calld0: CALLD0, #[doc = "0x324 - Hibernation Calendar Load"] pub calld1: CALLD1, _reserved17: [u8; 8usize], #[doc = "0x330 - Hibernation Calendar Match 0"] pub calm0: CALM0, #[doc = "0x334 - Hibernation Calendar Match 1"] pub calm1: CALM1, _reserved19: [u8; 40usize], #[doc = "0x360 - Hibernation Lock"] pub lock: LOCK, _reserved20: [u8; 156usize], #[doc = "0x400 - HIB Tamper Control"] pub tpctl: TPCTL, #[doc = "0x404 - HIB Tamper Status"] pub tpstat: TPSTAT, _reserved22: [u8; 8usize], #[doc = "0x410 - HIB Tamper I/O Control"] pub tpio: TPIO, _reserved23: [u8; 204usize], #[doc = "0x4e0 - HIB Tamper Log 0"] pub tplog0: TPLOG0, #[doc = "0x4e4 - HIB Tamper Log 1"] pub tplog1: TPLOG1, #[doc = "0x4e8 - HIB Tamper Log 2"] pub tplog2: TPLOG2, #[doc = "0x4ec - HIB Tamper Log 3"] pub tplog3: TPLOG3, #[doc = "0x4f0 - HIB Tamper Log 4"] pub tplog4: TPLOG4, #[doc = "0x4f4 - HIB Tamper Log 5"] pub tplog5: TPLOG5, #[doc = "0x4f8 - HIB Tamper Log 6"] pub tplog6: TPLOG6, #[doc = "0x4fc - HIB Tamper Log 7"] pub tplog7: TPLOG7, _reserved31: [u8; 2752usize], #[doc = "0xfc0 - Hibernation Peripheral Properties"] pub pp: PP, _reserved32: [u8; 4usize], #[doc = "0xfc8 - Hibernation Clock Control"] pub cc: CC, } #[doc = "Hibernation RTC Counter\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtcc](rtcc) module"] pub type RTCC = crate::Reg<u32, _RTCC>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RTCC; #[doc = "`read()` method returns [rtcc::R](rtcc::R) reader structure"] impl crate::Readable for RTCC {} #[doc = "Hibernation RTC Counter"] pub mod rtcc; #[doc = "Hibernation RTC Match 0\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtcm0](rtcm0) module"] pub type RTCM0 = crate::Reg<u32, _RTCM0>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RTCM0; #[doc = "`read()` method returns [rtcm0::R](rtcm0::R) reader structure"] impl crate::Readable for RTCM0 {} #[doc = "`write(|w| ..)` method takes [rtcm0::W](rtcm0::W) writer structure"] impl crate::Writable for RTCM0 {} #[doc = "Hibernation RTC Match 0"] pub mod rtcm0; #[doc = "Hibernation RTC Load\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtcld](rtcld) module"] pub type RTCLD = crate::Reg<u32, _RTCLD>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RTCLD; #[doc = "`read()` method returns [rtcld::R](rtcld::R) reader structure"] impl crate::Readable for RTCLD {} #[doc = "`write(|w| ..)` method takes [rtcld::W](rtcld::W) writer structure"] impl crate::Writable for RTCLD {} #[doc = "Hibernation RTC Load"] pub mod rtcld; #[doc = "Hibernation Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ctl](ctl) module"] pub type CTL = crate::Reg<u32, _CTL>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CTL; #[doc = "`read()` method returns [ctl::R](ctl::R) reader structure"] impl crate::Readable for CTL {} #[doc = "`write(|w| ..)` method takes [ctl::W](ctl::W) writer structure"] impl crate::Writable for CTL {} #[doc = "Hibernation Control"] pub mod ctl; #[doc = "Hibernation Interrupt Mask\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [im](im) module"] pub type IM = crate::Reg<u32, _IM>; #[allow(missing_docs)] #[doc(hidden)] pub struct _IM; #[doc = "`read()` method returns [im::R](im::R) reader structure"] impl crate::Readable for IM {} #[doc = "`write(|w| ..)` method takes [im::W](im::W) writer structure"] impl crate::Writable for IM {} #[doc = "Hibernation Interrupt Mask"] pub mod im; #[doc = "Hibernation Raw Interrupt Status\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ris](ris) module"] pub type RIS = crate::Reg<u32, _RIS>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RIS; #[doc = "`read()` method returns [ris::R](ris::R) reader structure"] impl crate::Readable for RIS {} #[doc = "Hibernation Raw Interrupt Status"] pub mod ris; #[doc = "Hibernation Masked Interrupt Status\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [mis](mis) module"] pub type MIS = crate::Reg<u32, _MIS>; #[allow(missing_docs)] #[doc(hidden)] pub struct _MIS; #[doc = "`read()` method returns [mis::R](mis::R) reader structure"] impl crate::Readable for MIS {} #[doc = "Hibernation Masked Interrupt Status"] pub mod mis; #[doc = "Hibernation Interrupt Clear\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ic](ic) module"] pub type IC = crate::Reg<u32, _IC>; #[allow(missing_docs)] #[doc(hidden)] pub struct _IC; #[doc = "`read()` method returns [ic::R](ic::R) reader structure"] impl crate::Readable for IC {} #[doc = "`write(|w| ..)` method takes [ic::W](ic::W) writer structure"] impl crate::Writable for IC {} #[doc = "Hibernation Interrupt Clear"] pub mod ic; #[doc = "Hibernation RTC Trim\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtct](rtct) module"] pub type RTCT = crate::Reg<u32, _RTCT>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RTCT; #[doc = "`read()` method returns [rtct::R](rtct::R) reader structure"] impl crate::Readable for RTCT {} #[doc = "`write(|w| ..)` method takes [rtct::W](rtct::W) writer structure"] impl crate::Writable for RTCT {} #[doc = "Hibernation RTC Trim"] pub mod rtct; #[doc = "Hibernation RTC Sub Seconds\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rtcss](rtcss) module"] pub type RTCSS = crate::Reg<u32, _RTCSS>; #[allow(missing_docs)] #[doc(hidden)] pub struct _RTCSS; #[doc = "`read()` method returns [rtcss::R](rtcss::R) reader structure"] impl crate::Readable for RTCSS {} #[doc = "`write(|w| ..)` method takes [rtcss::W](rtcss::W) writer structure"] impl crate::Writable for RTCSS {} #[doc = "Hibernation RTC Sub Seconds"] pub mod rtcss; #[doc = "Hibernation IO Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [io](io) module"] pub type IO = crate::Reg<u32, _IO>; #[allow(missing_docs)] #[doc(hidden)] pub struct _IO; #[doc = "`read()` method returns [io::R](io::R) reader structure"] impl crate::Readable for IO {} #[doc = "`write(|w| ..)` method takes [io::W](io::W) writer structure"] impl crate::Writable for IO {} #[doc = "Hibernation IO Configuration"] pub mod io; #[doc = "Hibernation Data\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [data](data) module"] pub type DATA = crate::Reg<u32, _DATA>; #[allow(missing_docs)] #[doc(hidden)] pub struct _DATA; #[doc = "`read()` method returns [data::R](data::R) reader structure"] impl crate::Readable for DATA {} #[doc = "`write(|w| ..)` method takes [data::W](data::W) writer structure"] impl crate::Writable for DATA {} #[doc = "Hibernation Data"] pub mod data; #[doc = "Hibernation Calendar Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [calctl](calctl) module"] pub type CALCTL = crate::Reg<u32, _CALCTL>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CALCTL; #[doc = "`read()` method returns [calctl::R](calctl::R) reader structure"] impl crate::Readable for CALCTL {} #[doc = "`write(|w| ..)` method takes [calctl::W](calctl::W) writer structure"] impl crate::Writable for CALCTL {} #[doc = "Hibernation Calendar Control"] pub mod calctl; #[doc = "Hibernation Calendar 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [cal0](cal0) module"] pub type CAL0 = crate::Reg<u32, _CAL0>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CAL0; #[doc = "`read()` method returns [cal0::R](cal0::R) reader structure"] impl crate::Readable for CAL0 {} #[doc = "Hibernation Calendar 0"] pub mod cal0; #[doc = "Hibernation Calendar 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [cal1](cal1) module"] pub type CAL1 = crate::Reg<u32, _CAL1>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CAL1; #[doc = "`read()` method returns [cal1::R](cal1::R) reader structure"] impl crate::Readable for CAL1 {} #[doc = "Hibernation Calendar 1"] pub mod cal1; #[doc = "Hibernation Calendar Load 0\n\nThis register you can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [calld0](calld0) module"] pub type CALLD0 = crate::Reg<u32, _CALLD0>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CALLD0; #[doc = "`write(|w| ..)` method takes [calld0::W](calld0::W) writer structure"] impl crate::Writable for CALLD0 {} #[doc = "Hibernation Calendar Load 0"] pub mod calld0; #[doc = "Hibernation Calendar Load\n\nThis register you can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [calld1](calld1) module"] pub type CALLD1 = crate::Reg<u32, _CALLD1>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CALLD1; #[doc = "`write(|w| ..)` method takes [calld1::W](calld1::W) writer structure"] impl crate::Writable for CALLD1 {} #[doc = "Hibernation Calendar Load"] pub mod calld1; #[doc = "Hibernation Calendar Match 0\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [calm0](calm0) module"] pub type CALM0 = crate::Reg<u32, _CALM0>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CALM0; #[doc = "`read()` method returns [calm0::R](calm0::R) reader structure"] impl crate::Readable for CALM0 {} #[doc = "`write(|w| ..)` method takes [calm0::W](calm0::W) writer structure"] impl crate::Writable for CALM0 {} #[doc = "Hibernation Calendar Match 0"] pub mod calm0; #[doc = "Hibernation Calendar Match 1\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [calm1](calm1) module"] pub type CALM1 = crate::Reg<u32, _CALM1>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CALM1; #[doc = "`read()` method returns [calm1::R](calm1::R) reader structure"] impl crate::Readable for CALM1 {} #[doc = "`write(|w| ..)` method takes [calm1::W](calm1::W) writer structure"] impl crate::Writable for CALM1 {} #[doc = "Hibernation Calendar Match 1"] pub mod calm1; #[doc = "Hibernation Lock\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [lock](lock) module"] pub type LOCK = crate::Reg<u32, _LOCK>; #[allow(missing_docs)] #[doc(hidden)] pub struct _LOCK; #[doc = "`read()` method returns [lock::R](lock::R) reader structure"] impl crate::Readable for LOCK {} #[doc = "`write(|w| ..)` method takes [lock::W](lock::W) writer structure"] impl crate::Writable for LOCK {} #[doc = "Hibernation Lock"] pub mod lock; #[doc = "HIB Tamper Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tpctl](tpctl) module"] pub type TPCTL = crate::Reg<u32, _TPCTL>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPCTL; #[doc = "`read()` method returns [tpctl::R](tpctl::R) reader structure"] impl crate::Readable for TPCTL {} #[doc = "`write(|w| ..)` method takes [tpctl::W](tpctl::W) writer structure"] impl crate::Writable for TPCTL {} #[doc = "HIB Tamper Control"] pub mod tpctl; #[doc = "HIB Tamper Status\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tpstat](tpstat) module"] pub type TPSTAT = crate::Reg<u32, _TPSTAT>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPSTAT; #[doc = "`read()` method returns [tpstat::R](tpstat::R) reader structure"] impl crate::Readable for TPSTAT {} #[doc = "`write(|w| ..)` method takes [tpstat::W](tpstat::W) writer structure"] impl crate::Writable for TPSTAT {} #[doc = "HIB Tamper Status"] pub mod tpstat; #[doc = "HIB Tamper I/O Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tpio](tpio) module"] pub type TPIO = crate::Reg<u32, _TPIO>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPIO; #[doc = "`read()` method returns [tpio::R](tpio::R) reader structure"] impl crate::Readable for TPIO {} #[doc = "`write(|w| ..)` method takes [tpio::W](tpio::W) writer structure"] impl crate::Writable for TPIO {} #[doc = "HIB Tamper I/O Control"] pub mod tpio; #[doc = "HIB Tamper Log 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog0](tplog0) module"] pub type TPLOG0 = crate::Reg<u32, _TPLOG0>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG0; #[doc = "`read()` method returns [tplog0::R](tplog0::R) reader structure"] impl crate::Readable for TPLOG0 {} #[doc = "HIB Tamper Log 0"] pub mod tplog0; #[doc = "HIB Tamper Log 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog1](tplog1) module"] pub type TPLOG1 = crate::Reg<u32, _TPLOG1>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG1; #[doc = "`read()` method returns [tplog1::R](tplog1::R) reader structure"] impl crate::Readable for TPLOG1 {} #[doc = "HIB Tamper Log 1"] pub mod tplog1; #[doc = "HIB Tamper Log 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog2](tplog2) module"] pub type TPLOG2 = crate::Reg<u32, _TPLOG2>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG2; #[doc = "`read()` method returns [tplog2::R](tplog2::R) reader structure"] impl crate::Readable for TPLOG2 {} #[doc = "HIB Tamper Log 2"] pub mod tplog2; #[doc = "HIB Tamper Log 3\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog3](tplog3) module"] pub type TPLOG3 = crate::Reg<u32, _TPLOG3>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG3; #[doc = "`read()` method returns [tplog3::R](tplog3::R) reader structure"] impl crate::Readable for TPLOG3 {} #[doc = "HIB Tamper Log 3"] pub mod tplog3; #[doc = "HIB Tamper Log 4\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog4](tplog4) module"] pub type TPLOG4 = crate::Reg<u32, _TPLOG4>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG4; #[doc = "`read()` method returns [tplog4::R](tplog4::R) reader structure"] impl crate::Readable for TPLOG4 {} #[doc = "HIB Tamper Log 4"] pub mod tplog4; #[doc = "HIB Tamper Log 5\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog5](tplog5) module"] pub type TPLOG5 = crate::Reg<u32, _TPLOG5>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG5; #[doc = "`read()` method returns [tplog5::R](tplog5::R) reader structure"] impl crate::Readable for TPLOG5 {} #[doc = "HIB Tamper Log 5"] pub mod tplog5; #[doc = "HIB Tamper Log 6\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog6](tplog6) module"] pub type TPLOG6 = crate::Reg<u32, _TPLOG6>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG6; #[doc = "`read()` method returns [tplog6::R](tplog6::R) reader structure"] impl crate::Readable for TPLOG6 {} #[doc = "HIB Tamper Log 6"] pub mod tplog6; #[doc = "HIB Tamper Log 7\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [tplog7](tplog7) module"] pub type TPLOG7 = crate::Reg<u32, _TPLOG7>; #[allow(missing_docs)] #[doc(hidden)] pub struct _TPLOG7; #[doc = "`read()` method returns [tplog7::R](tplog7::R) reader structure"] impl crate::Readable for TPLOG7 {} #[doc = "HIB Tamper Log 7"] pub mod tplog7; #[doc = "Hibernation Peripheral Properties\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pp](pp) module"] pub type PP = crate::Reg<u32, _PP>; #[allow(missing_docs)] #[doc(hidden)] pub struct _PP; #[doc = "`read()` method returns [pp::R](pp::R) reader structure"] impl crate::Readable for PP {} #[doc = "Hibernation Peripheral Properties"] pub mod pp; #[doc = "Hibernation Clock Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [cc](cc) module"] pub type CC = crate::Reg<u32, _CC>; #[allow(missing_docs)] #[doc(hidden)] pub struct _CC; #[doc = "`read()` method returns [cc::R](cc::R) reader structure"] impl crate::Readable for CC {} #[doc = "`write(|w| ..)` method takes [cc::W](cc::W) writer structure"] impl crate::Writable for CC {} #[doc = "Hibernation Clock Control"] pub mod cc;
use crate::{CoordinateType, MultiPolygon, Polygon}; use crate::algorithm::winding_order::{Winding, WindingOrder}; pub trait Orient<T> { /// Orients a Polygon's exterior and interior rings according to convention /// /// By default, the exterior ring of a Polygon is oriented counter-clockwise, and any interior /// rings are oriented clockwise. /// /// # Examples /// /// ``` /// use geo::orient::{Direction, Orient}; /// use geo::{LineString, Point, Polygon}; /// // a diamond shape, oriented clockwise outside /// let points_ext = vec![(1.0, 0.0), (0.0, 1.0), (1.0, 2.0), (2.0, 1.0), (1.0, 0.0)]; /// // counter-clockwise interior /// let points_int = vec![(1.0, 0.5), (1.5, 1.0), (1.0, 1.5), (0.5, 1.0), (1.0, 0.5)]; /// let poly = Polygon::new( /// LineString::from(points_ext), /// vec![LineString::from(points_int)], /// ); /// // a diamond shape, oriented counter-clockwise outside, /// let oriented_ext = vec![(1.0, 0.0), (2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)]; /// let oriented_ext_ls = LineString::from(oriented_ext); /// // clockwise interior /// let oriented_int = vec![(1.0, 0.5), (0.5, 1.0), (1.0, 1.5), (1.5, 1.0), (1.0, 0.5)]; /// let oriented_int_ls = LineString::from(oriented_int); /// // build corrected Polygon /// let oriented = poly.orient(Direction::Default); /// assert_eq!(oriented.exterior().0, oriented_ext_ls.0); /// assert_eq!(oriented.interiors()[0].0, oriented_int_ls.0); /// ``` fn orient(&self, orientation: Direction) -> Self; } impl<T> Orient<T> for Polygon<T> where T: CoordinateType, { fn orient(&self, direction: Direction) -> Polygon<T> { orient(self, direction) } } impl<T> Orient<T> for MultiPolygon<T> where T: CoordinateType, { fn orient(&self, direction: Direction) -> MultiPolygon<T> { MultiPolygon(self.0.iter().map(|poly| poly.orient(direction)).collect()) } } /// By default, a properly-oriented Polygon has its outer ring oriented counter-clockwise, /// and its inner ring(s) oriented clockwise. Selecting `Reversed` will result in a Polygon /// with a clockwise-oriented exterior ring, and counter-clockwise interior ring(s) #[derive(Copy, Clone, Debug)] pub enum Direction { /// exterior ring is oriented counter-clockwise, interior rings are oriented clockwise Default, /// exterior ring is oriented clockwise, interior rings are oriented counter-clockwise Reversed, } // orient a Polygon according to convention // by default, the exterior ring will be oriented ccw // and the interior ring(s) will be oriented clockwise fn orient<T>(poly: &Polygon<T>, direction: Direction) -> Polygon<T> where T: CoordinateType, { let interiors = poly .interiors() .iter() .map(|l| { l.clone_to_winding_order(match direction { Direction::Default => WindingOrder::Clockwise, Direction::Reversed => WindingOrder::CounterClockwise, }) }) .collect(); let ext_ring = poly.exterior().clone_to_winding_order(match direction { Direction::Default => WindingOrder::CounterClockwise, Direction::Reversed => WindingOrder::Clockwise, }); Polygon::new(ext_ring, interiors) } #[cfg(test)] mod test { use super::*; use crate::{LineString, Polygon}; #[test] fn test_polygon_orientation() { // a diamond shape, oriented clockwise outside let points_ext = vec![(1.0, 0.0), (0.0, 1.0), (1.0, 2.0), (2.0, 1.0), (1.0, 0.0)]; // counter-clockwise interior let points_int = vec![(1.0, 0.5), (1.5, 1.0), (1.0, 1.5), (0.5, 1.0), (1.0, 0.5)]; let poly1 = Polygon::new( LineString::from(points_ext), vec![LineString::from(points_int)], ); // a diamond shape, oriented counter-clockwise outside, let oriented_ext = vec![(1.0, 0.0), (2.0, 1.0), (1.0, 2.0), (0.0, 1.0), (1.0, 0.0)]; let oriented_ext_ls = LineString::from(oriented_ext); // clockwise interior let oriented_int_raw = vec![(1.0, 0.5), (0.5, 1.0), (1.0, 1.5), (1.5, 1.0), (1.0, 0.5)]; let oriented_int_ls = LineString::from(oriented_int_raw); // build corrected Polygon let oriented = orient(&poly1, Direction::Default); assert_eq!(oriented.exterior().0, oriented_ext_ls.0); assert_eq!(oriented.interiors()[0].0, oriented_int_ls.0); } }
use super::{ not::Not, or::Or, passthrough::Passthrough, ActiveFilter, DynamicFilter, FilterResult, GroupMatcher, LayoutFilter, }; use crate::internals::{query::view::Fetch, storage::component::ComponentTypeId, world::WorldId}; /// A filter which requires all filters within `T` match. #[derive(Debug, Clone)] pub struct And<T> { pub(super) filters: T, } macro_rules! and_filter { ($head_ty:ident) => { impl_and_filter!($head_ty); }; ($head_ty:ident, $( $tail_ty:ident ),*) => ( impl_and_filter!($head_ty, $( $tail_ty ),*); and_filter!($( $tail_ty ),*); ); } macro_rules! impl_and_filter { ( $( $ty:ident ),* ) => { impl<$( $ty ),*> ActiveFilter for And<($( $ty, )*)> {} impl<$( $ty: Default ),*> Default for And<($( $ty, )*)> { fn default() -> Self { Self { filters: ($( $ty::default(), )*) } } } impl<$( $ty: GroupMatcher ),*> GroupMatcher for And<($( $ty, )*)> { fn can_match_group() -> bool { $( $ty::can_match_group() )&&* } fn group_components() -> Vec<ComponentTypeId> { let mut components = Vec::new(); $( components.extend($ty::group_components()); )* components } } impl<$( $ty: LayoutFilter ),*> LayoutFilter for And<($( $ty, )*)> { #[inline] fn matches_layout(&self, components: &[ComponentTypeId]) -> FilterResult { #![allow(non_snake_case)] let ($( $ty, )*) = &self.filters; let mut result = FilterResult::Defer; $( result = result.coalesce_and($ty.matches_layout(components)); )* result } } impl<$( $ty: DynamicFilter ),*> DynamicFilter for And<($( $ty, )*)> { #[inline] fn prepare(&mut self, world: WorldId) { #![allow(non_snake_case)] let ($( $ty, )*) = &mut self.filters; $( $ty.prepare(world); )* } #[inline] fn matches_archetype<Fet: Fetch>(&mut self, fetch: &Fet) -> FilterResult { #![allow(non_snake_case)] let ($( $ty, )*) = &mut self.filters; let mut result = FilterResult::Defer; $( result = result.coalesce_and($ty.matches_archetype(fetch)); )* result } } impl<$( $ty ),*> std::ops::Not for And<($( $ty, )*)> { type Output = Not<Self>; #[inline] fn not(self) -> Self::Output { Not { filter: self } } } impl<$( $ty ),*, Rhs: ActiveFilter> std::ops::BitAnd<Rhs> for And<($( $ty, )*)> { type Output = And<($( $ty, )* Rhs)>; #[inline] fn bitand(self, rhs: Rhs) -> Self::Output { #![allow(non_snake_case)] let ($( $ty, )*) = self.filters; And { filters: ($( $ty, )* rhs), } } } impl<$( $ty ),*> std::ops::BitAnd<Passthrough> for And<($( $ty, )*)> { type Output = Self; #[inline] fn bitand(self, _: Passthrough) -> Self::Output { self } } impl<$( $ty ),*, Rhs: ActiveFilter> std::ops::BitOr<Rhs> for And<($( $ty, )*)> { type Output = Or<(Self, Rhs)>; #[inline] fn bitor(self, rhs: Rhs) -> Self::Output { Or { filters: (self, rhs), } } } impl<$( $ty ),*> std::ops::BitOr<Passthrough> for And<($( $ty, )*)> { type Output = Self; #[inline] fn bitor(self, _: Passthrough) -> Self::Output { self } } }; } #[cfg(feature = "extended-tuple-impls")] and_filter!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z); #[cfg(not(feature = "extended-tuple-impls"))] and_filter!(A, B, C, D, E, F, G, H);
use std::fs::File; use std::io::Read; use std::path::Path; pub mod assembler; pub mod instruction; pub mod repl; pub mod vm; use clap::App; fn main() { let yaml = clap::load_yaml!("cli.yml"); let matches = App::from_yaml(yaml).get_matches(); let target_file = matches.value_of("INPUT_FILE"); match target_file { Some(filename) => { let program = read_file(filename); let mut asm = assembler::Assembler::new(); let mut vm = vm::VM::new(); let program = asm.assemble(&program); match program { Ok(p) => { vm.add_bytes(p); vm.run(); std::process::exit(0); } Err(e) => println!("{:?}", e), } } None => { start_repl(); } } } fn start_repl() { let mut repl = repl::REPL::new(); repl.run(); } fn read_file(tmp: &str) -> String { let filename = Path::new(tmp); let mut f = match File::open(&filename) { Ok(f) => f, Err(e) => { println!("There was an error opening that file: {:?}", e); std::process::exit(1); } }; let mut contents = String::new(); match f.read_to_string(&mut contents) { Ok(_) => { return contents; } Err(e) => { println!("There was an error reading file: {:?}", e); std::process::exit(1); } } }
use ::amethyst::core::timing::Time; use ::amethyst::core::*; use ::amethyst::ecs::*; use serde::Serialize; use nphysics_ecs::ncollide::query::*; use nphysics_ecs::*; use specs_physics::colliders::ColliderComponent; #[derive(Debug, Clone, Default, Serialize, Deserialize, new)] pub struct Grounded { #[new(value = "false")] pub ground: bool, #[new(default)] pub since: f64, pub distance_check: f32, /// Checks if the selected entity collides with the ground. #[serde(skip)] pub watch_entity: Option<Entity>, } impl Component for Grounded { type Storage = DenseVecStorage<Self>; } #[derive(Default, new)] pub struct GroundCheckTag; impl Component for GroundCheckTag { type Storage = DenseVecStorage<Self>; } /// T: ObjectType for collider checks #[derive(new)] pub struct GroundCheckerSystem<T> { pub collider_types: Vec<T>, //#[new(default)] //contact_reader: Option<ReaderId<EntityProximityEvent>>, } impl<'a, T: Component + PartialEq> System<'a> for GroundCheckerSystem<T> { type SystemData = ( Entities<'a>, ReadStorage<'a, Transform>, WriteStorage<'a, Grounded>, ReadStorage<'a, T>, Read<'a, Time>, ReadExpect<'a, GeometricalWorldRes<f32>>, ReadStorage<'a, ColliderComponent<f32>>, ReadStorage<'a, GroundCheckTag>, ); fn run( &mut self, ( entities, transforms, mut grounded, _objecttypes, time, _contacts, colliders, ground_checks, ): Self::SystemData, ) { //let down = -Vector3::<f32>::y(); for (_entity, _transform2, _player_collider, mut grounded) in (&*entities, &transforms, &colliders, &mut grounded).join() { //let mut ground = false; /*let ray = Ray3::new(Point3::from_vec(transform.translation), down); // For all in ray for (v, p) in query_ray(&*tree, ray) { // Not self and close enough if v.value != entity && (transform.translation - Vector3::new(p.x, p.y, p.z)).magnitude() <= grounded.distance_check { // If we can jump off that type of collider if let Some(obj_type) = objecttypes.get(v.value) { if self.collider_types.contains(obj_type) { ground = true; } } //info!("hit bounding volume of {:?} at point {:?}", v.value, p); } }*/ /*info!("run {:?}", entity); // Check for secondary collider if any for contact in contacts.read(&mut self.contact_reader.as_mut().unwrap()) { info!("Contact {:?} -> {:?}",contact.0, contact.1); // Here because we need to empty the contacts EventChannel if let Some(secondary) = grounded.watch_entity { info!("Secondary"); if contact.0 == entity || contact.1 == entity { // We hit our player... let's ignore that. continue; } info!("tmp1"); if contact.0 != secondary && contact.1 != secondary { // This has nothing to do with the secondary collider. Skip! continue; } info!("type check"); let type1 = objecttypes.get(contact.0); let type2 = objecttypes.get(contact.1); if type1.is_none() || type2.is_none() { continue; } info!("good to go"); // If we can jump off that type of collider if self.collider_types.contains(type1.unwrap()) || self.collider_types.contains(type2.unwrap()) { match contact.2.new_status { // Collision with ground Proximity::Intersecting | Proximity::WithinMargin => { if ground && !grounded.ground { // Just grounded grounded.since = time.absolute_time_seconds(); } grounded.ground = true; }, // Collision stop Proximity::Disjoint => { grounded.ground = false; } } ground = true; } } }*/ if let Some(secondary) = grounded.watch_entity { let transform = transforms .get(secondary) .expect("No transform component on secondary collider."); let feet_collider = colliders .get(secondary) .expect("No collider component on secondary collider."); info!( "Gonna check for collision at player pos {:?}", transform.translation() ); let ground = (&*entities, &transforms, &colliders, &ground_checks) .join() .any(|(_entity, tr, collider, _)| { if let Proximity::Intersecting = proximity( &transform.isometry(), &*feet_collider.shape(), &tr.isometry(), &*collider.shape(), 0.0, ) { warn!("COLLISION!!!"); true } else { false } }); if ground && !grounded.ground { // Just grounded grounded.since = time.absolute_time_seconds(); } grounded.ground = ground; } } } }
use structopt::StructOpt; #[derive(Debug, StructOpt)] pub enum Command { #[structopt(name = "addblock")] /// Adds a block to the blockchain (use `addblock --help` for more info) AddBlock { #[structopt(short, long)] /// adds a block to the blockchain data: String, }, #[structopt(name = "printchain")] /// Prints all the blocks of the blockchain PrintChain, } #[derive(Debug, StructOpt)] pub struct Options { #[structopt(subcommand)] pub command: Command, }
use juniper::graphql_object; #[graphql_object] enum Character {} fn main() {}
use super::system_prelude::*; #[derive(Default)] pub struct KillEnemySystem; impl<'a> System<'a> for KillEnemySystem { type SystemData = ( Entities<'a>, ReadStorage<'a, Player>, ReadStorage<'a, Enemy>, ReadStorage<'a, Collision>, ReadStorage<'a, Loadable>, ReadStorage<'a, Loaded>, ReadStorage<'a, Gravity>, WriteStorage<'a, Velocity>, WriteStorage<'a, Spike>, ); fn run( &mut self, ( entities, players, enemies, collisions, loadables, loadeds, gravities, mut velocities, mut spikes, ): Self::SystemData, ) { // NOTE: The player can only kill enemies if the player already has gravity. if let Some((player, player_collision, player_velocity, _)) = (&players, &collisions, &mut velocities, &gravities) .join() .next() { if player_velocity.y < 0.0 { for ( enemy_entity, _, enemy_spike_opt, loadable_opt, loaded_opt, ) in ( &entities, &enemies, (&mut spikes).maybe(), loadables.maybe(), loadeds.maybe(), ) .join() { if let (None, None) | (Some(_), Some(_)) = (loadable_opt, loaded_opt) { if player_collision.in_collision_with(enemy_entity.id()) { // Kill enemy and make the player bounce off their head if let Some(jump_data) = player.jump_data.as_ref() { player_velocity.y = jump_data.bounce_strength; } entities .delete(enemy_entity) .expect("Tried to kill enemy"); if let Some(enemy_spike) = enemy_spike_opt { enemy_spike.enabled = false; } } } } } } } }
use std::{ pin::Pin, task::{Context, Poll}, }; use futures_core::ready; use pin_project_lite::pin_project; use crate::{actor::Actor, fut::ActorFuture}; pin_project! { /// Future for the [`map`](super::ActorFutureExt::map) method. #[project = MapProj] #[project_replace = MapProjReplace] #[derive(Debug)] #[must_use = "futures do nothing unless you `.await` or poll them"] pub enum Map<Fut, F> { Incomplete { #[pin] future: Fut, f: F, }, Complete, } } impl<Fut, F> Map<Fut, F> { pub(super) fn new(future: Fut, f: F) -> Self { Self::Incomplete { future, f } } } impl<U, Fut, A, F> ActorFuture<A> for Map<Fut, F> where Fut: ActorFuture<A>, A: Actor, F: FnOnce(Fut::Output, &mut A, &mut A::Context) -> U, { type Output = U; fn poll( mut self: Pin<&mut Self>, act: &mut A, ctx: &mut A::Context, task: &mut Context<'_>, ) -> Poll<Self::Output> { match self.as_mut().project() { MapProj::Incomplete { future, .. } => { let output = ready!(future.poll(act, ctx, task)); match self.project_replace(Map::Complete) { MapProjReplace::Incomplete { f, .. } => Poll::Ready(f(output, act, ctx)), MapProjReplace::Complete => unreachable!(), } } MapProj::Complete => { panic!("Map must not be polled after it returned `Poll::Ready`") } } } }
#[cfg(all(not(target_arch = "wasm32"), test))] mod test; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::process::Process; use liblumen_alloc::erts::term::prelude::Term; use crate::runtime::integer_to_string::decimal_integer_to_string; #[native_implemented::function(erlang:integer_to_binary/1)] pub fn result(process: &Process, integer: Term) -> exception::Result<Term> { let string = decimal_integer_to_string(integer)?; let binary = process.binary_from_str(&string); Ok(binary) }
use std::io::Seek; use crate::{types, Error}; use crossbeam_channel as cc; const RPC_VERSION: u32 = 1; #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[repr(u32)] pub(crate) enum OpCode { Handshake = 0, Frame = 1, Close = 2, Ping = 3, Pong = 4, } /// Message immediately sent to Discord upon establishing a connection #[derive(serde::Serialize)] pub(crate) struct Handshake { /// The RPC version we support #[serde(rename = "v")] version: u32, /// The unique identifier for this application client_id: String, } /// Parses the frame header for a message from Discord, which just consists /// of a 4 byte opcode and a 4 byte length of the actual message payload fn parse_frame_header(header: [u8; 8]) -> Result<(OpCode, u32), Error> { let op_code = { let mut bytes = [0; 4]; bytes.copy_from_slice(&header[..4]); u32::from_le_bytes(bytes) }; let op_code = match op_code { 0 => OpCode::Handshake, 1 => OpCode::Frame, 2 => OpCode::Close, 3 => OpCode::Ping, 4 => OpCode::Pong, unknown => { return Err(Error::UnknownVariant { kind: "OpCode", value: unknown, }) } }; let len = { let mut bytes = [0; 4]; bytes.copy_from_slice(&header[4..8]); u32::from_le_bytes(bytes) }; Ok((op_code, len)) } pub(crate) fn serialize_message( op_code: OpCode, data: &impl serde::Serialize, buffer: &mut Vec<u8>, ) -> Result<(), Error> { let start = buffer.len(); buffer.extend_from_slice(&(op_code as u32).to_le_bytes()); buffer.extend_from_slice(&[0; 4]); // We have to pass the whole vec, but since serde_json::to_writer doesn't // give us the Write back we have to wrap it in a cursor, but then we need // to advance it to point in the buffer we actually want to write the JSON // to, otherwise it will overwrite the beginning and make everyone sad let mut cursor = std::io::Cursor::new(buffer); cursor .seek(std::io::SeekFrom::Start(start as u64 + 8)) .unwrap(); match serde_json::to_writer(&mut cursor, data) { Ok(_) => { let buffer = cursor.into_inner(); let data_len = (buffer.len() - start - 8) as u32; buffer[start + 4..start + 8].copy_from_slice(&data_len.to_le_bytes()); } Err(e) => { let buffer = cursor.into_inner(); buffer.truncate(start); return Err(e.into()); } } Ok(()) } fn make_message(op_code: OpCode, data: &[u8]) -> Vec<u8> { let mut msg = Vec::with_capacity(data.len() + 8); msg.extend_from_slice(&(op_code as u32).to_le_bytes()); msg.extend_from_slice(&(data.len() as u32).to_le_bytes()); msg.extend_from_slice(data); msg } pub(crate) struct IoTask { /// The queue of messages to send to Discord pub(crate) stx: cc::Sender<Option<Vec<u8>>>, /// The queue of RPCs sent from Discord pub(crate) rrx: tokio::sync::mpsc::Receiver<IoMsg>, /// The handle to the task pub(crate) handle: tokio::task::JoinHandle<()>, } pub(crate) enum IoMsg { Disconnected(Error), Frame(Vec<u8>), } #[cfg(unix)] type Pipe = tokio::net::UnixStream; #[cfg(windows)] type Pipe = tokio::net::windows::named_pipe::NamedPipeClient; pub(crate) fn start_io_task(app_id: i64) -> IoTask { #[cfg(unix)] async fn connect() -> Result<Pipe, Error> { let tmp_path = std::env::var("XDG_RUNTIME_DIR") .or_else(|_| std::env::var("TMPDIR")) .or_else(|_| std::env::var("TMP")) .or_else(|_| std::env::var("TEMP")) .unwrap_or_else(|_| "/tmp".to_owned()); #[cfg(feature = "local-testing")] if let Ok(id) = std::env::var("DISCORD_INSTANCE_ID") { let socket_path = format!("{}/discord-ipc-{}", tmp_path, id); return match Pipe::connect(&socket_path).await { Ok(stream) => { tracing::debug!("connected to {}!", socket_path); Ok(stream) } Err(e) => { tracing::error!("Unable to connect to {}: {}", socket_path, e); Err(Error::io("connecting to socket", e)) } }; } // Discord just uses a simple round robin approach to finding a socket to use let mut socket_path = format!("{}/discord-ipc-0", tmp_path); for seq in 0..10i32 { socket_path.pop(); use std::fmt::Write; write!(&mut socket_path, "{}", seq).unwrap(); match Pipe::connect(&socket_path).await { Ok(stream) => { tracing::debug!("connected to {}!", socket_path); return Ok(stream); } Err(e) => { tracing::trace!("Unable to connect to {}: {}", socket_path, e); } } } Err(Error::NoConnection) } #[cfg(windows)] async fn connect() -> Result<Pipe, Error> { use tokio::net::windows::named_pipe::ClientOptions; #[cfg(feature = "local-testing")] if let Ok(id) = std::env::var("DISCORD_INSTANCE_ID") { let socket_path = format!("\\\\?\\pipe\\discord-ipc-{}", id); return match ClientOptions::new().open(&socket_path) { Ok(stream) => { tracing::debug!("connected to {}!", socket_path); Ok(stream) } Err(e) => { tracing::error!("Unable to connect to {}: {}", socket_path, e); Err(Error::io("connecting to socket", e)) } }; } // Discord just uses a simple round robin approach to finding a socket to use let mut socket_path = "\\\\?\\pipe\\discord-ipc-0".to_owned(); for seq in 0..10i32 { socket_path.pop(); use std::fmt::Write; write!(&mut socket_path, "{}", seq).unwrap(); match ClientOptions::new().open(&socket_path) { Ok(stream) => { tracing::debug!("connected to {}!", socket_path); return Ok(stream); } Err(e) => { tracing::trace!("Unable to connect to {}: {}", socket_path, e); } } } Err(Error::NoConnection) } // Send queue let (stx, srx) = cc::bounded::<Option<Vec<u8>>>(100); // Receive queue let (rtx, rrx) = tokio::sync::mpsc::channel(100); // The io thread also sends messages let io_stx = stx.clone(); let handle = tokio::task::spawn(async move { async fn io_loop( stream: impl SocketStream, app_id: i64, stx: &cc::Sender<Option<Vec<u8>>>, srx: &cc::Receiver<Option<Vec<u8>>>, rtx: &tokio::sync::mpsc::Sender<IoMsg>, ) -> Result<(), Error> { // We always send the handshake immediately on establishing a connection, // Discord should then respond with a `Ready` RPC let mut handshake = Vec::with_capacity(128); serialize_message( OpCode::Handshake, &Handshake { version: RPC_VERSION, client_id: app_id.to_string(), }, &mut handshake, )?; stx.send(Some(handshake))?; struct ReadBuf<const N: usize> { buf: [u8; N], cursor: usize, } impl<const N: usize> ReadBuf<N> { fn new() -> Self { Self { buf: [0u8; N], cursor: 0, } } } let mut header_buf = ReadBuf::<8>::new(); let mut data_buf = Vec::with_capacity(1024); let mut data_cursor = 0; let mut valid_header: Option<(OpCode, u32)> = None; let mut top_message: Option<(Vec<u8>, usize)> = None; let mut interval = tokio::time::interval(std::time::Duration::from_millis(10)); loop { // We use crossbeam channels for sending messages to this I/O // task as they provide a little more functionality compared to // tokio mpsc channels, but that means we need some way to sleep // this task, as otherwise the stream.ready() is basically always // going to immediately return and report it is writable which // causes this task to peg a core and actually cause tokio to // fail to wake other tasks, however, we do try and read all data // that is pending on the pipe each tick, so it's essentially // just the write that is limited to a maximum of 1 per tick // which is fine since the tick is quite small relative to the // amount of messages we actually send to Discord interval.tick().await; let ready = stream .ready(tokio::io::Interest::READABLE | tokio::io::Interest::WRITABLE) .await .map_err(|e| Error::io("polling socket readiness", e))?; if ready.is_readable() { 'read: loop { let mut buf = match &valid_header { Some((_, len)) => &mut data_buf[data_cursor..*len as usize], None => &mut header_buf.buf[header_buf.cursor..], }; match stream.try_read(&mut buf) { Ok(n) => { if n == 0 { return Err(Error::NoConnection); } match valid_header { Some((op, len)) => { data_cursor += n; let len = len as usize; if data_cursor == len { match op { OpCode::Close => { let close: types::CloseFrame<'_> = serde_json::from_slice(&data_buf)?; tracing::debug!("Received close request from Discord: {:?} - {:?}", close.code, close.message); return Err(Error::Close( close .message .unwrap_or("unknown reason") .to_owned(), )); } OpCode::Frame => { if rtx .send(IoMsg::Frame(data_buf.clone())) .await .is_err() { tracing::error!( "Dropped RPC as queue is too full" ); } } OpCode::Ping => { let pong_response = make_message(OpCode::Pong, &data_buf); tracing::debug!( "Responding to PING request from Discord" ); stx.send(Some(pong_response))?; } OpCode::Pong => { tracing::debug!( "Received PONG response from Discord" ); } OpCode::Handshake => { tracing::error!("Received a HANDSHAKE request from Discord, the stream is likely corrupt"); return Err(Error::CorruptConnection); } } valid_header = None; header_buf.cursor = 0; data_buf.clear(); data_cursor = 0; } } None => { header_buf.cursor += n; if header_buf.cursor == header_buf.buf.len() { let header = parse_frame_header(header_buf.buf)?; // Ensure the data buffer has enough space data_buf.resize(header.1 as usize, 0); valid_header = Some(header); } } } } Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { break 'read; } Err(e) => { return Err(Error::io("reading socket", e)); } } } } if ready.is_writable() { if top_message.is_none() { if let Ok(msg) = srx.try_recv() { top_message = match msg { Some(msg) => Some((msg, 0)), None => { tracing::debug!("Discord I/O thread received shutdown signal"); return Ok(()); } }; } } if let Some((message, cursor)) = &mut top_message { let to_write = message.len() - *cursor; match stream.try_write(&message[*cursor..]) { Ok(n) => { if n == to_write { top_message = None; } else { *cursor += n; } } Err(ref e) if e.kind() == std::io::ErrorKind::WouldBlock => { continue; } Err(e) => { return Err(Error::io("writing socket", e)); } } } } } } let mut reconnect_dur = std::time::Duration::from_millis(500); loop { match connect().await { Err(e) => { tracing::debug!("Failed to connect to Discord: {}", e); reconnect_dur *= 2; if reconnect_dur.as_secs() > 60 { reconnect_dur = std::time::Duration::from_secs(60); } tokio::time::sleep(reconnect_dur).await; } Ok(stream) => { reconnect_dur = std::time::Duration::from_millis(500); match io_loop(stream, app_id, &io_stx, &srx, &rtx).await { Err(e) => { tracing::debug!("I/O loop failed: {:#}", e); if let Error::Close(e) = &e { tracing::warn!( reason = %e, "Shutting down I/O loop due to Discord close request" ); return; } if rtx.try_send(IoMsg::Disconnected(e)).is_err() { tracing::error!("Dropped disconnect message as queue is too full"); } // Drain the send queue so we don't confuse Discord while let Ok(msg) = srx.try_recv() { // Also while we're here, check if we actually want // to exit altogether // // TODO: also need to check this when we're not // connected to Discord at all if msg.is_none() { return; } } tokio::time::sleep(reconnect_dur).await; } Ok(_) => return, } } } } }); IoTask { stx, rrx, handle } } // UnixStream and NamedPipe both have the same high level interface, but those // aren't traits, just regular methods, so we unify them in our own trait #[async_trait::async_trait] trait SocketStream { async fn ready(&self, interest: tokio::io::Interest) -> std::io::Result<tokio::io::Ready>; fn try_read(&self, buf: &mut [u8]) -> std::io::Result<usize>; fn try_write(&self, buf: &[u8]) -> std::io::Result<usize>; } #[cfg(unix)] #[async_trait::async_trait] impl SocketStream for Pipe { async fn ready(&self, interest: tokio::io::Interest) -> std::io::Result<tokio::io::Ready> { self.ready(interest).await } #[inline] fn try_read(&self, buf: &mut [u8]) -> std::io::Result<usize> { self.try_read(buf) } #[inline] fn try_write(&self, buf: &[u8]) -> std::io::Result<usize> { self.try_write(buf) } } #[cfg(windows)] #[async_trait::async_trait] impl SocketStream for Pipe { async fn ready(&self, interest: tokio::io::Interest) -> std::io::Result<tokio::io::Ready> { self.ready(interest).await } #[inline] fn try_read(&self, buf: &mut [u8]) -> std::io::Result<usize> { self.try_read(buf) } #[inline] fn try_write(&self, buf: &[u8]) -> std::io::Result<usize> { self.try_write(buf) } }
use crate::window::{Window, WindowType, Geometry}; use std::fmt::Debug; use crate::keys::KeyCombo; use std::hash::Hash; use crate::config::Config; use futures::Stream; pub mod xcb_server; #[derive(Debug, Eq, PartialEq)] pub enum Event<W, K> { DisplayInited, ScreenAdded(W, Geometry), KeyPressed(K), WindowAdded(W, WindowType), WindowRemoved(W), WindowFocused(W), DisplayEnded, Ignored, } pub trait DisplayServer: Stream<Item=Event<<Self as DisplayServer>::Window, <Self as DisplayServer>::KeyCombo>> + Clone { type Window: Debug + Clone + Eq; type KeyCombo: From<KeyCombo> + Hash + Eq + Debug; fn new(config: &Config) -> Self; fn configure_window(&self, window: &Window<Self::Window>); fn set_visibility(&self, window: &Self::Window, show: bool); fn quit(&self); }
extern crate piston_meta; #[test] fn test_syntax_opengex() { use piston_meta::*; let syntax_src = include_str!("assets/opengex-syntax.txt").to_string(); let rules = stderr_unwrap(&syntax_src, syntax(&syntax_src)); let ogex_src = include_str!("assets/cube.ogex").to_string(); let mut data = vec![]; stderr_unwrap(&ogex_src, parse(&rules, &ogex_src, &mut data)); } #[test] fn test_syntax_opendll() { use piston_meta::*; let syntax_src = include_str!("assets/openddl-syntax.txt").to_string(); let rules = stderr_unwrap(&syntax_src, syntax(&syntax_src)); let ogex_src = include_str!("assets/cube.ogex").to_string(); let mut data = vec![]; stderr_unwrap(&ogex_src, parse(&rules, &ogex_src, &mut data)); }