text stringlengths 8 4.13M |
|---|
use std::result;
use std::io;
pub type Result<T> = result::Result<T, Error>;
#[derive(Debug)]
pub enum Error {
MusicContainer(hex_music_container::error::Error),
Database(hex_database::Error),
Io(io::Error),
Ffmpeg(String),
ChannelFailed,
FileNotFound
}
|
pub const TARGET: &str = "127.0.0.1";
// Deployment Management Defaults
pub const DEPLOYMENT_PORT: i32 = 8002;
// Gossip Defaults
pub const GOSSIP_PORT: i32 = 8001;
pub const GOSSIP_INTERVAL: i16 = 500;
pub const GOSSIP_FANOUT: i8 = 3;
// API Defaults
pub const API_PORT: i32 = 8000;
pub fn blank() {}
|
use core::fmt;
use serde::{Deserialize, Serialize};
/// The syntactic shapes that values must match to be passed into a command. You can think of this as the type-checking that occurs when you call a function.
#[derive(Debug, Copy, Clone, Deserialize, Serialize)]
pub enum SyntaxShape {
/// Any syntactic form is allowed
Any,
/// Strings and string-like bare words are allowed
String,
/// Only a numeric (integer or decimal) value is allowed
Number,
/// Only an integer value is allowed
Int,
/// A filepath is allowed
Path,
/// A glob pattern is allowed, eg `foo*`
Pattern,
}
impl fmt::Display for SyntaxShape {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}",
match self {
SyntaxShape::Any => "any",
SyntaxShape::String => "string",
SyntaxShape::Number => "number",
SyntaxShape::Int => "integer",
SyntaxShape::Path => "path",
SyntaxShape::Pattern => "pattern",
}
)
}
}
|
//!
#![warn(missing_docs)]
#![cfg_attr(feature = "const", feature(const_fn))]
mod raw_int;
pub mod wide_int;
|
pub fn binary_search(nums: &[i32], target: i32) -> Option<usize> {
use std::cmp::Ordering;
let (mut low, mut high) = (0, nums.len());
while low < high {
let mid = low + (high - low) / 2;
match nums[mid].cmp(&target) {
Ordering::Less => low = mid + 1,
Ordering::Equal => return Some(mid),
Ordering::Greater => high = mid,
}
}
None
}
#[cfg(test)]
mod binary_search_tests {
use super::*;
#[test]
fn binary_test_one() {
let numbers = vec![-1, 0, 3, 5, 9, 12];
assert_eq!(binary_search(&numbers, 3), Some(2));
}
}
|
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "Networking_BackgroundTransfer")]
pub mod BackgroundTransfer;
#[cfg(feature = "Networking_Connectivity")]
pub mod Connectivity;
#[cfg(feature = "Networking_NetworkOperators")]
pub mod NetworkOperators;
#[cfg(feature = "Networking_Proximity")]
pub mod Proximity;
#[cfg(feature = "Networking_PushNotifications")]
pub mod PushNotifications;
#[cfg(feature = "Networking_ServiceDiscovery")]
pub mod ServiceDiscovery;
#[cfg(feature = "Networking_Sockets")]
pub mod Sockets;
#[cfg(feature = "Networking_Vpn")]
pub mod Vpn;
#[cfg(feature = "Networking_XboxLive")]
pub mod XboxLive;
#[link(name = "windows")]
extern "system" {}
#[repr(transparent)]
pub struct DomainNameType(pub i32);
impl DomainNameType {
pub const Suffix: Self = Self(0i32);
pub const FullyQualified: Self = Self(1i32);
}
impl ::core::marker::Copy for DomainNameType {}
impl ::core::clone::Clone for DomainNameType {
fn clone(&self) -> Self {
*self
}
}
pub type EndpointPair = *mut ::core::ffi::c_void;
pub type HostName = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct HostNameSortOptions(pub u32);
impl HostNameSortOptions {
pub const None: Self = Self(0u32);
pub const OptimizeForLongConnections: Self = Self(2u32);
}
impl ::core::marker::Copy for HostNameSortOptions {}
impl ::core::clone::Clone for HostNameSortOptions {
fn clone(&self) -> Self {
*self
}
}
#[repr(transparent)]
pub struct HostNameType(pub i32);
impl HostNameType {
pub const DomainName: Self = Self(0i32);
pub const Ipv4: Self = Self(1i32);
pub const Ipv6: Self = Self(2i32);
pub const Bluetooth: Self = Self(3i32);
}
impl ::core::marker::Copy for HostNameType {}
impl ::core::clone::Clone for HostNameType {
fn clone(&self) -> Self {
*self
}
}
|
use std::cmp::Reverse;
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet, VecDeque};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000_000_007;
fn main() {
let n: usize = parse_line().unwrap();
let s: String = parse_line().unwrap();
let s = s.chars().collect_vec();
let mut xixi: Vec<usize> = vec![];
let mut tmp = std::usize::MAX;
for (i, c) in s.iter().enumerate().rev() {
if std::usize::MAX == tmp && *c == 'o' {
continue;
}
if *c == 'x' {
tmp = i;
}
if *c == 'o' {
xixi.push(tmp);
}
}
let mut oioi: Vec<usize> = vec![];
let mut tmp = std::usize::MAX;
for (i, c) in s.iter().enumerate().rev() {
if std::usize::MAX == tmp && *c == 'x' {
continue;
}
if *c == 'o' {
tmp = i;
}
if *c == 'x' {
oioi.push(tmp);
}
}
// dbg文遅いのでコメントアウトする必要がある
// dbg!(&s, &xixi, &oioi);
let mut ans = 0;
for xi in xixi {
ans += n - xi;
}
for oi in oioi {
ans += n - oi;
}
println!("{}", ans);
}
|
#![feature(test)]
#![feature(stdsimd)]
#![feature(mmx_target_feature)]
#![feature(slice_internals)]
extern crate core;
extern crate stdsimd;
extern crate test;
#[macro_use]
extern crate jetscii;
extern crate faster;
extern crate memchr;
extern crate twoway;
#[cfg(test)]
mod bench;
// FIXME: Trying doing this with aligned instructions
pub fn is_ascii_simd(slice: &[u8]) -> bool {
return if cfg!(target_arch = "x86_64") &&
((cfg!(target_feature = "avx2") ||
cfg!(target_feature = "sse2") ||
cfg!(target_feature = "sse") ||
cfg!(target_feature = "mmx")) ||
(is_x86_feature_detected!("avx2") ||
is_x86_feature_detected!("sse2") ||
is_x86_feature_detected!("sse") ||
is_x86_feature_detected!("mmx")))
{
unsafe { is_ascii_simd_x86_64(slice) }
} else {
slice.is_ascii()
};
#[cfg(target_arch = "x86_64")]
unsafe fn is_ascii_simd_x86_64(slice: &[u8]) -> bool {
use std::arch::x86_64::*;
use std::simd::{u8x32, u8x16, u8x8};
use std::simd::FromBits;
let mut slice = slice;
if cfg!(target_feature = "avx2") ||
is_x86_feature_detected!("avx2")
{
while slice.len() >= 32 {
let vec = u8x32::load_unaligned(&slice[..32]);
let vec: __m256i = __m256i::from_bits(vec);
if _mm256_movemask_epi8(vec) != 0 {
return false;
}
slice = &slice[32..];
}
debug_assert!(slice.len() < 32);
}
if cfg!(target_feature = "sse2") ||
is_x86_feature_detected!("sse2")
{
while slice.len() >= 16 {
let vec = u8x16::load_unaligned(&slice[..16]);
let vec: __m128i = __m128i::from_bits(vec);
if _mm_movemask_epi8(vec) != 0 {
return false;
}
slice = &slice[16..];
}
debug_assert!(slice.len() < 16);
}
if cfg!(target_feature = "sse") ||
is_x86_feature_detected!("sse")
{
while slice.len() >= 8 {
let vec = u8x8::load_unaligned(&slice[..8]);
let vec: __m64 = __m64::from_bits(vec);
if _mm_movemask_pi8(vec) != 0 {
return false;
}
slice = &slice[8..];
}
debug_assert!(slice.len() < 8);
}
slice.is_ascii()
}
}
pub fn is_ascii_simd2(slice: &[u8]) -> bool {
return if cfg!(target_arch = "x86_64") &&
((cfg!(target_feature = "avx2") ||
cfg!(target_feature = "sse2") ||
cfg!(target_feature = "sse") ||
cfg!(target_feature = "mmx")) ||
(is_x86_feature_detected!("avx2") ||
is_x86_feature_detected!("sse2") ||
is_x86_feature_detected!("sse") ||
is_x86_feature_detected!("mmx")))
{
unsafe { is_ascii_simd_x86_64(slice) }
} else {
slice.is_ascii()
};
#[cfg(target_arch = "x86_64")]
unsafe fn is_ascii_simd_x86_64(slice: &[u8]) -> bool {
use std::arch::x86_64::*;
use std::simd::{u8x32, u8x16, u8x8};
use std::simd::FromBits;
let have_avx2 = cfg!(target_feature = "avx2") ||
is_x86_feature_detected!("avx2");
let have_sse2 = cfg!(target_feature = "sse2") ||
is_x86_feature_detected!("sse2");
let have_sse = cfg!(target_feature = "sse") ||
is_x86_feature_detected!("sse");
let mut slice = slice;
let avx2_align = 32;
let sse2_align = 16;
let sse_align = 8;
let is_aligned = |addr: usize, align: usize| addr & (align - 1) == 0;
let max_align = if have_avx2 { avx2_align }
else if have_sse2 { sse2_align }
else if have_sse { sse_align }
else { 1 };
loop {
if slice.is_empty() { return true }
let addr = slice.get_unchecked(0) as *const _ as usize;
if is_aligned(addr, max_align) {
break;
}
if have_sse2 && is_aligned(addr, sse2_align) && slice.len() >= 16 {
let vec = u8x16::load_aligned_unchecked(slice.get_unchecked(..16));
let vec: __m128i = __m128i::from_bits(vec);
if _mm_movemask_epi8(vec) != 0 {
return false;
}
slice = slice.get_unchecked(16..);
} else if have_sse && is_aligned(addr, sse_align) && slice.len() >= 8 {
let vec = u8x8::load_aligned_unchecked(slice.get_unchecked(..8));
let vec: __m64 = __m64::from_bits(vec);
if _mm_movemask_pi8(vec) != 0 {
return false;
}
slice = slice.get_unchecked(8..);
} else {
if !slice.get_unchecked(0).is_ascii() {
return false;
}
slice = slice.get_unchecked(1..);
}
}
if have_avx2 {
while slice.len() >= 32 {
let vec = u8x32::load_aligned_unchecked(slice.get_unchecked(..32));
let vec: __m256i = __m256i::from_bits(vec);
if _mm256_movemask_epi8(vec) != 0 {
return false;
}
slice = slice.get_unchecked(32..);
}
debug_assert!(slice.len() < 32);
}
if have_sse2 {
while slice.len() >= 16 {
let vec = u8x16::load_aligned_unchecked(slice.get_unchecked(..16));
let vec: __m128i = __m128i::from_bits(vec);
if _mm_movemask_epi8(vec) != 0 {
return false;
}
slice = slice.get_unchecked(16..);
}
debug_assert!(slice.len() < 16);
}
if have_sse {
while slice.len() >= 8 {
let vec = u8x8::load_aligned_unchecked(slice.get_unchecked(..8));
let vec: __m64 = __m64::from_bits(vec);
if _mm_movemask_pi8(vec) != 0 {
return false;
}
slice = slice.get_unchecked(8..);
}
debug_assert!(slice.len() < 8);
}
slice.is_ascii()
}
}
pub fn is_ascii_simd3(slice: &[u8]) -> bool {
if !cfg!(target_arch = "x86_64") {
return slice.is_ascii();
}
// In my experiments on skylake sse2 is faster than avx2 here
if cfg!(target_feature = "sse2") || is_x86_feature_detected!("sse2") {
return unsafe { is_ascii_simd3_x86_64_sse2(slice) };
}
if cfg!(target_feature = "avx2") || is_x86_feature_detected!("avx2") {
return unsafe { is_ascii_simd3_x86_64_avx2(slice) };
}
if cfg!(target_feature = "sse") || is_x86_feature_detected!("sse") {
return unsafe { is_ascii_simd3_x86_64_sse(slice) };
}
return slice.is_ascii();
}
#[cfg(target_arch = "x86_64")]
pub unsafe fn is_ascii_simd3_x86_64_avx2(mut slice: &[u8]) -> bool {
use std::arch::x86_64::*;
use std::simd::u8x32;
use std::simd::FromBits;
while slice.len() >= 32 {
let vec = u8x32::load_unaligned_unchecked(&slice.get_unchecked(..32));
let vec: __m256i = __m256i::from_bits(vec);
if _mm256_movemask_epi8(vec) != 0 {
return false;
}
slice = &slice.get_unchecked(32..);
}
if slice.len() >= 16 {
is_ascii_simd3_x86_64_sse2(slice)
} else {
slice.is_ascii()
}
}
#[cfg(target_arch = "x86_64")]
pub unsafe fn is_ascii_simd3_x86_64_sse2(mut slice: &[u8]) -> bool {
use std::arch::x86_64::*;
use std::simd::u8x16;
use std::simd::FromBits;
while slice.len() >= 16 {
let vec = u8x16::load_unaligned_unchecked(&slice[..16]);
let vec: __m128i = __m128i::from_bits(vec);
if _mm_movemask_epi8(vec) != 0 {
return false;
}
slice = &slice[16..];
}
if slice.len() >= 16 {
is_ascii_simd3_x86_64_sse(slice)
} else {
slice.is_ascii()
}
}
#[cfg(target_arch = "x86_64")]
pub unsafe fn is_ascii_simd3_x86_64_sse(mut slice: &[u8]) -> bool {
use std::arch::x86_64::*;
use std::simd::u8x8;
use std::simd::FromBits;
while slice.len() >= 8 {
let vec = u8x8::load_unaligned_unchecked(&slice.get_unchecked(..8));
let vec: __m64 = __m64::from_bits(vec);
if _mm_movemask_pi8(vec) != 0 {
return false;
}
slice = &slice.get_unchecked(8..);
}
slice.is_ascii()
}
#[derive(PartialEq, Eq)]
pub enum Accel { AVX2, SSE2, SSE, Any }
pub fn is_ascii_auto_simd(slice: &[u8], accel: Accel) -> bool {
return if cfg!(target_arch = "x86_64") {
if (cfg!(target_feature = "avx2") || is_x86_feature_detected!("avx2"))
&& (accel == Accel::AVX2 || accel == Accel::Any) {
#[target_feature(enable = "avx2")]
#[inline]
unsafe fn go(slice: &[u8]) -> bool {
slice.is_ascii()
}
unsafe { go(slice) }
} else if (cfg!(target_feature = "sse2") || is_x86_feature_detected!("sse2"))
&& (accel == Accel::SSE2 || accel == Accel::Any) {
#[target_feature(enable = "sse2")]
#[inline]
unsafe fn go(slice: &[u8]) -> bool {
slice.is_ascii()
}
unsafe { go(slice) }
} else if (cfg!(target_feature = "sse") || is_x86_feature_detected!("sse"))
&& (accel == Accel::SSE || accel == Accel::Any) {
#[target_feature(enable = "sse")]
#[inline]
unsafe fn go(slice: &[u8]) -> bool {
slice.is_ascii()
}
unsafe { go(slice) }
} else {
slice.is_ascii()
}
} else {
slice.is_ascii()
}
}
#[inline(never)]
pub fn is_ascii_naive_uninlined(buf: &[u8]) -> bool {
for byte in buf.iter() {
if *byte & 128 != 0 {
return false;
}
}
true
}
#[inline(always)]
pub fn is_ascii_naive_inlined(buf: &[u8]) -> bool {
for byte in buf.iter() {
if *byte & 128 != 0 {
return false;
}
}
true
}
pub fn fast_lines(buf: &str) -> FastLines {
FastLines(buf.as_bytes())
}
pub struct FastLines<'a>(&'a [u8]);
impl<'a> Iterator for FastLines<'a> {
type Item = &'a str;
// TODO: inline vs inline(never)
fn next(&mut self) -> Option<&'a str> {
use memchr::memchr;
let slice = &mut self.0;
if self.0.is_empty() {
return None;
}
let line;
unsafe {
if let Some(i) = memchr(b'\n', slice) {
if i > 0 && slice.get_unchecked(i - 1) == &b'\r' {
line = slice.get_unchecked(0..i - 1);
*slice = slice.get_unchecked(i + 1..);
} else {
line = slice.get_unchecked(0..i);
*slice = slice.get_unchecked(i + 1..);
}
} else {
line = slice;
*slice = slice.get_unchecked(0..0);
}
Some(::std::str::from_utf8_unchecked(line))
}
}
}
|
// Copyright 2014-2018 Optimal Computing (NZ) Ltd.
// Licensed under the MIT license. See LICENSE for details.
//! # float-cmp
//!
//! WARNING: comparing floating point numbers is very tricky and situation dependent, and
//! best avoided if at all possible. There is no panacea that "just works".
//!
//! float-cmp defines traits for approximate comparison of floating point types which have fallen
//! away from exact equality due to the limited precision available within floating point
//! representations. Implementations of these traits are provided for `f32` and `f64` types.
//!
//! The recommended go-to solution (although it may not be appropriate in all cases) is the
//! `approx_eq()` function in the `ApproxEq` trait. An epsilon test is performed first, which
//! handles very small numbers, zeroes, and differing signs of very small numbers, considering
//! them equal if the difference is less than the given epsilon (e.g. f32::EPSILON). For larger
//! numbers, floating point representations are spaced further apart, and in these cases the ulps
//! test comes to the rescue. Numbers are considered equal if the number of floating point
//! representations between them is below a specified bound (Ulps are a cardinal count of
//! floating point representations that separate two floating point numbers).
//!
//! Several other traits are provided including `Ulps`, `ApproxEqUlps`, `ApproxOrdUlps`, and
//! `ApproxEqRatio`.
//!
//! ## The problem
//!
//! Floating point operations must round answers to the nearest representable number. Multiple
//! operations may result in an answer different from what you expect. In the following example,
//! the assert will fail, even though the printed output says "0.45 == 0.45":
//!
//! ```should_panic
//! # extern crate float_cmp;
//! # use float_cmp::ApproxEq;
//! # fn main() {
//! let a = 0.15_f32 + 0.15_f32 + 0.15_f32;
//! let b = 0.1_f32 + 0.1_f32 + 0.25_f32;
//! println!("{} == {}", a, b);
//! assert!(a==b) // Fails, because they are not exactly equal
//! # }
//! ```
//!
//! This fails because the correct answer to most operations isn't exactly representable, and so
//! your computer's processor chooses to represent the answer with the closest value it has
//! available. This introduces error, and this error can accumulate as multiple operations are
//! performed.
//!
//! ## The solution
//!
//! With `ApproxEq`, we can get the answer we intend:
//!
//! ```
//! # extern crate float_cmp;
//! # use float_cmp::ApproxEq;
//! # fn main() {
//! let a = 0.15_f32 + 0.15_f32 + 0.15_f32;
//! let b = 0.1_f32 + 0.1_f32 + 0.25_f32;
//! println!("{} == {}", a, b);
//! assert!(a.approx_eq(&b, 2.0 * ::std::f32::EPSILON, 2)) // They are equal, within 2 ulps
//! # }
//! ```
//!
//! For most cases, I recommend you use a smallish integer for the `ulps` parameter (1 to 5
//! or so), and a similar small multiple of the floating point's EPSILON constant (1.0 to 5.0
//! or so), but there are *plenty* of cases where this is insufficient.
//!
//! ## Some explanation
//!
//! We use the term ULP (units of least precision, or units in the last place) to mean the
//! difference between two adjacent floating point representations (adjacent meaning that there is
//! no floating point number between them). This term is borrowed from prior work (personally I
//! would have chosen "quanta"). The size of an ULP (measured as a float) varies
//! depending on the exponents of the floating point numbers in question. That is a good thing,
//! because as numbers fall away from equality due to the imprecise nature of their representation,
//! they fall away in ULPs terms, not in absolute terms. Pure epsilon-based comparisons are
//! absolute and thus don't map well to the nature of the additive error issue. They work fine
//! for many ranges of numbers, but not for others (consider comparing -0.0000000028
//! to +0.00000097).
//!
//! ## Implementing these traits
//!
//! You can implement `ApproxEq` for your own complex types. The trait and type parameter
//! notation can be a bit tricky, especially if your type is type parameterized around
//! floating point types. So here is an example (you'll probably not specify the Copy trait
//! directly, but use some other NumTraits type floating point trait):
//!
//! ```
//! use float_cmp::{Ulps, ApproxEq};
//!
//! pub struct Vec2<F> {
//! pub x: F,
//! pub y: F,
//! }
//!
//! impl<F: Ulps + ApproxEq<Flt=F> + Copy> ApproxEq for Vec2<F> {
//! type Flt = F;
//!
//! fn approx_eq(&self, other: &Self,
//! epsilon: <F as ApproxEq>::Flt,
//! ulps: <<F as ApproxEq>::Flt as Ulps>::U) -> bool
//! {
//! self.x.approx_eq(&other.x, epsilon, ulps)
//! && self.y.approx_eq(&other.y, epsilon, ulps)
//! }
//! }
//! ```
//!
//! ## Inspiration
//!
//! This crate was inspired by this Random ASCII blog post:
//!
//! [https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/](https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/)
extern crate num_traits;
mod ulps;
pub use self::ulps::Ulps;
mod ulps_eq;
pub use self::ulps_eq::ApproxEqUlps;
mod ulps_ord;
pub use self::ulps_ord::ApproxOrdUlps;
mod eq;
pub use self::eq::ApproxEq;
mod ratio;
pub use self::ratio::ApproxEqRatio;
|
use async_std::task;
async fn calc(a: i32, b: i32) -> i32 {
(a + 1) * (a - 1) * b
}
fn main() {
let r = task::block_on(calc(5, 7));
println!("result: {}", r);
}
|
use std::path::Path;
use std::io;
use std::io::Write;
use std::fs::{self, File};
use std::env;
use std::collections::HashMap;
use image::GenericImageView;
use chrono::Datelike;
macro_rules! def_impl {
($name:ident) => {
impl $name {
fn write(&self, mut into: impl io::Write, name: &str) {
writeln!(into, "pub const {}: {} = {:#X?};", name, stringify!($name), self).unwrap();
}
fn write_start(mut into: impl io::Write, name: &str, len: usize) {
writeln!(into, "pub const {}: [{}; {}] = [", name, stringify!($name), len).unwrap();
}
fn write_entry(&self, mut into: impl io::Write) {
writeln!(into, " {:#X?},",self).unwrap();
}
fn write_end(mut into: impl io::Write) {
writeln!(into, "];").unwrap();
}
}
};
}
#[derive(Debug)]
struct DataDef {
offset: usize,
pal: usize
}
def_impl!(DataDef);
#[derive(Debug)]
struct LevelDef {
offset: usize,
width: u8,
height: u8,
start_pos: Field,
}
def_impl!(LevelDef);
struct Field(String);
impl std::fmt::Debug for Field {
fn fmt(&self, fmt: &mut std::fmt::Formatter) -> std::fmt::Result {
fmt.pad(&self.0)
}
}
fn main() {
let out_dir = env::var("OUT_DIR").unwrap();
let dest_path = Path::new(&out_dir).join("data.rs");
let bin_path = Path::new(&out_dir).join("data.bin");
let mut f = File::create(&dest_path).unwrap();
let mut data = vec![];
let mut pal = vec![];
let img = image::open("assets/fg/fries.png").unwrap().to_rgba8();
embed_fg(&img, 16, &mut data, &mut pal).write(&mut f, "BLOCKS");
let img = image::open("assets/bg/hills.png").unwrap().to_rgba8();
embed_bg(&img, &mut data, &mut pal).write(&mut f, "BG");
let img = image::open("assets/sprites/toothpaste.png").unwrap().to_rgba8();
embed_fg(&img, 32, &mut data, &mut pal).write(&mut f, "TOOTHPASTE");
let img = image::open("assets/sprites/entities.png").unwrap().to_rgba8();
embed_fg(&img, 32, &mut data, &mut pal).write(&mut f, "ENTITIES");
/*
let img = image::open("assets/sprites/particles.png").unwrap().to_rgba8();
embed_fg(&img, 16, &mut data, &mut pal).write(&mut f, "PARTICLES");
*/
let img = image::open("assets/fonts/boldface.png").unwrap().to_rgba8();
embed_fg(&img, 8, &mut data, &mut pal).write(&mut f, "BOLDFACE");
let mut ent_list = vec![];
let mut ent = String::new();
let mut ent_len = 0;
let count = 3;
writeln!(f, "pub static LEVEL_COUNT: usize = {};", count);
LevelDef::write_start(&mut f, "MAPS", count);
for i in 0..count {
let level = serde_json::from_slice(&fs::read(format!("assets/maps/L0A{}.json", i)).unwrap()).unwrap();
embed_map(&level, &mut data).write_entry(&mut f);
ent_list.push(embed_entities(&level, &mut ent, &mut ent_len));
}
LevelDef::write_end(&mut f);
ent_list.push(ent_len);
write!(f, "pub static ENTITY_LIST: [EntityEntry; {}] = [{}];", ent_len, ent);
write!(f, "pub static ENTITY_OFFSET: [usize; {}] = {:?};", ent_list.len(), ent_list);
let comp = lz4::block::compress(&data, lz4::block::CompressionMode::HIGHCOMPRESSION(12).into(), false).unwrap();
std::fs::write(bin_path, &comp).unwrap();
std::fs::write("data.bin", &comp).unwrap();
std::fs::write("data_raw.bin", &data).unwrap();
writeln!(f, r#"pub static mut DATA: [u8; {0:}] = [0; {0:}];"#, data.len()).unwrap();
writeln!(f, r#"pub static DATA_LZ4: [u8; {}] = *include_bytes!(concat!(env!("OUT_DIR"), "/data.bin"));"#, comp.len()).unwrap();
writeln!(f, "pub static PAL_DATA: [u32; {}] = {:#08X?};", pal.len(), pal).unwrap();
let title_path = Path::new(&out_dir).join("title.txt");
let date = chrono::offset::Local::today();
let month = date.month() as i32 + (date.year() - 2021) * 12;
std::fs::write(title_path, format!("MINTY ADVENTURES BUILD {:02}{:02}", month, date.day()));
}
fn embed_map(level: &serde_json::Value, data: &mut Vec<u8>) -> LevelDef {
let offset = data.len();
let tiles = &level["layers"][0]["data"];
for i in tiles.as_array().unwrap().iter() {
data.push((i.as_u64().unwrap() - 1) as u8);
}
let width = level["width"].as_u64().unwrap() as u8;
let height = level["height"].as_u64().unwrap() as u8;
let entities = &level["layers"][1]["objects"].as_array().unwrap();
let list = entities.iter().map(|c| c["gid"].as_u64().unwrap()).collect::<Vec<_>>();
let start_pos = entities.iter().find(|c| c["gid"].as_u64().unwrap() & 0xFFF == 0x210).map(|c| {
Field(format!("vec2({}, {})", c["x"].as_u64().unwrap() * 256, c["y"].as_u64().unwrap() * 256))
}).expect(&format!("{:?}", list));
LevelDef {
offset,
width,
height,
start_pos
}
}
fn embed_entities(level: &serde_json::Value, out: &mut String, len: &mut usize) -> usize {
use std::fmt::Write;
let base = *len;
let entities = &level["layers"][1]["objects"].as_array().unwrap();
for i in entities.iter() {
// x:u16 y:u16 id
let x = (i["x"].as_u64().unwrap() / 0x10) as u8 + 1;
let y = (i["y"].as_u64().unwrap() / 0x10) as u8 - 1;
let id = match i["gid"].as_u64().unwrap() & 0xFFF {
0x111 => 2,
//0x45 => 3,
//0x49 => 4,
//0x51 => 5,
_ => continue,
//c => panic!("no such EntityKind: {}", c)
};
writeln!(out, r"EntityEntry {{
x: {:#02X}, y: {:#02X}, kind: {}
}}, ", x, y, id);
*len += 1;
}
base
}
fn embed_fg(image: &image::RgbaImage, size: u32, data: &mut Vec<u8>, pal: &mut Vec<u32>) -> DataDef {
let mut palette = HashMap::new();
let offset = data.len();
let pal_offset = pal.len();
for ty in 0..image.height()/size {
for tx in 0..image.width()/size {
data.extend(image.view(tx*size, ty*size, size, size).pixels().map(|(_,_,c)| {
let c = u32::from_le_bytes(c.0);
let len = palette.len();
let id = palette.entry(c).or_insert_with(|| {
pal.push(c);
len
});
*id as u8
}));
}
}
DataDef {
offset,
pal: pal_offset,
}
}
fn embed_bg(image: &image::RgbaImage, data: &mut Vec<u8>, pal: &mut Vec<u32>) -> DataDef {
let mut palette = HashMap::new();
let offset = data.len();
let pal_offset = pal.len();
data.extend(image.pixels().map(|c| {
let c = u32::from_le_bytes(c.0);
let len = palette.len();
let id = palette.entry(c).or_insert_with(|| {
pal.push(c);
len
});
*id as u8
}));
DataDef {
offset,
pal: pal_offset,
}
}
|
use crate::utils::get_fl_name;
use proc_macro::TokenStream;
use quote::*;
use syn::*;
pub fn impl_image_trait(ast: &DeriveInput) -> TokenStream {
let name = &ast.ident;
let name_str = get_fl_name(name.to_string());
let new = Ident::new(format!("{}_{}", name_str, "new").as_str(), name.span());
let draw = Ident::new(format!("{}_{}", name_str, "draw").as_str(), name.span());
let width = Ident::new(format!("{}_{}", name_str, "width").as_str(), name.span());
let height = Ident::new(format!("{}_{}", name_str, "height").as_str(), name.span());
let delete = Ident::new(format!("{}_{}", name_str, "delete").as_str(), name.span());
let count = Ident::new(format!("{}_{}", name_str, "count").as_str(), name.span());
let data = Ident::new(format!("{}_{}", name_str, "data").as_str(), name.span());
let copy = Ident::new(format!("{}_{}", name_str, "copy").as_str(), name.span());
let scale = Ident::new(format!("{}_{}", name_str, "scale").as_str(), name.span());
let gen = quote! {
unsafe impl Sync for #name {}
unsafe impl Send for #name {}
impl Drop for #name {
fn drop(&mut self) {
unsafe { #delete(self._inner) }
}
}
impl Clone for #name {
fn clone(&self) -> Self {
self.copy()
}
}
unsafe impl ImageExt for #name {
fn copy(&self) -> Self {
unsafe {
let img = #copy(self._inner);
assert!(!img.is_null());
#name {
_inner: img,
}
}
}
fn draw(&mut self, arg2: i32, arg3: i32, arg4: i32, arg5: i32) {
unsafe { #draw(self._inner, arg2, arg3, arg4, arg5) }
}
fn width(&self) -> i32 {
unsafe {
#width(self._inner)
}
}
fn height(&self) -> i32 {
unsafe {
#height(self._inner)
}
}
unsafe fn as_ptr(&self) -> *mut raw::c_void {
unsafe {
mem::transmute(self._inner)
}
}
unsafe fn as_image_ptr(&self) -> *mut fltk_sys::image::Fl_Image {
unsafe {
mem::transmute(self._inner)
}
}
unsafe fn from_image_ptr(ptr: *mut fltk_sys::image::Fl_Image) -> Self {
unsafe {
assert!(!ptr.is_null());
#name {
_inner: mem::transmute(ptr),
}
}
}
fn to_rgb(&self) -> Vec<u8> {
unsafe {
let ptr = #data(self._inner);
let cnt = #width(self._inner) * #height(self._inner) * 3;
let ret: &[u8] = std::slice::from_raw_parts(ptr as *const u8, cnt as usize);
ret.to_vec()
}
}
fn scale(&mut self, width: i32, height: i32, proportional: bool, can_expand: bool) {
unsafe {
#scale(self._inner, width, height, proportional as i32, can_expand as i32)
}
}
}
};
gen.into()
}
|
use clippy_utils::diagnostics::span_lint_and_then;
use clippy_utils::ty::is_type_diagnostic_item;
use clippy_utils::{method_chain_args, return_ty};
use if_chain::if_chain;
use rustc_hir as hir;
use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
use rustc_hir::{Expr, ImplItemKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::hir::map::Map;
use rustc_middle::ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{sym, Span};
declare_clippy_lint! {
/// ### What it does
/// Checks for functions of type `Result` that contain `expect()` or `unwrap()`
///
/// ### Why is this bad?
/// These functions promote recoverable errors to non-recoverable errors which may be undesirable in code bases which wish to avoid panics.
///
/// ### Known problems
/// This can cause false positives in functions that handle both recoverable and non recoverable errors.
///
/// ### Example
/// Before:
/// ```rust
/// fn divisible_by_3(i_str: String) -> Result<(), String> {
/// let i = i_str
/// .parse::<i32>()
/// .expect("cannot divide the input by three");
///
/// if i % 3 != 0 {
/// Err("Number is not divisible by 3")?
/// }
///
/// Ok(())
/// }
/// ```
///
/// After:
/// ```rust
/// fn divisible_by_3(i_str: String) -> Result<(), String> {
/// let i = i_str
/// .parse::<i32>()
/// .map_err(|e| format!("cannot divide the input by three: {}", e))?;
///
/// if i % 3 != 0 {
/// Err("Number is not divisible by 3")?
/// }
///
/// Ok(())
/// }
/// ```
#[clippy::version = "1.48.0"]
pub UNWRAP_IN_RESULT,
restriction,
"functions of type `Result<..>` or `Option`<...> that contain `expect()` or `unwrap()`"
}
declare_lint_pass!(UnwrapInResult=> [UNWRAP_IN_RESULT]);
impl<'tcx> LateLintPass<'tcx> for UnwrapInResult {
fn check_impl_item(&mut self, cx: &LateContext<'tcx>, impl_item: &'tcx hir::ImplItem<'_>) {
if_chain! {
// first check if it's a method or function
if let hir::ImplItemKind::Fn(ref _signature, _) = impl_item.kind;
// checking if its return type is `result` or `option`
if is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::Result)
|| is_type_diagnostic_item(cx, return_ty(cx, impl_item.hir_id()), sym::Option);
then {
lint_impl_body(cx, impl_item.span, impl_item);
}
}
}
}
struct FindExpectUnwrap<'a, 'tcx> {
lcx: &'a LateContext<'tcx>,
typeck_results: &'tcx ty::TypeckResults<'tcx>,
result: Vec<Span>,
}
impl<'a, 'tcx> Visitor<'tcx> for FindExpectUnwrap<'a, 'tcx> {
type Map = Map<'tcx>;
fn visit_expr(&mut self, expr: &'tcx Expr<'_>) {
// check for `expect`
if let Some(arglists) = method_chain_args(expr, &["expect"]) {
let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
if is_type_diagnostic_item(self.lcx, reciever_ty, sym::Option)
|| is_type_diagnostic_item(self.lcx, reciever_ty, sym::Result)
{
self.result.push(expr.span);
}
}
// check for `unwrap`
if let Some(arglists) = method_chain_args(expr, &["unwrap"]) {
let reciever_ty = self.typeck_results.expr_ty(&arglists[0][0]).peel_refs();
if is_type_diagnostic_item(self.lcx, reciever_ty, sym::Option)
|| is_type_diagnostic_item(self.lcx, reciever_ty, sym::Result)
{
self.result.push(expr.span);
}
}
// and check sub-expressions
intravisit::walk_expr(self, expr);
}
fn nested_visit_map(&mut self) -> NestedVisitorMap<Self::Map> {
NestedVisitorMap::None
}
}
fn lint_impl_body<'tcx>(cx: &LateContext<'tcx>, impl_span: Span, impl_item: &'tcx hir::ImplItem<'_>) {
if let ImplItemKind::Fn(_, body_id) = impl_item.kind {
let body = cx.tcx.hir().body(body_id);
let mut fpu = FindExpectUnwrap {
lcx: cx,
typeck_results: cx.tcx.typeck(impl_item.def_id),
result: Vec::new(),
};
fpu.visit_expr(&body.value);
// if we've found one, lint
if !fpu.result.is_empty() {
span_lint_and_then(
cx,
UNWRAP_IN_RESULT,
impl_span,
"used unwrap or expect in a function that returns result or option",
move |diag| {
diag.help("unwrap and expect should not be used in a function that returns result or option");
diag.span_note(fpu.result, "potential non-recoverable error(s)");
},
);
}
}
}
|
use scheme::LispResult;
use scheme::value::Sexp;
use scheme::error::LispError::*;
use scheme::machine::LispMachine;
pub fn apply_proc(vm: &mut LispMachine, args: &[Sexp]) -> LispResult<Sexp> {
use self::Sexp::*;
let arity = args.len();
if arity < 2 {
return Err(ArityMismatch("apply".to_string(), 2, arity));
}
let mut arg_list = vec![];
let (last, init) = args[1..].split_last().unwrap();
if let List(mut xs) = last.clone() {
if *xs.last().unwrap() != Nil {
return Err(TypeMismatch("list".to_owned(), format!("{}", last)));
}
xs.pop();
for arg in init {
arg_list.push(arg.clone())
}
for arg in *xs {
arg_list.push(arg)
}
} else if *last == Nil {
for arg in init {
arg_list.push(arg.clone())
}
} else {
return Err(TypeMismatch("list".to_owned(), format!("{}", last)));
};
vm.apply(&args[0], &arg_list)
}
|
use crate::types::{Game, Enemy, Object, EnemyData, Vec2};
use crate::util;
impl Game {
pub fn load_level(&mut self, id: u8) -> Vec<Enemy> {
let bytes = self.levels_data[id as usize].clone();
let amount = bytes[0];
let mut result = vec![];
for i in 0..amount as u32 {
let offset = i * 5;
let view = bytes[(offset as usize + 1)..(offset as usize + 6)].to_vec();
let enemy_id = view[3];
let enemy_data = self.load_enemy(enemy_id);
let enemy = Enemy {
id: enemy_id,
position: Vec2 {
x: view[0] as i32 * 256 + view[1] as i32,
y: view[2] as i32
},
dir: (view[4] as i32) - 1,
data: enemy_data,
explosion_frames: 2,
anim_state: 0
};
result.push(enemy);
}
result
}
pub fn load_enemy(&mut self, id: u8) -> EnemyData {
let true_id = if id == 255 { 41 } else { id };
let bytes = self.enemies_data[true_id as usize].clone();
let mut enemy = EnemyData {
model_id: bytes[0],
size: Vec2 { x: 0, y: 0 },
anim_count: bytes[1],
lives: bytes[2] as i8,
floats: bytes[3] == 1,
shot_time: bytes[4],
move_up: bytes[5] == 1,
move_down: bytes[6] == 1,
move_anyway: bytes[7] == 1,
moves_between: Vec2 { x: bytes[8] as i32, y: bytes[9] as i32 }
};
for _ in enemy.model_id..enemy.anim_count {
let obj = self.load_object(enemy.model_id);
if enemy.size.x < obj.size.x {
enemy.size.x = obj.size.x;
}
if enemy.size.y < obj.size.y {
enemy.size.y = obj.size.y;
}
}
enemy
}
pub fn load_object(&mut self, id: u8) -> Object {
let true_id = if id > 51 { id - 250 + 52 } else { id };
let bytes = self.objects_data[true_id as usize].clone();
let obj = Object {
size: Vec2 {
x: bytes[0] as i32,
y: bytes[1] as i32
},
data: util::uncompress(bytes[2..].to_vec())
};
obj
}
}
|
use std::iter;
use hdf5;
use crate::board::{BoardState, BitBoard, rank_bb, Direction};
use crate::moves::{Move, MoveMeta, BitPositions, MoveList};
use crate::utils;
pub const WHITE: bool = true;
pub const BLACK: bool = false;
#[derive(hdf5::H5Type, Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(u8)]
pub enum SqOccupation {
Empty = 1,
White = 2,
Black = 3,
}
impl Default for SqOccupation {
fn default() -> Self {
SqOccupation::Empty
}
}
impl From<bool> for SqOccupation {
fn from(player: bool) -> Self {
match player {
false => SqOccupation::Black,
true => SqOccupation::White,
}
}
}
pub mod std_pieces {
use crate::board::BitBoard;
use crate::pieces::{Piece, PieceType, WHITE, BLACK};
pub const STD_PIECECOUNT: usize = 6*2;
static WHITE_PAWN: Piece = Piece{ piece_type: PieceType::Pawn, player: WHITE };
static WHITE_KNIGHT: Piece = Piece{ piece_type: PieceType::Knight, player: WHITE };
static WHITE_BISHOP: Piece = Piece{ piece_type: PieceType::Bishop, player: WHITE };
static WHITE_ROOK: Piece = Piece{ piece_type: PieceType::Rook, player: WHITE };
static WHITE_QUEEN: Piece = Piece{ piece_type: PieceType::Queen, player: WHITE };
static WHITE_KING: Piece = Piece{ piece_type: PieceType::King, player: WHITE };
static BLACK_PAWN: Piece = Piece{ piece_type: PieceType::Pawn, player: BLACK };
static BLACK_KNIGHT: Piece = Piece{ piece_type: PieceType::Knight, player: BLACK };
static BLACK_BISHOP: Piece = Piece{ piece_type: PieceType::Bishop, player: BLACK };
static BLACK_ROOK: Piece = Piece{ piece_type: PieceType::Rook, player: BLACK };
static BLACK_QUEEN: Piece = Piece{ piece_type: PieceType::Queen, player: BLACK };
static BLACK_KING: Piece = Piece{ piece_type: PieceType::King, player: BLACK };
pub fn get_piece(i: usize) -> Piece {
match i {
0 => WHITE_PAWN,
1 => WHITE_KNIGHT,
2 => WHITE_BISHOP,
3 => WHITE_ROOK,
4 => WHITE_QUEEN,
5 => WHITE_KING,
6 => BLACK_PAWN,
7 => BLACK_KNIGHT,
8 => BLACK_BISHOP,
9 => BLACK_ROOK,
10 => BLACK_QUEEN,
11 => BLACK_KING,
_ => Piece::invalid()
}
}
pub fn get_piece_i(piece: &Piece) -> usize {
match piece {
&Piece{ piece_type: PieceType::Pawn, player: WHITE } => 0 ,
&Piece{ piece_type: PieceType::Knight, player: WHITE } => 1 ,
&Piece{ piece_type: PieceType::Bishop, player: WHITE } => 2 ,
&Piece{ piece_type: PieceType::Rook, player: WHITE } => 3 ,
&Piece{ piece_type: PieceType::Queen, player: WHITE } => 4 ,
&Piece{ piece_type: PieceType::King, player: WHITE } => 5 ,
&Piece{ piece_type: PieceType::Pawn, player: BLACK } => 6 ,
&Piece{ piece_type: PieceType::Knight, player: BLACK } => 7 ,
&Piece{ piece_type: PieceType::Bishop, player: BLACK } => 8 ,
&Piece{ piece_type: PieceType::Rook, player: BLACK } => 9 ,
&Piece{ piece_type: PieceType::Queen, player: BLACK } => 10,
&Piece{ piece_type: PieceType::King, player: BLACK } => 11,
_ => 12
}
}
pub fn match_piece_i(piece_type: PieceType, player: bool) -> usize {
get_piece_i(&Piece{ piece_type, player })
}
pub fn player_pieces_i(player: bool) -> usize {
if player { 0 } else { 6 }
}
pub const STD_BITBOARDS: [BitBoard; STD_PIECECOUNT] = [
STD_PAWNS_WHITE, // White Pawns
STD_KNIGHTS_WHITE, // White Knights
STD_BISHOPS_WHITE, // White Bishops
STD_ROOKS_WHITE, // White Rooks
STD_QUEENS_WHITE, // White Queens
STD_KINGS_WHITE, // White Kings
STD_PAWNS_BLACK, // Black Pawns
STD_KNIGHTS_BLACK, // Black Knights
STD_BISHOPS_BLACK, // Black Bishops
STD_ROOKS_BLACK, // Black Rooks
STD_QUEENS_BLACK, // Black Queens
STD_KINGS_BLACK, // Black Kings
];
const STD_PAWNS_WHITE: BitBoard = 0xff_00;
const STD_KNIGHTS_WHITE: BitBoard = 0x42;
const STD_BISHOPS_WHITE: BitBoard = 0x24;
const STD_ROOKS_WHITE: BitBoard = 0x81;
const STD_QUEENS_WHITE: BitBoard = 0x08;
const STD_KINGS_WHITE: BitBoard = 0x10;
const STD_PAWNS_BLACK: BitBoard = 0x00_ff_00_00_00_00_00_00;
const STD_KNIGHTS_BLACK: BitBoard = 0x42_00_00_00_00_00_00_00;
const STD_BISHOPS_BLACK: BitBoard = 0x24_00_00_00_00_00_00_00;
const STD_ROOKS_BLACK: BitBoard = 0x81_00_00_00_00_00_00_00;
const STD_QUEENS_BLACK: BitBoard = 0x08_00_00_00_00_00_00_00;
const STD_KINGS_BLACK: BitBoard = 0x10_00_00_00_00_00_00_00;
}
#[derive(hdf5::H5Type, Copy, Clone, PartialEq, Eq, Hash, Debug)]
#[repr(u8)]
pub enum PieceType {
Invalid = 0,
Pawn = 1,
Knight = 2,
Bishop = 3,
Rook = 4,
Queen = 5,
King = 6,
}
impl PieceType {
pub fn value(&self) -> u8 {
*self as u8
}
pub fn from_value(v: u8) -> PieceType{
match v {
1 => PieceType::Pawn, // 0b0001
2 => PieceType::Knight, // 0b0010
3 => PieceType::Bishop, // 0b0011
4 => PieceType::Rook, // 0b0100
5 => PieceType::Queen, // 0b0101
6 => PieceType::King, // 0b0110
_ => PieceType::Invalid, // 0b0000
}
}
pub fn an(&self) -> &'static str {
match self {
PieceType::Pawn => "",
PieceType::Knight => "N",
PieceType::Bishop => "B",
PieceType::Rook => "R",
PieceType::Queen => "Q",
PieceType::King => "K",
PieceType::Invalid => "_",
}
}
}
impl Default for PieceType {
fn default() -> Self {
PieceType::Invalid
}
}
const PROMO_TARGETS: [PieceType; 4] = [ PieceType::Knight, PieceType::Bishop, PieceType::Rook, PieceType::Queen ];
const PIECETYPE_BITS: u8 = 3;
const PIECETYPE_MASK: u8 = 0b0111;
// Piece(0b0000_1xxx) for white pieces. Piece(0b0000_0xxx) for black pieces
#[derive(Copy, Clone, PartialEq)]
pub struct Piece {
pub piece_type: PieceType,
pub player: bool
}
impl Piece {
pub fn from_bits(piecebits: u8) -> Piece {
Piece {
piece_type: PieceType::from_value(piecebits & PIECETYPE_MASK),
player: piecebits > PIECETYPE_MASK
}
}
pub fn to_bits(&self) -> u8 {
((self.player as u8) << PIECETYPE_BITS) | self.piece_type.value()
}
/// Algebraic notation
pub fn an(&self) -> &'static str {
self.piece_type.an()
}
pub fn piece_char(&self) -> char {
match self {
Piece{ piece_type: PieceType::Pawn, player: WHITE } => 'P',
Piece{ piece_type: PieceType::Knight, player: WHITE } => 'N',
Piece{ piece_type: PieceType::Bishop, player: WHITE } => 'B',
Piece{ piece_type: PieceType::Rook, player: WHITE } => 'R',
Piece{ piece_type: PieceType::Queen, player: WHITE } => 'Q',
Piece{ piece_type: PieceType::King, player: WHITE } => 'K',
Piece{ piece_type: PieceType::Pawn, player: BLACK } => 'p',
Piece{ piece_type: PieceType::Knight, player: BLACK } => 'n',
Piece{ piece_type: PieceType::Bishop, player: BLACK } => 'b',
Piece{ piece_type: PieceType::Rook, player: BLACK } => 'r',
Piece{ piece_type: PieceType::Queen, player: BLACK } => 'q',
Piece{ piece_type: PieceType::King, player: BLACK } => 'k',
_ => '·',
}
}
pub fn invalid() -> Piece {
Piece{ piece_type: PieceType::Invalid, player: WHITE }
}
/// Return the piece attack mask and the the ray that checks the king, if king is in check
pub fn attack_check_mask(&self, piece_mask: &BitBoard, empty: &BitBoard, king_mask: &BitBoard) -> (BitBoard, BitBoard) {
let forward = self.player;
match self.piece_type {
PieceType::Pawn => {
let mut check_mask = 0;
// forward left capture
let dir = if forward { Direction::NW } else { Direction::SE };
let cp_l_dest = utils::slide(*piece_mask, 1, &dir);
if cp_l_dest & king_mask > 0 {
check_mask |= utils::slide(*king_mask, 1, &dir.opp())
}
// forward right capture
let dir = if forward { Direction::NE } else { Direction::SW };
let cp_r_dest = utils::slide(*piece_mask, 1, &dir);
if cp_l_dest & king_mask > 0 {
check_mask |= utils::slide(*king_mask, 1, &dir.opp())
}
(cp_l_dest | cp_r_dest, check_mask)
},
PieceType::Knight => {
let mut a_mask = 0;
let mut check_mask = 0;
for knight_pos in BitPositions(*piece_mask) {
let attack_mask = utils::knight_attack(knight_pos);
a_mask |= attack_mask;
if attack_mask & king_mask > 0 {
for king_pos in BitPositions(*king_mask) {
check_mask |= utils::ray(king_pos, knight_pos);
}
}
}
(a_mask, check_mask)
},
PieceType::Bishop => {
let mut a_mask = 0;
let mut check_mask = 0;
for bishop_pos in BitPositions(*piece_mask) {
let attack_mask = utils::bishop_attack(bishop_pos, !empty);
a_mask |= attack_mask;
if attack_mask & king_mask > 0 {
for king_pos in BitPositions(*king_mask) {
check_mask |= utils::ray(king_pos, bishop_pos);
}
}
}
(a_mask, check_mask)
},
PieceType::Rook => {
let mut a_mask = 0;
let mut check_mask = 0;
for rook_pos in BitPositions(*piece_mask) {
let attack_mask = utils::rook_attack(rook_pos, !empty);
a_mask |= attack_mask;
if attack_mask & king_mask > 0 {
for king_pos in BitPositions(*king_mask) {
check_mask |= utils::ray(king_pos, rook_pos);
}
}
}
(a_mask, check_mask)
},
PieceType::Queen => {
let mut a_mask = 0;
let mut check_mask = 0;
for queen_pos in BitPositions(*piece_mask) {
let attack_mask = utils::bishop_attack(queen_pos, !empty);
let attack_mask = attack_mask ^ utils::rook_attack(queen_pos, !empty);
a_mask |= attack_mask;
if attack_mask & king_mask > 0 {
for king_pos in BitPositions(*king_mask) {
check_mask |= utils::ray(king_pos, queen_pos);
}
}
}
(a_mask, check_mask)
},
PieceType::King => {
let mut a_mask = 0;
for king_pos in BitPositions(*piece_mask) {
a_mask |= utils::king_attack(king_pos);
}
(a_mask, 0)
},
PieceType::Invalid => {(0, 0)},
}
}
/// Finds pseudolegal moves for this piece. Except castling with no rights
pub fn pseudo_move_list(&self, piece_mask: &BitBoard, board_state: &BoardState, move_list: &mut MoveList) {
let board = board_state.board;
let empty = board.empty_mask();
let forward = self.player;
let _player_mask = board.player_mask(forward);
let oppnt_mask = board.player_mask(!forward);
match self.piece_type {
PieceType::Pawn => {
pawn_moves(forward, &piece_mask, &utils::ONES, &empty, &oppnt_mask, &board.enp_target, self, move_list);
},
PieceType::Knight => {
for knight_pos in BitPositions(*piece_mask) {
let attack_mask = utils::knight_attack(knight_pos);
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(knight_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(knight_pos), BitPositions(cp_dest) );
}
},
PieceType::Bishop => {
for bishop_pos in BitPositions(*piece_mask) {
let attack_mask = utils::bishop_attack(bishop_pos, !empty);
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(bishop_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(bishop_pos), BitPositions(cp_dest) );
}
},
PieceType::Rook => {
for rook_pos in BitPositions(*piece_mask) {
let attack_mask = utils::rook_attack(rook_pos, !empty);
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(rook_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(rook_pos), BitPositions(cp_dest) );
}
},
PieceType::Queen => {
for queen_pos in BitPositions(*piece_mask) {
let attack_mask = utils::bishop_attack(queen_pos, !empty);
let attack_mask = attack_mask ^ utils::rook_attack(queen_pos, !empty);
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(queen_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(queen_pos), BitPositions(cp_dest) );
}
},
PieceType::King => {
for king_pos in BitPositions(*piece_mask) {
let attack_mask = utils::king_attack(king_pos);
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
// can only castle while not in check
if *(board_state.opp_check_mask) == 0 {
// check short castle rights
if board.castle_rights(forward, true) {
// check that opp does not attack the squares the king will travel over
if (board_state.opp_attack_mask & utils::castle_travel_squares(forward, true) == 0) &&
// and the squares between are not occupied
(!empty & utils::castle_empty_squares(forward, true) == 0) {
let meta = MoveMeta::Castle{ is_short: true };
move_list.push(Move::new(self, &meta, king_pos, 0));
}
}
// check long castle rights
if board.castle_rights(forward, false) {
if (board_state.opp_attack_mask & utils::castle_travel_squares(forward, false) == 0) &&
(!empty & utils::castle_empty_squares(forward, false) == 0) {
let meta = MoveMeta::Castle{ is_short: false };
move_list.push(Move::new(self, &meta, king_pos, 0));
}
}
}
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(king_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(king_pos), BitPositions(cp_dest) );
}
},
PieceType::Invalid => {},
}
}
/// Finds legal (almost) moves for this piece. Returns the piece(s) attack mask
/// Only the corner case of enpassant capture leading to a check along the 4th rank is illegal
pub fn move_list(&self, piece_mask: &BitBoard, board_state: &BoardState, move_list: &mut MoveList) {
let board = board_state.board;
let empty = board.empty_mask();
let forward = self.player;
let _player_mask = board.player_mask(forward);
let oppnt_mask = board.player_mask(!forward);
match self.piece_type {
PieceType::Pawn => {
// Clear pinned pawns
// Loop through pinned pawns, add each pawn's moves separately with the pin ray as valid_mask.
// Probably not efficient
let pinned_pawns = piece_mask & board_state.pinned_mask;
let piece_mask = piece_mask & !board_state.pinned_mask;
for pawn_pos in BitPositions(pinned_pawns) {
if let Some(ray) = board_state.pinned_pieces.get(&pawn_pos) {
let valid_mask = if ray == &0 { &utils::ONES } else { ray };
pawn_moves(forward, &piece_mask, valid_mask, &empty, &oppnt_mask, &board.enp_target, self, move_list);
}
}
// use the check mask as the valid mask
let valid_mask = if board_state.opp_check_mask == &0 { &utils::ONES } else { board_state.opp_check_mask };
pawn_moves(forward, &piece_mask, valid_mask, &empty, &oppnt_mask, &board.enp_target, self, move_list);
},
PieceType::Knight => {
for knight_pos in BitPositions(*piece_mask) {
let mut attack_mask = utils::knight_attack(knight_pos);
// Masking with the ray is unnecessary. Knights cant move along rays
if let Some(ray) = board_state.pinned_pieces.get(&knight_pos) {
attack_mask &= ray;
}
if *(board_state.opp_check_mask) > 0 {
attack_mask &= board_state.opp_check_mask;
}
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(knight_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(knight_pos), BitPositions(cp_dest) );
}
},
PieceType::Bishop => {
for bishop_pos in BitPositions(*piece_mask) {
let mut attack_mask = utils::bishop_attack(bishop_pos, !empty);
// if piece is pinned, only move along the pin ray
if let Some(ray) = board_state.pinned_pieces.get(&bishop_pos) {
attack_mask &= ray;
}
// if in check only moves that block the check are valid
if *(board_state.opp_check_mask) > 0 {
attack_mask &= board_state.opp_check_mask;
}
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(bishop_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(bishop_pos), BitPositions(cp_dest) );
}
},
PieceType::Rook => {
for rook_pos in BitPositions(*piece_mask) {
let mut attack_mask = utils::rook_attack(rook_pos, !empty);
if let Some(ray) = board_state.pinned_pieces.get(&rook_pos) {
attack_mask &= ray;
}
if *(board_state.opp_check_mask) > 0 {
attack_mask &= board_state.opp_check_mask;
}
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(rook_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(rook_pos), BitPositions(cp_dest) );
}
},
PieceType::Queen => {
for queen_pos in BitPositions(*piece_mask) {
let attack_mask = utils::bishop_attack(queen_pos, !empty);
let mut attack_mask = attack_mask ^ utils::rook_attack(queen_pos, !empty);
if let Some(ray) = board_state.pinned_pieces.get(&queen_pos) {
attack_mask &= ray;
}
if *(board_state.opp_check_mask) > 0 {
attack_mask &= board_state.opp_check_mask;
}
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(queen_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(queen_pos), BitPositions(cp_dest) );
}
},
PieceType::King => {
for king_pos in BitPositions(*piece_mask) {
let attack_mask = utils::king_attack(king_pos);
// clear attacked squares
let attack_mask = attack_mask & !board_state.opp_attack_mask;
let ncp_dest = attack_mask & empty;
let cp_dest = attack_mask & oppnt_mask;
// can only castle while not in check
if *(board_state.opp_check_mask) == 0 {
// check short castle rights
if board.castle_rights(forward, true) {
// check that opp does not attack the squares the king will travel over
if (board_state.opp_attack_mask & utils::castle_travel_squares(forward, true) == 0) &&
// and the squares between are not occupied
(!empty & utils::castle_empty_squares(forward, true) == 0) {
let meta = MoveMeta::Castle{ is_short: true };
move_list.push(Move::new(self, &meta, king_pos, 0));
}
}
// check long castle rights
if board.castle_rights(forward, false) {
if (board_state.opp_attack_mask & utils::castle_travel_squares(forward, false) == 0) &&
(!empty & utils::castle_empty_squares(forward, false) == 0) {
let meta = MoveMeta::Castle{ is_short: false };
move_list.push(Move::new(self, &meta, king_pos, 0));
}
}
}
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self, &meta, iter::repeat(king_pos), BitPositions(ncp_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self, &meta, iter::repeat(king_pos), BitPositions(cp_dest) );
}
},
PieceType::Invalid => {},
}
}
}
impl Default for Piece {
fn default() -> Self {
Piece::invalid()
}
}
impl std::fmt::Display for Piece {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.piece_char())
}
}
fn pawn_moves(
forward: bool,
piece_mask: &BitBoard,
valid_mask: &BitBoard,
empty: &BitBoard,
opp_mask: &BitBoard,
enp_target: &u8,
self_: &Piece,
move_list: &mut MoveList
) {
let rank7 = if forward { rank_bb::SEVEN } else { rank_bb::TWO };
let rank8 = if forward { rank_bb::EIGHT } else { rank_bb::ONE };
// direction is reversed since we shift the dest(empty/opponent) squares towards our pawns
let mut dir = if forward { Direction::S } else { Direction::N };
// single pawn push
// valid mask can be the combined pin rays or the check ray
let pp1 = utils::slide(empty & valid_mask, 1, &dir) & piece_mask;
// with promotion
let pp_promo = pp1 & rank7;
// double pawn push
let mut pp2 = if forward { rank_bb::FOUR } else { rank_bb::FIVE };
pp2 = utils::slide(pp2 & empty & valid_mask, 1, &dir) & empty;
pp2 = utils::slide(pp2, 1, &dir) & piece_mask;
// the piece destinations
dir = if forward { Direction::N } else { Direction::S };
let pp1_dest = utils::slide(pp1, 1, &dir);
let pp_promo_dest = pp1_dest & rank8;
let pp2_dest = utils::slide(pp2, 2, &dir);
// normal capture
// forward left capture
dir = if forward { Direction::SE } else { Direction::NW };
let cp_l = utils::slide(opp_mask & valid_mask, 1, &dir) & piece_mask;
// with promotion
let cp_l_promo = cp_l & rank7;
// dest
dir = if forward { Direction::NW } else { Direction::SE };
let cp_l_dest = utils::slide(cp_l, 1, &dir);
let cp_l_promo_dest = cp_l_dest & rank8;
// forward right capture
dir = if forward { Direction::SW } else { Direction::NE };
let cp_r = utils::slide(opp_mask & valid_mask, 1, &dir) & piece_mask;
// with promotion. the promo sqs from cp_r are cleared at gen moves
let cp_r_promo = cp_r & rank7;
// dest
dir = if forward { Direction::NE } else { Direction::SW };
let cp_r_dest = utils::slide(cp_r, 1, &dir);
let cp_r_promo_dest = cp_r_dest & rank8;
// enpassant capture
let mut cp_enp = 0;
let mut cp_enp_dest = 0;
if *enp_target != 0 &&
*valid_mask == utils::ONES // can't enpassant capture to block a check or when pinned
{
cp_enp_dest = if forward { enp_target+8 } else { enp_target-8 };
let dest_mask = utils::pos_mask(cp_enp_dest);
cp_enp = if forward {
utils::slide(dest_mask, 1, &Direction::SW) |
utils::slide(dest_mask, 1, &Direction::SE)
} else {
utils::slide(dest_mask, 1, &Direction::NW) |
utils::slide(dest_mask, 1, &Direction::NE)
} & piece_mask;
}
let meta = MoveMeta::Quiet;
move_list.push_from_forpiece( self_, &meta, BitPositions(pp1 & !rank7), BitPositions(pp1_dest & !rank8) );
move_list.push_from_forpiece( self_, &meta, BitPositions(pp2), BitPositions(pp2_dest) );
let meta = MoveMeta::Capture;
move_list.push_from_forpiece( self_, &meta, BitPositions(cp_l & !rank7), BitPositions(cp_l_dest & !rank8) );
move_list.push_from_forpiece( self_, &meta, BitPositions(cp_r & !rank7), BitPositions(cp_r_dest & !rank8) );
let meta = MoveMeta::Enpassant;
move_list.push_from_forpiece( self_, &meta, BitPositions(cp_enp), iter::repeat(cp_enp_dest) );
// each possible target piecetype for promo is a separate move
for promo_to in &PROMO_TARGETS {
let meta = MoveMeta::Promotion{ is_capture: false, piece_type: *promo_to };
move_list.push_from_forpiece( self_, &meta, BitPositions(pp_promo), BitPositions(pp_promo_dest) );
let meta = MoveMeta::Promotion{ is_capture: true, piece_type: *promo_to };
move_list.push_from_forpiece( self_, &meta, BitPositions(cp_l_promo), BitPositions(cp_l_promo_dest) );
move_list.push_from_forpiece( self_, &meta, BitPositions(cp_r_promo), BitPositions(cp_r_promo_dest) );
}
}
|
/*
* File : command.rs
* Purpose: defines functions which carry out possible user commands
* Program: red
* About : command-line text editor
* Authors: Tommy Lincoln <pajamapants3000@gmail.com>
* License: MIT; See LICENSE!
* Notes : All operation functions have same signature
* Created: 11/05/2016
*/
//! Operations callable by the user during program execution
//!
//! All operations take as arguments the current state.buffer, editor state, and
//! command (these may eventually be condensed into editor state) and return
//! Result<(), RedError>
//!
//! All operations assume that the addresses passed through the command have
//! already been checked for validity and range. This is handled when the
//! command is parsed, and so is a safe assumption.
// *** Bring in to namespace *** {{{
use std::collections::hash_map::HashMap;
use std::process::exit;
use std::io::{Write, BufRead, BufWriter, stdout, StdoutLock, stdin};
use std::ffi::OsStr;
use buf::*;
use error::*;
use parse::*;
use io::get_input;
use ::{EditorState, EditorMode, print_help, print_msg, term_size, Change};
use self::NotableLine::*;
// ^^^ Bring in to namespace ^^^ }}}
// *** Attributes *** {{{
const NUM_OPERATIONS: usize = 27;
const COMMAND_PREFIX: &'static str = "@";
// ^^^ Attributes ^^^ }}}
// *** Constants *** {{{
// ^^^ Constants ^^^ }}}
// *** Data Structures *** {{{
enum NotableLine {
FirstLine,
LastLine,
CurrentLine,
CurrentPlusOneLine,
LineNotApplicable
}
pub struct Operations {
operation_map: HashMap<char, OpData>,
}
struct OpData {
function: Box<Fn( &mut EditorState, Command ) -> Result<(), RedError>>,
default_initial_address: NotableLine,
default_final_address: NotableLine,
}
impl Operations {// {{{
/// Creates Operations HashMap// {{{
pub fn new() -> Operations {// {{{
let mut _operation_map: HashMap<char, OpData> =
HashMap::with_capacity( NUM_OPERATIONS );
// Insert operations and data //{{{
_operation_map.insert( 'a',// {{{
OpData{ function: Box::new(append),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'c',// {{{
OpData{ function: Box::new(change),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'd',// {{{
OpData{ function: Box::new(delete),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'e',// {{{
OpData{ function: Box::new(edit),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'E',// {{{
OpData{ function: Box::new(edit_unsafe),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'f',// {{{
OpData{ function: Box::new(filename),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'g',// {{{
OpData{ function: Box::new(global),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 'G',// {{{
OpData{ function: Box::new(global_interactive),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 'h',// {{{
OpData{ function: Box::new(help_recall),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'H',// {{{
OpData{ function: Box::new(help_tgl),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'i',// {{{
OpData{ function: Box::new(insert),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'j',// {{{
OpData{ function: Box::new(join),
default_initial_address: CurrentLine,
default_final_address:
CurrentPlusOneLine,
}
);// }}}
_operation_map.insert( 'k',// {{{
OpData{ function: Box::new(mark),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'l',// {{{
OpData{ function: Box::new(lines_list),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'm',// {{{
OpData{ function: Box::new(move_lines),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'n',// {{{
OpData{ function: Box::new(print_numbered),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'p',// {{{
OpData{ function: Box::new(print),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'P',// {{{
OpData{ function: Box::new(prompt),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'q',// {{{
OpData{ function: Box::new(quit),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'r',// {{{
OpData{ function: Box::new(read),
default_initial_address: LastLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 's',// {{{
OpData{ function: Box::new(substitute),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 't',// {{{
OpData{ function: Box::new(transfer),
default_initial_address: CurrentLine,
default_final_address: CurrentLine,
}
);// }}}
_operation_map.insert( 'u',// {{{
OpData{ function: Box::new(undo),
default_initial_address:
LineNotApplicable,
default_final_address:
LineNotApplicable,
}
);// }}}
_operation_map.insert( 'v',// {{{
OpData{ function: Box::new(global_inverse),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 'V',// {{{
OpData{ function:
Box::new(global_inverse_interactive),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 'w',// {{{
OpData{ function: Box::new(write_to_disk),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
_operation_map.insert( 'W',// {{{
OpData{ function: Box::new(append_to_disk),
default_initial_address: FirstLine,
default_final_address: LastLine,
}
);// }}}
//}}}
Operations { operation_map: _operation_map }
}// }}}
// }}}
/// Execute command// {{{
pub fn execute( &self, state: &mut EditorState, command: Command )//{{{
-> Result<(), RedError> {
match self.operation_map.contains_key( &command.operation ) {
true => {
let ref op_to_execute = self.operation_map
.get( &command.operation ).unwrap().function;
op_to_execute( state, command )
},
false => {
Err(RedError::InvalidOperation{ operation: command.operation })
},
}
}// }}}
// }}}
/// Execute list of commands at address// {{{
fn execute_list( &self, state: &mut EditorState,// {{{
commands: &str, address: usize ) -> Result<(), RedError> {
for cmd in commands.lines() {
let mut _command: Command;
if cmd.trim().is_empty() {
_command = Command {
address_initial: address,
address_final: address,
operation: 'p',
parameters: "",
operations: &self,
};
} else {
_command = try!( parse_command( cmd, state, &self ));
_command.address_initial = address;
_command.address_final = address;
}
try!( self.execute( state, _command ));
state.buffer.set_current_address( address );
}
Ok( () )
}// }}}
// }}}
}// }}}
// ^^^ Data Structures ^^^ }}}
// *** Functions *** {{{
/// Avoid `unused` warnings for functions that don't modify mode// {{{
fn mode_noop( mode: &mut EditorMode ) -> EditorMode {// {{{
match mode {
&mut EditorMode::Command => EditorMode::Command,
&mut EditorMode::Insert => EditorMode::Insert,
}
}// }}}
// }}}
/// A simple placeholder function for unimplemented features// {{{
fn placeholder( state: &mut EditorState, command: Command)//{{{
-> Result<(), RedError> {
print_msg( state, &format!(
"Operation not yet implemented: {}", command.operation ));
state.mode = mode_noop( &mut state.mode );
match state.buffer.get_file_name() {
Some( file_name ) => {
print_msg( state, &format!(
"Continuing work on {}", file_name.to_str()
.unwrap_or("<invalid UTF-8>")) );
return Err(
RedError::InvalidOperation{ operation: command.operation } );
}
None => {
return Err(
RedError::InvalidOperation{ operation: command.operation } );
}
}
}// }}}
// }}}
fn append( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'a', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
state.buffer.set_current_address( _final );
state.mode = EditorMode::Insert;
Ok( () )
}//}}}
/// Deletes address range and inserts text in its place// {{{
fn change( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'c', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
let delete_command = Command{ address_initial: _initial,
address_final: _final, operation: 'd', parameters: "",
operations: command.operations };
let insert_command = Command{ address_initial: _initial,
address_final: _initial, operation: 'i', parameters: "",
operations: command.operations };
try!( delete( state, delete_command ) );
try!( insert( state, insert_command ) );
Ok( () )
}//}}}
// }}}
fn delete( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'd', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
state.u_deleting_lines( _initial, _final );
for _ in _initial .. ( _final + 1 ) {
// NOTE: lines move as you delete them - don't increment!
try!( state.buffer.delete_line( _initial ) );
}
state.buffer.set_current_address( _initial - 1 );
Ok( () )
}//}}}
fn edit( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'e', command.operation );
let _ = try!( state.buffer.on_close() );
edit_unsafe( state, Command{ address_initial: command.address_initial,
address_final: command.address_final, operation: 'E',
parameters: command.parameters, operations: command.operations, })
}//}}}
fn edit_unsafe( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'E', command.operation );
let content = command.parameters;
if &content[0..1] == COMMAND_PREFIX { // process command
match Buffer::new( BufferInput::Command(content[1..].to_string() )) {
Ok( _buffer ) => {
EditorState::new( _buffer );
},
Err(e) => {
return Err(e);
},
};
print_msg( &state, &format!( "Now editing output of command: {}",
state.buffer.get_file_name()
.unwrap_or( OsStr::new("<untitled>") )
.to_str()
.unwrap_or( "<invalid UTF-8>" ) ));
} else { // process file
match Buffer::new(BufferInput::File( content.to_string() )) {
Ok( _buffer ) => {
state.buffer = _buffer;
},
Err(e) => {
return Err(e);
},
};
print_msg( &state, &format!( "Now editing file: {}",
state.buffer.get_file_name()
.unwrap_or( OsStr::new("<untitled>") )
.to_str()
.unwrap_or( "<invalid UTF-8>" ) ));
}
Ok( () )
}//}}}
fn filename( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'f', command.operation );
if command.parameters == "" {
match state.buffer.get_file_name() {
Some(f) => println!( "filename: {}", f.to_str()
.unwrap_or("<invalid UTF-8>") ),
None => println!( "no filename currently set" ),
}
} else {
try!( state.buffer.set_file( command.parameters ));
}
Ok( () )
}//}}}
/// Execute a set of commands on lines matching pattern
///
/// TODO:
/// * current address handling is a bit simplified for now
/// * creating new operations object may be costly (?)
fn global( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'g', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let ( pattern, commands ) = try!(parse_global_op(command.parameters));
for address in _initial .. _final + 1 {
if state.buffer.does_match( pattern, address ) {
try!( command.operations.execute_list( state, commands, address ));
}
}
Ok( () )
}//}}}
fn global_interactive( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'G', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let mut input: String = String::new();
let mut last_input: String = String::new();
let ( pattern, commands ) = try!(parse_global_op(command.parameters));
// make sure no additional text after /re/
if !commands.is_empty() {
return Err( RedError::ParameterSyntax{
parameter: "global_interactive: ".to_string() +
command.parameters });
}
let prompt_save = state.prompt.clone();
state.prompt = "(G)%".to_string();
for address in _initial .. _final + 1 {
if state.buffer.does_match( pattern, address ) {
state.buffer.set_current_address( address );
print_numbered( state, Command{
address_initial: address,
address_final: address,
operation: 'n',
operations: command.operations,
parameters: "" }).expect(
"global_interactive: line matching regex doesn't exist!" );
input = try!( get_input( input, state ));
if input.trim() == "&" {
input = last_input;
}
try!( command.operations.execute_list( state, &input, address ));
last_input = input;
input = String::new();
}
}
state.prompt = prompt_save;
Ok( () )
}//}}}
fn help_recall( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'h', command.operation );
placeholder( state, command )
}//}}}
fn help_tgl( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'H', command.operation );
state.show_help = !state.show_help;
println!("help output set to {:?}", match state.show_help {
true => "on",
false => "off", });
Ok( () )
}//}}}
fn insert( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'i', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
state.buffer.set_current_address( _final - 1 );
state.mode = EditorMode::Insert;
Ok( () )
}//}}}
fn join( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'j', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
state.u_deleting_lines( _initial, _final );
try!( state.buffer.join_lines( _initial, _final ));
state.u_added_current_line();
Ok( () )
}//}}}
fn mark( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'k', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
// make sure we have been provided a single character for the mark
let param_len = command.parameters.len();
if param_len > 1 || param_len == 0 {
print_help( state, "mark must be a single character" );
return Err( RedError::ParameterSyntax{
parameter: command.parameters.to_string() });
}
let mark_char = match command.parameters.chars().next() {
Some(x) => {
if !( 'a' <= x && x <= 'z' ) {
print_help( state,
"mark must be a lowercase latin character ('a'..'z')" );
return Err( RedError::ParameterSyntax{
parameter: command.parameters.to_string() });
} else {
x
}
},
None => {
print_help( state, "failed to parse mark character" );
return Err( RedError::ParameterSyntax{
parameter: command.parameters.to_string() });
},
};
// if given a section of lines, mark the beginning
state.buffer.set_marker( mark_char, _final );
Ok( () )
}//}}}
// XXX: write built-in implementation in Buffer?
fn lines_list( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'l', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let stdout = stdout();
let handle = stdout.lock();
let mut writer = BufWriter::new( handle );
let mut ch_written: usize = 0;
let line_prefix: &str; // ! to indicate unknown screen size
let term_width: usize;
let term_height: usize;
if let Some((w, h)) = term_size::dimensions() {
line_prefix = "";
term_width = w;
term_height = h;
} else {
line_prefix = "!";
term_width = 0;
term_height = 0;
}
for address in _initial .. _final + 1 {
let line = state.buffer.get_line_content( address ).unwrap_or("");
try!( writer.write( line_prefix.as_bytes() )
.map_err(|_| RedError::Stdout));
ch_written += line_prefix.len();
for ch in line.chars() {
for _ch in ch.escape_default() {
try!( writer.write( &[_ch as u8] )
.map_err(|_| RedError::Stdout));
ch_written += 1;
if line_prefix.len() == 0 && ch_written ==
( term_width - line_prefix.len() ) * ( term_height - 1 ) {
try!( writer.flush().map_err(|_| RedError::Stdout));
prompt_for_more( &mut writer );
}
}
}
try!( writer.write( "$\n".as_bytes() ).map_err(|_| RedError::Stdout));
ch_written += 1;
ch_written += term_width - ( ch_written % term_width );
try!( writer.flush().map_err(|_| RedError::Stdout));
}
Ok( () )
}//}}}
/// Prompts the user to press enter and waits until they do// {{{
fn prompt_for_more( stdout_writer: &mut BufWriter<StdoutLock> ) {// {{{
stdout_writer.write( "--<press enter to continue>--".as_bytes() )
.expect( "prompt_for_more: error writing to stdout" );
stdout_writer.flush().expect( "prompt_for_more: error writing to stdout" );
let stdin = stdin();
let mut handle = stdin.lock();
let mut buf = String::new();
handle.read_line( &mut buf ).expect( "error reading keystroke" );
stdout_writer.write( &['\n' as u8] )
.expect( "prompt_for_more: error writing to stdout" );
}// }}}
// }}}
fn move_lines( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'm', command.operation );
state.u_reset();
state.u_lock();
let mut destination: usize;
let ( _initial, _final ) = default_addrs( state, &command );
state.u_deleting_lines( _initial, _final );
if command.parameters == "0" {
destination = 0;
} else {
destination = try!( parse_address_field( command.parameters, state ))
.unwrap_or( state.buffer.get_current_address() );
}
try!( state.buffer.move_lines( &_initial, &_final, &destination ));
// destination is the address to which lines are appended,
// so it is one less than the first moved line
// if it is anywhere between the moved lines, it ends up just before
// initial
// XXX: wait... doesn't that mean it should be a no-op?
// save that for next update - this works for now.
if (_initial-1) <= destination && destination <= _final {
destination = _initial - 1;
}
// we adjust dest. not by the diff, but num lines (hence the extra 1)
if _final < destination && destination <= state.buffer.num_lines() {
destination = destination - ( 1 + _final - _initial );
}
state.buffer.set_current_address( destination + 1 + ( _final - _initial ));
state.u_added_lines( destination + 1,
destination + 1 + ( _final - _initial ));
Ok( () )
}//}}}
// XXX: write built-in implementation in Buffer?
fn print_numbered( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'n', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let num_lines_f: f64 = state.buffer.num_lines() as f64 + 1.0_f64;
let _width = num_lines_f.log10().ceil() as usize;
for ( _num, _line ) in state.buffer.lines_iterator().enumerate()
.skip( _initial - 1 )
.take(( _final + 1 ) - _initial )
.map( |(x, y)| ( x+1, y )) {
print!( "{:width$}|", _num, width = _width );
println!("{}", _line );
}
state.buffer.set_current_address( _final );
Ok( () )
}//}}}
/// Display range of lines of state.buffer in terminal // {{{
///
/// Caller will choose the start and finish addresses to fit
/// the range of the state.buffer; For example, if the user tries
/// to print beyond the end of the state.buffer, address_final will
/// be the address of the last line of the state.buffer (in other
/// words, the lines number of the last line)
///
/// # Panics
/// if println! panics, which happens if it fails to write
/// to io::stdout()
///
fn print( state: &mut EditorState, command: Command )//{{{
-> Result<(), RedError> {
assert_eq!( 'p', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
for indx in _initial .. ( _final + 1 ) {
println!("{}", state.buffer.get_line_content( indx ).expect(
"ops::print: called get_line_content on out-of-range line" ) );
}
state.buffer.set_current_address( _final );
// TODO: Drop this? Or Keep to avoid unused warnings?
state.mode = EditorMode::Command;
Ok( () )
}// }}}
// }}}
/// Toggles (sets?) commant prompt
fn prompt( state: &mut EditorState, command: Command )//{{{
-> Result<(), RedError> {
assert_eq!( 'p', command.operation );
placeholder( state, command )
}// }}}
// }}}
/// Exit program// {{{
///
/// Make sure all state.buffers have been saved
///
/// Delete all temprary storage
fn quit( state: &mut EditorState, command: Command )//{{{
-> Result<(), RedError> {
assert_eq!( 'q', command.operation );
match state.buffer.on_close() {
Ok( _ ) => exit( error_code( RedError::Quit ) as i32),
Err( _ ) => exit( error_code( RedError::NoDestruct ) as i32),
}
}// }}}
//}}}
fn read( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'r', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
placeholder( state, command )
}//}}}
fn substitute( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 's', command.operation );
state.u_reset();
state.u_lock();
let ( _initial, _final ) = default_addrs( state, &command );
state.u_deleting_lines( _initial, _final );
let sub_parms: Substitution = try!( parse_substitution_parameter(
command.parameters ));
state.buffer.substitute( &sub_parms.to_match, &sub_parms.to_sub,
sub_parms.which, _initial, _final );
state.u_added_lines( _initial, _final );
Ok( () )
}//}}}
fn transfer( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 't', command.operation );
state.u_reset();
state.u_lock();
let destination: usize;
let ( _initial, _final ) = default_addrs( state, &command );
if command.parameters == "0" {
destination = 0;
} else {
destination = try!(parse_address_field(command.parameters, state ))
.unwrap_or(state.buffer.get_current_address() );
}
try!( state.buffer.copy_lines( _initial, _final, destination ));
state.u_added_lines( destination + 1,
destination + 1 + ( _final - _initial ));
Ok( () )
}//}}}
fn undo( state: &mut EditorState, command: Command )
-> Result<(), RedError> {// {{{
assert_eq!( 'u', command.operation );
let address = state.u_get_wascurrent_address();
let markers = state.u_get_markers();
let mut changes = state.u_get_changes();
state.u_unlock();
state.u_reset();
state.u_lock();
loop {
match changes.pop() {
Some( Change::Add{ address: _address }) => {
state.u_deleting_line( _address );
try!( state.buffer.delete_line( _address ) );
},
Some( Change::Remove{ address: _address, content: _content }) => {
state.u_added_line( _address );
state.buffer.append_line( _address - 1, &_content );
},
None => break,
}
}
state.buffer.set_current_address( address );
for indx in ( 'a' as u8 ) .. ( 'z' as u8 ) + 1 {
state.buffer.set_marker( indx as char,
markers[ ( indx as usize ) - ( 'a' as usize ) ] );
}
Ok( () )
}//}}}
fn global_inverse( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'v', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let ( pattern, commands ) = try!(parse_global_op(command.parameters));
for address in _initial .. _final + 1 {
if !state.buffer.does_match( pattern, address ) {
try!( command.operations.execute_list( state, commands, address ));
}
}
Ok( () )
}//}}}
fn global_inverse_interactive( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'V', command.operation );
let ( _initial, _final ) = default_addrs( state, &command );
let mut input: String = String::new();
let mut last_input: String = String::new();
let ( pattern, commands ) = try!(parse_global_op(command.parameters));
// make sure no additional text after /re/
if !commands.is_empty() {
return Err( RedError::ParameterSyntax{
parameter: "global_interactive: ".to_string() +
command.parameters });
}
let prompt_save = state.prompt.clone();
state.prompt = "(G)%".to_string();
for address in _initial .. _final + 1 {
if !state.buffer.does_match( pattern, address ) {
state.buffer.set_current_address( address );
print_numbered( state, Command{
address_initial: address,
address_final: address,
operation: 'n',
operations: command.operations,
parameters: "" }).expect(
"global_interactive: line matching regex doesn't exist!" );
input = try!( get_input( input, state ));
if input.trim() == "&" {
input = last_input;
}
try!( command.operations.execute_list( state, &input, address ));
last_input = input;
input = String::new();
}
}
state.prompt = prompt_save;
Ok( () )
}//}}}
/// Write state.buffer to file// {{{
fn write_to_disk( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'w', command.operation );
// TODO: Drop this? Or Keep to avoid unused warnings?
state.mode = EditorMode::Command;
let ( _initial, _final ) = default_addrs( state, &command );
state.buffer.write_to_disk( command.parameters, false, _initial, _final )
}// }}}
// }}}
fn append_to_disk( state: &mut EditorState,//{{{
command: Command ) -> Result<(), RedError> {
assert_eq!( 'W', command.operation );
// TODO: Drop this? Or Keep to avoid unused warnings?
state.mode = EditorMode::Command;
let ( _initial, _final ) = default_addrs( state, &command );
state.buffer.write_to_disk( command.parameters, true, _initial, _final )
}//}}}
/// Return pair of lines, either original or the specified defaults// {{{
///
/// Defaults are used if both original integers are 0;
/// Also fixes lower address to be 1 instead of zero if an otherwise
/// suitable range is provided;
fn default_addrs( state: &EditorState, command: &Command ) -> (usize, usize) {// {{{
let default_i = match command.operations.operation_map
.get( &command.operation ).unwrap().default_initial_address {
FirstLine => 1,
LastLine => state.buffer.num_lines(),
CurrentLine => state.buffer.get_current_address(),
CurrentPlusOneLine => state.buffer.get_current_address() + 1,
LineNotApplicable => 1,
};
let default_f = match command.operations.operation_map
.get( &command.operation ).unwrap().default_final_address {
FirstLine => 1,
LastLine => state.buffer.num_lines(),
CurrentLine => state.buffer.get_current_address(),
CurrentPlusOneLine => state.buffer.get_current_address() + 1,
LineNotApplicable => 1,
};
if command.address_initial == 0 {
if command.address_final == 0 {
( default_i, default_f )
} else {
( 1, command.address_final )
}
} else {
( command.address_initial, command.address_final )
}
}// }}}
// }}}
// ^^^ Functions ^^^ }}}
|
#![feature(trait_alias)]
use std::ops::Add;
trait Id = Eq + Clone;
trait Quantity = Add<Output = Self> + Clone;
#[derive(Clone, Copy, Debug)]
struct Stock<I, Q> {
id: I,
qty: Q,
}
impl<I: Id, Q: Quantity> Add for Stock<I, Q> {
type Output = Self;
fn add(self, other: Self) -> Self::Output {
if self.id == other.id {
Self {
id: self.id.clone(),
qty: self.qty + other.qty,
}
} else {
self
}
}
}
fn plus<T: Add<Output = T>>(a: T, b: T) -> T {
a + b
}
fn main() {
let a = Stock { id: "s1", qty: 10 };
let b = Stock { id: "s1", qty: 5 };
let c = Stock { id: "s2", qty: 3 };
println!("a + b = {:?}", a + b);
println!("plus(a, b) = {:?}", plus(a, b));
println!("a + c = {:?}", a + c);
}
|
use sort;
fn main() {
let vec = sort::generate_random_numbers(1000);
sort::run(&vec);
}
|
use crate::Match;
/// A matcher string that matched during a scan.
#[derive(Debug)]
pub struct YrString<'a> {
/// Name of the string, with the '$'.
pub identifier: &'a str,
/// Matches of the string for the scan.
pub matches: Vec<Match>,
}
|
// Copyright 2018 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};
use fuchsia_syslog::macros::*;
use serde_json::{to_value, Value};
use std::sync::Arc;
// Testing helper methods
use crate::wlan::facade::WlanFacade;
// Takes ACTS method command and executes corresponding FIDL method
// Packages result into serde::Value
pub async fn wlan_method_to_fidl(
method_name: String,
args: Value,
wlan_facade: Arc<WlanFacade>,
) -> Result<Value, Error> {
match method_name.as_ref() {
"scan" => {
fx_log_info!(tag: "WlanFacade", "performing wlan scan");
let results = wlan_facade.scan().await?;
fx_log_info!(tag: "WlanFacade", "received {:?} scan results", results.len());
// return the scan results
to_value(results).map_err(|e| format_err!("error handling scan results: {}", e))
}
"connect" => {
let target_ssid = match args.get("target_ssid") {
Some(ssid) => {
let ssid = match ssid.as_str() {
Some(ssid) => ssid.as_bytes().to_vec(),
None => {
bail!("Please provide a target ssid");
}
};
ssid
}
None => bail!("Please provide a target ssid"),
};
let target_pwd = match args.get("target_pwd") {
Some(pwd) => match pwd.clone().as_str() {
Some(pwd) => pwd.as_bytes().to_vec(),
None => {
fx_log_info!(tag: "WlanFacade", "Please check provided password");
vec![0; 0]
}
},
_ => vec![0; 0],
};
fx_log_info!(tag: "WlanFacade", "performing wlan connect to SSID: {:?}", target_ssid);
let results = wlan_facade.connect(target_ssid, target_pwd).await?;
to_value(results).map_err(|e| format_err!("error handling connection result: {}", e))
}
"disconnect" => {
fx_log_info!(tag: "WlanFacade", "performing wlan disconnect");
wlan_facade.disconnect().await?;
to_value(true).map_err(|e| format_err!("error handling disconnect: {}", e))
}
"status" => {
fx_log_info!(tag: "WlanFacade", "fetching connection status");
let result = wlan_facade.status().await?;
to_value(result).map_err(|e| format_err!("error handling connection status: {}", e))
}
_ => return Err(format_err!("unsupported command!")),
}
}
|
use crate::{Section, SectionLayout, GenericObject, DrawCall};
pub struct World {
section_size: f64,
locations: Vec<(i32, i32)>,
sections: Vec<Section>,
general_layout: SectionLayout,
static_objects: Vec<Box<dyn GenericObject>>,
}
// -x = right
// +x = left
// -z = up/away
// +z = down/towards
impl World {
pub fn new(section_size: f64) -> World {
let mut locations = vec!(
( 1, -2), ( 0, -2), (-1, -2),
( 2, -1), ( 1, -1), ( 0, -1), (-1, -1), (-2, -1), (-3, -1), (-4, -1), (-5, -1),
( 1, 0), ( 0, 0), (-1, 0), (-2, 0), (-3, 0), (-4, 0), (-5, 0),
( 2, 1), ( 1, 1), ( 0, 1), (-1, 1), (-2, 1), (-3, 1), (-4, 1), (-5, 1),
( 1, 2), (-1, 2)
);
let mut sections = vec!(
Section::new( 1, -2, section_size).floor().front_wall().left_wall().right_wall(),
Section::new( 0, -2, section_size),
Section::new(-1, -2, section_size).floor().front_wall().left_wall().right_wall(),
Section::new( 2, -1, section_size).floor().right_wall().front_wall().back_wall(),
Section::new( 1, -1, section_size),
Section::new( 0, -1, section_size),
Section::new(-1, -1, section_size),
Section::new(-2, -1, section_size),
Section::new(-3, -1, section_size).floor().back_wall().left_wall(),
Section::new(-4, -1, section_size).floor(),
Section::new(-5, -1, section_size).floor().back_wall(),
Section::new( 1, 0, section_size),
Section::new( 0, 0, section_size).floor().left_wall().front_wall().back_wall(),
Section::new(-1, 0, section_size).floor().front_wall().back_wall(),
Section::new(-2, 0, section_size).floor().front_wall().back_wall(),
Section::new(-3, 0, section_size).floor(),
Section::new(-4, 0, section_size).floor(),
Section::new(-5, 0, section_size).floor().right_wall(),
Section::new( 2, 1, section_size).floor().right_wall().front_wall().back_wall(),
Section::new( 1, 1, section_size),
Section::new( 0, 1, section_size),
Section::new(-1, 1, section_size),
Section::new(-2, 1, section_size),
Section::new(-3, 1, section_size).floor().left_wall().front_wall(),
Section::new(-4, 1, section_size).floor(),
Section::new(-5, 1, section_size).floor().front_wall(),
Section::new( 1, 2, section_size).floor().back_wall().left_wall().right_wall(),
Section::new(-1, 2, section_size).floor().back_wall().left_wall().right_wall(),
);
let mut static_objects: Vec<Box<dyn GenericObject>> = Vec::new();
for section in &mut sections {
static_objects.append(&mut (section.static_objects()));
}
World {
section_size,
locations,
sections,
general_layout: SectionLayout::grid(section_size),
static_objects,
}
}
pub fn xz_from_grid_index(&self, x: i32, z: i32) -> (f64, f64) {
(x as f64 * self.section_size, z as f64 * self.section_size)
}
pub fn calculate_grid_area_indexs(&self, x: f64, z: f64, range: u32) -> Vec<(i32, i32)> {
let mut grid_indexs = Vec::new();
let (center_x, center_z) = self.calculate_grid_index(x, z);
println!("Center x {} z {}", center_x, center_z);
for i in 0..range {
for j in 0..range {
let e_x = center_x+i as i32-(range as f32*0.5).floor() as i32;
let e_z = center_z+j as i32-(range as f32*0.5).floor() as i32;
if e_x == center_x && e_z == center_z {
} else {
grid_indexs.push((e_x, e_z));
}
//let x = e_x * self.size;
//let z = e_z * self.size;
//grid_indexs.push(new_section);
}
}
grid_indexs
}
pub fn calculate_grid_index(&self, x: f64, z: f64) -> (i32, i32) {
let grid_x = x / self.section_size;
let grid_z = z / self.section_size;
(grid_x as i32, grid_z as i32)
}
pub fn load_area(&mut self, x: i32, z: i32, range: u32) -> Vec<Section> {
let mut new_sections = Vec::new();
for i in 0..range {
for j in 0..range {
if let Some(new_section) = self.load_section(x+i as i32-(range as f32*0.5).floor() as i32, z+j as i32-(range as f32*0.5).floor() as i32) {
new_sections.push(new_section);
}
}
}
new_sections
}
pub fn load_section(&mut self, x: i32, y: i32) -> Option<Section> {
let mut new_section = None;
let location_loaded = self.locations.clone().into_iter().filter(|(x1, y1)| x == *x1 && y == *y1).map(|x| true).collect::<Vec<bool>>().len() > 0;
if !location_loaded {
let mut section = self.general_layout.get_section(x,y);
self.locations.push((x, y));
section.set_pos(x,y);
self.static_objects.append(&mut section.clone().static_objects());
self.sections.push(section.clone());
new_section = Some(section);
}
new_section
}
pub fn section_at_xz(&mut self, x: i32, z: i32) -> Option<Section> {
let mut section = None;
let mut index: i32 = -1;
for i in 0..self.locations.len() {
if self.locations[i] == (x, z) {
index = i as i32;
}
}
if index != -1 {
section = Some(self.sections[index as usize].clone());
}
section
}
pub fn objects(&self) -> &Vec<Box<dyn GenericObject>> {
&self.static_objects
}
pub fn mut_objects(&mut self) -> &mut Vec<Box<dyn GenericObject>> {
&mut self.static_objects
}
pub fn draw(&self, draw_calls: &mut Vec<DrawCall>) {
for object in &self.static_objects {
object.draw(true, draw_calls);
}
}
}
|
use std::fs;
use std::cmp::min;
use std::time::Instant;
use std::collections::BTreeSet;
fn optimized_solution_part1(numbers: Vec<u16>) -> () {
let (mut low, high): (Vec<u16>, Vec<u16>) = numbers.iter().partition(|&&x| x <= (2020 / 2));
let mut n: usize = min(low.len(), high.len());
if n == 0 {
assert!(low.len() >= 2);
let last_low: u16 = *low.last().expect("Something was wrong, there should be an index here");
low.pop();
let last_last_low: u16 = *low.last().expect("Something was wrong, there should be an index here");
assert_eq!(last_last_low, last_low);
assert_eq!(last_last_low, 1010);
println!("Found 1010 twice ! {}", last_last_low * last_low);
}
let mut last_index: usize = 0;
while n > 0 {
let last_low: u16 = *low.last().expect("Something was wrong, there should be an index here");
low.pop();
for i in last_index..high.len() {
let current_high: u16 = *high.get(i).expect("Something was wrong, there should be an index here");
if last_low + current_high == 2020 {
println!("Found {} and {} which makes {}", last_low, current_high, last_low * current_high);
return;
}
if last_low + current_high > 2020 {
// we know that this low is not that good so we can discard it
break;
} else {
last_index = i;
}
}
n -= 1;
}
println!("Found no solution ;(");
}
fn optimized_solution_part1_hashset(numbers: Vec<u16>) -> () {
let mut s: BTreeSet<u16> = BTreeSet::new();
for i in 0..numbers.len() {
let current = *numbers.get(i).expect("Something was wrong, there should be an index here");
let diff = 2020 - current;
if s.contains(&diff) {
println!("Found {} and {} which makes {}", diff, current, diff * current);
return;
}
s.insert(current);
}
println!("Found no solution ;(");
}
fn dumb_solution_part1(numbers: Vec<u16>) {
for i in 0..numbers.len() {
let outer: u16 = *numbers.get(i).expect("Something was wrong, there should be an index here");
for j in i..numbers.len() {
let inner: u16 = *numbers.get(j).expect("Something was wrong, there should be an index here");
if inner + outer == 2020 {
println!("Found {} and {} which makes {}", outer, inner, outer * inner);
return;
}
}
}
println!("Found no solution ;(");
}
fn dumb_solution_part2(numbers: Vec<u16>) {
for i in 0..numbers.len() {
let n1: u16 = *numbers.get(i).expect("Something was wrong, there should be an index here");
for j in i..numbers.len() {
let n2: u16 = *numbers.get(j).expect("Something was wrong, there should be an index here");
for k in j..numbers.len() {
let n3: u16 = *numbers.get(k).expect("Something was wrong, there should be an index here");
if n1 + n2 + n3 == 2020 {
println!("Found {}, {} and {} which makes {}", n1, n2, n3, (n1 as u64).wrapping_mul(n2 as u64).wrapping_mul(n3 as u64));
return;
}
}
}
}
println!("Found no solution ;(");
}
fn optimized_solution_part2_hashset(numbers: Vec<u16>) -> () {
let n = numbers.len();
let mut last: u16 = 0u16;
for i in 0..n - 2 {
let n1: u16 = *numbers.get(i).expect("Something was wrong, there should be an index here");
if last == n1 {
continue;
}
last = n1;
let mut s: BTreeSet<u16> = BTreeSet::new();
for j in i+1..numbers.len() {
let n2 = *numbers.get(j).expect("Something was wrong, there should be an index here");
if n1 + n2 > 2020 {
break;
}
let diff = 2020 - n1 - n2;
if s.contains(&diff) {
println!("Found {}, {} and {} which makes {}", n1, n2, diff, (n1 as u64).wrapping_mul(n2 as u64).wrapping_mul(diff as u64));
return;
}
s.insert(n1 );
s.insert(n2 );
}
}
}
fn optimized_solution_part2(numbers: Vec<u16>) -> () {
let n = numbers.len();
for i in 0..n - 2 {
let a = *numbers.get(i).expect("Something was wrong, there should be an index here");
let mut start = i + 1;
let mut end = n - 1;
while start < end {
let b = *numbers.get(start).expect("Something was wrong, there should be an index here");
let c = *numbers.get(end).expect("Something was wrong, there should be an index here");
if a + b + c == 2020 {
println!("Found {}, {} and {} which makes {}", a, b, c, (a as u64).wrapping_mul(b as u64).wrapping_mul(c as u64));
start = start + 1;
end = end - 1;
return;
} else if a + b + c > 2020 {
end = end - 1;
} else {
start = start + 1;
}
}
}
println!("Found no solution ;(");
}
fn main() {
let input = fs::read_to_string("input/test.txt")
.expect("Something went wrong reading the file");
let lines = input.lines();
let mut numbers: Vec<u16> = vec![];
for line in lines {
numbers.push(line.parse::<u16>().expect("Ouf that's not a number !"))
}
// this is the key part
numbers.sort();
println!("Running dumb solution part1");
let now = Instant::now();
dumb_solution_part1(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
println!("Running optimized solution part1");
let now = Instant::now();
optimized_solution_part1(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
println!("Running optimized solution part1 hashset");
let now = Instant::now();
optimized_solution_part1_hashset(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
println!("Running dumb solution part2");
let now = Instant::now();
dumb_solution_part2(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
println!("Running optimized solution part2");
let now = Instant::now();
optimized_solution_part2(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
println!("Running optimized solution part2 hashset");
let now = Instant::now();
optimized_solution_part2_hashset(numbers.clone());
println!("Took {}us", now.elapsed().as_micros());
}
|
use ndarray::{arr2, Array2};
use num_complex::{Complex, Complex32};
/// Representation of a quantum gate.
#[derive(Clone, Debug, PartialEq)]
pub struct Gate {
pub inner: Array2<Complex32>,
}
impl Gate {
/// Produces the Identity gate.
pub fn identity() -> Self {
let matrix = arr2(&[
[Complex32::new(1.0, 0.0), Complex32::new(0.0, 0.0)],
[Complex32::new(0.0, 0.0), Complex32::new(1.0, 0.0)],
]);
Self { inner: matrix }
}
/// Produces the Hadamard gate.
pub fn hadamard() -> Self {
let sqrt2 = 2.0_f32.sqrt();
let mut matrix = arr2(&[
[Complex32::new(1.0, 0.0), Complex32::new(1.0, 0.0)],
[Complex32::new(1.0, 0.0), Complex32::new(-1.0, 0.0)],
]);
Self {
inner: matrix.map_mut(|c| c.unscale(sqrt2)),
}
}
/// Produces the Pauli-X gate, the analog of the classical NOT gate.
pub fn pauli_x() -> Self {
let matrix = arr2(&[
[Complex32::new(0.0, 0.0), Complex32::new(1.0, 0.0)],
[Complex32::new(1.0, 0.0), Complex32::new(0.0, 0.0)],
]);
Self { inner: matrix }
}
/// Produces the Pauli-Y gate, the analog of the classical NOT gate.
pub fn pauli_y() -> Self {
let matrix = arr2(&[
[Complex32::new(0.0, 0.0), -Complex::i()],
[Complex::i(), Complex32::new(0.0, 0.0)],
]);
Self { inner: matrix }
}
/// Produces the Pauli-Z gate, the analog of the classical NOT gate.
pub fn pauli_z() -> Self {
let matrix = arr2(&[
[Complex32::new(1.0, 0.0), Complex32::new(0.0, 0.0)],
[Complex32::new(0.0, 0.0), -Complex32::new(1.0, 0.0)],
]);
Self { inner: matrix }
}
}
|
use std::fs::File;
use std::io::prelude::*;
use std::path::Path;
type ButtonLine = (u8, u8, u8);
const BUTTONS: [[char; 3]; 3] = [['1', '2', '3'], ['4', '5', '6'], ['7', '8', '9']];
const EXTENDED_BUTTONS: [[char; 5]; 5] = [['0', '0', '1', '0', '0'],
['0', '2', '3', '4', '0'],
['5', '6', '7', '8', '9'],
['0', 'A', 'B', 'C', '0'],
['0', '0', 'D', '0', '0']];
fn get_button_coords(start_on: &(usize, usize), steps: &str) -> (usize, usize) {
let mut x = start_on.0;
let mut y = start_on.1;
for direction in steps.chars() {
match direction {
'U' if y > 0 => y -= 1,
'D' if y < 2 => y += 1,
'L' if x > 0 => x -= 1,
'R' if x < 2 => x += 1,
_ => {}
}
}
(x, y)
}
fn get_extended_button_coords(start_on: &(usize, usize), steps: &str) -> (usize, usize) {
let mut x = start_on.0;
let mut y = start_on.1;
for direction in steps.chars() {
match direction {
'U' if y > 0 && EXTENDED_BUTTONS[y - 1][x] != '0' => y -= 1,
'D' if y < 4 && EXTENDED_BUTTONS[y + 1][x] != '0' => y += 1,
'L' if x > 0 && EXTENDED_BUTTONS[y][x - 1] != '0' => x -= 1,
'R' if x < 4 && EXTENDED_BUTTONS[y][x + 1] != '0' => x += 1,
_ => {}
}
}
(x, y)
}
macro_rules! print_buttons {
( $( [$func_name:ident, $steps_instr:expr, $buttons:expr]; )+ ) => {
{
$(
let mut buttons_list: Vec<char> = vec!();
let start_from: (usize, usize) = (1, 1);
for steps in $steps_instr.trim().lines() {
let start_from = $func_name(&start_from, steps);
buttons_list.push($buttons[start_from.1][start_from.0]);
}
println!("Buttons: {:?}", buttons_list);
)*
}
};
}
fn main() {
let path = Path::new("data/input.txt");
let mut file = File::open(&path).expect("File read error");
let mut s = String::new();
file.read_to_string(&mut s).unwrap();
print_buttons!([get_button_coords, s, BUTTONS];
[get_extended_button_coords, s, EXTENDED_BUTTONS];);
}
#[test]
fn test_get_button_coords() {
let start: (u8, u8) = (1, 1);
assert_eq!(get_button_coords(&start, "ULL"), (0, 0)); // 1
assert_eq!(get_button_coords(&(0, 0), "RRDDD"), (2, 2)); // 9
assert_eq!(get_button_coords(&(2, 2), "LURDL"), (1, 2)); // 8
assert_eq!(get_button_coords(&(1, 2), "UUUUD"), (1, 1)); // 5
}
|
// Code generated by software.amazon.smithy.rust.codegen.smithy-rs. DO NOT EDIT.
pub fn parse_http_generic_error(
response: &http::Response<bytes::Bytes>,
) -> Result<smithy_types::Error, smithy_json::deserialize::Error> {
crate::json_errors::parse_generic_error(response.body(), response.headers())
}
pub fn deser_structure_limit_exceeded_exceptionjson_err(
input: &[u8],
mut builder: crate::error::limit_exceeded_exception::Builder,
) -> Result<crate::error::limit_exceeded_exception::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Message" => {
builder = builder.set_message(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_structure_resource_not_found_exceptionjson_err(
input: &[u8],
mut builder: crate::error::resource_not_found_exception::Builder,
) -> Result<crate::error::resource_not_found_exception::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Message" => {
builder = builder.set_message(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_structure_resource_unavailable_exceptionjson_err(
input: &[u8],
mut builder: crate::error::resource_unavailable_exception::Builder,
) -> Result<crate::error::resource_unavailable_exception::Builder, smithy_json::deserialize::Error>
{
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Message" => {
builder = builder.set_message(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_create_connection(
input: &[u8],
mut builder: crate::output::create_connection_output::Builder,
) -> Result<crate::output::create_connection_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"ConnectionArn" => {
builder = builder.set_connection_arn(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Tags" => {
builder = builder.set_tags(crate::json_deser::deser_list_tag_list(tokens)?);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_create_host(
input: &[u8],
mut builder: crate::output::create_host_output::Builder,
) -> Result<crate::output::create_host_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"HostArn" => {
builder = builder.set_host_arn(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Tags" => {
builder = builder.set_tags(crate::json_deser::deser_list_tag_list(tokens)?);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_get_connection(
input: &[u8],
mut builder: crate::output::get_connection_output::Builder,
) -> Result<crate::output::get_connection_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Connection" => {
builder = builder
.set_connection(crate::json_deser::deser_structure_connection(tokens)?);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_get_host(
input: &[u8],
mut builder: crate::output::get_host_output::Builder,
) -> Result<crate::output::get_host_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Name" => {
builder = builder.set_name(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Status" => {
builder = builder.set_status(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ProviderType" => {
builder = builder.set_provider_type(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| {
s.to_unescaped()
.map(|u| crate::model::ProviderType::from(u.as_ref()))
})
.transpose()?,
);
}
"ProviderEndpoint" => {
builder = builder.set_provider_endpoint(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"VpcConfiguration" => {
builder = builder.set_vpc_configuration(
crate::json_deser::deser_structure_vpc_configuration(tokens)?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_list_connections(
input: &[u8],
mut builder: crate::output::list_connections_output::Builder,
) -> Result<crate::output::list_connections_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Connections" => {
builder = builder.set_connections(
crate::json_deser::deser_list_connection_list(tokens)?,
);
}
"NextToken" => {
builder = builder.set_next_token(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_list_hosts(
input: &[u8],
mut builder: crate::output::list_hosts_output::Builder,
) -> Result<crate::output::list_hosts_output::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Hosts" => {
builder =
builder.set_hosts(crate::json_deser::deser_list_host_list(tokens)?);
}
"NextToken" => {
builder = builder.set_next_token(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_operation_list_tags_for_resource(
input: &[u8],
mut builder: crate::output::list_tags_for_resource_output::Builder,
) -> Result<crate::output::list_tags_for_resource_output::Builder, smithy_json::deserialize::Error>
{
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Tags" => {
builder = builder.set_tags(crate::json_deser::deser_list_tag_list(tokens)?);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_structure_conflict_exceptionjson_err(
input: &[u8],
mut builder: crate::error::conflict_exception::Builder,
) -> Result<crate::error::conflict_exception::Builder, smithy_json::deserialize::Error> {
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Message" => {
builder = builder.set_message(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn deser_structure_unsupported_operation_exceptionjson_err(
input: &[u8],
mut builder: crate::error::unsupported_operation_exception::Builder,
) -> Result<crate::error::unsupported_operation_exception::Builder, smithy_json::deserialize::Error>
{
let mut tokens_owned =
smithy_json::deserialize::json_token_iter(crate::json_deser::or_empty_doc(input))
.peekable();
let tokens = &mut tokens_owned;
smithy_json::deserialize::token::expect_start_object(tokens.next())?;
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Message" => {
builder = builder.set_message(
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
if tokens.next().is_some() {
return Err(smithy_json::deserialize::Error::custom(
"found more JSON tokens after completing parsing",
));
}
Ok(builder)
}
pub fn or_empty_doc(data: &[u8]) -> &[u8] {
if data.is_empty() {
b"{}"
} else {
data
}
}
#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_tag_list<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<crate::model::Tag>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartArray { .. }) => {
let mut items = Vec::new();
loop {
match tokens.peek() {
Some(Ok(smithy_json::deserialize::Token::EndArray { .. })) => {
tokens.next().transpose().unwrap();
break;
}
_ => {
let value = crate::json_deser::deser_structure_tag(tokens)?;
if let Some(value) = value {
items.push(value);
}
}
}
}
Ok(Some(items))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start array or null",
)),
}
}
pub fn deser_structure_connection<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Connection>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::model::Connection::builder();
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"ConnectionName" => {
builder = builder.set_connection_name(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ConnectionArn" => {
builder = builder.set_connection_arn(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ProviderType" => {
builder = builder.set_provider_type(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| {
s.to_unescaped()
.map(|u| crate::model::ProviderType::from(u.as_ref()))
})
.transpose()?,
);
}
"OwnerAccountId" => {
builder = builder.set_owner_account_id(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ConnectionStatus" => {
builder = builder.set_connection_status(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| {
s.to_unescaped().map(|u| {
crate::model::ConnectionStatus::from(u.as_ref())
})
})
.transpose()?,
);
}
"HostArn" => {
builder = builder.set_host_arn(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
Ok(Some(builder.build()))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start object or null",
)),
}
}
pub fn deser_structure_vpc_configuration<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::VpcConfiguration>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::model::VpcConfiguration::builder();
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"VpcId" => {
builder = builder.set_vpc_id(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"SubnetIds" => {
builder = builder.set_subnet_ids(
crate::json_deser::deser_list_subnet_ids(tokens)?,
);
}
"SecurityGroupIds" => {
builder = builder.set_security_group_ids(
crate::json_deser::deser_list_security_group_ids(tokens)?,
);
}
"TlsCertificate" => {
builder = builder.set_tls_certificate(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
Ok(Some(builder.build()))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start object or null",
)),
}
}
#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_connection_list<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<crate::model::Connection>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartArray { .. }) => {
let mut items = Vec::new();
loop {
match tokens.peek() {
Some(Ok(smithy_json::deserialize::Token::EndArray { .. })) => {
tokens.next().transpose().unwrap();
break;
}
_ => {
let value = crate::json_deser::deser_structure_connection(tokens)?;
if let Some(value) = value {
items.push(value);
}
}
}
}
Ok(Some(items))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start array or null",
)),
}
}
#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_host_list<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<crate::model::Host>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartArray { .. }) => {
let mut items = Vec::new();
loop {
match tokens.peek() {
Some(Ok(smithy_json::deserialize::Token::EndArray { .. })) => {
tokens.next().transpose().unwrap();
break;
}
_ => {
let value = crate::json_deser::deser_structure_host(tokens)?;
if let Some(value) = value {
items.push(value);
}
}
}
}
Ok(Some(items))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start array or null",
)),
}
}
pub fn deser_structure_tag<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Tag>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::model::Tag::builder();
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Key" => {
builder = builder.set_key(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"Value" => {
builder = builder.set_value(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
Ok(Some(builder.build()))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start object or null",
)),
}
}
#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_subnet_ids<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<std::string::String>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartArray { .. }) => {
let mut items = Vec::new();
loop {
match tokens.peek() {
Some(Ok(smithy_json::deserialize::Token::EndArray { .. })) => {
tokens.next().transpose().unwrap();
break;
}
_ => {
let value =
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?;
if let Some(value) = value {
items.push(value);
}
}
}
}
Ok(Some(items))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start array or null",
)),
}
}
#[allow(clippy::type_complexity, non_snake_case)]
pub fn deser_list_security_group_ids<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<std::vec::Vec<std::string::String>>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartArray { .. }) => {
let mut items = Vec::new();
loop {
match tokens.peek() {
Some(Ok(smithy_json::deserialize::Token::EndArray { .. })) => {
tokens.next().transpose().unwrap();
break;
}
_ => {
let value =
smithy_json::deserialize::token::expect_string_or_null(tokens.next())?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?;
if let Some(value) = value {
items.push(value);
}
}
}
}
Ok(Some(items))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start array or null",
)),
}
}
pub fn deser_structure_host<'a, I>(
tokens: &mut std::iter::Peekable<I>,
) -> Result<Option<crate::model::Host>, smithy_json::deserialize::Error>
where
I: Iterator<
Item = Result<smithy_json::deserialize::Token<'a>, smithy_json::deserialize::Error>,
>,
{
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::ValueNull { .. }) => Ok(None),
Some(smithy_json::deserialize::Token::StartObject { .. }) => {
#[allow(unused_mut)]
let mut builder = crate::model::Host::builder();
loop {
match tokens.next().transpose()? {
Some(smithy_json::deserialize::Token::EndObject { .. }) => break,
Some(smithy_json::deserialize::Token::ObjectKey { key, .. }) => {
match key.to_unescaped()?.as_ref() {
"Name" => {
builder = builder.set_name(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"HostArn" => {
builder = builder.set_host_arn(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"ProviderType" => {
builder = builder.set_provider_type(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| {
s.to_unescaped()
.map(|u| crate::model::ProviderType::from(u.as_ref()))
})
.transpose()?,
);
}
"ProviderEndpoint" => {
builder = builder.set_provider_endpoint(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"VpcConfiguration" => {
builder = builder.set_vpc_configuration(
crate::json_deser::deser_structure_vpc_configuration(tokens)?,
);
}
"Status" => {
builder = builder.set_status(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
"StatusMessage" => {
builder = builder.set_status_message(
smithy_json::deserialize::token::expect_string_or_null(
tokens.next(),
)?
.map(|s| s.to_unescaped().map(|u| u.into_owned()))
.transpose()?,
);
}
_ => smithy_json::deserialize::token::skip_value(tokens)?,
}
}
_ => {
return Err(smithy_json::deserialize::Error::custom(
"expected object key or end object",
))
}
}
}
Ok(Some(builder.build()))
}
_ => Err(smithy_json::deserialize::Error::custom(
"expected start object or null",
)),
}
}
|
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[link(name = "windows")]
extern "system" {}
#[repr(transparent)]
pub struct ContentAccessRestrictionLevel(pub i32);
impl ContentAccessRestrictionLevel {
pub const Allow: Self = Self(0i32);
pub const Warn: Self = Self(1i32);
pub const Block: Self = Self(2i32);
pub const Hide: Self = Self(3i32);
}
impl ::core::marker::Copy for ContentAccessRestrictionLevel {}
impl ::core::clone::Clone for ContentAccessRestrictionLevel {
fn clone(&self) -> Self {
*self
}
}
pub type ContentRestrictionsBrowsePolicy = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct RatedContentCategory(pub i32);
impl RatedContentCategory {
pub const General: Self = Self(0i32);
pub const Application: Self = Self(1i32);
pub const Game: Self = Self(2i32);
pub const Movie: Self = Self(3i32);
pub const Television: Self = Self(4i32);
pub const Music: Self = Self(5i32);
}
impl ::core::marker::Copy for RatedContentCategory {}
impl ::core::clone::Clone for RatedContentCategory {
fn clone(&self) -> Self {
*self
}
}
pub type RatedContentDescription = *mut ::core::ffi::c_void;
pub type RatedContentRestrictions = *mut ::core::ffi::c_void;
|
use std::collections::VecDeque;
use std::iter::FromIterator;
fn crab_cups(cups: &mut VecDeque<i32>, rounds: i32) {
let min_label: i32 = *cups.iter().min().unwrap();
let max_label: i32 = *cups.iter().max().unwrap();
let next_destination_label = |destination_label: i32| -> i32 {
let mut next = destination_label - 1;
if next < min_label {
next = max_label;
}
next
};
let mut picked_up: Vec<i32> = Vec::with_capacity(3);
for i in 0..rounds {
for _ in 0..3 {
picked_up.push(cups.remove(1).unwrap());
}
let mut destination_label = cups[0];
destination_label = next_destination_label(destination_label);
while picked_up.iter().find(|&&cup| cup == destination_label).is_some() {
destination_label = next_destination_label(destination_label);
}
let destination_pos = cups.iter().position(|&cup| cup == destination_label).unwrap();
for (i, cup) in picked_up.iter().enumerate() {
cups.insert(destination_pos + i + 1, *cup);
}
picked_up.clear();
cups.rotate_left(1);
if i % 10_000 == 0 {
println!("{}", i);
}
}
cups.rotate_left(cups.iter().position(|&cup| cup == 1).unwrap());
}
// for the record, it took me less time to code this than it did to run crab_cups()...
fn crab_cups_2000() {
// cups don't move, what's clockwise to them changes though...
// index == cup's label, value == next cup clockwise
let mut cups: Vec<i32> = Vec::with_capacity(1_000_001);
cups.resize(1_000_001, 0);
cups[6] = 1;
cups[1] = 4;
cups[4] = 7;
cups[7] = 5;
cups[5] = 2;
cups[2] = 8;
cups[8] = 3;
cups[3] = 9;
cups[9] = 6;
let min_label = 1_i32;
let max_label = 1_000_000_i32;
for i in 9..1_000_000 {
cups[i as usize] = i + 1;
}
cups[1_000_000] = 6;
let next_destination_label = |destination_label: i32| -> i32 {
let mut next = destination_label - 1;
if next < min_label {
next = max_label;
}
next
};
let mut current = 6_i32;
for _ in 0..10_000_000 {
// "pick up" 3 cups
let cup1 = cups[current as usize];
let cup2 = cups[cup1 as usize];
let cup3 = cups[cup2 as usize];
// Whatever was clockwise of cup3 is now clockwise of current
cups[current as usize] = cups[cup3 as usize];
let mut destination = next_destination_label(current);
while destination == cup1 || destination == cup2 || destination == cup3 {
destination = next_destination_label(destination);
}
// "Place" the cups back down, cup1 already points to cup2 and cup2 already points to cup3
let temp = cups[destination as usize];
cups[destination as usize] = cup1;
cups[cup3 as usize] = temp;
current = cups[current as usize];
}
let cup1 = cups[1];
let cup2 = cups[cup1 as usize];
println!("Part 2: {}", cup1 as i64 * cup2 as i64);
}
fn main() {
let mut cups = VecDeque::from_iter(vec![6, 1, 4, 7, 5, 2, 8, 3, 9].iter().cloned());
crab_cups(&mut cups, 100);
print!("Part 1: ");
for i in 1..cups.len() {
print!("{}", cups[i]);
}
println!("");
crab_cups_2000();
}
|
use proconio::{input, marker::Usize1};
fn main() {
input! {
n: usize,
a: [Usize1; n * 3],
};
let mut pos = vec![vec![]; n];
for i in 0..(n * 3) {
pos[a[i]].push(i);
}
let mut ans = (0..n).collect::<Vec<_>>();
ans.sort_by_key(|&i| pos[i][1]);
for i in 0..n {
print!("{}", ans[i] + 1);
if i + 1 < n {
print!(" ");
} else {
print!("\n");
}
}
}
|
use crate::prelude::*;
#[repr(C)]
#[derive(Debug)]
pub struct VkSparseMemoryBind {
pub resourceOffset: VkDeviceSize,
pub size: VkDeviceSize,
pub memory: VkDeviceMemory,
pub memoryOffset: VkDeviceSize,
pub flags: VkSparseMemoryBindFlagBits,
}
|
use proconio::input;
fn main() {
input! {
n: usize,
x: usize,
ab: [(usize, usize); n],
};
let mut dp = vec![false; x + 1];
dp[0] = true;
for (a, b) in ab {
for y in (0..x).rev() {
for c in (a..=(a*b)).step_by(a) {
if y + c <= x {
dp[y + c] |= dp[y];
}
}
}
}
if dp[x] {
println!("Yes");
} else {
println!("No");
}
}
|
// use std::{thread, time};
//take experssion, gather exponents, if exponent 2 has an expression, not function
//types of equations
// Quadratic Equation
// Linear Equation
// Radical Equation
// Exponential Equation
// Rational Equation
//term
// #[derive(Debug)]
struct Equation {
equation: String,
isfunc: bool,
terms: Vec<Term>,
//pterms: Vec<Term>,
opps: String,
// abterm: String,
}
impl Equation {
fn new(mut eqtion: String) -> Self {
eqtion.retain(|c| !c.is_whitespace());
let mut t = String::from("");
let mut o = String::from("");
let mut vt: Vec<Term> = vec![];
let elen = eqtion.len() as usize;
let mut i: usize = 0;
let mut cindex: usize = 0;
let mut myabop = false;
let mut myabterm = String::from("");
let mut absstart = false;
for c in eqtion.chars() {
// if (c == '|') && (eqtion.chars().last().unwrap() == '|') || absstart == True {
if (c == '|') || (absstart == true) {
if (absstart == true) && (c == '|') {
absstart = false;
let mut tt = Term::new(myabop);
tt.process(myabterm.clone());
vt.push(tt);
myabop = false;
continue;
}
myabop = true;
// let tempc: String = String::from(c);
absstart = true;
if c != '|' {
println!("c is : {}", c);
myabterm.push(c);
}
continue;
}
t.push(c);
i += 1;
cindex += 1;
if (c == '+') || (c == '-') || (c == '*') {
o.push(c);
let mut tt = Term::new(myabop);
println!("t indexed is :{:?}", t[0..i - 1].to_string().clone());
tt.process(t[0..i - 1].to_string().clone());
vt.push(tt);
t = String::from("").clone();
i = 0;
println!("vt: {:?}", vt);
continue;
}
if c == '=' {
let mut tt = Term::new(myabop);
println!("t indexed is :{:?}", t[0..i - 1].to_string().clone());
tt.process(t[0..i - 1].to_string().clone());
vt.push(tt);
t = String::from("").clone();
i = 0;
continue;
}
if cindex == elen {
let mut tt = Term::new(myabop);
println!("t is :{:?}", t[0..i].to_string().clone());
tt.process(t[0..i].to_string().clone());
vt.push(tt);
}
}
Self {
equation: eqtion,
isfunc: true,
terms: vt,
opps: o,
// abterm: myabterm,
}
}
fn afunc(&mut self) {
for ct in &self.terms {
if !ct.variable.is_none() && !ct.exponent.is_none() {
if (ct.variable.unwrap() == 'y')
&& (ct.exponent.unwrap() % 2 == 0)
&& ct.exponent.unwrap() != 0
{
self.isfunc = false;
}
}
if !ct.variable.is_none() {
if (ct.variable.unwrap() == 'y') && (ct.abs == true) {
self.isfunc = false;
}
}
}
}
}
#[derive(Debug, Clone)]
struct Term {
coefficient: Option<i32>,
variable: Option<char>, // x or y or n, y , x or nuymber type
exponent: Option<i32>,
abs: bool,
}
impl Term {
fn new(absv: bool) -> Self {
Self {
coefficient: None,
variable: None,
exponent: None,
abs: absv,
}
}
fn process(&mut self, t: String) {
let buff = &mut String::from("");
let mut coeff: Option<i32> = None;
let mut vr = None;
let mut exp: String = String::from("");
let mut i: usize = 0;
for c in t.chars() {
&buff.push(c);
if (c == 'x') || (c == 'y') {
vr = Some(c);
if buff == "" {
coeff = None;
} else {
let scoeff: String = buff[0..i].to_string();
if !scoeff.is_empty() {
coeff = Some(scoeff.parse::<i32>().unwrap());
}
}
i = i + 1;
*buff = String::from("");
continue;
}
if c == '^' {
*buff = String::from("");
}
if c == t.chars().last().unwrap() {
println!("buff: {}", buff);
exp = buff.clone();
}
// i = i + 1;
i += 1;
}
if exp != "" {
println!("exp: {}", exp);
self.exponent = Some(exp.parse::<i32>().unwrap());
}
self.variable = vr;
if coeff.is_none() {
self.coefficient = None;
} else {
self.coefficient = coeff;
}
}
}
fn main() {
let mut equation = Equation::new(String::from("y = 3x + 1"));
equation.afunc();
println!(
"is it a function: {}, terms: {:#?}",
equation.isfunc, equation.terms
);
}
#[cfg(test)]
mod test {
use super::*;
#[test]
fn checkforfnfalse() {
let mut tequation = Equation::new(String::from("5x^8 + |3y| = 15"));
tequation.afunc();
for tterm in &tequation.terms {
if !tterm.variable.is_none() {
// (absstart == true) && (c == '|')
if (tterm.variable.unwrap() == 'y') && (tterm.abs == true) {
assert!(!tequation.isfunc);
}
}
}
}
#[test]
fn checkforfntrue() {
let mut tnequation = Equation::new(String::from("5x^8 + 3y2 = 15"));
tnequation.afunc();
for tterm in &tnequation.terms {
if tterm.variable != None {
if (tterm.variable.unwrap() == 'y') && (tterm.abs == false) {
assert!(!tnequation.isfunc);
}
}
}
}
}
|
use crate::{ import::*, WsErr, WsErrKind, WsState, WsIo, WsEvent, CloseEvent, notify };
/// The meta data related to a websocket.
///
/// Most of the methods on this type directly map to the web API. For more documentation, check the
/// [MDN WebSocket documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/WebSocket).
//
pub struct WsStream
{
ws : Rc<WebSocket> ,
pharos : Rc<RefCell< Pharos<WsEvent> >> ,
_on_open : Closure< dyn FnMut() > ,
_on_error: Closure< dyn FnMut() > ,
_on_close: Closure< dyn FnMut( JsCloseEvt ) > ,
}
impl WsStream
{
const OPEN_CLOSE: Filter<WsEvent> = Filter::Pointer( |evt: &WsEvent| evt.is_open() | evt.is_closed() );
/// Connect to the server. The future will resolve when the connection has been established with a successful WebSocket
/// handshake.
///
/// This returns both a [WsStream] (allow manipulating and requesting meta data for the connection) and
/// a [WsIo] (AsyncRead/AsyncWrite + Stream/Sink over [WsMessage](crate::WsMessage)).
///
/// A WsStream instance is observable through the [`pharos::Observable`](https://docs.rs/pharos/0.2.0/pharos/trait.Observable.html) and [`pharos::ObservableUnbounded`](https://docs.rs/pharos/0.2.0/pharos/trait.UnboundedObservable.html) traits. The type of event is [WsEvent]. In the case of a Close event, there will be additional information included
/// as a [CloseEvent].
///
/// When you drop this, the connection does not get closed, however when you drop [WsIo] it does. Streams
/// of events will be dropped, so you will no longer receive events. One thing is possible if you really
/// need it, that's dropping [WsStream] but keeping [WsIo]. Now through [WsIo::wrapped] you can
/// access the underlying [web_sys::WebSocket] and set event handlers on it for `on_open`, `on_close`,
/// `on_error`. If you would do that while [WsStream] is still around, that would break the event system
/// and can lead to errors if you still call methods on [WsStream].
///
/// **Note**: Sending protocols to a server that doesn't support them will make the connection fail.
///
/// ## Errors
///
/// Browsers will forbid making websocket connections to certain ports. See this [Stack Overflow question](https://stackoverflow.com/questions/4313403/why-do-browsers-block-some-ports/4314070).
/// `connect` will return a [WsErrKind::ForbiddenPort].
///
/// If the URL is invalid, a [WsErrKind::InvalidUrl] is returned. See the [HTML Living Standard](https://html.spec.whatwg.org/multipage/web-sockets.html#dom-websocket) for more information.
///
/// When the connection fails (server port not open, wrong ip, wss:// on ws:// server, ... See the [HTML Living Standard](https://html.spec.whatwg.org/multipage/web-sockets.html#dom-websocket)
/// for details on all failure possibilities), a [WsErrKind::ConnectionFailed] is returned.
//
pub async fn connect( url: impl AsRef<str>, protocols: impl Into<Option<Vec<&str>>> )
-> Result< (Self, WsIo), WsErr >
{
let res = match protocols.into()
{
None => WebSocket::new( url.as_ref() ),
Some(v) =>
{
let js_protos = v.iter().fold( Array::new(), |acc, proto|
{
acc.push( &JsValue::from_str( proto ) );
acc
});
WebSocket::new_with_str_sequence( url.as_ref(), &js_protos )
}
};
// Deal with errors from the WebSocket constructor
//
let ws = match res
{
Ok(ws) => Rc::new( ws ),
Err(e) =>
{
let de: &DomException = e.unchecked_ref();
match de.code()
{
DomException::SECURITY_ERR => return Err( WsErrKind::ForbiddenPort.into() ),
DomException::SYNTAX_ERR =>
return Err( WsErrKind::InvalidUrl{ supplied: url.as_ref().to_string() }.into() ),
_ => unreachable!(),
};
}
};
// Create our pharos
//
let pharos = Rc::new( RefCell::new( Pharos::default() ));
let ph1 = pharos.clone();
let ph2 = pharos.clone();
let ph3 = pharos.clone();
let ph4 = pharos.clone();
// Setup our event listeners
// TODO: figure out a way to avoid the trivial cast.
//
#[ allow( trivial_casts ) ]
//
let on_open = Closure::wrap( Box::new( move ||
{
trace!( "websocket open event" );
// notify observers
//
notify( ph1.clone(), WsEvent::Open )
}) as Box< dyn FnMut() > );
#[ allow( trivial_casts ) ]
//
let on_error = Closure::wrap( Box::new( move ||
{
trace!( "websocket error event" );
// notify observers
//
notify( ph2.clone(), WsEvent::Error )
}) as Box< dyn FnMut() > );
#[ allow( trivial_casts ) ]
//
let on_close = Closure::wrap( Box::new( move |evt: JsCloseEvt|
{
trace!( "websocket close event" );
let c = WsEvent::Closed( CloseEvent
{
code : evt.code() ,
reason : evt.reason() ,
was_clean: evt.was_clean(),
});
notify( ph3.clone(), c )
}) as Box< dyn FnMut( JsCloseEvt ) > );
ws.set_onopen ( Some( &on_open .as_ref().unchecked_ref() ));
ws.set_onclose( Some( &on_close.as_ref().unchecked_ref() ));
ws.set_onerror( Some( &on_error.as_ref().unchecked_ref() ));
// Listen to the events to figure out whether the connection opens successfully. We don't want to deal with
// the error event. Either a close event happens, in which case we want to recover the CloseEvent to return it
// to the user, or an Open event happens in which case we are happy campers.
//
let mut evts = match pharos.borrow_mut().observe( Self::OPEN_CLOSE.into() )
{
Ok(events) => events ,
Err(e) => unreachable!( "{:?}", e ) , // only happens if we closed it.
};
// If the connection is closed, return error
//
if let Some( WsEvent::Closed(evt) ) = evts.next().await
{
trace!( "WebSocket connection closed!" );
return Err( WsErrKind::ConnectionFailed{ event: evt }.into() )
}
trace!( "WebSocket connection opened!" );
// We don't handle Blob's
//
ws.set_binary_type( BinaryType::Arraybuffer );
Ok
((
Self
{
pharos ,
ws : ws.clone() ,
_on_open : on_open ,
_on_error: on_error ,
_on_close: on_close ,
},
WsIo::new( ws, ph4 )
))
}
/// Close the socket. The future will resolve once the socket's state has become `WsState::CLOSED`.
/// See: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)
//
pub async fn close( &self ) -> Result< CloseEvent, WsErr >
{
match self.ready_state()
{
WsState::Closed => return Err( WsErrKind::ConnectionNotOpen.into() ),
WsState::Closing => {}
_ =>
{
// This can not throw normally, because the only errors the API can return is if we use a code or
// a reason string, which we don't.
// See [MDN](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close#Exceptions_thrown).
//
self.ws.close().unwrap_throw();
// Notify Observers
//
notify( self.pharos.clone(), WsEvent::Closing )
}
}
let mut evts = match self.pharos.borrow_mut().observe( Filter::Pointer( WsEvent::is_closed ).into() )
{
Ok(events) => events ,
Err(e) => unreachable!( "{:?}", e ) , // only happens if we closed it.
};
// We promised the user a CloseEvent, so we don't have much choice but to unwrap this. In any case, the stream will
// never end and this will hang if the browser fails to send a close event.
//
let ce = evts.next().await.expect_throw( "receive a close event" );
trace!( "WebSocket connection closed!" );
if let WsEvent::Closed(e) = ce { Ok( e ) }
else { unreachable!() }
}
/// Close the socket. The future will resolve once the socket's state has become `WsState::CLOSED`.
/// See: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)
//
pub async fn close_code( &self, code: u16 ) -> Result<CloseEvent, WsErr>
{
match self.ready_state()
{
WsState::Closed => return Err( WsErrKind::ConnectionNotOpen.into() ),
WsState::Closing => {}
_ =>
{
match self.ws.close_with_code( code )
{
// Notify Observers
//
Ok(_) => notify( self.pharos.clone(), WsEvent::Closing ),
Err(_) =>
{
let e = WsErr::from( WsErrKind::InvalidCloseCode{ supplied: code } );
error!( "{}", e );
return Err( e );
}
}
}
}
let mut evts = match self.pharos.borrow_mut().observe( Filter::Pointer( WsEvent::is_closed ).into() )
{
Ok(events) => events ,
Err(e) => unreachable!( "{:?}", e ) , // only happens if we closed it.
};
let ce = evts.next().await.expect_throw( "receive a close event" );
trace!( "WebSocket connection closed!" );
if let WsEvent::Closed(e) = ce { Ok(e) }
else { unreachable!() }
}
/// Close the socket. The future will resolve once the socket's state has become `WsState::CLOSED`.
/// See: [MDN Documentation](https://developer.mozilla.org/en-US/docs/Web/API/WebSocket/close)
//
pub async fn close_reason( &self, code: u16, reason: impl AsRef<str> ) -> Result<CloseEvent, WsErr>
{
match self.ready_state()
{
WsState::Closed => return Err( WsErrKind::ConnectionNotOpen.into() ),
WsState::Closing => {}
_ =>
{
if reason.as_ref().len() > 123
{
let e = WsErr::from( WsErrKind::ReasonStringToLong );
error!( "{}", e );
return Err( e );
}
match self.ws.close_with_code_and_reason( code, reason.as_ref() )
{
// Notify Observers
//
Ok(_) => notify( self.pharos.clone(), WsEvent::Closing ),
Err(_) =>
{
let e = WsErr::from( WsErrKind::InvalidCloseCode{ supplied: code } );
error!( "{}", e );
return Err( e )
}
}
}
}
let mut evts = match self.pharos.borrow_mut().observe( Filter::Pointer( WsEvent::is_closed ).into() )
{
Ok(events) => events ,
Err(e) => unreachable!( "{:?}", e ) , // only happens if we closed it.
};
let ce = evts.next().await.expect_throw( "receive a close event" );
trace!( "WebSocket connection closed!" );
if let WsEvent::Closed(e) = ce { Ok(e) }
else { unreachable!() }
}
/// Verify the [WsState] of the connection.
//
pub fn ready_state( &self ) -> WsState
{
self.ws.ready_state().try_into().map_err( |e| error!( "{}", e ) )
// This can't throw unless the browser gives us an invalid ready state
//
.expect_throw( "Convert ready state from browser API" )
}
/// Access the wrapped [web_sys::WebSocket](https://docs.rs/web-sys/0.3.25/web_sys/struct.WebSocket.html) directly.
///
/// `ws_stream_wasm` tries to expose all useful functionality through an idiomatic rust API, so hopefully
/// you won't need this, however if I missed something, you can.
///
/// ## Caveats
/// If you call `set_onopen`, `set_onerror`, `set_onmessage` or `set_onclose` on this, you will overwrite
/// the event listeners from `ws_stream_wasm`, and things will break.
//
pub fn wrapped( &self ) -> &WebSocket
{
&self.ws
}
/// The number of bytes of data that have been queued but not yet transmitted to the network.
///
/// **NOTE:** that this is the number of bytes buffered by the underlying platform WebSocket
/// implementation. It does not reflect any buffering performed by ws_stream.
//
pub fn buffered_amount( &self ) -> u32
{
self.ws.buffered_amount()
}
/// The extensions selected by the server as negotiated during the connection.
///
/// **NOTE**: This is an untested feature. The back-end server we use for testing (tungstenite)
/// does not support Extensions.
//
pub fn extensions( &self ) -> String
{
self.ws.extensions()
}
/// The name of the sub-protocol the server selected during the connection.
///
/// This will be one of the strings specified in the protocols parameter when
/// creating this WsStream instance.
//
pub fn protocol(&self) -> String
{
self.ws.protocol()
}
/// Retrieve the address to which this socket is connected.
//
pub fn url( &self ) -> String
{
self.ws.url()
}
}
impl fmt::Debug for WsStream
{
fn fmt( &self, f: &mut fmt::Formatter<'_> ) -> fmt::Result
{
write!( f, "WsStream for connection: {}", self.url() )
}
}
impl Observable<WsEvent> for WsStream
{
type Error = pharos::Error;
fn observe( &mut self, options: ObserveConfig<WsEvent> ) -> Result< Events<WsEvent>, Self::Error >
{
self.pharos.borrow_mut().observe( options )
}
}
impl Drop for WsStream
{
// We don't block here, just tell the browser to close the connection and move on.
// TODO: is this necessary or would it be closed automatically when we drop the WebSocket
// object? Note that there is also the WsStream which holds a clone.
//
fn drop( &mut self )
{
trace!( "Drop WsStream" );
self.ws.set_onopen ( None );
self.ws.set_onclose( None );
self.ws.set_onerror( None );
}
}
|
use std::collections::BTreeMap;
use rustc_serialize::json::{Json,ToJson};
use parse::*;
use types::Date;
make_prop_type!(FilterOperator, "FilterOperator",
operator: String => "operator",
conditions: Vec<Filter> => "conditions"
);
make_prop_type!(FilterCondition, "FilterCondition",
in_mailboxes: Presence<Vec<String>> => "inMailboxes",
not_in_mailboxes: Presence<Vec<String>> => "notInnMailboxes",
before: Presence<Date> => "before",
after: Presence<Date> => "after",
min_size: Presence<u64> => "minSize",
max_size: Presence<u64> => "maxSize",
thread_is_flagged: Presence<bool> => "threadIsFlagged",
thread_is_unread: Presence<bool> => "threadIsUnread",
is_flagged: Presence<bool> => "isFlagged",
is_unread: Presence<bool> => "isUnread",
is_answered: Presence<bool> => "isAnswered",
is_draft: Presence<bool> => "isDraft",
has_attachment: Presence<bool> => "hasAttachment",
text: Presence<String> => "text",
from: Presence<String> => "from",
to: Presence<String> => "to",
cc: Presence<String> => "cc",
bcc: Presence<String> => "bcc",
subject: Presence<String> => "subject",
body: Presence<String> => "body",
header: Presence<Vec<String>> => "header"
);
#[derive(Clone, PartialEq, Debug)]
pub enum Filter {
Operator(FilterOperator),
Condition(FilterCondition),
}
impl ToJson for Filter {
fn to_json(&self) -> Json {
match *self {
Filter::Operator(ref o) => o.to_json(),
Filter::Condition(ref c) => c.to_json(),
}
}
}
impl FromJson for Filter {
fn from_json(json: &Json) -> Result<Filter,ParseError> {
match *json {
Json::Object(ref o) => {
match o.get("operator") {
Some(_) => Ok(Filter::Operator(try!(FilterOperator::from_json(json)))),
None => Ok(Filter::Condition(try!(FilterCondition::from_json(json)))),
}
},
_ => Err(ParseError::InvalidJsonType("Filter".to_string())),
}
}
}
make_prop_type!(RemovedItem, "RemovedItem",
message_id: String => "messageId",
thread_id: String => "threadId"
);
make_prop_type!(AddedItem, "AddedItem",
message_id: String => "messageId",
thread_id: String => "threadId",
index: u64 => "index"
);
make_method_args_type!(GetMessageListRequestArgs, "GetMessageListRequestArgs",
account_id: Presence<String> => "accountId",
//filter:
sort: Presence<Vec<String>> => "sort",
collapse_threads: Presence<bool> => "collapseThreads",
position: Presence<u64> => "position",
anchor: Presence<String> => "anchor",
anchor_offset: Presence<i64> => "anchorOffset",
limit: Presence<u64> => "limit",
fetch_threads: Presence<bool> => "fetchThreads",
fetch_messages: Presence<bool> => "fetchMessages",
fetch_message_properties: Presence<bool> => "fetchMessageProperties",
fetch_search_snippets: Presence<bool> => "fetchSearchSnippets"
);
make_method_args_type!(GetMessageListResponseArgs, "GetMessageListResponseArgs",
account_id: String => "accountId",
//filter:
sort: Vec<String> => "sort",
collapse_threads: bool => "collapseThreads",
state: String => "state",
can_calculate_updates: bool => "can_calculate_updates",
position: u64 => "position",
total: u64 => "total",
thread_ids: Vec<String> => "thread_ids",
message_ids: Vec<String> => "message_ids"
);
make_method_args_type!(GetMessageListUpdatesRequestArgs, "GetMessageListRequestArgs",
account_id: Presence<String> => "accountId",
//filter:
sort: Presence<Vec<String>> => "sort",
collapse_threads: Presence<bool> => "collapseThreads",
since_state: String => "sinceState",
upto_message_id: Presence<String> => "uptoMessageId",
max_changes: Presence<u64> => "maxChanges"
);
make_method_args_type!(GetMessageListUpdatesResponseArgs, "GetMessageListResponseArgs",
account_id: String => "accountId",
//filter:
sort: Vec<String> => "sort",
collapse_threads: bool => "collapseThreads",
old_state: String => "oldState",
new_state: String => "newState",
upto_message_id: Presence<String> => "uptoMessageId",
total: u64 => "total",
removed: Vec<RemovedItem> => "removed",
added: Vec<AddedItem> => "added"
);
|
//! ECDSA signing key
use super::{CurveAlg, Signature, VerifyingKey};
use crate::signature::{Error, Keypair, Signer};
use ::ecdsa::{
elliptic_curve::{sec1, FieldBytesSize},
SignatureSize,
};
use core::marker::PhantomData;
use generic_array::ArrayLength;
use pkcs8::DecodePrivateKey;
use ring::{
self,
rand::SystemRandom,
signature::{EcdsaKeyPair, KeyPair as _},
};
/// ECDSA signing key. Generic over elliptic curves.
pub struct SigningKey<C>
where
C: CurveAlg,
SignatureSize<C>: ArrayLength<u8>,
{
/// *ring* ECDSA keypair
keypair: EcdsaKeyPair,
/// Cryptographically secure random number generator
csrng: SystemRandom,
/// Elliptic curve type
curve: PhantomData<C>,
}
impl<C> SigningKey<C>
where
C: CurveAlg,
SignatureSize<C>: ArrayLength<u8>,
{
/// Initialize a [`SigningKey`] from a raw keypair
pub fn from_keypair_bytes(signing_key: &[u8], verifying_key: &[u8]) -> Result<Self, Error> {
EcdsaKeyPair::from_private_key_and_public_key(C::signing_alg(), signing_key, verifying_key)
.map(|keypair| Self {
keypair,
csrng: SystemRandom::new(),
curve: PhantomData,
})
.map_err(|_| Error::new())
}
/// Get the [`VerifyingKey`] for this [`SigningKey`]
pub fn verifying_key(&self) -> VerifyingKey<C>
where
FieldBytesSize<C>: sec1::ModulusSize,
{
VerifyingKey::new(self.keypair.public_key().as_ref()).unwrap()
}
}
impl<C> DecodePrivateKey for SigningKey<C>
where
C: CurveAlg,
SignatureSize<C>: ArrayLength<u8>,
{
fn from_pkcs8_der(pkcs8_bytes: &[u8]) -> Result<Self, pkcs8::Error> {
EcdsaKeyPair::from_pkcs8(C::signing_alg(), pkcs8_bytes)
.map(|keypair| Self {
keypair,
csrng: SystemRandom::new(),
curve: PhantomData,
})
.map_err(|_| pkcs8::Error::KeyMalformed)
}
}
impl<C> Keypair for SigningKey<C>
where
C: CurveAlg,
FieldBytesSize<C>: sec1::ModulusSize,
SignatureSize<C>: ArrayLength<u8>,
{
type VerifyingKey = VerifyingKey<C>;
fn verifying_key(&self) -> VerifyingKey<C> {
self.verifying_key()
}
}
impl<C> Signer<Signature<C>> for SigningKey<C>
where
C: CurveAlg,
SignatureSize<C>: ArrayLength<u8>,
{
fn try_sign(&self, msg: &[u8]) -> Result<Signature<C>, Error> {
self.keypair
.sign(&self.csrng, msg)
.map_err(|_| Error::new())
.and_then(|sig| Signature::try_from(sig.as_ref()))
}
}
|
//! Configuration directory path helpers.
use directories::ProjectDirs;
use serde::Deserialize;
use serde_yaml::Value;
use std::fs::{create_dir_all, File};
use std::io::prelude::*;
use std::path::PathBuf;
use crate::error::AppError;
/// Returns the path of a file/pattern inside the configuration directory.
pub fn get_path(pattern: &str) -> Result<PathBuf, AppError> {
let proj_dirs =
ProjectDirs::from("org", crate_authors!(), crate_name!()).ok_or(AppError::ConfigPath)?;
let config_dir = proj_dirs.config_dir();
let mut path = PathBuf::from(config_dir);
create_dir_all(&path).map_err(|e| AppError::ProjectCreateConfigDir(path.clone(), e))?;
path.push(pattern);
Ok(path)
}
/// Returns the path of a project file, adding `.yml` extension it.
pub fn get_project_path(project_name: &str) -> Result<PathBuf, AppError> {
let mut file_path = get_path(project_name)?;
file_path.set_extension("yml");
Ok(file_path)
}
/// Read project file, parse it to [`serde_yaml::Value`].
pub fn get_project_yaml(project_name: &str) -> Result<Value, AppError> {
let mut filename = project_name.to_owned();
filename.push_str(".yml");
let project_file_path = get_path(&filename)?;
let mut contents = String::new();
File::open(&project_file_path)
.map_err(|_| AppError::ProjectFileNotFound(project_file_path.clone()))?
.read_to_string(&mut contents)
.map_err(|e| AppError::ProjectFileRead(project_file_path.clone(), e))?;
let de = serde_yaml::Deserializer::from_str(&contents);
Value::deserialize(de)
.map_err(|e| AppError::YamlParse(project_file_path.clone(), format!("{e}")))
}
|
#![feature(test)]
extern crate test;
use test::Bencher;
use coruscant_nbt::{to_gzip_writer, to_writer, Compression};
use serde::Serialize;
use std::collections::HashMap;
#[derive(Serialize)]
#[serde(rename = "wrap")]
struct Wrap {
#[serde(rename = "inner")]
inner: Inner,
}
#[derive(Serialize)]
struct Inner {
map: HashMap<&'static str, f32>,
}
// 44 bytes (uncompressed) in total
fn value() -> Wrap {
let mut map = HashMap::new();
map.insert("123", 123.456);
map.insert("456", 789.012);
Wrap {
inner: Inner { map },
}
}
#[bench]
fn json_ser_simple(b: &mut Bencher) {
let value = value();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = serde_json::to_writer(&mut vec, &value).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_simple(b: &mut Bencher) {
let value = value();
let mut vec = Vec::with_capacity(128);
b.iter(|| {
let _ = to_writer(&mut vec, &value).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_simple_gzip_none(b: &mut Bencher) {
let value = value();
let mut vec = Vec::with_capacity(128);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::none()).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_simple_gzip_fast(b: &mut Bencher) {
let value = value();
let mut vec = Vec::with_capacity(128);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::fast()).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_simple_gzip_best(b: &mut Bencher) {
let value = value();
let mut vec = Vec::with_capacity(128);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::best()).unwrap();
vec.clear();
});
}
#[derive(Serialize)]
struct TestStruct {
#[serde(rename = "byteTest")]
byte_test: i8,
#[serde(rename = "shortTest")]
short_test: i16,
#[serde(rename = "intTest")]
int_test: i32,
#[serde(rename = "longTest")]
long_test: i64,
#[serde(rename = "floatTest")]
float_test: f32,
#[serde(rename = "doubleTest")]
double_test: f64,
#[serde(rename = "stringTest")]
string_test: &'static str,
#[serde(rename = "listTest (long)")]
list_long_test: [i64; 5],
#[serde(rename = "listTest (compound)")]
list_compound_test: Vec<NestedCompound>,
#[serde(
rename = "byteArrayTest (the first 1000 values of (n*n*255+n*7)%100, starting with n=0 (0, 62, 34, 16, 8, ...))"
)]
byte_array_test: Box<[i8]>,
#[serde(rename = "nested compound test")]
nested: Nested,
}
#[derive(Serialize)]
struct Nested {
egg: Food,
ham: Food,
}
#[derive(Serialize)]
struct Food {
name: &'static str,
value: f32,
}
#[derive(Serialize)]
struct NestedCompound {
#[serde(rename = "created-on")]
created_on: i64,
name: &'static str,
}
// 1537 bytes (uncompressed) in total
fn value_big() -> TestStruct {
let mut byte_array_test = Vec::new();
for i in 0i32..1000 {
let value = (i * i * 255 + i * 7) % 100;
byte_array_test.push(value as i8)
}
let byte_array_test = byte_array_test.into_boxed_slice();
TestStruct {
nested: Nested {
egg: Food {
name: "Eggbert",
value: 0.5,
},
ham: Food {
name: "Hampus",
value: 0.75,
},
},
byte_test: 127,
short_test: 32767,
int_test: 2147483647,
long_test: 9223372036854775807,
double_test: 0.49312871321823148,
float_test: 0.49823147058486938,
string_test: "HELLO WORLD THIS IS A TEST STRING!",
list_long_test: [11, 12, 13, 14, 15],
list_compound_test: vec![
NestedCompound {
created_on: 1264099775885,
name: "Compound tag #0",
},
NestedCompound {
created_on: 1264099775885,
name: "Compound tag #1",
},
],
byte_array_test,
}
}
#[bench]
fn json_ser_big(b: &mut Bencher) {
let value = value_big();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = serde_json::to_writer(&mut vec, &value).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_big(b: &mut Bencher) {
let value = value_big();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = to_writer(&mut vec, &value).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_big_gzip_none(b: &mut Bencher) {
let value = value_big();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::none()).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_big_gzip_fast(b: &mut Bencher) {
let value = value_big();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::fast()).unwrap();
vec.clear();
});
}
#[bench]
fn nbt_ser_big_gzip_best(b: &mut Bencher) {
let value = value_big();
let mut vec = Vec::with_capacity(512);
b.iter(|| {
let _ = to_gzip_writer(&mut vec, &value, Compression::best()).unwrap();
vec.clear();
});
}
|
use glob::PatternError;
use std::fmt::{Display, Formatter, Result};
use std::path::PathBuf;
pub use error_chain::ChainedError;
pub use lalrpop_util::ParseError;
pub use crate::ast::ErrorKind;
use crate::connection::{ConnectionError, ConnectionErrorKind};
pub use crate::model::ValidationKind;
use crate::sql::lexer;
error_chain! {
types {
PsqlpackError, PsqlpackErrorKind, PsqlpackResultExt, PsqlpackResult;
}
links {
Connection(ConnectionError, ConnectionErrorKind);
}
errors {
ProjectReadError(path: PathBuf) {
description("Couldn't read project file")
display("Couldn't read project file: {}", path.as_path().display())
}
ProjectParseError(message: String) {
description("Couldn't parse project file")
display("Couldn't parse project file: {}", message)
}
InvalidScriptPath(path: String) {
description("Invalid script path in project file")
display("Invalid script path in project file: {}", path)
}
PublishProfileReadError(path: PathBuf) {
description("Couldn't read publish profile file")
display("Couldn't read publish profile file: {}", path.as_path().display())
}
PublishProfileParseError(message: String) {
description("Couldn't parse publish profile")
display("Couldn't parse publish profile: {}", message)
}
PackageCreationError(message: String) {
description("Failed to create package")
display("Failed to create package: {}", message)
}
PackageReadError(path: PathBuf) {
description("Couldn't read package file")
display("Couldn't read package file: {}", path.as_path().display())
}
PackageUnarchiveError(path: PathBuf) {
description("Couldn't unarchive package file")
display("Couldn't unarchive package file: {}", path.as_path().display())
}
PackageInternalReadError(file_name: String) {
description("Couldn't read part of the package file")
display("Couldn't read part of the package file: {}", file_name)
}
QueryExtensionsError {
description("Couldn't query extensions")
}
PackageQuerySchemasError {
description("Couldn't query schemas")
}
PackageQueryTypesError {
description("Couldn't query types")
}
PackageQueryFunctionsError {
description("Couldn't query functions")
}
PackageQueryTablesError {
description("Couldn't query tables")
}
PackageQueryColumnsError {
description("Couldn't query columns")
}
PackageQueryTableConstraintsError {
description("Couldn't query table constraints")
}
PackageQueryIndexesError {
description("Couldn't query indexes")
}
PackageFunctionArgsInspectError(args: String) {
description("Couldn't inspect function args")
display("Couldn't inspect function args: {}", args)
}
PackageFunctionReturnTypeInspectError(return_type: String) {
description("Couldn't inspect function return type")
display("Couldn't inspect function return type: {}", return_type)
}
PublishInvalidOperationError(message: String) {
description("Couldn't publish database due to an invalid operation")
display("Couldn't publish database due to an invalid operation: {}", message)
}
PublishUnsafeOperationError(message: String) {
description("Unsafe Operation")
display("Couldn't publish database due to an unsafe operation: {}", message)
}
GlobPatternError(err: PatternError) {
description("An error in the glob pattern was found")
display("An error in the glob pattern was found: {}", err)
}
#[allow(clippy::upper_case_acronyms)]
IOError(file: String, message: String) {
description("IO error when reading a file")
display("IO error when reading {}: {}", file, message)
}
LexicalError(reason: String, line: String, line_number: usize, start: usize, end: usize) {
description("Lexical error encountered")
display("Lexical error encountered on line {},{}: {}\n{}",
line_number, reason, *start, LineFormatter(line, *start, *end))
}
SyntaxError(file: String, line: String, line_number: usize, start: usize, end: usize) {
description("SQL syntax error encountered")
display(
"SQL syntax error encountered in {} on line {},{}:\n{}",
file, line_number, *start, LineFormatter(line, *start, *end))
}
ParseError(file: String, errors: Vec<ParseError<(), lexer::Token, &'static str>>) {
description("Parser error")
display("Parser errors in {}:\n{}", file, ParseErrorsFormatter(errors))
}
InlineParseError(error: ParseError<(), lexer::Token, &'static str>) {
description("Parser error")
display("Parser error: {}", ParseErrorFormatter(error))
}
HandledParseError(kind: ErrorKind) {
description("Parser error")
display("Parser error: {}", kind)
}
TemplateGenerationError(message: String) {
description("Error generating template")
display("Error generating template: {}", message)
}
GenerationError(message: String) {
description("Error generating package")
display("Error generating package: {}", message)
}
ValidationError(errors: Vec<ValidationKind>) {
description("Package validation error")
display("Package validation error{}:\n{}",
if errors.len() > 1 { "s" } else { "" },
ValidationErrorFormatter(errors)
)
}
FormatError(file: String, message: String) {
description("Format error when reading a file")
display("Format error when reading {}: {}", file, message)
}
DatabaseError(message: String) {
description("Database error")
display("Database error: {}", message)
}
DatabaseExecuteError(query: String) {
description("Database error executing query")
display("Database error executing: {}", query)
}
DatabaseConnectionFinishError {
description("Database connection couldn't finish")
display("Database connection couldn't finish")
}
ExtractError(message: String) {
description("Extract Error")
display("Extraction Error: {}", message)
}
ProjectError(message: String) {
description("Project format error")
display("Project format error: {}", message)
}
PublishError(message: String) {
description("Publish error")
display("Publish error: {}", message)
}
MultipleErrors(errors: Vec<PsqlpackError>) {
description("Multiple errors")
display("Multiple errors:\n{}", MultipleErrorFormatter(errors))
}
}
}
fn write_err(f: &mut Formatter, error: &ParseError<(), lexer::Token, &'static str>) -> Result {
match *error {
ParseError::InvalidToken { .. } => write!(f, "Invalid token"),
ParseError::UnrecognizedToken {
ref token,
ref expected,
} => {
writeln!(f, "Unexpected {:?}", token.1)?;
write!(f, " Expected one of:\n {}", expected.join(", "))
}
ParseError::UnrecognizedEOF { ref expected, .. } => {
writeln!(f, "Unexpected end of file")?;
write!(f, " Expected one of:\n {}", expected.join(", "))
}
ParseError::ExtraToken { ref token } => write!(f, "Extra token detected: {:?}", token),
ParseError::User { ref error } => write!(f, "{:?}", error),
}
}
struct LineFormatter<'fmt>(&'fmt str, usize, usize);
const MAX_LINE_LENGTH: usize = 78;
impl<'fmt> Display for LineFormatter<'fmt> {
fn fmt(&self, f: &mut Formatter) -> Result {
let mut line = self.0;
let mut start = self.1;
let mut end = self.2;
if line.len() > MAX_LINE_LENGTH {
if start > 20 {
let adj = start - 20;
let (_, l) = line.split_at(adj);
line = l;
start -= adj;
end -= adj;
}
if line.len() > MAX_LINE_LENGTH && end < MAX_LINE_LENGTH {
let (l, _) = line.split_at(MAX_LINE_LENGTH);
line = l;
}
}
write!(f, " {}\n {}{}", line, " ".repeat(start), "^".repeat(end - start))?;
Ok(())
}
}
struct ParseErrorsFormatter<'fmt>(&'fmt Vec<ParseError<(), lexer::Token, &'static str>>);
impl<'fmt> Display for ParseErrorsFormatter<'fmt> {
fn fmt(&self, f: &mut Formatter) -> Result {
for (i, error) in self.0.iter().enumerate() {
write!(f, "{}: ", i,)?;
write_err(f, error)?;
}
Ok(())
}
}
struct ParseErrorFormatter<'fmt>(&'fmt ParseError<(), lexer::Token, &'static str>);
impl<'fmt> Display for ParseErrorFormatter<'fmt> {
fn fmt(&self, f: &mut Formatter) -> Result {
write_err(f, self.0)
}
}
struct MultipleErrorFormatter<'fmt>(&'fmt Vec<PsqlpackError>);
impl<'fmt> Display for MultipleErrorFormatter<'fmt> {
fn fmt(&self, f: &mut Formatter) -> Result {
for (i, error) in self.0.iter().enumerate() {
write!(f, "--- Error {} ---\n{}", i, error)?;
}
Ok(())
}
}
struct ValidationErrorFormatter<'fmt>(&'fmt Vec<ValidationKind>);
impl<'fmt> Display for ValidationErrorFormatter<'fmt> {
fn fmt(&self, f: &mut Formatter) -> Result {
for error in self.0.iter() {
writeln!(f, " - {}", error)?;
}
Ok(())
}
}
|
//! Synopsys DesignWare ABP UART
use static_assertions::{assert_eq_align, assert_eq_size, const_assert_eq};
register! {
ReceiveHolding,
u32,
RO,
Fields [
Data WIDTH(U8) OFFSET(U0),
]
}
register! {
TransmitHolding,
u32,
WO,
Fields [
Data WIDTH(U8) OFFSET(U0),
]
}
register! {
DivisorLatchLow,
u32,
RW,
Fields [
Lsb WIDTH(U8) OFFSET(U0),
]
}
register! {
DivisorLatchHigh,
u32,
RW,
Fields [
Msb WIDTH(U8) OFFSET(U0),
]
}
register! {
IntEnable,
u32,
RW,
Fields [
Erbfi WIDTH(U1) OFFSET(U0),
Etbei WIDTH(U1) OFFSET(U1),
Elsi WIDTH(U1) OFFSET(U2),
Edssi WIDTH(U1) OFFSET(U3),
Ptime WIDTH(U1) OFFSET(U7),
]
}
register! {
IntStatus,
u32,
RO,
Fields [
PendingInt WIDTH(U4) OFFSET(U0) [
ModemStatus = U0,
NotPending = U1,
ThrEmpty = U2,
Rx = U4,
RxLineStatus = U6,
Busy = U7,
CharTimeout = U12
]
FifoEnabled WIDTH(U2) OFFSET(U6) [
Disabled = U0,
Enabled = U3
],
]
}
register! {
FifoControl,
u32,
WO,
Fields [
FifoEnable WIDTH(U1) OFFSET(U0),
RxFifoReset WIDTH(U1) OFFSET(U1),
TxFifoReset WIDTH(U1) OFFSET(U2),
DmaMode WIDTH(U1) OFFSET(U3) [
Mode0 = U0,
Mode1 = U1
]
TxEmptryTrigger WIDTH(U2) OFFSET(U4) [
OneChar = U0,
QuarterFull = U1,
HalfFull = U2,
TwoFromFull = U3
]
RxTrigger WIDTH(U2) OFFSET(U6) [
FifoEmpty = U0,
TwoChars = U1,
QuarterFull = U2,
HalfFull = U3
]
]
}
register! {
LineControl,
u32,
RW,
Fields [
DataLength WIDTH(U2) OFFSET(U0) [
FiveBits = U0,
SixBits = U1,
SevenBits = U2,
EightBits = U3
]
StopBits WIDTH(U1) OFFSET(U2) [
One = U0,
OneDotFive = U1
]
ParityEnable WIDTH(U1) OFFSET(U3),
EventParitySelect WIDTH(U2) OFFSET(U4) [
Odd = U0,
Event = U1,
ReverseLCR = U2
]
BreakControl WIDTH(U1) OFFSET(U6),
DivisorLatchAccess WIDTH(U1) OFFSET(U7)
]
}
register! {
ModemControl,
u32,
RW,
Fields [
DataTerminalReady WIDTH(U1) OFFSET(U0) [
DtrDeAsserted = U0,
DtrAsserted = U1
]
RequestToSend WIDTH(U1) OFFSET(U1) [
RtsDeAsserted = U0,
RtsAsserted = U1
]
LoopBackMode WIDTH(U1) OFFSET(U4),
AutoFlowControl WIDTH(U1) OFFSET(U5),
SirModeEnable WIDTH(U1) OFFSET(U6)
]
}
register! {
LineStatus,
u32,
RO,
Fields [
DataReady WIDTH(U1) OFFSET(U0),
OverrunError WIDTH(U1) OFFSET(U1),
ParityError WIDTH(U1) OFFSET(U2),
FramingError WIDTH(U1) OFFSET(U3),
BreakInterrupt WIDTH(U1) OFFSET(U4),
ThrEmpty WIDTH(U1) OFFSET(U5),
TxEmpty WIDTH(U1) OFFSET(U6),
RxFifoError WIDTH(U1) OFFSET(U7),
]
}
register! {
ModemStatus,
u32,
RO,
Fields [
DeltaClearToSend WIDTH(U1) OFFSET(U0),
DeltaDataSetReady WIDTH(U1) OFFSET(U1),
TrailingEdgeRingInd WIDTH(U1) OFFSET(U2),
DeltaDataCarDetect WIDTH(U1) OFFSET(U3),
LineStateOfClearToSend WIDTH(U1) OFFSET(U4),
LineStateOfDataSetReady WIDTH(U1) OFFSET(U5),
LineStateOfRingInd WIDTH(U1) OFFSET(U6),
LineStateOfDataCarDetect WIDTH(U1) OFFSET(U7),
]
}
register! {
Scratch,
u32,
RW,
Fields [
Data WIDTH(U8) OFFSET(U0),
]
}
register! {
Status,
u32,
RO,
Fields [
Busy WIDTH(U1) OFFSET(U0),
TxFifoNotFull WIDTH(U1) OFFSET(U1),
TxFifoEmpty WIDTH(U1) OFFSET(U2),
RxFifoNotEmpty WIDTH(U1) OFFSET(U3),
RxFifoFull WIDTH(U1) OFFSET(U4),
]
}
register! {
TransmitFifoLevel,
u32,
RO,
Fields [
Count WIDTH(U7) OFFSET(U0),
]
}
register! {
ReceiveFifoLevel,
u32,
RO,
Fields [
Count WIDTH(U7) OFFSET(U0),
]
}
const_assert_eq!(core::mem::size_of::<RegisterBlock>(), 0x88);
assert_eq_align!(RegisterBlock, ReceiveRegisterBlock);
assert_eq_align!(RegisterBlock, TransmitRegisterBlock);
assert_eq_size!(RegisterBlock, ReceiveRegisterBlock);
assert_eq_size!(RegisterBlock, TransmitRegisterBlock);
#[repr(C)]
pub struct RegisterBlock {
pub dll: DivisorLatchLow::Register, // 0x00
pub dlh: DivisorLatchHigh::Register, // 0x04
__reserved_1: u32, // 0x08
pub lcr: LineControl::Register, // 0x0C
pub mcr: ModemControl::Register, // 0x10
pub lsr: LineStatus::Register, // 0x14
pub msr: ModemStatus::Register, // 0x18
pub spr: Scratch::Register, // 0x1C
__reserved_2: [u32; 23], // 0x20
pub sr: Status::Register, // 0x7C
pub tfl: TransmitFifoLevel::Register, // 0x80
pub rfl: ReceiveFifoLevel::Register, // 0x84
}
#[repr(C)]
pub struct ReceiveRegisterBlock {
pub rhr: ReceiveHolding::Register, // 0x00
pub ier: IntEnable::Register, // 0x04
pub isr: IntStatus::Register, // 0x08
pub lcr: LineControl::Register, // 0x0C
pub mcr: ModemControl::Register, // 0x10
pub lsr: LineStatus::Register, // 0x14
pub msr: ModemStatus::Register, // 0x18
pub spr: Scratch::Register, // 0x1C
__reserved_0: [u32; 23], // 0x20
pub sr: Status::Register, // 0x7C
pub tfl: TransmitFifoLevel::Register, // 0x80
pub rfl: ReceiveFifoLevel::Register, // 0x84
}
#[repr(C)]
pub struct TransmitRegisterBlock {
pub thr: TransmitHolding::Register, // 0x00
pub ier: IntEnable::Register, // 0x04
pub fcr: FifoControl::Register, // 0x08
pub lcr: LineControl::Register, // 0x0C
pub mcr: ModemControl::Register, // 0x10
pub lsr: LineStatus::Register, // 0x14
pub msr: ModemStatus::Register, // 0x18
pub spr: Scratch::Register, // 0x1C
__reserved_0: [u32; 23], // 0x20
pub sr: Status::Register, // 0x7C
pub tfl: TransmitFifoLevel::Register, // 0x80
pub rfl: ReceiveFifoLevel::Register, // 0x84
}
pub struct NotConfigured;
pub struct Receive;
pub struct Transmit;
pub trait UartMode: private::Sealed {}
impl UartMode for NotConfigured {}
impl UartMode for Receive {}
impl UartMode for Transmit {}
pub(crate) mod private {
pub trait Sealed {}
impl Sealed for super::NotConfigured {}
impl Sealed for super::Receive {}
impl Sealed for super::Transmit {}
}
|
use bytesize::ByteSize;
use chrono::{DateTime, Local};
use chrono_humanize::HumanTime;
use crate::error::Error;
use std::fs::DirEntry;
#[cfg(not(target_os = "windows"))]
use std::os::unix::ffi::OsStrExt;
use url::percent_encoding;
#[cfg(target_os = "windows")]
use OsStrExt;
#[derive(Debug)]
pub struct ShareEntry {
name: String,
link: String,
is_dir: bool,
size: String,
date: DateTime<Local>,
date_string: String,
}
impl ShareEntry {
pub fn name(&self) -> &str {
&self.name
}
pub fn link(&self) -> &str {
&self.link
}
pub fn is_dir(&self) -> bool {
self.is_dir
}
pub fn size(&self) -> &str {
&self.size
}
pub fn date(&self) -> DateTime<Local> {
self.date
}
pub fn date_string(&self) -> &str {
&self.date_string
}
pub fn try_from(value: &DirEntry) -> Result<Self, Error> {
let metadata = value
.metadata()
.map_err(|e| Error::from_io(e, value.path().to_path_buf()))?;
let is_dir = metadata.is_dir();
let mut name = value.file_name();
if metadata.is_dir() {
name.push("/");
}
let link =
percent_encoding::percent_encode(name.as_bytes(), percent_encoding::DEFAULT_ENCODE_SET)
.to_string();
let name = name.to_string_lossy().into_owned();
let size = if !is_dir {
ByteSize::b(metadata.len()).to_string_as(false)
} else {
String::new()
};
let date = metadata
.modified()
.map_err(|e| Error::from_io(e, value.path().to_path_buf()))?
.into();
let date_string = HumanTime::from(date).to_string();
Ok(Self {
name,
link,
is_dir,
size,
date,
date_string,
})
}
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
pub const AUTO_WIDTH: i32 = -1i32;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AppEvents(pub ::windows::core::IUnknown);
impl AppEvents {}
unsafe impl ::windows::core::Interface for AppEvents {
type Vtable = AppEvents_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfc7a4252_78ac_4532_8c5a_563cfe138863);
}
impl ::core::convert::From<AppEvents> for ::windows::core::IUnknown {
fn from(value: AppEvents) -> Self {
value.0
}
}
impl ::core::convert::From<&AppEvents> for ::windows::core::IUnknown {
fn from(value: &AppEvents) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<AppEvents> for super::Com::IDispatch {
fn from(value: AppEvents) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&AppEvents> for super::Com::IDispatch {
fn from(value: &AppEvents) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct AppEvents_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
);
pub const AppEventsDHTMLConnector: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xade6444b_c91f_4e37_92a4_5bb430a33340);
pub const Application: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x49b2791a_b1ae_4c90_9b8e_e860ba07f889);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct CCM_COMMANDID_MASK_CONSTANTS(pub u32);
pub const CCM_COMMANDID_MASK_RESERVED: CCM_COMMANDID_MASK_CONSTANTS = CCM_COMMANDID_MASK_CONSTANTS(4294901760u32);
impl ::core::convert::From<u32> for CCM_COMMANDID_MASK_CONSTANTS {
fn from(value: u32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for CCM_COMMANDID_MASK_CONSTANTS {
type Abi = Self;
}
impl ::core::ops::BitOr for CCM_COMMANDID_MASK_CONSTANTS {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ::core::ops::BitAnd for CCM_COMMANDID_MASK_CONSTANTS {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl ::core::ops::BitOrAssign for CCM_COMMANDID_MASK_CONSTANTS {
fn bitor_assign(&mut self, rhs: Self) {
self.0.bitor_assign(rhs.0)
}
}
impl ::core::ops::BitAndAssign for CCM_COMMANDID_MASK_CONSTANTS {
fn bitand_assign(&mut self, rhs: Self) {
self.0.bitand_assign(rhs.0)
}
}
impl ::core::ops::Not for CCM_COMMANDID_MASK_CONSTANTS {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct CCM_INSERTIONALLOWED(pub i32);
pub const CCM_INSERTIONALLOWED_TOP: CCM_INSERTIONALLOWED = CCM_INSERTIONALLOWED(1i32);
pub const CCM_INSERTIONALLOWED_NEW: CCM_INSERTIONALLOWED = CCM_INSERTIONALLOWED(2i32);
pub const CCM_INSERTIONALLOWED_TASK: CCM_INSERTIONALLOWED = CCM_INSERTIONALLOWED(4i32);
pub const CCM_INSERTIONALLOWED_VIEW: CCM_INSERTIONALLOWED = CCM_INSERTIONALLOWED(8i32);
impl ::core::convert::From<i32> for CCM_INSERTIONALLOWED {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for CCM_INSERTIONALLOWED {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct CCM_INSERTIONPOINTID(pub i32);
pub const CCM_INSERTIONPOINTID_MASK_SPECIAL: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-65536i32);
pub const CCM_INSERTIONPOINTID_MASK_SHARED: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-2147483648i32);
pub const CCM_INSERTIONPOINTID_MASK_CREATE_PRIMARY: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(1073741824i32);
pub const CCM_INSERTIONPOINTID_MASK_ADD_PRIMARY: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(536870912i32);
pub const CCM_INSERTIONPOINTID_MASK_ADD_3RDPARTY: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(268435456i32);
pub const CCM_INSERTIONPOINTID_MASK_RESERVED: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(268369920i32);
pub const CCM_INSERTIONPOINTID_MASK_FLAGINDEX: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(31i32);
pub const CCM_INSERTIONPOINTID_PRIMARY_TOP: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1610612736i32);
pub const CCM_INSERTIONPOINTID_PRIMARY_NEW: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1610612735i32);
pub const CCM_INSERTIONPOINTID_PRIMARY_TASK: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1610612734i32);
pub const CCM_INSERTIONPOINTID_PRIMARY_VIEW: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1610612733i32);
pub const CCM_INSERTIONPOINTID_PRIMARY_HELP: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1610612732i32);
pub const CCM_INSERTIONPOINTID_3RDPARTY_NEW: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1879048191i32);
pub const CCM_INSERTIONPOINTID_3RDPARTY_TASK: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-1879048190i32);
pub const CCM_INSERTIONPOINTID_ROOT_MENU: CCM_INSERTIONPOINTID = CCM_INSERTIONPOINTID(-2147483648i32);
impl ::core::convert::From<i32> for CCM_INSERTIONPOINTID {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for CCM_INSERTIONPOINTID {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct CCM_SPECIAL(pub i32);
pub const CCM_SPECIAL_SEPARATOR: CCM_SPECIAL = CCM_SPECIAL(1i32);
pub const CCM_SPECIAL_SUBMENU: CCM_SPECIAL = CCM_SPECIAL(2i32);
pub const CCM_SPECIAL_DEFAULT_ITEM: CCM_SPECIAL = CCM_SPECIAL(4i32);
pub const CCM_SPECIAL_INSERTION_POINT: CCM_SPECIAL = CCM_SPECIAL(8i32);
pub const CCM_SPECIAL_TESTONLY: CCM_SPECIAL = CCM_SPECIAL(16i32);
impl ::core::convert::From<i32> for CCM_SPECIAL {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for CCM_SPECIAL {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct CONTEXTMENUITEM {
pub strName: super::super::Foundation::PWSTR,
pub strStatusBarText: super::super::Foundation::PWSTR,
pub lCommandID: i32,
pub lInsertionPointID: i32,
pub fFlags: i32,
pub fSpecialFlags: i32,
}
#[cfg(feature = "Win32_Foundation")]
impl CONTEXTMENUITEM {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for CONTEXTMENUITEM {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for CONTEXTMENUITEM {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("CONTEXTMENUITEM").field("strName", &self.strName).field("strStatusBarText", &self.strStatusBarText).field("lCommandID", &self.lCommandID).field("lInsertionPointID", &self.lInsertionPointID).field("fFlags", &self.fFlags).field("fSpecialFlags", &self.fSpecialFlags).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for CONTEXTMENUITEM {
fn eq(&self, other: &Self) -> bool {
self.strName == other.strName && self.strStatusBarText == other.strStatusBarText && self.lCommandID == other.lCommandID && self.lInsertionPointID == other.lInsertionPointID && self.fFlags == other.fFlags && self.fSpecialFlags == other.fSpecialFlags
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for CONTEXTMENUITEM {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for CONTEXTMENUITEM {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct CONTEXTMENUITEM2 {
pub strName: super::super::Foundation::PWSTR,
pub strStatusBarText: super::super::Foundation::PWSTR,
pub lCommandID: i32,
pub lInsertionPointID: i32,
pub fFlags: i32,
pub fSpecialFlags: i32,
pub strLanguageIndependentName: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl CONTEXTMENUITEM2 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for CONTEXTMENUITEM2 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for CONTEXTMENUITEM2 {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("CONTEXTMENUITEM2")
.field("strName", &self.strName)
.field("strStatusBarText", &self.strStatusBarText)
.field("lCommandID", &self.lCommandID)
.field("lInsertionPointID", &self.lInsertionPointID)
.field("fFlags", &self.fFlags)
.field("fSpecialFlags", &self.fSpecialFlags)
.field("strLanguageIndependentName", &self.strLanguageIndependentName)
.finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for CONTEXTMENUITEM2 {
fn eq(&self, other: &Self) -> bool {
self.strName == other.strName && self.strStatusBarText == other.strStatusBarText && self.lCommandID == other.lCommandID && self.lInsertionPointID == other.lInsertionPointID && self.fFlags == other.fFlags && self.fSpecialFlags == other.fSpecialFlags && self.strLanguageIndependentName == other.strLanguageIndependentName
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for CONTEXTMENUITEM2 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for CONTEXTMENUITEM2 {
type Abi = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Column(pub ::windows::core::IUnknown);
impl Column {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Name(&self) -> ::windows::core::Result<super::super::Foundation::BSTR> {
let mut result__: <super::super::Foundation::BSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BSTR>(result__)
}
pub unsafe fn Width(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetWidth(&self, width: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(width)).ok()
}
pub unsafe fn DisplayPosition(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetDisplayPosition(&self, index: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(index)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Hidden(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetHidden<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, hidden: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), hidden.into_param().abi()).ok()
}
pub unsafe fn SetAsSortColumn(&self, sortorder: _ColumnSortOrder) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), ::core::mem::transmute(sortorder)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn IsSortColumn(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
}
unsafe impl ::windows::core::Interface for Column {
type Vtable = Column_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfd1c5f63_2b16_4d06_9ab3_f45350b940ab);
}
impl ::core::convert::From<Column> for ::windows::core::IUnknown {
fn from(value: Column) -> Self {
value.0
}
}
impl ::core::convert::From<&Column> for ::windows::core::IUnknown {
fn from(value: &Column) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Column {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Column {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Column> for super::Com::IDispatch {
fn from(value: Column) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Column> for super::Com::IDispatch {
fn from(value: &Column) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Column {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Column {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Column_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, width: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, width: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, displayposition: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hidden: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hidden: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, sortorder: _ColumnSortOrder) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, issortcolumn: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Columns(pub ::windows::core::IUnknown);
impl Columns {
pub unsafe fn Item(&self, index: i32) -> ::windows::core::Result<Column> {
let mut result__: <Column as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(index), &mut result__).from_abi::<Column>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
}
unsafe impl ::windows::core::Interface for Columns {
type Vtable = Columns_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x383d4d97_fc44_478b_b139_6323dc48611c);
}
impl ::core::convert::From<Columns> for ::windows::core::IUnknown {
fn from(value: Columns) -> Self {
value.0
}
}
impl ::core::convert::From<&Columns> for ::windows::core::IUnknown {
fn from(value: &Columns) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Columns {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Columns {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Columns> for super::Com::IDispatch {
fn from(value: Columns) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Columns> for super::Com::IDispatch {
fn from(value: &Columns) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Columns {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Columns {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Columns_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32, column: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
pub const ConsolePower: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf0285374_dff1_11d3_b433_00c04f8ecd78);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ContextMenu(pub ::windows::core::IUnknown);
impl ContextMenu {
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn Item<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, indexorpath: Param0) -> ::windows::core::Result<MenuItem> {
let mut result__: <MenuItem as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), indexorpath.into_param().abi(), &mut result__).from_abi::<MenuItem>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for ContextMenu {
type Vtable = ContextMenu_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdab39ce0_25e6_4e07_8362_ba9c95706545);
}
impl ::core::convert::From<ContextMenu> for ::windows::core::IUnknown {
fn from(value: ContextMenu) -> Self {
value.0
}
}
impl ::core::convert::From<&ContextMenu> for ::windows::core::IUnknown {
fn from(value: &ContextMenu) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<ContextMenu> for super::Com::IDispatch {
fn from(value: ContextMenu) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&ContextMenu> for super::Com::IDispatch {
fn from(value: &ContextMenu) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for ContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &ContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ContextMenu_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, indexorpath: ::core::mem::ManuallyDrop<super::Com::VARIANT>, menuitem: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct DATA_OBJECT_TYPES(pub i32);
pub const CCT_SCOPE: DATA_OBJECT_TYPES = DATA_OBJECT_TYPES(32768i32);
pub const CCT_RESULT: DATA_OBJECT_TYPES = DATA_OBJECT_TYPES(32769i32);
pub const CCT_SNAPIN_MANAGER: DATA_OBJECT_TYPES = DATA_OBJECT_TYPES(32770i32);
pub const CCT_UNINITIALIZED: DATA_OBJECT_TYPES = DATA_OBJECT_TYPES(65535i32);
impl ::core::convert::From<i32> for DATA_OBJECT_TYPES {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for DATA_OBJECT_TYPES {
type Abi = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Document(pub ::windows::core::IUnknown);
impl Document {
pub unsafe fn Save(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SaveAs<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, filename: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), filename.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Close<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, savechanges: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), savechanges.into_param().abi()).ok()
}
pub unsafe fn Views(&self) -> ::windows::core::Result<Views> {
let mut result__: <Views as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Views>(result__)
}
pub unsafe fn SnapIns(&self) -> ::windows::core::Result<SnapIns> {
let mut result__: <SnapIns as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), &mut result__).from_abi::<SnapIns>(result__)
}
pub unsafe fn ActiveView(&self) -> ::windows::core::Result<View> {
let mut result__: <View as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<View>(result__)
}
pub unsafe fn Name(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetName<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, name: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), name.into_param().abi()).ok()
}
pub unsafe fn Location(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn IsSaved(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
pub unsafe fn Mode(&self) -> ::windows::core::Result<_DocumentMode> {
let mut result__: <_DocumentMode as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), &mut result__).from_abi::<_DocumentMode>(result__)
}
pub unsafe fn SetMode(&self, mode: _DocumentMode) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).18)(::core::mem::transmute_copy(self), ::core::mem::transmute(mode)).ok()
}
pub unsafe fn RootNode(&self) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).19)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn ScopeNamespace(&self) -> ::windows::core::Result<ScopeNamespace> {
let mut result__: <ScopeNamespace as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).20)(::core::mem::transmute_copy(self), &mut result__).from_abi::<ScopeNamespace>(result__)
}
pub unsafe fn CreateProperties(&self) -> ::windows::core::Result<Properties> {
let mut result__: <Properties as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).21)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Properties>(result__)
}
pub unsafe fn Application(&self) -> ::windows::core::Result<_Application> {
let mut result__: <_Application as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).22)(::core::mem::transmute_copy(self), &mut result__).from_abi::<_Application>(result__)
}
}
unsafe impl ::windows::core::Interface for Document {
type Vtable = Document_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x225120d6_1e0f_40a3_93fe_1079e6a8017b);
}
impl ::core::convert::From<Document> for ::windows::core::IUnknown {
fn from(value: Document) -> Self {
value.0
}
}
impl ::core::convert::From<&Document> for ::windows::core::IUnknown {
fn from(value: &Document) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Document {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Document {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Document> for super::Com::IDispatch {
fn from(value: Document) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Document> for super::Com::IDispatch {
fn from(value: &Document) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Document {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Document {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Document_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, filename: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, savechanges: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, views: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, snapins: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, location: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, issaved: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, mode: *mut _DocumentMode) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, mode: _DocumentMode) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenamespace: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, properties: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, application: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Extension(pub ::windows::core::IUnknown);
impl Extension {
pub unsafe fn Name(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Vendor(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Version(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Extensions(&self) -> ::windows::core::Result<Extensions> {
let mut result__: <Extensions as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Extensions>(result__)
}
pub unsafe fn SnapinCLSID(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn EnableAllExtensions<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, enable: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), enable.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Enable<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, enable: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), enable.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for Extension {
type Vtable = Extension_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xad4d6ca6_912f_409b_a26e_7fd234aef542);
}
impl ::core::convert::From<Extension> for ::windows::core::IUnknown {
fn from(value: Extension) -> Self {
value.0
}
}
impl ::core::convert::From<&Extension> for ::windows::core::IUnknown {
fn from(value: &Extension) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Extension {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Extension {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Extension> for super::Com::IDispatch {
fn from(value: Extension) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Extension> for super::Com::IDispatch {
fn from(value: &Extension) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Extension {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Extension {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Extension_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, vendor: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, version: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, extensions: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, snapinclsid: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, enable: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, enable: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Extensions(pub ::windows::core::IUnknown);
impl Extensions {
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn Item(&self, index: i32) -> ::windows::core::Result<Extension> {
let mut result__: <Extension as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(index), &mut result__).from_abi::<Extension>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for Extensions {
type Vtable = Extensions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x82dbea43_8ca4_44bc_a2ca_d18741059ec8);
}
impl ::core::convert::From<Extensions> for ::windows::core::IUnknown {
fn from(value: Extensions) -> Self {
value.0
}
}
impl ::core::convert::From<&Extensions> for ::windows::core::IUnknown {
fn from(value: &Extensions) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Extensions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Extensions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Extensions> for super::Com::IDispatch {
fn from(value: Extensions) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Extensions> for super::Com::IDispatch {
fn from(value: &Extensions) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Extensions {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Extensions {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Extensions_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32, extension: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Frame(pub ::windows::core::IUnknown);
impl Frame {
pub unsafe fn Maximize(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Minimize(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Restore(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Top(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetTop(&self, top: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(top)).ok()
}
pub unsafe fn Bottom(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetBottom(&self, bottom: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), ::core::mem::transmute(bottom)).ok()
}
pub unsafe fn Left(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetLeft(&self, left: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), ::core::mem::transmute(left)).ok()
}
pub unsafe fn Right(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetRight(&self, right: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), ::core::mem::transmute(right)).ok()
}
}
unsafe impl ::windows::core::Interface for Frame {
type Vtable = Frame_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe5e2d970_5bb3_4306_8804_b0968a31c8e6);
}
impl ::core::convert::From<Frame> for ::windows::core::IUnknown {
fn from(value: Frame) -> Self {
value.0
}
}
impl ::core::convert::From<&Frame> for ::windows::core::IUnknown {
fn from(value: &Frame) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Frame {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Frame {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Frame> for super::Com::IDispatch {
fn from(value: Frame) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Frame> for super::Com::IDispatch {
fn from(value: &Frame) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Frame {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Frame {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Frame_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, top: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, top: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, bottom: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, bottom: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, left: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, left: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, right: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, right: i32) -> ::windows::core::HRESULT,
);
pub const HDI_HIDDEN: u32 = 1u32;
pub const HIDE_COLUMN: i32 = -4i32;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IColumnData(pub ::windows::core::IUnknown);
impl IColumnData {
pub unsafe fn SetColumnConfigData(&self, pcolid: *const SColumnSetID, pcolsetdata: *const MMC_COLUMN_SET_DATA) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pcolid), ::core::mem::transmute(pcolsetdata)).ok()
}
pub unsafe fn GetColumnConfigData(&self, pcolid: *const SColumnSetID) -> ::windows::core::Result<*mut MMC_COLUMN_SET_DATA> {
let mut result__: <*mut MMC_COLUMN_SET_DATA as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(pcolid), &mut result__).from_abi::<*mut MMC_COLUMN_SET_DATA>(result__)
}
pub unsafe fn SetColumnSortData(&self, pcolid: *const SColumnSetID, pcolsortdata: *const MMC_SORT_SET_DATA) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(pcolid), ::core::mem::transmute(pcolsortdata)).ok()
}
pub unsafe fn GetColumnSortData(&self, pcolid: *const SColumnSetID) -> ::windows::core::Result<*mut MMC_SORT_SET_DATA> {
let mut result__: <*mut MMC_SORT_SET_DATA as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(pcolid), &mut result__).from_abi::<*mut MMC_SORT_SET_DATA>(result__)
}
}
unsafe impl ::windows::core::Interface for IColumnData {
type Vtable = IColumnData_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x547c1354_024d_11d3_a707_00c04f8ef4cb);
}
impl ::core::convert::From<IColumnData> for ::windows::core::IUnknown {
fn from(value: IColumnData) -> Self {
value.0
}
}
impl ::core::convert::From<&IColumnData> for ::windows::core::IUnknown {
fn from(value: &IColumnData) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IColumnData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IColumnData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IColumnData_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcolid: *const SColumnSetID, pcolsetdata: *const MMC_COLUMN_SET_DATA) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcolid: *const SColumnSetID, ppcolsetdata: *mut *mut MMC_COLUMN_SET_DATA) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcolid: *const SColumnSetID, pcolsortdata: *const MMC_SORT_SET_DATA) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcolid: *const SColumnSetID, ppcolsortdata: *mut *mut MMC_SORT_SET_DATA) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IComponent(pub ::windows::core::IUnknown);
impl IComponent {
pub unsafe fn Initialize<'a, Param0: ::windows::core::IntoParam<'a, IConsole>>(&self, lpconsole: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), lpconsole.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn Notify<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, event: MMC_NOTIFY_TYPE, arg: Param2, param3: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), ::core::mem::transmute(event), arg.into_param().abi(), param3.into_param().abi()).ok()
}
pub unsafe fn Destroy(&self, cookie: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDataObject(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDataObject> {
let mut result__: <super::Com::IDataObject as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDataObject>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetResultViewType(&self, cookie: isize, ppviewtype: *mut super::super::Foundation::PWSTR, pviewoptions: *mut i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(ppviewtype), ::core::mem::transmute(pviewoptions)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetDisplayInfo(&self, presultdataitem: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(presultdataitem)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CompareObjects<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobjecta: Param0, lpdataobjectb: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpdataobjecta.into_param().abi(), lpdataobjectb.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IComponent {
type Vtable = IComponent_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb2_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IComponent> for ::windows::core::IUnknown {
fn from(value: IComponent) -> Self {
value.0
}
}
impl ::core::convert::From<&IComponent> for ::windows::core::IUnknown {
fn from(value: &IComponent) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IComponent {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IComponent {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IComponent_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpconsole: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, event: MMC_NOTIFY_TYPE, arg: super::super::Foundation::LPARAM, param3: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdataobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, ppviewtype: *mut super::super::Foundation::PWSTR, pviewoptions: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, presultdataitem: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobjecta: ::windows::core::RawPtr, lpdataobjectb: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IComponent2(pub ::windows::core::IUnknown);
impl IComponent2 {
pub unsafe fn Initialize<'a, Param0: ::windows::core::IntoParam<'a, IConsole>>(&self, lpconsole: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), lpconsole.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn Notify<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, event: MMC_NOTIFY_TYPE, arg: Param2, param3: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), ::core::mem::transmute(event), arg.into_param().abi(), param3.into_param().abi()).ok()
}
pub unsafe fn Destroy(&self, cookie: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDataObject(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDataObject> {
let mut result__: <super::Com::IDataObject as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDataObject>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetResultViewType(&self, cookie: isize, ppviewtype: *mut super::super::Foundation::PWSTR, pviewoptions: *mut i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(ppviewtype), ::core::mem::transmute(pviewoptions)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetDisplayInfo(&self, presultdataitem: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(presultdataitem)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CompareObjects<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobjecta: Param0, lpdataobjectb: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpdataobjecta.into_param().abi(), lpdataobjectb.into_param().abi()).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDispatch(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDispatch> {
let mut result__: <super::Com::IDispatch as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDispatch>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetResultViewType2(&self, cookie: isize, presultviewtype: *mut RESULT_VIEW_TYPE_INFO) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(presultviewtype)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn RestoreResultView(&self, cookie: isize, presultviewtype: *const RESULT_VIEW_TYPE_INFO) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(presultviewtype)).ok()
}
}
unsafe impl ::windows::core::Interface for IComponent2 {
type Vtable = IComponent2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x79a2d615_4a10_4ed4_8c65_8633f9335095);
}
impl ::core::convert::From<IComponent2> for ::windows::core::IUnknown {
fn from(value: IComponent2) -> Self {
value.0
}
}
impl ::core::convert::From<&IComponent2> for ::windows::core::IUnknown {
fn from(value: &IComponent2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IComponent2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IComponent2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IComponent2> for IComponent {
fn from(value: IComponent2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IComponent2> for IComponent {
fn from(value: &IComponent2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IComponent> for IComponent2 {
fn into_param(self) -> ::windows::core::Param<'a, IComponent> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IComponent> for &IComponent2 {
fn into_param(self) -> ::windows::core::Param<'a, IComponent> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IComponent2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpconsole: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, event: MMC_NOTIFY_TYPE, arg: super::super::Foundation::LPARAM, param3: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdataobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, ppviewtype: *mut super::super::Foundation::PWSTR, pviewoptions: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, presultdataitem: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobjecta: ::windows::core::RawPtr, lpdataobjectb: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdispatch: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, presultviewtype: *mut ::core::mem::ManuallyDrop<RESULT_VIEW_TYPE_INFO>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, presultviewtype: *const ::core::mem::ManuallyDrop<RESULT_VIEW_TYPE_INFO>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IComponentData(pub ::windows::core::IUnknown);
impl IComponentData {
pub unsafe fn Initialize<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>>(&self, punknown: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), punknown.into_param().abi()).ok()
}
pub unsafe fn CreateComponent(&self) -> ::windows::core::Result<IComponent> {
let mut result__: <IComponent as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IComponent>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn Notify<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, event: MMC_NOTIFY_TYPE, arg: Param2, param3: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), ::core::mem::transmute(event), arg.into_param().abi(), param3.into_param().abi()).ok()
}
pub unsafe fn Destroy(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDataObject(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDataObject> {
let mut result__: <super::Com::IDataObject as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDataObject>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetDisplayInfo(&self, pscopedataitem: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(pscopedataitem)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CompareObjects<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobjecta: Param0, lpdataobjectb: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpdataobjecta.into_param().abi(), lpdataobjectb.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IComponentData {
type Vtable = IComponentData_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x955ab28a_5218_11d0_a985_00c04fd8d565);
}
impl ::core::convert::From<IComponentData> for ::windows::core::IUnknown {
fn from(value: IComponentData) -> Self {
value.0
}
}
impl ::core::convert::From<&IComponentData> for ::windows::core::IUnknown {
fn from(value: &IComponentData) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IComponentData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IComponentData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IComponentData_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, punknown: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppcomponent: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, event: MMC_NOTIFY_TYPE, arg: super::super::Foundation::LPARAM, param3: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdataobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pscopedataitem: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobjecta: ::windows::core::RawPtr, lpdataobjectb: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IComponentData2(pub ::windows::core::IUnknown);
impl IComponentData2 {
pub unsafe fn Initialize<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>>(&self, punknown: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), punknown.into_param().abi()).ok()
}
pub unsafe fn CreateComponent(&self) -> ::windows::core::Result<IComponent> {
let mut result__: <IComponent as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IComponent>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn Notify<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, event: MMC_NOTIFY_TYPE, arg: Param2, param3: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), ::core::mem::transmute(event), arg.into_param().abi(), param3.into_param().abi()).ok()
}
pub unsafe fn Destroy(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDataObject(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDataObject> {
let mut result__: <super::Com::IDataObject as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDataObject>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetDisplayInfo(&self, pscopedataitem: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(pscopedataitem)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CompareObjects<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobjecta: Param0, lpdataobjectb: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpdataobjecta.into_param().abi(), lpdataobjectb.into_param().abi()).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryDispatch(&self, cookie: isize, r#type: DATA_OBJECT_TYPES) -> ::windows::core::Result<super::Com::IDispatch> {
let mut result__: <super::Com::IDispatch as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(cookie), ::core::mem::transmute(r#type), &mut result__).from_abi::<super::Com::IDispatch>(result__)
}
}
unsafe impl ::windows::core::Interface for IComponentData2 {
type Vtable = IComponentData2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xcca0f2d2_82de_41b5_bf47_3b2076273d5c);
}
impl ::core::convert::From<IComponentData2> for ::windows::core::IUnknown {
fn from(value: IComponentData2) -> Self {
value.0
}
}
impl ::core::convert::From<&IComponentData2> for ::windows::core::IUnknown {
fn from(value: &IComponentData2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IComponentData2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IComponentData2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IComponentData2> for IComponentData {
fn from(value: IComponentData2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IComponentData2> for IComponentData {
fn from(value: &IComponentData2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IComponentData> for IComponentData2 {
fn into_param(self) -> ::windows::core::Param<'a, IComponentData> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IComponentData> for &IComponentData2 {
fn into_param(self) -> ::windows::core::Param<'a, IComponentData> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IComponentData2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, punknown: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppcomponent: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, event: MMC_NOTIFY_TYPE, arg: super::super::Foundation::LPARAM, param3: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdataobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pscopedataitem: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobjecta: ::windows::core::RawPtr, lpdataobjectb: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cookie: isize, r#type: DATA_OBJECT_TYPES, ppdispatch: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsole(pub ::windows::core::IUnknown);
impl IConsole {
pub unsafe fn SetHeader<'a, Param0: ::windows::core::IntoParam<'a, IHeaderCtrl>>(&self, pheader: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pheader.into_param().abi()).ok()
}
pub unsafe fn SetToolbar<'a, Param0: ::windows::core::IntoParam<'a, IToolbar>>(&self, ptoolbar: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ptoolbar.into_param().abi()).ok()
}
pub unsafe fn QueryResultView(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn QueryScopeImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
pub unsafe fn QueryResultImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn UpdateAllViews<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, data: Param1, hint: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), data.into_param().abi(), ::core::mem::transmute(hint)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn MessageBox<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, lpsztext: Param0, lpsztitle: Param1, fustyle: u32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpsztext.into_param().abi(), lpsztitle.into_param().abi(), ::core::mem::transmute(fustyle), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn QueryConsoleVerb(&self) -> ::windows::core::Result<IConsoleVerb> {
let mut result__: <IConsoleVerb as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IConsoleVerb>(result__)
}
pub unsafe fn SelectScopeItem(&self, hscopeitem: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetMainWindow(&self) -> ::windows::core::Result<super::super::Foundation::HWND> {
let mut result__: <super::super::Foundation::HWND as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::HWND>(result__)
}
pub unsafe fn NewWindow(&self, hscopeitem: isize, loptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem), ::core::mem::transmute(loptions)).ok()
}
}
unsafe impl ::windows::core::Interface for IConsole {
type Vtable = IConsole_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb1_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IConsole> for ::windows::core::IUnknown {
fn from(value: IConsole) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsole> for ::windows::core::IUnknown {
fn from(value: &IConsole) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsole {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsole {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsole_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pheader: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ptoolbar: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, punknown: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, data: super::super::Foundation::LPARAM, hint: isize) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpsztext: super::super::Foundation::PWSTR, lpsztitle: super::super::Foundation::PWSTR, fustyle: u32, piretval: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppconsoleverb: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, phwnd: *mut super::super::Foundation::HWND) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize, loptions: u32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsole2(pub ::windows::core::IUnknown);
impl IConsole2 {
pub unsafe fn SetHeader<'a, Param0: ::windows::core::IntoParam<'a, IHeaderCtrl>>(&self, pheader: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pheader.into_param().abi()).ok()
}
pub unsafe fn SetToolbar<'a, Param0: ::windows::core::IntoParam<'a, IToolbar>>(&self, ptoolbar: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ptoolbar.into_param().abi()).ok()
}
pub unsafe fn QueryResultView(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn QueryScopeImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
pub unsafe fn QueryResultImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn UpdateAllViews<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, data: Param1, hint: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), data.into_param().abi(), ::core::mem::transmute(hint)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn MessageBox<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, lpsztext: Param0, lpsztitle: Param1, fustyle: u32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpsztext.into_param().abi(), lpsztitle.into_param().abi(), ::core::mem::transmute(fustyle), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn QueryConsoleVerb(&self) -> ::windows::core::Result<IConsoleVerb> {
let mut result__: <IConsoleVerb as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IConsoleVerb>(result__)
}
pub unsafe fn SelectScopeItem(&self, hscopeitem: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetMainWindow(&self) -> ::windows::core::Result<super::super::Foundation::HWND> {
let mut result__: <super::super::Foundation::HWND as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::HWND>(result__)
}
pub unsafe fn NewWindow(&self, hscopeitem: isize, loptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem), ::core::mem::transmute(loptions)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Expand<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, hitem: isize, bexpand: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), bexpand.into_param().abi()).ok()
}
pub unsafe fn IsTaskpadViewPreferred(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetStatusText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszstatustext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), pszstatustext.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IConsole2 {
type Vtable = IConsole2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x103d842a_aa63_11d1_a7e1_00c04fd8d565);
}
impl ::core::convert::From<IConsole2> for ::windows::core::IUnknown {
fn from(value: IConsole2) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsole2> for ::windows::core::IUnknown {
fn from(value: &IConsole2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsole2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsole2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IConsole2> for IConsole {
fn from(value: IConsole2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IConsole2> for IConsole {
fn from(value: &IConsole2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole> for IConsole2 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole> for &IConsole2 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsole2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pheader: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ptoolbar: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, punknown: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, data: super::super::Foundation::LPARAM, hint: isize) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpsztext: super::super::Foundation::PWSTR, lpsztitle: super::super::Foundation::PWSTR, fustyle: u32, piretval: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppconsoleverb: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, phwnd: *mut super::super::Foundation::HWND) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize, loptions: u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, bexpand: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszstatustext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsole3(pub ::windows::core::IUnknown);
impl IConsole3 {
pub unsafe fn SetHeader<'a, Param0: ::windows::core::IntoParam<'a, IHeaderCtrl>>(&self, pheader: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pheader.into_param().abi()).ok()
}
pub unsafe fn SetToolbar<'a, Param0: ::windows::core::IntoParam<'a, IToolbar>>(&self, ptoolbar: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ptoolbar.into_param().abi()).ok()
}
pub unsafe fn QueryResultView(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn QueryScopeImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
pub unsafe fn QueryResultImageList(&self) -> ::windows::core::Result<IImageList> {
let mut result__: <IImageList as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IImageList>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn UpdateAllViews<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lpdataobject: Param0, data: Param1, hint: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi(), data.into_param().abi(), ::core::mem::transmute(hint)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn MessageBox<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, lpsztext: Param0, lpsztitle: Param1, fustyle: u32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), lpsztext.into_param().abi(), lpsztitle.into_param().abi(), ::core::mem::transmute(fustyle), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn QueryConsoleVerb(&self) -> ::windows::core::Result<IConsoleVerb> {
let mut result__: <IConsoleVerb as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IConsoleVerb>(result__)
}
pub unsafe fn SelectScopeItem(&self, hscopeitem: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetMainWindow(&self) -> ::windows::core::Result<super::super::Foundation::HWND> {
let mut result__: <super::super::Foundation::HWND as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::HWND>(result__)
}
pub unsafe fn NewWindow(&self, hscopeitem: isize, loptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem), ::core::mem::transmute(loptions)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Expand<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, hitem: isize, bexpand: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), bexpand.into_param().abi()).ok()
}
pub unsafe fn IsTaskpadViewPreferred(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetStatusText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszstatustext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), pszstatustext.into_param().abi()).ok()
}
pub unsafe fn RenameScopeItem(&self, hscopeitem: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), ::core::mem::transmute(hscopeitem)).ok()
}
}
unsafe impl ::windows::core::Interface for IConsole3 {
type Vtable = IConsole3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4f85efdb_d0e1_498c_8d4a_d010dfdd404f);
}
impl ::core::convert::From<IConsole3> for ::windows::core::IUnknown {
fn from(value: IConsole3) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsole3> for ::windows::core::IUnknown {
fn from(value: &IConsole3) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IConsole3> for IConsole2 {
fn from(value: IConsole3) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IConsole3> for IConsole2 {
fn from(value: &IConsole3) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole2> for IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole2> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole2> for &IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole2> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
impl ::core::convert::From<IConsole3> for IConsole {
fn from(value: IConsole3) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IConsole3> for IConsole {
fn from(value: &IConsole3) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole> for IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsole> for &IConsole3 {
fn into_param(self) -> ::windows::core::Param<'a, IConsole> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsole3_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pheader: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ptoolbar: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, punknown: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppimagelist: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr, data: super::super::Foundation::LPARAM, hint: isize) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpsztext: super::super::Foundation::PWSTR, lpsztitle: super::super::Foundation::PWSTR, fustyle: u32, piretval: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppconsoleverb: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, phwnd: *mut super::super::Foundation::HWND) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize, loptions: u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, bexpand: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszstatustext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hscopeitem: isize) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsoleNameSpace(pub ::windows::core::IUnknown);
impl IConsoleNameSpace {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertItem(&self, item: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn DeleteItem(&self, hitem: isize, fdeletethis: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), ::core::mem::transmute(fdeletethis)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetItem(&self, item: *const SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetItem(&self, item: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn GetChildItem(&self, item: isize, pitemchild: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemchild), ::core::mem::transmute(pcookie)).ok()
}
pub unsafe fn GetNextItem(&self, item: isize, pitemnext: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemnext), ::core::mem::transmute(pcookie)).ok()
}
pub unsafe fn GetParentItem(&self, item: isize, pitemparent: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemparent), ::core::mem::transmute(pcookie)).ok()
}
}
unsafe impl ::windows::core::Interface for IConsoleNameSpace {
type Vtable = IConsoleNameSpace_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xbedeb620_f24d_11cf_8afc_00aa003ca9f6);
}
impl ::core::convert::From<IConsoleNameSpace> for ::windows::core::IUnknown {
fn from(value: IConsoleNameSpace) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsoleNameSpace> for ::windows::core::IUnknown {
fn from(value: &IConsoleNameSpace) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsoleNameSpace {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsoleNameSpace {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsoleNameSpace_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, fdeletethis: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *const SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemchild: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemnext: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemparent: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsoleNameSpace2(pub ::windows::core::IUnknown);
impl IConsoleNameSpace2 {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertItem(&self, item: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn DeleteItem(&self, hitem: isize, fdeletethis: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), ::core::mem::transmute(fdeletethis)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetItem(&self, item: *const SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetItem(&self, item: *mut SCOPEDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn GetChildItem(&self, item: isize, pitemchild: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemchild), ::core::mem::transmute(pcookie)).ok()
}
pub unsafe fn GetNextItem(&self, item: isize, pitemnext: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemnext), ::core::mem::transmute(pcookie)).ok()
}
pub unsafe fn GetParentItem(&self, item: isize, pitemparent: *mut isize, pcookie: *mut isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(item), ::core::mem::transmute(pitemparent), ::core::mem::transmute(pcookie)).ok()
}
pub unsafe fn Expand(&self, hitem: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem)).ok()
}
pub unsafe fn AddExtension(&self, hitem: isize, lpclsid: *const ::windows::core::GUID) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), ::core::mem::transmute(lpclsid)).ok()
}
}
unsafe impl ::windows::core::Interface for IConsoleNameSpace2 {
type Vtable = IConsoleNameSpace2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x255f18cc_65db_11d1_a7dc_00c04fd8d565);
}
impl ::core::convert::From<IConsoleNameSpace2> for ::windows::core::IUnknown {
fn from(value: IConsoleNameSpace2) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsoleNameSpace2> for ::windows::core::IUnknown {
fn from(value: &IConsoleNameSpace2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsoleNameSpace2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsoleNameSpace2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IConsoleNameSpace2> for IConsoleNameSpace {
fn from(value: IConsoleNameSpace2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IConsoleNameSpace2> for IConsoleNameSpace {
fn from(value: &IConsoleNameSpace2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsoleNameSpace> for IConsoleNameSpace2 {
fn into_param(self) -> ::windows::core::Param<'a, IConsoleNameSpace> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IConsoleNameSpace> for &IConsoleNameSpace2 {
fn into_param(self) -> ::windows::core::Param<'a, IConsoleNameSpace> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsoleNameSpace2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, fdeletethis: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *const SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut SCOPEDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemchild: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemnext: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: isize, pitemparent: *mut isize, pcookie: *mut isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, lpclsid: *const ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsolePower(pub ::windows::core::IUnknown);
impl IConsolePower {
pub unsafe fn SetExecutionState(&self, dwadd: u32, dwremove: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(dwadd), ::core::mem::transmute(dwremove)).ok()
}
pub unsafe fn ResetIdleTimer(&self, dwflags: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(dwflags)).ok()
}
}
unsafe impl ::windows::core::Interface for IConsolePower {
type Vtable = IConsolePower_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1cfbdd0e_62ca_49ce_a3af_dbb2de61b068);
}
impl ::core::convert::From<IConsolePower> for ::windows::core::IUnknown {
fn from(value: IConsolePower) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsolePower> for ::windows::core::IUnknown {
fn from(value: &IConsolePower) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsolePower {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsolePower {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsolePower_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dwadd: u32, dwremove: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dwflags: u32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsolePowerSink(pub ::windows::core::IUnknown);
impl IConsolePowerSink {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn OnPowerBroadcast<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, nevent: u32, lparam: Param1) -> ::windows::core::Result<super::super::Foundation::LRESULT> {
let mut result__: <super::super::Foundation::LRESULT as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(nevent), lparam.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::LRESULT>(result__)
}
}
unsafe impl ::windows::core::Interface for IConsolePowerSink {
type Vtable = IConsolePowerSink_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3333759f_fe4f_4975_b143_fec0a5dd6d65);
}
impl ::core::convert::From<IConsolePowerSink> for ::windows::core::IUnknown {
fn from(value: IConsolePowerSink) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsolePowerSink> for ::windows::core::IUnknown {
fn from(value: &IConsolePowerSink) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsolePowerSink {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsolePowerSink {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsolePowerSink_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nevent: u32, lparam: super::super::Foundation::LPARAM, plreturn: *mut super::super::Foundation::LRESULT) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IConsoleVerb(pub ::windows::core::IUnknown);
impl IConsoleVerb {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetVerbState(&self, ecmdid: MMC_CONSOLE_VERB, nstate: MMC_BUTTON_STATE) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(ecmdid), ::core::mem::transmute(nstate), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetVerbState<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, ecmdid: MMC_CONSOLE_VERB, nstate: MMC_BUTTON_STATE, bstate: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(ecmdid), ::core::mem::transmute(nstate), bstate.into_param().abi()).ok()
}
pub unsafe fn SetDefaultVerb(&self, ecmdid: MMC_CONSOLE_VERB) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(ecmdid)).ok()
}
pub unsafe fn GetDefaultVerb(&self) -> ::windows::core::Result<MMC_CONSOLE_VERB> {
let mut result__: <MMC_CONSOLE_VERB as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<MMC_CONSOLE_VERB>(result__)
}
}
unsafe impl ::windows::core::Interface for IConsoleVerb {
type Vtable = IConsoleVerb_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe49f7a60_74af_11d0_a286_00c04fd8fe93);
}
impl ::core::convert::From<IConsoleVerb> for ::windows::core::IUnknown {
fn from(value: IConsoleVerb) -> Self {
value.0
}
}
impl ::core::convert::From<&IConsoleVerb> for ::windows::core::IUnknown {
fn from(value: &IConsoleVerb) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IConsoleVerb {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IConsoleVerb {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IConsoleVerb_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ecmdid: MMC_CONSOLE_VERB, nstate: MMC_BUTTON_STATE, pstate: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ecmdid: MMC_CONSOLE_VERB, nstate: MMC_BUTTON_STATE, bstate: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ecmdid: MMC_CONSOLE_VERB) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pecmdid: *mut MMC_CONSOLE_VERB) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IContextMenuCallback(pub ::windows::core::IUnknown);
impl IContextMenuCallback {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddItem(&self, pitem: *const CONTEXTMENUITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pitem)).ok()
}
}
unsafe impl ::windows::core::Interface for IContextMenuCallback {
type Vtable = IContextMenuCallback_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb7_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IContextMenuCallback> for ::windows::core::IUnknown {
fn from(value: IContextMenuCallback) -> Self {
value.0
}
}
impl ::core::convert::From<&IContextMenuCallback> for ::windows::core::IUnknown {
fn from(value: &IContextMenuCallback) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IContextMenuCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IContextMenuCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IContextMenuCallback_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pitem: *const CONTEXTMENUITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IContextMenuCallback2(pub ::windows::core::IUnknown);
impl IContextMenuCallback2 {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddItem(&self, pitem: *const CONTEXTMENUITEM2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pitem)).ok()
}
}
unsafe impl ::windows::core::Interface for IContextMenuCallback2 {
type Vtable = IContextMenuCallback2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe178bc0e_2ed0_4b5e_8097_42c9087e8b33);
}
impl ::core::convert::From<IContextMenuCallback2> for ::windows::core::IUnknown {
fn from(value: IContextMenuCallback2) -> Self {
value.0
}
}
impl ::core::convert::From<&IContextMenuCallback2> for ::windows::core::IUnknown {
fn from(value: &IContextMenuCallback2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IContextMenuCallback2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IContextMenuCallback2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IContextMenuCallback2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pitem: *const CONTEXTMENUITEM2) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IContextMenuProvider(pub ::windows::core::IUnknown);
impl IContextMenuProvider {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddItem(&self, pitem: *const CONTEXTMENUITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pitem)).ok()
}
pub unsafe fn EmptyMenuList(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn AddPrimaryExtensionItems<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, piextension: Param0, pidataobject: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), piextension.into_param().abi(), pidataobject.into_param().abi()).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn AddThirdPartyExtensionItems<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, pidataobject: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), pidataobject.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ShowContextMenu<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>>(&self, hwndparent: Param0, xpos: i32, ypos: i32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), hwndparent.into_param().abi(), ::core::mem::transmute(xpos), ::core::mem::transmute(ypos), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for IContextMenuProvider {
type Vtable = IContextMenuProvider_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb6_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IContextMenuProvider> for ::windows::core::IUnknown {
fn from(value: IContextMenuProvider) -> Self {
value.0
}
}
impl ::core::convert::From<&IContextMenuProvider> for ::windows::core::IUnknown {
fn from(value: &IContextMenuProvider) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IContextMenuProvider {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IContextMenuProvider {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IContextMenuProvider> for IContextMenuCallback {
fn from(value: IContextMenuProvider) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IContextMenuProvider> for IContextMenuCallback {
fn from(value: &IContextMenuProvider) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IContextMenuCallback> for IContextMenuProvider {
fn into_param(self) -> ::windows::core::Param<'a, IContextMenuCallback> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IContextMenuCallback> for &IContextMenuProvider {
fn into_param(self) -> ::windows::core::Param<'a, IContextMenuCallback> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IContextMenuProvider_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pitem: *const CONTEXTMENUITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, piextension: ::windows::core::RawPtr, pidataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pidataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hwndparent: super::super::Foundation::HWND, xpos: i32, ypos: i32, plselected: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IControlbar(pub ::windows::core::IUnknown);
impl IControlbar {
pub unsafe fn Create<'a, Param1: ::windows::core::IntoParam<'a, IExtendControlbar>>(&self, ntype: MMC_CONTROL_TYPE, pextendcontrolbar: Param1) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(ntype), pextendcontrolbar.into_param().abi(), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn Attach<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>>(&self, ntype: MMC_CONTROL_TYPE, lpunknown: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(ntype), lpunknown.into_param().abi()).ok()
}
pub unsafe fn Detach<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>>(&self, lpunknown: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lpunknown.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IControlbar {
type Vtable = IControlbar_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x69fb811e_6c1c_11d0_a2cb_00c04fd909dd);
}
impl ::core::convert::From<IControlbar> for ::windows::core::IUnknown {
fn from(value: IControlbar) -> Self {
value.0
}
}
impl ::core::convert::From<&IControlbar> for ::windows::core::IUnknown {
fn from(value: &IControlbar) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IControlbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IControlbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IControlbar_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ntype: MMC_CONTROL_TYPE, pextendcontrolbar: ::windows::core::RawPtr, ppunknown: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ntype: MMC_CONTROL_TYPE, lpunknown: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpunknown: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IDisplayHelp(pub ::windows::core::IUnknown);
impl IDisplayHelp {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ShowTopic<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszhelptopic: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pszhelptopic.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IDisplayHelp {
type Vtable = IDisplayHelp_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xcc593830_b926_11d1_8063_0000f875a9ce);
}
impl ::core::convert::From<IDisplayHelp> for ::windows::core::IUnknown {
fn from(value: IDisplayHelp) -> Self {
value.0
}
}
impl ::core::convert::From<&IDisplayHelp> for ::windows::core::IUnknown {
fn from(value: &IDisplayHelp) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IDisplayHelp {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IDisplayHelp {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IDisplayHelp_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszhelptopic: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IEnumTASK(pub ::windows::core::IUnknown);
impl IEnumTASK {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Next(&self, celt: u32, rgelt: *mut MMC_TASK, pceltfetched: *mut u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(celt), ::core::mem::transmute(rgelt), ::core::mem::transmute(pceltfetched)).ok()
}
pub unsafe fn Skip(&self, celt: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(celt)).ok()
}
pub unsafe fn Reset(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Clone(&self) -> ::windows::core::Result<IEnumTASK> {
let mut result__: <IEnumTASK as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<IEnumTASK>(result__)
}
}
unsafe impl ::windows::core::Interface for IEnumTASK {
type Vtable = IEnumTASK_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x338698b1_5a02_11d1_9fec_00600832db4a);
}
impl ::core::convert::From<IEnumTASK> for ::windows::core::IUnknown {
fn from(value: IEnumTASK) -> Self {
value.0
}
}
impl ::core::convert::From<&IEnumTASK> for ::windows::core::IUnknown {
fn from(value: &IEnumTASK) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IEnumTASK {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IEnumTASK {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IEnumTASK_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, celt: u32, rgelt: *mut MMC_TASK, pceltfetched: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, celt: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppenum: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendContextMenu(pub ::windows::core::IUnknown);
impl IExtendContextMenu {
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn AddMenuItems<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, IContextMenuCallback>>(&self, pidataobject: Param0, picallback: Param1, pinsertionallowed: *mut i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pidataobject.into_param().abi(), picallback.into_param().abi(), ::core::mem::transmute(pinsertionallowed)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn Command<'a, Param1: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lcommandid: i32, pidataobject: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(lcommandid), pidataobject.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IExtendContextMenu {
type Vtable = IExtendContextMenu_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4f3b7a4f_cfac_11cf_b8e3_00c04fd8d5b0);
}
impl ::core::convert::From<IExtendContextMenu> for ::windows::core::IUnknown {
fn from(value: IExtendContextMenu) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendContextMenu> for ::windows::core::IUnknown {
fn from(value: &IExtendContextMenu) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendContextMenu {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendContextMenu_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pidataobject: ::windows::core::RawPtr, picallback: ::windows::core::RawPtr, pinsertionallowed: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lcommandid: i32, pidataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendControlbar(pub ::windows::core::IUnknown);
impl IExtendControlbar {
pub unsafe fn SetControlbar<'a, Param0: ::windows::core::IntoParam<'a, IControlbar>>(&self, pcontrolbar: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pcontrolbar.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ControlbarNotify<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, event: MMC_NOTIFY_TYPE, arg: Param1, param2: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(event), arg.into_param().abi(), param2.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IExtendControlbar {
type Vtable = IExtendControlbar_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x49506520_6f40_11d0_a98b_00c04fd8d565);
}
impl ::core::convert::From<IExtendControlbar> for ::windows::core::IUnknown {
fn from(value: IExtendControlbar) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendControlbar> for ::windows::core::IUnknown {
fn from(value: &IExtendControlbar) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendControlbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendControlbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendControlbar_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcontrolbar: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, event: MMC_NOTIFY_TYPE, arg: super::super::Foundation::LPARAM, param2: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendPropertySheet(pub ::windows::core::IUnknown);
impl IExtendPropertySheet {
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CreatePropertyPages<'a, Param0: ::windows::core::IntoParam<'a, IPropertySheetCallback>, Param2: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpprovider: Param0, handle: isize, lpidataobject: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), lpprovider.into_param().abi(), ::core::mem::transmute(handle), lpidataobject.into_param().abi()).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryPagesFor<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobject: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IExtendPropertySheet {
type Vtable = IExtendPropertySheet_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x85de64dc_ef21_11cf_a285_00c04fd8dbe6);
}
impl ::core::convert::From<IExtendPropertySheet> for ::windows::core::IUnknown {
fn from(value: IExtendPropertySheet) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendPropertySheet> for ::windows::core::IUnknown {
fn from(value: &IExtendPropertySheet) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendPropertySheet {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendPropertySheet {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendPropertySheet_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpprovider: ::windows::core::RawPtr, handle: isize, lpidataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendPropertySheet2(pub ::windows::core::IUnknown);
impl IExtendPropertySheet2 {
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn CreatePropertyPages<'a, Param0: ::windows::core::IntoParam<'a, IPropertySheetCallback>, Param2: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpprovider: Param0, handle: isize, lpidataobject: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), lpprovider.into_param().abi(), ::core::mem::transmute(handle), lpidataobject.into_param().abi()).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn QueryPagesFor<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpdataobject: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), lpdataobject.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_System_Com"))]
pub unsafe fn GetWatermarks<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, lpidataobject: Param0, lphwatermark: *mut super::super::Graphics::Gdi::HBITMAP, lphheader: *mut super::super::Graphics::Gdi::HBITMAP, lphpalette: *mut super::super::Graphics::Gdi::HPALETTE, bstretch: *mut super::super::Foundation::BOOL) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lpidataobject.into_param().abi(), ::core::mem::transmute(lphwatermark), ::core::mem::transmute(lphheader), ::core::mem::transmute(lphpalette), ::core::mem::transmute(bstretch)).ok()
}
}
unsafe impl ::windows::core::Interface for IExtendPropertySheet2 {
type Vtable = IExtendPropertySheet2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb7a87232_4a51_11d1_a7ea_00c04fd909dd);
}
impl ::core::convert::From<IExtendPropertySheet2> for ::windows::core::IUnknown {
fn from(value: IExtendPropertySheet2) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendPropertySheet2> for ::windows::core::IUnknown {
fn from(value: &IExtendPropertySheet2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendPropertySheet2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendPropertySheet2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IExtendPropertySheet2> for IExtendPropertySheet {
fn from(value: IExtendPropertySheet2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IExtendPropertySheet2> for IExtendPropertySheet {
fn from(value: &IExtendPropertySheet2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IExtendPropertySheet> for IExtendPropertySheet2 {
fn into_param(self) -> ::windows::core::Param<'a, IExtendPropertySheet> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IExtendPropertySheet> for &IExtendPropertySheet2 {
fn into_param(self) -> ::windows::core::Param<'a, IExtendPropertySheet> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendPropertySheet2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpprovider: ::windows::core::RawPtr, handle: isize, lpidataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpidataobject: ::windows::core::RawPtr, lphwatermark: *mut super::super::Graphics::Gdi::HBITMAP, lphheader: *mut super::super::Graphics::Gdi::HBITMAP, lphpalette: *mut super::super::Graphics::Gdi::HPALETTE, bstretch: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_Graphics_Gdi", feature = "Win32_System_Com")))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendTaskPad(pub ::windows::core::IUnknown);
impl IExtendTaskPad {
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn TaskNotify<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, pdo: Param0, arg: *const super::Com::VARIANT, param2: *const super::Com::VARIANT) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pdo.into_param().abi(), ::core::mem::transmute(arg), ::core::mem::transmute(param2)).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn EnumTasks<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pdo: Param0, sztaskgroup: Param1) -> ::windows::core::Result<IEnumTASK> {
let mut result__: <IEnumTASK as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), pdo.into_param().abi(), sztaskgroup.into_param().abi(), &mut result__).from_abi::<IEnumTASK>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetTitle<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszgroup: Param0) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), pszgroup.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetDescriptiveText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszgroup: Param0) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), pszgroup.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetBackground<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszgroup: Param0) -> ::windows::core::Result<MMC_TASK_DISPLAY_OBJECT> {
let mut result__: <MMC_TASK_DISPLAY_OBJECT as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), pszgroup.into_param().abi(), &mut result__).from_abi::<MMC_TASK_DISPLAY_OBJECT>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetListPadInfo<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszgroup: Param0) -> ::windows::core::Result<MMC_LISTPAD_INFO> {
let mut result__: <MMC_LISTPAD_INFO as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), pszgroup.into_param().abi(), &mut result__).from_abi::<MMC_LISTPAD_INFO>(result__)
}
}
unsafe impl ::windows::core::Interface for IExtendTaskPad {
type Vtable = IExtendTaskPad_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8dee6511_554d_11d1_9fea_00600832db4a);
}
impl ::core::convert::From<IExtendTaskPad> for ::windows::core::IUnknown {
fn from(value: IExtendTaskPad) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendTaskPad> for ::windows::core::IUnknown {
fn from(value: &IExtendTaskPad) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendTaskPad {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendTaskPad {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendTaskPad_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pdo: ::windows::core::RawPtr, arg: *const ::core::mem::ManuallyDrop<super::Com::VARIANT>, param2: *const ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pdo: ::windows::core::RawPtr, sztaskgroup: super::super::Foundation::PWSTR, ppenumtask: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszgroup: super::super::Foundation::PWSTR, psztitle: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszgroup: super::super::Foundation::PWSTR, pszdescriptivetext: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszgroup: super::super::Foundation::PWSTR, ptdo: *mut MMC_TASK_DISPLAY_OBJECT) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszgroup: super::super::Foundation::PWSTR, lplistpadinfo: *mut MMC_LISTPAD_INFO) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IExtendView(pub ::windows::core::IUnknown);
impl IExtendView {
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn GetViews<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, IViewExtensionCallback>>(&self, pdataobject: Param0, pviewextensioncallback: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pdataobject.into_param().abi(), pviewextensioncallback.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IExtendView {
type Vtable = IExtendView_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x89995cee_d2ed_4c0e_ae5e_df7e76f3fa53);
}
impl ::core::convert::From<IExtendView> for ::windows::core::IUnknown {
fn from(value: IExtendView) -> Self {
value.0
}
}
impl ::core::convert::From<&IExtendView> for ::windows::core::IUnknown {
fn from(value: &IExtendView) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IExtendView {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IExtendView {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IExtendView_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pdataobject: ::windows::core::RawPtr, pviewextensioncallback: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IHeaderCtrl(pub ::windows::core::IUnknown);
impl IHeaderCtrl {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertColumn<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, ncol: i32, title: Param1, nformat: i32, nwidth: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), title.into_param().abi(), ::core::mem::transmute(nformat), ::core::mem::transmute(nwidth)).ok()
}
pub unsafe fn DeleteColumn(&self, ncol: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetColumnText<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, ncol: i32, title: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), title.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetColumnText(&self, ncol: i32) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
pub unsafe fn SetColumnWidth(&self, ncol: i32, nwidth: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), ::core::mem::transmute(nwidth)).ok()
}
pub unsafe fn GetColumnWidth(&self, ncol: i32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for IHeaderCtrl {
type Vtable = IHeaderCtrl_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb3_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IHeaderCtrl> for ::windows::core::IUnknown {
fn from(value: IHeaderCtrl) -> Self {
value.0
}
}
impl ::core::convert::From<&IHeaderCtrl> for ::windows::core::IUnknown {
fn from(value: &IHeaderCtrl) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IHeaderCtrl {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IHeaderCtrl {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IHeaderCtrl_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, title: super::super::Foundation::PWSTR, nformat: i32, nwidth: i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, title: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, ptext: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, nwidth: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, pwidth: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IHeaderCtrl2(pub ::windows::core::IUnknown);
impl IHeaderCtrl2 {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertColumn<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, ncol: i32, title: Param1, nformat: i32, nwidth: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), title.into_param().abi(), ::core::mem::transmute(nformat), ::core::mem::transmute(nwidth)).ok()
}
pub unsafe fn DeleteColumn(&self, ncol: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetColumnText<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, ncol: i32, title: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), title.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetColumnText(&self, ncol: i32) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
pub unsafe fn SetColumnWidth(&self, ncol: i32, nwidth: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), ::core::mem::transmute(nwidth)).ok()
}
pub unsafe fn GetColumnWidth(&self, ncol: i32) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncol), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn SetChangeTimeOut(&self, utimeout: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(utimeout)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetColumnFilter(&self, ncolumn: u32, dwtype: u32, pfilterdata: *const MMC_FILTERDATA) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncolumn), ::core::mem::transmute(dwtype), ::core::mem::transmute(pfilterdata)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetColumnFilter(&self, ncolumn: u32, pdwtype: *mut u32, pfilterdata: *mut MMC_FILTERDATA) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncolumn), ::core::mem::transmute(pdwtype), ::core::mem::transmute(pfilterdata)).ok()
}
}
unsafe impl ::windows::core::Interface for IHeaderCtrl2 {
type Vtable = IHeaderCtrl2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9757abb8_1b32_11d1_a7ce_00c04fd8d565);
}
impl ::core::convert::From<IHeaderCtrl2> for ::windows::core::IUnknown {
fn from(value: IHeaderCtrl2) -> Self {
value.0
}
}
impl ::core::convert::From<&IHeaderCtrl2> for ::windows::core::IUnknown {
fn from(value: &IHeaderCtrl2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IHeaderCtrl2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IHeaderCtrl2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IHeaderCtrl2> for IHeaderCtrl {
fn from(value: IHeaderCtrl2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IHeaderCtrl2> for IHeaderCtrl {
fn from(value: &IHeaderCtrl2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IHeaderCtrl> for IHeaderCtrl2 {
fn into_param(self) -> ::windows::core::Param<'a, IHeaderCtrl> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IHeaderCtrl> for &IHeaderCtrl2 {
fn into_param(self) -> ::windows::core::Param<'a, IHeaderCtrl> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IHeaderCtrl2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, title: super::super::Foundation::PWSTR, nformat: i32, nwidth: i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, title: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, ptext: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, nwidth: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncol: i32, pwidth: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, utimeout: u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncolumn: u32, dwtype: u32, pfilterdata: *const MMC_FILTERDATA) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncolumn: u32, pdwtype: *mut u32, pfilterdata: *mut MMC_FILTERDATA) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IImageList(pub ::windows::core::IUnknown);
impl IImageList {
pub unsafe fn ImageListSetIcon(&self, picon: *const isize, nloc: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(picon), ::core::mem::transmute(nloc)).ok()
}
pub unsafe fn ImageListSetStrip(&self, pbmapsm: *const isize, pbmaplg: *const isize, nstartloc: i32, cmask: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(pbmapsm), ::core::mem::transmute(pbmaplg), ::core::mem::transmute(nstartloc), ::core::mem::transmute(cmask)).ok()
}
}
unsafe impl ::windows::core::Interface for IImageList {
type Vtable = IImageList_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb8_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IImageList> for ::windows::core::IUnknown {
fn from(value: IImageList) -> Self {
value.0
}
}
impl ::core::convert::From<&IImageList> for ::windows::core::IUnknown {
fn from(value: &IImageList) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IImageList {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IImageList {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IImageList_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, picon: *const isize, nloc: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pbmapsm: *const isize, pbmaplg: *const isize, nstartloc: i32, cmask: u32) -> ::windows::core::HRESULT,
);
pub const ILSIF_LEAVE_LARGE_ICON: u32 = 1073741824u32;
pub const ILSIF_LEAVE_SMALL_ICON: u32 = 536870912u32;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IMMCVersionInfo(pub ::windows::core::IUnknown);
impl IMMCVersionInfo {
pub unsafe fn GetMMCVersion(&self, pversionmajor: *mut i32, pversionminor: *mut i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pversionmajor), ::core::mem::transmute(pversionminor)).ok()
}
}
unsafe impl ::windows::core::Interface for IMMCVersionInfo {
type Vtable = IMMCVersionInfo_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa8d2c5fe_cdcb_4b9d_bde5_a27343ff54bc);
}
impl ::core::convert::From<IMMCVersionInfo> for ::windows::core::IUnknown {
fn from(value: IMMCVersionInfo) -> Self {
value.0
}
}
impl ::core::convert::From<&IMMCVersionInfo> for ::windows::core::IUnknown {
fn from(value: &IMMCVersionInfo) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IMMCVersionInfo {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IMMCVersionInfo {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IMMCVersionInfo_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pversionmajor: *mut i32, pversionminor: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IMenuButton(pub ::windows::core::IUnknown);
impl IMenuButton {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddButton<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, idcommand: i32, lpbuttontext: Param1, lptooltiptext: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(idcommand), lpbuttontext.into_param().abi(), lptooltiptext.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetButton<'a, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, idcommand: i32, lpbuttontext: Param1, lptooltiptext: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(idcommand), lpbuttontext.into_param().abi(), lptooltiptext.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetButtonState<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, idcommand: i32, nstate: MMC_BUTTON_STATE, bstate: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(idcommand), ::core::mem::transmute(nstate), bstate.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IMenuButton {
type Vtable = IMenuButton_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x951ed750_d080_11d0_b197_000000000000);
}
impl ::core::convert::From<IMenuButton> for ::windows::core::IUnknown {
fn from(value: IMenuButton) -> Self {
value.0
}
}
impl ::core::convert::From<&IMenuButton> for ::windows::core::IUnknown {
fn from(value: &IMenuButton) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IMenuButton {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IMenuButton {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IMenuButton_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, idcommand: i32, lpbuttontext: super::super::Foundation::PWSTR, lptooltiptext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, idcommand: i32, lpbuttontext: super::super::Foundation::PWSTR, lptooltiptext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, idcommand: i32, nstate: MMC_BUTTON_STATE, bstate: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IMessageView(pub ::windows::core::IUnknown);
impl IMessageView {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetTitleText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, psztitletext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), psztitletext.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetBodyText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszbodytext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), pszbodytext.into_param().abi()).ok()
}
pub unsafe fn SetIcon(&self, id: IconIdentifier) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(id)).ok()
}
pub unsafe fn Clear(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
}
unsafe impl ::windows::core::Interface for IMessageView {
type Vtable = IMessageView_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x80f94174_fccc_11d2_b991_00c04f8ecd78);
}
impl ::core::convert::From<IMessageView> for ::windows::core::IUnknown {
fn from(value: IMessageView) -> Self {
value.0
}
}
impl ::core::convert::From<&IMessageView> for ::windows::core::IUnknown {
fn from(value: &IMessageView) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IMessageView {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IMessageView {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IMessageView_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, psztitletext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszbodytext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, id: IconIdentifier) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct INodeProperties(pub ::windows::core::IUnknown);
impl INodeProperties {
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn GetProperty<'a, Param0: ::windows::core::IntoParam<'a, super::Com::IDataObject>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, pdataobject: Param0, szpropertyname: Param1) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pdataobject.into_param().abi(), szpropertyname.into_param().abi(), &mut result__).from_abi::<*mut u16>(result__)
}
}
unsafe impl ::windows::core::Interface for INodeProperties {
type Vtable = INodeProperties_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x15bc4d24_a522_4406_aa55_0749537a6865);
}
impl ::core::convert::From<INodeProperties> for ::windows::core::IUnknown {
fn from(value: INodeProperties) -> Self {
value.0
}
}
impl ::core::convert::From<&INodeProperties> for ::windows::core::IUnknown {
fn from(value: &INodeProperties) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for INodeProperties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a INodeProperties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct INodeProperties_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pdataobject: ::windows::core::RawPtr, szpropertyname: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, pbstrproperty: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IPropertySheetCallback(pub ::windows::core::IUnknown);
impl IPropertySheetCallback {
#[cfg(feature = "Win32_UI_Controls")]
pub unsafe fn AddPage<'a, Param0: ::windows::core::IntoParam<'a, super::super::UI::Controls::HPROPSHEETPAGE>>(&self, hpage: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), hpage.into_param().abi()).ok()
}
#[cfg(feature = "Win32_UI_Controls")]
pub unsafe fn RemovePage<'a, Param0: ::windows::core::IntoParam<'a, super::super::UI::Controls::HPROPSHEETPAGE>>(&self, hpage: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), hpage.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IPropertySheetCallback {
type Vtable = IPropertySheetCallback_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x85de64dd_ef21_11cf_a285_00c04fd8dbe6);
}
impl ::core::convert::From<IPropertySheetCallback> for ::windows::core::IUnknown {
fn from(value: IPropertySheetCallback) -> Self {
value.0
}
}
impl ::core::convert::From<&IPropertySheetCallback> for ::windows::core::IUnknown {
fn from(value: &IPropertySheetCallback) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IPropertySheetCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IPropertySheetCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IPropertySheetCallback_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_UI_Controls")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hpage: super::super::UI::Controls::HPROPSHEETPAGE) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_UI_Controls"))] usize,
#[cfg(feature = "Win32_UI_Controls")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hpage: super::super::UI::Controls::HPROPSHEETPAGE) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_UI_Controls"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IPropertySheetProvider(pub ::windows::core::IUnknown);
impl IPropertySheetProvider {
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))]
pub unsafe fn CreatePropertySheet<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>, Param3: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, title: Param0, r#type: u8, cookie: isize, pidataobjectm: Param3, dwoptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), title.into_param().abi(), ::core::mem::transmute(r#type), ::core::mem::transmute(cookie), pidataobjectm.into_param().abi(), ::core::mem::transmute(dwoptions)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn FindPropertySheet<'a, Param1: ::windows::core::IntoParam<'a, IComponent>, Param2: ::windows::core::IntoParam<'a, super::Com::IDataObject>>(&self, hitem: isize, lpcomponent: Param1, lpdataobject: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(hitem), lpcomponent.into_param().abi(), lpdataobject.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddPrimaryPages<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IUnknown>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::HWND>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, lpunknown: Param0, bcreatehandle: Param1, hnotifywindow: Param2, bscopepane: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lpunknown.into_param().abi(), bcreatehandle.into_param().abi(), hnotifywindow.into_param().abi(), bscopepane.into_param().abi()).ok()
}
pub unsafe fn AddExtensionPages(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Show(&self, window: isize, page: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(window), ::core::mem::transmute(page)).ok()
}
}
unsafe impl ::windows::core::Interface for IPropertySheetProvider {
type Vtable = IPropertySheetProvider_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x85de64de_ef21_11cf_a285_00c04fd8dbe6);
}
impl ::core::convert::From<IPropertySheetProvider> for ::windows::core::IUnknown {
fn from(value: IPropertySheetProvider) -> Self {
value.0
}
}
impl ::core::convert::From<&IPropertySheetProvider> for ::windows::core::IUnknown {
fn from(value: &IPropertySheetProvider) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IPropertySheetProvider {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IPropertySheetProvider {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IPropertySheetProvider_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, title: super::super::Foundation::PWSTR, r#type: u8, cookie: isize, pidataobjectm: ::windows::core::RawPtr, dwoptions: u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com")))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hitem: isize, lpcomponent: ::windows::core::RawPtr, lpdataobject: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpunknown: ::windows::core::RawPtr, bcreatehandle: super::super::Foundation::BOOL, hnotifywindow: super::super::Foundation::HWND, bscopepane: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, window: isize, page: i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IRequiredExtensions(pub ::windows::core::IUnknown);
impl IRequiredExtensions {
pub unsafe fn EnableAllExtensions(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn GetFirstExtension(&self) -> ::windows::core::Result<::windows::core::GUID> {
let mut result__: <::windows::core::GUID as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
pub unsafe fn GetNextExtension(&self) -> ::windows::core::Result<::windows::core::GUID> {
let mut result__: <::windows::core::GUID as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
unsafe impl ::windows::core::Interface for IRequiredExtensions {
type Vtable = IRequiredExtensions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x72782d7a_a4a0_11d1_af0f_00c04fb6dd2c);
}
impl ::core::convert::From<IRequiredExtensions> for ::windows::core::IUnknown {
fn from(value: IRequiredExtensions) -> Self {
value.0
}
}
impl ::core::convert::From<&IRequiredExtensions> for ::windows::core::IUnknown {
fn from(value: &IRequiredExtensions) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IRequiredExtensions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IRequiredExtensions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IRequiredExtensions_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pextclsid: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pextclsid: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IResultData(pub ::windows::core::IUnknown);
impl IResultData {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn DeleteItem(&self, itemid: isize, ncol: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(itemid), ::core::mem::transmute(ncol)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn FindItemByLParam<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lparam: Param0) -> ::windows::core::Result<isize> {
let mut result__: <isize as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lparam.into_param().abi(), &mut result__).from_abi::<isize>(result__)
}
pub unsafe fn DeleteAllRsltItems(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetItem(&self, item: *const RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetNextItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn ModifyItemState(&self, nindex: i32, itemid: isize, uadd: u32, uremove: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(nindex), ::core::mem::transmute(itemid), ::core::mem::transmute(uadd), ::core::mem::transmute(uremove)).ok()
}
pub unsafe fn ModifyViewStyle(&self, add: MMC_RESULT_VIEW_STYLE, remove: MMC_RESULT_VIEW_STYLE) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(add), ::core::mem::transmute(remove)).ok()
}
pub unsafe fn SetViewMode(&self, lviewmode: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), ::core::mem::transmute(lviewmode)).ok()
}
pub unsafe fn GetViewMode(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn UpdateItem(&self, itemid: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), ::core::mem::transmute(itemid)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Sort<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, ncolumn: i32, dwsortoptions: u32, luserparam: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncolumn), ::core::mem::transmute(dwsortoptions), luserparam.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetDescBarText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, desctext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), desctext.into_param().abi()).ok()
}
pub unsafe fn SetItemCount(&self, nitemcount: i32, dwoptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), ::core::mem::transmute(nitemcount), ::core::mem::transmute(dwoptions)).ok()
}
}
unsafe impl ::windows::core::Interface for IResultData {
type Vtable = IResultData_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x31da5fa0_e0eb_11cf_9f21_00aa003ca9f6);
}
impl ::core::convert::From<IResultData> for ::windows::core::IUnknown {
fn from(value: IResultData) -> Self {
value.0
}
}
impl ::core::convert::From<&IResultData> for ::windows::core::IUnknown {
fn from(value: &IResultData) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IResultData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IResultData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IResultData_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itemid: isize, ncol: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lparam: super::super::Foundation::LPARAM, pitemid: *mut isize) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *const RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nindex: i32, itemid: isize, uadd: u32, uremove: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, add: MMC_RESULT_VIEW_STYLE, remove: MMC_RESULT_VIEW_STYLE) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lviewmode: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lviewmode: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itemid: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncolumn: i32, dwsortoptions: u32, luserparam: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, desctext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nitemcount: i32, dwoptions: u32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IResultData2(pub ::windows::core::IUnknown);
impl IResultData2 {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn DeleteItem(&self, itemid: isize, ncol: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(itemid), ::core::mem::transmute(ncol)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn FindItemByLParam<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, lparam: Param0) -> ::windows::core::Result<isize> {
let mut result__: <isize as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), lparam.into_param().abi(), &mut result__).from_abi::<isize>(result__)
}
pub unsafe fn DeleteAllRsltItems(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetItem(&self, item: *const RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetNextItem(&self, item: *mut RESULTDATAITEM) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), ::core::mem::transmute(item)).ok()
}
pub unsafe fn ModifyItemState(&self, nindex: i32, itemid: isize, uadd: u32, uremove: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), ::core::mem::transmute(nindex), ::core::mem::transmute(itemid), ::core::mem::transmute(uadd), ::core::mem::transmute(uremove)).ok()
}
pub unsafe fn ModifyViewStyle(&self, add: MMC_RESULT_VIEW_STYLE, remove: MMC_RESULT_VIEW_STYLE) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), ::core::mem::transmute(add), ::core::mem::transmute(remove)).ok()
}
pub unsafe fn SetViewMode(&self, lviewmode: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), ::core::mem::transmute(lviewmode)).ok()
}
pub unsafe fn GetViewMode(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn UpdateItem(&self, itemid: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), ::core::mem::transmute(itemid)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Sort<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, ncolumn: i32, dwsortoptions: u32, luserparam: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncolumn), ::core::mem::transmute(dwsortoptions), luserparam.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetDescBarText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, desctext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), desctext.into_param().abi()).ok()
}
pub unsafe fn SetItemCount(&self, nitemcount: i32, dwoptions: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), ::core::mem::transmute(nitemcount), ::core::mem::transmute(dwoptions)).ok()
}
pub unsafe fn RenameResultItem(&self, itemid: isize) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).18)(::core::mem::transmute_copy(self), ::core::mem::transmute(itemid)).ok()
}
}
unsafe impl ::windows::core::Interface for IResultData2 {
type Vtable = IResultData2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0f36e0eb_a7f1_4a81_be5a_9247f7de4b1b);
}
impl ::core::convert::From<IResultData2> for ::windows::core::IUnknown {
fn from(value: IResultData2) -> Self {
value.0
}
}
impl ::core::convert::From<&IResultData2> for ::windows::core::IUnknown {
fn from(value: &IResultData2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IResultData2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IResultData2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<IResultData2> for IResultData {
fn from(value: IResultData2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&IResultData2> for IResultData {
fn from(value: &IResultData2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, IResultData> for IResultData2 {
fn into_param(self) -> ::windows::core::Param<'a, IResultData> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, IResultData> for &IResultData2 {
fn into_param(self) -> ::windows::core::Param<'a, IResultData> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IResultData2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itemid: isize, ncol: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lparam: super::super::Foundation::LPARAM, pitemid: *mut isize) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *const RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, item: *mut RESULTDATAITEM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nindex: i32, itemid: isize, uadd: u32, uremove: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, add: MMC_RESULT_VIEW_STYLE, remove: MMC_RESULT_VIEW_STYLE) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lviewmode: i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lviewmode: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itemid: isize) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncolumn: i32, dwsortoptions: u32, luserparam: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, desctext: super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nitemcount: i32, dwoptions: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itemid: isize) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IResultDataCompare(pub ::windows::core::IUnknown);
impl IResultDataCompare {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Compare<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, luserparam: Param0, cookiea: isize, cookieb: isize, pnresult: *mut i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), luserparam.into_param().abi(), ::core::mem::transmute(cookiea), ::core::mem::transmute(cookieb), ::core::mem::transmute(pnresult)).ok()
}
}
unsafe impl ::windows::core::Interface for IResultDataCompare {
type Vtable = IResultDataCompare_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe8315a52_7a1a_11d0_a2d2_00c04fd909dd);
}
impl ::core::convert::From<IResultDataCompare> for ::windows::core::IUnknown {
fn from(value: IResultDataCompare) -> Self {
value.0
}
}
impl ::core::convert::From<&IResultDataCompare> for ::windows::core::IUnknown {
fn from(value: &IResultDataCompare) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IResultDataCompare {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IResultDataCompare {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IResultDataCompare_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, luserparam: super::super::Foundation::LPARAM, cookiea: isize, cookieb: isize, pnresult: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IResultDataCompareEx(pub ::windows::core::IUnknown);
impl IResultDataCompareEx {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Compare(&self, prdc: *const RDCOMPARE) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(prdc), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for IResultDataCompareEx {
type Vtable = IResultDataCompareEx_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x96933476_0251_11d3_aeb0_00c04f8ecd78);
}
impl ::core::convert::From<IResultDataCompareEx> for ::windows::core::IUnknown {
fn from(value: IResultDataCompareEx) -> Self {
value.0
}
}
impl ::core::convert::From<&IResultDataCompareEx> for ::windows::core::IUnknown {
fn from(value: &IResultDataCompareEx) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IResultDataCompareEx {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IResultDataCompareEx {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IResultDataCompareEx_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, prdc: *const RDCOMPARE, pnresult: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IResultOwnerData(pub ::windows::core::IUnknown);
impl IResultOwnerData {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn FindItem(&self, pfindinfo: *const RESULTFINDINFO) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pfindinfo), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn CacheHint(&self, nstartindex: i32, nendindex: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(nstartindex), ::core::mem::transmute(nendindex)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SortItems<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::LPARAM>>(&self, ncolumn: i32, dwsortoptions: u32, luserparam: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(ncolumn), ::core::mem::transmute(dwsortoptions), luserparam.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IResultOwnerData {
type Vtable = IResultOwnerData_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9cb396d8_ea83_11d0_aef1_00c04fb6dd2c);
}
impl ::core::convert::From<IResultOwnerData> for ::windows::core::IUnknown {
fn from(value: IResultOwnerData) -> Self {
value.0
}
}
impl ::core::convert::From<&IResultOwnerData> for ::windows::core::IUnknown {
fn from(value: &IResultOwnerData) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IResultOwnerData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IResultOwnerData {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IResultOwnerData_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pfindinfo: *const RESULTFINDINFO, pnfoundindex: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nstartindex: i32, nendindex: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ncolumn: i32, dwsortoptions: u32, luserparam: super::super::Foundation::LPARAM) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ISnapinAbout(pub ::windows::core::IUnknown);
impl ISnapinAbout {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetSnapinDescription(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetProvider(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetSnapinVersion(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_UI_WindowsAndMessaging")]
pub unsafe fn GetSnapinImage(&self) -> ::windows::core::Result<super::super::UI::WindowsAndMessaging::HICON> {
let mut result__: <super::super::UI::WindowsAndMessaging::HICON as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::UI::WindowsAndMessaging::HICON>(result__)
}
#[cfg(feature = "Win32_Graphics_Gdi")]
pub unsafe fn GetStaticFolderImage(&self, hsmallimage: *mut super::super::Graphics::Gdi::HBITMAP, hsmallimageopen: *mut super::super::Graphics::Gdi::HBITMAP, hlargeimage: *mut super::super::Graphics::Gdi::HBITMAP, cmask: *mut u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(hsmallimage), ::core::mem::transmute(hsmallimageopen), ::core::mem::transmute(hlargeimage), ::core::mem::transmute(cmask)).ok()
}
}
unsafe impl ::windows::core::Interface for ISnapinAbout {
type Vtable = ISnapinAbout_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1245208c_a151_11d0_a7d7_00c04fd909dd);
}
impl ::core::convert::From<ISnapinAbout> for ::windows::core::IUnknown {
fn from(value: ISnapinAbout) -> Self {
value.0
}
}
impl ::core::convert::From<&ISnapinAbout> for ::windows::core::IUnknown {
fn from(value: &ISnapinAbout) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ISnapinAbout {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ISnapinAbout {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ISnapinAbout_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpdescription: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpname: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpversion: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, happicon: *mut super::super::UI::WindowsAndMessaging::HICON) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_UI_WindowsAndMessaging"))] usize,
#[cfg(feature = "Win32_Graphics_Gdi")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, hsmallimage: *mut super::super::Graphics::Gdi::HBITMAP, hsmallimageopen: *mut super::super::Graphics::Gdi::HBITMAP, hlargeimage: *mut super::super::Graphics::Gdi::HBITMAP, cmask: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Graphics_Gdi"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ISnapinHelp(pub ::windows::core::IUnknown);
impl ISnapinHelp {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetHelpTopic(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
}
unsafe impl ::windows::core::Interface for ISnapinHelp {
type Vtable = ISnapinHelp_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa6b15ace_df59_11d0_a7dd_00c04fd909dd);
}
impl ::core::convert::From<ISnapinHelp> for ::windows::core::IUnknown {
fn from(value: ISnapinHelp) -> Self {
value.0
}
}
impl ::core::convert::From<&ISnapinHelp> for ::windows::core::IUnknown {
fn from(value: &ISnapinHelp) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ISnapinHelp {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ISnapinHelp {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ISnapinHelp_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpcompiledhelpfile: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ISnapinHelp2(pub ::windows::core::IUnknown);
impl ISnapinHelp2 {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetHelpTopic(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetLinkedTopics(&self) -> ::windows::core::Result<super::super::Foundation::PWSTR> {
let mut result__: <super::super::Foundation::PWSTR as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::PWSTR>(result__)
}
}
unsafe impl ::windows::core::Interface for ISnapinHelp2 {
type Vtable = ISnapinHelp2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4861a010_20f9_11d2_a510_00c04fb6dd2c);
}
impl ::core::convert::From<ISnapinHelp2> for ::windows::core::IUnknown {
fn from(value: ISnapinHelp2) -> Self {
value.0
}
}
impl ::core::convert::From<&ISnapinHelp2> for ::windows::core::IUnknown {
fn from(value: &ISnapinHelp2) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ISnapinHelp2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ISnapinHelp2 {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ISnapinHelp2> for ISnapinHelp {
fn from(value: ISnapinHelp2) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
impl ::core::convert::From<&ISnapinHelp2> for ISnapinHelp {
fn from(value: &ISnapinHelp2) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
impl<'a> ::windows::core::IntoParam<'a, ISnapinHelp> for ISnapinHelp2 {
fn into_param(self) -> ::windows::core::Param<'a, ISnapinHelp> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
impl<'a> ::windows::core::IntoParam<'a, ISnapinHelp> for &ISnapinHelp2 {
fn into_param(self) -> ::windows::core::Param<'a, ISnapinHelp> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ISnapinHelp2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpcompiledhelpfile: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, lpcompiledhelpfiles: *mut super::super::Foundation::PWSTR) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ISnapinProperties(pub ::windows::core::IUnknown);
impl ISnapinProperties {
pub unsafe fn Initialize<'a, Param0: ::windows::core::IntoParam<'a, Properties>>(&self, pproperties: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pproperties.into_param().abi()).ok()
}
pub unsafe fn QueryPropertyNames<'a, Param0: ::windows::core::IntoParam<'a, ISnapinPropertiesCallback>>(&self, pcallback: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), pcallback.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn PropertiesChanged(&self, cproperties: i32, pproperties: *const MMC_SNAPIN_PROPERTY) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(cproperties), ::core::mem::transmute(pproperties)).ok()
}
}
unsafe impl ::windows::core::Interface for ISnapinProperties {
type Vtable = ISnapinProperties_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf7889da9_4a02_4837_bf89_1a6f2a021010);
}
impl ::core::convert::From<ISnapinProperties> for ::windows::core::IUnknown {
fn from(value: ISnapinProperties) -> Self {
value.0
}
}
impl ::core::convert::From<&ISnapinProperties> for ::windows::core::IUnknown {
fn from(value: &ISnapinProperties) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ISnapinProperties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ISnapinProperties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ISnapinProperties_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pproperties: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pcallback: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, cproperties: i32, pproperties: *const ::core::mem::ManuallyDrop<MMC_SNAPIN_PROPERTY>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ISnapinPropertiesCallback(pub ::windows::core::IUnknown);
impl ISnapinPropertiesCallback {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddPropertyName<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszpropname: Param0, dwflags: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pszpropname.into_param().abi(), ::core::mem::transmute(dwflags)).ok()
}
}
unsafe impl ::windows::core::Interface for ISnapinPropertiesCallback {
type Vtable = ISnapinPropertiesCallback_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa50fa2e5_7e61_45eb_a8d4_9a07b3e851a8);
}
impl ::core::convert::From<ISnapinPropertiesCallback> for ::windows::core::IUnknown {
fn from(value: ISnapinPropertiesCallback) -> Self {
value.0
}
}
impl ::core::convert::From<&ISnapinPropertiesCallback> for ::windows::core::IUnknown {
fn from(value: &ISnapinPropertiesCallback) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ISnapinPropertiesCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ISnapinPropertiesCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ISnapinPropertiesCallback_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszpropname: super::super::Foundation::PWSTR, dwflags: u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IStringTable(pub ::windows::core::IUnknown);
impl IStringTable {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddString<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszadd: Param0) -> ::windows::core::Result<u32> {
let mut result__: <u32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), pszadd.into_param().abi(), &mut result__).from_abi::<u32>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetString(&self, stringid: u32, cchbuffer: u32, lpbuffer: super::super::Foundation::PWSTR, pcchout: *mut u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(stringid), ::core::mem::transmute(cchbuffer), ::core::mem::transmute(lpbuffer), ::core::mem::transmute(pcchout)).ok()
}
pub unsafe fn GetStringLength(&self, stringid: u32) -> ::windows::core::Result<u32> {
let mut result__: <u32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(stringid), &mut result__).from_abi::<u32>(result__)
}
pub unsafe fn DeleteString(&self, stringid: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(stringid)).ok()
}
pub unsafe fn DeleteAllStrings(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn FindString<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::PWSTR>>(&self, pszfind: Param0) -> ::windows::core::Result<u32> {
let mut result__: <u32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), pszfind.into_param().abi(), &mut result__).from_abi::<u32>(result__)
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn Enumerate(&self) -> ::windows::core::Result<super::Com::IEnumString> {
let mut result__: <super::Com::IEnumString as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::Com::IEnumString>(result__)
}
}
unsafe impl ::windows::core::Interface for IStringTable {
type Vtable = IStringTable_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xde40b7a4_0f65_11d2_8e25_00c04f8ecd78);
}
impl ::core::convert::From<IStringTable> for ::windows::core::IUnknown {
fn from(value: IStringTable) -> Self {
value.0
}
}
impl ::core::convert::From<&IStringTable> for ::windows::core::IUnknown {
fn from(value: &IStringTable) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IStringTable {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IStringTable {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IStringTable_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszadd: super::super::Foundation::PWSTR, pstringid: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, stringid: u32, cchbuffer: u32, lpbuffer: super::super::Foundation::PWSTR, pcchout: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, stringid: u32, pcchstring: *mut u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, stringid: u32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pszfind: super::super::Foundation::PWSTR, pstringid: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, ppenum: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IToolbar(pub ::windows::core::IUnknown);
impl IToolbar {
#[cfg(feature = "Win32_Graphics_Gdi")]
pub unsafe fn AddBitmap<'a, Param1: ::windows::core::IntoParam<'a, super::super::Graphics::Gdi::HBITMAP>>(&self, nimages: i32, hbmp: Param1, cxsize: i32, cysize: i32, crmask: u32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(nimages), hbmp.into_param().abi(), ::core::mem::transmute(cxsize), ::core::mem::transmute(cysize), ::core::mem::transmute(crmask)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddButtons(&self, nbuttons: i32, lpbuttons: *const MMCBUTTON) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).4)(::core::mem::transmute_copy(self), ::core::mem::transmute(nbuttons), ::core::mem::transmute(lpbuttons)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn InsertButton(&self, nindex: i32, lpbutton: *const MMCBUTTON) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).5)(::core::mem::transmute_copy(self), ::core::mem::transmute(nindex), ::core::mem::transmute(lpbutton)).ok()
}
pub unsafe fn DeleteButton(&self, nindex: i32) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).6)(::core::mem::transmute_copy(self), ::core::mem::transmute(nindex)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn GetButtonState(&self, idcommand: i32, nstate: MMC_BUTTON_STATE) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(idcommand), ::core::mem::transmute(nstate), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetButtonState<'a, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, idcommand: i32, nstate: MMC_BUTTON_STATE, bstate: Param2) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(idcommand), ::core::mem::transmute(nstate), bstate.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for IToolbar {
type Vtable = IToolbar_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43136eb9_d36c_11cf_adbc_00aa00a80033);
}
impl ::core::convert::From<IToolbar> for ::windows::core::IUnknown {
fn from(value: IToolbar) -> Self {
value.0
}
}
impl ::core::convert::From<&IToolbar> for ::windows::core::IUnknown {
fn from(value: &IToolbar) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IToolbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IToolbar {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IToolbar_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Graphics_Gdi")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nimages: i32, hbmp: super::super::Graphics::Gdi::HBITMAP, cxsize: i32, cysize: i32, crmask: u32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Graphics_Gdi"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nbuttons: i32, lpbuttons: *const MMCBUTTON) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nindex: i32, lpbutton: *const MMCBUTTON) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nindex: i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, idcommand: i32, nstate: MMC_BUTTON_STATE, pstate: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, idcommand: i32, nstate: MMC_BUTTON_STATE, bstate: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct IViewExtensionCallback(pub ::windows::core::IUnknown);
impl IViewExtensionCallback {
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn AddView(&self, pextviewdata: *const MMC_EXT_VIEW_DATA) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).3)(::core::mem::transmute_copy(self), ::core::mem::transmute(pextviewdata)).ok()
}
}
unsafe impl ::windows::core::Interface for IViewExtensionCallback {
type Vtable = IViewExtensionCallback_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x34dd928a_7599_41e5_9f5e_d6bc3062c2da);
}
impl ::core::convert::From<IViewExtensionCallback> for ::windows::core::IUnknown {
fn from(value: IViewExtensionCallback) -> Self {
value.0
}
}
impl ::core::convert::From<&IViewExtensionCallback> for ::windows::core::IUnknown {
fn from(value: &IViewExtensionCallback) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IViewExtensionCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a IViewExtensionCallback {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct IViewExtensionCallback_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pextviewdata: *const MMC_EXT_VIEW_DATA) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct IconIdentifier(pub i32);
pub const Icon_None: IconIdentifier = IconIdentifier(0i32);
pub const Icon_Error: IconIdentifier = IconIdentifier(32513i32);
pub const Icon_Question: IconIdentifier = IconIdentifier(32514i32);
pub const Icon_Warning: IconIdentifier = IconIdentifier(32515i32);
pub const Icon_Information: IconIdentifier = IconIdentifier(32516i32);
pub const Icon_First: IconIdentifier = IconIdentifier(32513i32);
pub const Icon_Last: IconIdentifier = IconIdentifier(32516i32);
impl ::core::convert::From<i32> for IconIdentifier {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for IconIdentifier {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MENUBUTTONDATA {
pub idCommand: i32,
pub x: i32,
pub y: i32,
}
impl MENUBUTTONDATA {}
impl ::core::default::Default for MENUBUTTONDATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MENUBUTTONDATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MENUBUTTONDATA").field("idCommand", &self.idCommand).field("x", &self.x).field("y", &self.y).finish()
}
}
impl ::core::cmp::PartialEq for MENUBUTTONDATA {
fn eq(&self, other: &Self) -> bool {
self.idCommand == other.idCommand && self.x == other.x && self.y == other.y
}
}
impl ::core::cmp::Eq for MENUBUTTONDATA {}
unsafe impl ::windows::core::Abi for MENUBUTTONDATA {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMCBUTTON {
pub nBitmap: i32,
pub idCommand: i32,
pub fsState: u8,
pub fsType: u8,
pub lpButtonText: super::super::Foundation::PWSTR,
pub lpTooltipText: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl MMCBUTTON {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMCBUTTON {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMCBUTTON {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMCBUTTON").field("nBitmap", &self.nBitmap).field("idCommand", &self.idCommand).field("fsState", &self.fsState).field("fsType", &self.fsType).field("lpButtonText", &self.lpButtonText).field("lpTooltipText", &self.lpTooltipText).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMCBUTTON {
fn eq(&self, other: &Self) -> bool {
self.nBitmap == other.nBitmap && self.idCommand == other.idCommand && self.fsState == other.fsState && self.fsType == other.fsType && self.lpButtonText == other.lpButtonText && self.lpTooltipText == other.lpTooltipText
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMCBUTTON {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMCBUTTON {
type Abi = Self;
}
pub const MMCLV_AUTO: i32 = -1i32;
pub const MMCLV_NOICON: i32 = -1i32;
pub const MMCLV_NOPARAM: i32 = -2i32;
pub const MMCLV_NOPTR: u32 = 0u32;
pub const MMCLV_UPDATE_NOINVALIDATEALL: u32 = 1u32;
pub const MMCLV_UPDATE_NOSCROLL: u32 = 2u32;
pub const MMCLV_VIEWSTYLE_FILTERED: u32 = 4u32;
pub const MMCLV_VIEWSTYLE_ICON: u32 = 0u32;
pub const MMCLV_VIEWSTYLE_LIST: u32 = 3u32;
pub const MMCLV_VIEWSTYLE_REPORT: u32 = 1u32;
pub const MMCLV_VIEWSTYLE_SMALLICON: u32 = 2u32;
pub const MMCVersionInfo: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd6fedb1d_cf21_4bd9_af3b_c5468e9c6684);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_ACTION_TYPE(pub i32);
pub const MMC_ACTION_UNINITIALIZED: MMC_ACTION_TYPE = MMC_ACTION_TYPE(-1i32);
pub const MMC_ACTION_ID: MMC_ACTION_TYPE = MMC_ACTION_TYPE(0i32);
pub const MMC_ACTION_LINK: MMC_ACTION_TYPE = MMC_ACTION_TYPE(1i32);
pub const MMC_ACTION_SCRIPT: MMC_ACTION_TYPE = MMC_ACTION_TYPE(2i32);
impl ::core::convert::From<i32> for MMC_ACTION_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_ACTION_TYPE {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_BUTTON_STATE(pub i32);
pub const ENABLED: MMC_BUTTON_STATE = MMC_BUTTON_STATE(1i32);
pub const CHECKED: MMC_BUTTON_STATE = MMC_BUTTON_STATE(2i32);
pub const HIDDEN: MMC_BUTTON_STATE = MMC_BUTTON_STATE(4i32);
pub const INDETERMINATE: MMC_BUTTON_STATE = MMC_BUTTON_STATE(8i32);
pub const BUTTONPRESSED: MMC_BUTTON_STATE = MMC_BUTTON_STATE(16i32);
impl ::core::convert::From<i32> for MMC_BUTTON_STATE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_BUTTON_STATE {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MMC_COLUMN_DATA {
pub nColIndex: i32,
pub dwFlags: u32,
pub nWidth: i32,
pub ulReserved: usize,
}
impl MMC_COLUMN_DATA {}
impl ::core::default::Default for MMC_COLUMN_DATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MMC_COLUMN_DATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_COLUMN_DATA").field("nColIndex", &self.nColIndex).field("dwFlags", &self.dwFlags).field("nWidth", &self.nWidth).field("ulReserved", &self.ulReserved).finish()
}
}
impl ::core::cmp::PartialEq for MMC_COLUMN_DATA {
fn eq(&self, other: &Self) -> bool {
self.nColIndex == other.nColIndex && self.dwFlags == other.dwFlags && self.nWidth == other.nWidth && self.ulReserved == other.ulReserved
}
}
impl ::core::cmp::Eq for MMC_COLUMN_DATA {}
unsafe impl ::windows::core::Abi for MMC_COLUMN_DATA {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MMC_COLUMN_SET_DATA {
pub cbSize: i32,
pub nNumCols: i32,
pub pColData: *mut MMC_COLUMN_DATA,
}
impl MMC_COLUMN_SET_DATA {}
impl ::core::default::Default for MMC_COLUMN_SET_DATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MMC_COLUMN_SET_DATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_COLUMN_SET_DATA").field("cbSize", &self.cbSize).field("nNumCols", &self.nNumCols).field("pColData", &self.pColData).finish()
}
}
impl ::core::cmp::PartialEq for MMC_COLUMN_SET_DATA {
fn eq(&self, other: &Self) -> bool {
self.cbSize == other.cbSize && self.nNumCols == other.nNumCols && self.pColData == other.pColData
}
}
impl ::core::cmp::Eq for MMC_COLUMN_SET_DATA {}
unsafe impl ::windows::core::Abi for MMC_COLUMN_SET_DATA {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_CONSOLE_VERB(pub i32);
pub const MMC_VERB_NONE: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(0i32);
pub const MMC_VERB_OPEN: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32768i32);
pub const MMC_VERB_COPY: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32769i32);
pub const MMC_VERB_PASTE: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32770i32);
pub const MMC_VERB_DELETE: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32771i32);
pub const MMC_VERB_PROPERTIES: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32772i32);
pub const MMC_VERB_RENAME: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32773i32);
pub const MMC_VERB_REFRESH: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32774i32);
pub const MMC_VERB_PRINT: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32775i32);
pub const MMC_VERB_CUT: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32776i32);
pub const MMC_VERB_MAX: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32777i32);
pub const MMC_VERB_FIRST: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32768i32);
pub const MMC_VERB_LAST: MMC_CONSOLE_VERB = MMC_CONSOLE_VERB(32776i32);
impl ::core::convert::From<i32> for MMC_CONSOLE_VERB {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_CONSOLE_VERB {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_CONTROL_TYPE(pub i32);
pub const TOOLBAR: MMC_CONTROL_TYPE = MMC_CONTROL_TYPE(0i32);
pub const MENUBUTTON: MMC_CONTROL_TYPE = MMC_CONTROL_TYPE(1i32);
pub const COMBOBOXBAR: MMC_CONTROL_TYPE = MMC_CONTROL_TYPE(2i32);
impl ::core::convert::From<i32> for MMC_CONTROL_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_CONTROL_TYPE {
type Abi = Self;
}
pub const MMC_DEFAULT_OPERATION_COPY: u32 = 1u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_EXPANDSYNC_STRUCT {
pub bHandled: super::super::Foundation::BOOL,
pub bExpanding: super::super::Foundation::BOOL,
pub hItem: isize,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_EXPANDSYNC_STRUCT {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_EXPANDSYNC_STRUCT {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_EXPANDSYNC_STRUCT {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_EXPANDSYNC_STRUCT").field("bHandled", &self.bHandled).field("bExpanding", &self.bExpanding).field("hItem", &self.hItem).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_EXPANDSYNC_STRUCT {
fn eq(&self, other: &Self) -> bool {
self.bHandled == other.bHandled && self.bExpanding == other.bExpanding && self.hItem == other.hItem
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_EXPANDSYNC_STRUCT {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_EXPANDSYNC_STRUCT {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_EXT_VIEW_DATA {
pub viewID: ::windows::core::GUID,
pub pszURL: super::super::Foundation::PWSTR,
pub pszViewTitle: super::super::Foundation::PWSTR,
pub pszTooltipText: super::super::Foundation::PWSTR,
pub bReplacesDefaultView: super::super::Foundation::BOOL,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_EXT_VIEW_DATA {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_EXT_VIEW_DATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_EXT_VIEW_DATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_EXT_VIEW_DATA").field("viewID", &self.viewID).field("pszURL", &self.pszURL).field("pszViewTitle", &self.pszViewTitle).field("pszTooltipText", &self.pszTooltipText).field("bReplacesDefaultView", &self.bReplacesDefaultView).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_EXT_VIEW_DATA {
fn eq(&self, other: &Self) -> bool {
self.viewID == other.viewID && self.pszURL == other.pszURL && self.pszViewTitle == other.pszViewTitle && self.pszTooltipText == other.pszTooltipText && self.bReplacesDefaultView == other.bReplacesDefaultView
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_EXT_VIEW_DATA {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_EXT_VIEW_DATA {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_FILTERDATA {
pub pszText: super::super::Foundation::PWSTR,
pub cchTextMax: i32,
pub lValue: i32,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_FILTERDATA {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_FILTERDATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_FILTERDATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_FILTERDATA").field("pszText", &self.pszText).field("cchTextMax", &self.cchTextMax).field("lValue", &self.lValue).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_FILTERDATA {
fn eq(&self, other: &Self) -> bool {
self.pszText == other.pszText && self.cchTextMax == other.cchTextMax && self.lValue == other.lValue
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_FILTERDATA {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_FILTERDATA {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_FILTER_CHANGE_CODE(pub i32);
pub const MFCC_DISABLE: MMC_FILTER_CHANGE_CODE = MMC_FILTER_CHANGE_CODE(0i32);
pub const MFCC_ENABLE: MMC_FILTER_CHANGE_CODE = MMC_FILTER_CHANGE_CODE(1i32);
pub const MFCC_VALUE_CHANGE: MMC_FILTER_CHANGE_CODE = MMC_FILTER_CHANGE_CODE(2i32);
impl ::core::convert::From<i32> for MMC_FILTER_CHANGE_CODE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_FILTER_CHANGE_CODE {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_FILTER_TYPE(pub i32);
pub const MMC_STRING_FILTER: MMC_FILTER_TYPE = MMC_FILTER_TYPE(0i32);
pub const MMC_INT_FILTER: MMC_FILTER_TYPE = MMC_FILTER_TYPE(1i32);
pub const MMC_FILTER_NOVALUE: MMC_FILTER_TYPE = MMC_FILTER_TYPE(32768i32);
impl ::core::convert::From<i32> for MMC_FILTER_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_FILTER_TYPE {
type Abi = Self;
}
pub const MMC_IMAGECALLBACK: i32 = -1i32;
pub const MMC_ITEM_OVERLAY_STATE_MASK: u32 = 3840u32;
pub const MMC_ITEM_OVERLAY_STATE_SHIFT: u32 = 8u32;
pub const MMC_ITEM_STATE_MASK: u32 = 255u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_LISTPAD_INFO {
pub szTitle: super::super::Foundation::PWSTR,
pub szButtonText: super::super::Foundation::PWSTR,
pub nCommandID: isize,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_LISTPAD_INFO {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_LISTPAD_INFO {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_LISTPAD_INFO {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_LISTPAD_INFO").field("szTitle", &self.szTitle).field("szButtonText", &self.szButtonText).field("nCommandID", &self.nCommandID).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_LISTPAD_INFO {
fn eq(&self, other: &Self) -> bool {
self.szTitle == other.szTitle && self.szButtonText == other.szButtonText && self.nCommandID == other.nCommandID
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_LISTPAD_INFO {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_LISTPAD_INFO {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_MENU_COMMAND_IDS(pub i32);
pub const MMCC_STANDARD_VIEW_SELECT: MMC_MENU_COMMAND_IDS = MMC_MENU_COMMAND_IDS(-1i32);
impl ::core::convert::From<i32> for MMC_MENU_COMMAND_IDS {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_MENU_COMMAND_IDS {
type Abi = Self;
}
pub const MMC_MULTI_SELECT_COOKIE: i32 = -2i32;
pub const MMC_NODEID_SLOW_RETRIEVAL: u32 = 1u32;
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_NOTIFY_TYPE(pub i32);
pub const MMCN_ACTIVATE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32769i32);
pub const MMCN_ADD_IMAGES: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32770i32);
pub const MMCN_BTN_CLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32771i32);
pub const MMCN_CLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32772i32);
pub const MMCN_COLUMN_CLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32773i32);
pub const MMCN_CONTEXTMENU: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32774i32);
pub const MMCN_CUTORMOVE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32775i32);
pub const MMCN_DBLCLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32776i32);
pub const MMCN_DELETE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32777i32);
pub const MMCN_DESELECT_ALL: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32778i32);
pub const MMCN_EXPAND: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32779i32);
pub const MMCN_HELP: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32780i32);
pub const MMCN_MENU_BTNCLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32781i32);
pub const MMCN_MINIMIZED: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32782i32);
pub const MMCN_PASTE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32783i32);
pub const MMCN_PROPERTY_CHANGE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32784i32);
pub const MMCN_QUERY_PASTE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32785i32);
pub const MMCN_REFRESH: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32786i32);
pub const MMCN_REMOVE_CHILDREN: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32787i32);
pub const MMCN_RENAME: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32788i32);
pub const MMCN_SELECT: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32789i32);
pub const MMCN_SHOW: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32790i32);
pub const MMCN_VIEW_CHANGE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32791i32);
pub const MMCN_SNAPINHELP: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32792i32);
pub const MMCN_CONTEXTHELP: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32793i32);
pub const MMCN_INITOCX: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32794i32);
pub const MMCN_FILTER_CHANGE: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32795i32);
pub const MMCN_FILTERBTN_CLICK: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32796i32);
pub const MMCN_RESTORE_VIEW: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32797i32);
pub const MMCN_PRINT: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32798i32);
pub const MMCN_PRELOAD: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32799i32);
pub const MMCN_LISTPAD: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32800i32);
pub const MMCN_EXPANDSYNC: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32801i32);
pub const MMCN_COLUMNS_CHANGED: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32802i32);
pub const MMCN_CANPASTE_OUTOFPROC: MMC_NOTIFY_TYPE = MMC_NOTIFY_TYPE(32803i32);
impl ::core::convert::From<i32> for MMC_NOTIFY_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_NOTIFY_TYPE {
type Abi = Self;
}
pub const MMC_NW_OPTION_CUSTOMTITLE: u32 = 8u32;
pub const MMC_NW_OPTION_NOACTIONPANE: u32 = 32u32;
pub const MMC_NW_OPTION_NONE: u32 = 0u32;
pub const MMC_NW_OPTION_NOPERSIST: u32 = 16u32;
pub const MMC_NW_OPTION_NOSCOPEPANE: u32 = 1u32;
pub const MMC_NW_OPTION_NOTOOLBARS: u32 = 2u32;
pub const MMC_NW_OPTION_SHORTTITLE: u32 = 4u32;
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_PROPERTY_ACTION(pub i32);
pub const MMC_PROPACT_DELETING: MMC_PROPERTY_ACTION = MMC_PROPERTY_ACTION(1i32);
pub const MMC_PROPACT_CHANGING: MMC_PROPERTY_ACTION = MMC_PROPERTY_ACTION(2i32);
pub const MMC_PROPACT_INITIALIZED: MMC_PROPERTY_ACTION = MMC_PROPERTY_ACTION(3i32);
impl ::core::convert::From<i32> for MMC_PROPERTY_ACTION {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_PROPERTY_ACTION {
type Abi = Self;
}
pub const MMC_PROP_CHANGEAFFECTSUI: u32 = 1u32;
pub const MMC_PROP_MODIFIABLE: u32 = 2u32;
pub const MMC_PROP_PERSIST: u32 = 8u32;
pub const MMC_PROP_REMOVABLE: u32 = 4u32;
pub const MMC_PSO_HASHELP: u32 = 2u32;
pub const MMC_PSO_NEWWIZARDTYPE: u32 = 4u32;
pub const MMC_PSO_NOAPPLYNOW: u32 = 1u32;
pub const MMC_PSO_NO_PROPTITLE: u32 = 8u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_RESTORE_VIEW {
pub dwSize: u32,
pub cookie: isize,
pub pViewType: super::super::Foundation::PWSTR,
pub lViewOptions: i32,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_RESTORE_VIEW {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_RESTORE_VIEW {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_RESTORE_VIEW {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_RESTORE_VIEW").field("dwSize", &self.dwSize).field("cookie", &self.cookie).field("pViewType", &self.pViewType).field("lViewOptions", &self.lViewOptions).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_RESTORE_VIEW {
fn eq(&self, other: &Self) -> bool {
self.dwSize == other.dwSize && self.cookie == other.cookie && self.pViewType == other.pViewType && self.lViewOptions == other.lViewOptions
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_RESTORE_VIEW {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_RESTORE_VIEW {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_RESULT_VIEW_STYLE(pub i32);
pub const MMC_SINGLESEL: MMC_RESULT_VIEW_STYLE = MMC_RESULT_VIEW_STYLE(1i32);
pub const MMC_SHOWSELALWAYS: MMC_RESULT_VIEW_STYLE = MMC_RESULT_VIEW_STYLE(2i32);
pub const MMC_NOSORTHEADER: MMC_RESULT_VIEW_STYLE = MMC_RESULT_VIEW_STYLE(4i32);
pub const MMC_ENSUREFOCUSVISIBLE: MMC_RESULT_VIEW_STYLE = MMC_RESULT_VIEW_STYLE(8i32);
impl ::core::convert::From<i32> for MMC_RESULT_VIEW_STYLE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_RESULT_VIEW_STYLE {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_SCOPE_ITEM_STATE(pub i32);
pub const MMC_SCOPE_ITEM_STATE_NORMAL: MMC_SCOPE_ITEM_STATE = MMC_SCOPE_ITEM_STATE(1i32);
pub const MMC_SCOPE_ITEM_STATE_BOLD: MMC_SCOPE_ITEM_STATE = MMC_SCOPE_ITEM_STATE(2i32);
pub const MMC_SCOPE_ITEM_STATE_EXPANDEDONCE: MMC_SCOPE_ITEM_STATE = MMC_SCOPE_ITEM_STATE(3i32);
impl ::core::convert::From<i32> for MMC_SCOPE_ITEM_STATE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_SCOPE_ITEM_STATE {
type Abi = Self;
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
impl ::core::clone::Clone for MMC_SNAPIN_PROPERTY {
fn clone(&self) -> Self {
unimplemented!()
}
}
#[repr(C)]
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub struct MMC_SNAPIN_PROPERTY {
pub pszPropName: super::super::Foundation::PWSTR,
pub varValue: super::Com::VARIANT,
pub eAction: MMC_PROPERTY_ACTION,
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
impl MMC_SNAPIN_PROPERTY {}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
impl ::core::default::Default for MMC_SNAPIN_PROPERTY {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
impl ::core::cmp::PartialEq for MMC_SNAPIN_PROPERTY {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
impl ::core::cmp::Eq for MMC_SNAPIN_PROPERTY {}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
unsafe impl ::windows::core::Abi for MMC_SNAPIN_PROPERTY {
type Abi = ::core::mem::ManuallyDrop<Self>;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MMC_SORT_DATA {
pub nColIndex: i32,
pub dwSortOptions: u32,
pub ulReserved: usize,
}
impl MMC_SORT_DATA {}
impl ::core::default::Default for MMC_SORT_DATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MMC_SORT_DATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_SORT_DATA").field("nColIndex", &self.nColIndex).field("dwSortOptions", &self.dwSortOptions).field("ulReserved", &self.ulReserved).finish()
}
}
impl ::core::cmp::PartialEq for MMC_SORT_DATA {
fn eq(&self, other: &Self) -> bool {
self.nColIndex == other.nColIndex && self.dwSortOptions == other.dwSortOptions && self.ulReserved == other.ulReserved
}
}
impl ::core::cmp::Eq for MMC_SORT_DATA {}
unsafe impl ::windows::core::Abi for MMC_SORT_DATA {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MMC_SORT_SET_DATA {
pub cbSize: i32,
pub nNumItems: i32,
pub pSortData: *mut MMC_SORT_DATA,
}
impl MMC_SORT_SET_DATA {}
impl ::core::default::Default for MMC_SORT_SET_DATA {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MMC_SORT_SET_DATA {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_SORT_SET_DATA").field("cbSize", &self.cbSize).field("nNumItems", &self.nNumItems).field("pSortData", &self.pSortData).finish()
}
}
impl ::core::cmp::PartialEq for MMC_SORT_SET_DATA {
fn eq(&self, other: &Self) -> bool {
self.cbSize == other.cbSize && self.nNumItems == other.nNumItems && self.pSortData == other.pSortData
}
}
impl ::core::cmp::Eq for MMC_SORT_SET_DATA {}
unsafe impl ::windows::core::Abi for MMC_SORT_SET_DATA {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_TASK {
pub sDisplayObject: MMC_TASK_DISPLAY_OBJECT,
pub szText: super::super::Foundation::PWSTR,
pub szHelpString: super::super::Foundation::PWSTR,
pub eActionType: MMC_ACTION_TYPE,
pub Anonymous: MMC_TASK_0,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub union MMC_TASK_0 {
pub nCommandID: isize,
pub szActionURL: super::super::Foundation::PWSTR,
pub szScript: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK_0 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK_0 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK_0 {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK_0 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK_0 {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_TASK_DISPLAY_BITMAP {
pub szMouseOverBitmap: super::super::Foundation::PWSTR,
pub szMouseOffBitmap: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK_DISPLAY_BITMAP {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK_DISPLAY_BITMAP {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_TASK_DISPLAY_BITMAP {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_TASK_DISPLAY_BITMAP").field("szMouseOverBitmap", &self.szMouseOverBitmap).field("szMouseOffBitmap", &self.szMouseOffBitmap).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK_DISPLAY_BITMAP {
fn eq(&self, other: &Self) -> bool {
self.szMouseOverBitmap == other.szMouseOverBitmap && self.szMouseOffBitmap == other.szMouseOffBitmap
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK_DISPLAY_BITMAP {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK_DISPLAY_BITMAP {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_TASK_DISPLAY_OBJECT {
pub eDisplayType: MMC_TASK_DISPLAY_TYPE,
pub Anonymous: MMC_TASK_DISPLAY_OBJECT_0,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK_DISPLAY_OBJECT {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK_DISPLAY_OBJECT {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK_DISPLAY_OBJECT {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK_DISPLAY_OBJECT {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK_DISPLAY_OBJECT {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub union MMC_TASK_DISPLAY_OBJECT_0 {
pub uBitmap: MMC_TASK_DISPLAY_BITMAP,
pub uSymbol: MMC_TASK_DISPLAY_SYMBOL,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK_DISPLAY_OBJECT_0 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK_DISPLAY_OBJECT_0 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK_DISPLAY_OBJECT_0 {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK_DISPLAY_OBJECT_0 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK_DISPLAY_OBJECT_0 {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct MMC_TASK_DISPLAY_SYMBOL {
pub szFontFamilyName: super::super::Foundation::PWSTR,
pub szURLtoEOT: super::super::Foundation::PWSTR,
pub szSymbolString: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl MMC_TASK_DISPLAY_SYMBOL {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for MMC_TASK_DISPLAY_SYMBOL {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for MMC_TASK_DISPLAY_SYMBOL {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_TASK_DISPLAY_SYMBOL").field("szFontFamilyName", &self.szFontFamilyName).field("szURLtoEOT", &self.szURLtoEOT).field("szSymbolString", &self.szSymbolString).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for MMC_TASK_DISPLAY_SYMBOL {
fn eq(&self, other: &Self) -> bool {
self.szFontFamilyName == other.szFontFamilyName && self.szURLtoEOT == other.szURLtoEOT && self.szSymbolString == other.szSymbolString
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for MMC_TASK_DISPLAY_SYMBOL {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for MMC_TASK_DISPLAY_SYMBOL {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_TASK_DISPLAY_TYPE(pub i32);
pub const MMC_TASK_DISPLAY_UNINITIALIZED: MMC_TASK_DISPLAY_TYPE = MMC_TASK_DISPLAY_TYPE(0i32);
pub const MMC_TASK_DISPLAY_TYPE_SYMBOL: MMC_TASK_DISPLAY_TYPE = MMC_TASK_DISPLAY_TYPE(1i32);
pub const MMC_TASK_DISPLAY_TYPE_VANILLA_GIF: MMC_TASK_DISPLAY_TYPE = MMC_TASK_DISPLAY_TYPE(2i32);
pub const MMC_TASK_DISPLAY_TYPE_CHOCOLATE_GIF: MMC_TASK_DISPLAY_TYPE = MMC_TASK_DISPLAY_TYPE(3i32);
pub const MMC_TASK_DISPLAY_TYPE_BITMAP: MMC_TASK_DISPLAY_TYPE = MMC_TASK_DISPLAY_TYPE(4i32);
impl ::core::convert::From<i32> for MMC_TASK_DISPLAY_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_TASK_DISPLAY_TYPE {
type Abi = Self;
}
pub const MMC_VER: u32 = 512u32;
pub const MMC_VIEW_OPTIONS_CREATENEW: u32 = 16u32;
pub const MMC_VIEW_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST: u32 = 64u32;
pub const MMC_VIEW_OPTIONS_FILTERED: u32 = 8u32;
pub const MMC_VIEW_OPTIONS_LEXICAL_SORT: u32 = 128u32;
pub const MMC_VIEW_OPTIONS_MULTISELECT: u32 = 2u32;
pub const MMC_VIEW_OPTIONS_NOLISTVIEWS: u32 = 1u32;
pub const MMC_VIEW_OPTIONS_NONE: u32 = 0u32;
pub const MMC_VIEW_OPTIONS_OWNERDATALIST: u32 = 4u32;
pub const MMC_VIEW_OPTIONS_USEFONTLINKING: u32 = 32u32;
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct MMC_VIEW_TYPE(pub i32);
pub const MMC_VIEW_TYPE_LIST: MMC_VIEW_TYPE = MMC_VIEW_TYPE(0i32);
pub const MMC_VIEW_TYPE_HTML: MMC_VIEW_TYPE = MMC_VIEW_TYPE(1i32);
pub const MMC_VIEW_TYPE_OCX: MMC_VIEW_TYPE = MMC_VIEW_TYPE(2i32);
impl ::core::convert::From<i32> for MMC_VIEW_TYPE {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for MMC_VIEW_TYPE {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct MMC_VISIBLE_COLUMNS {
pub nVisibleColumns: i32,
pub rgVisibleCols: [i32; 1],
}
impl MMC_VISIBLE_COLUMNS {}
impl ::core::default::Default for MMC_VISIBLE_COLUMNS {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for MMC_VISIBLE_COLUMNS {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("MMC_VISIBLE_COLUMNS").field("nVisibleColumns", &self.nVisibleColumns).field("rgVisibleCols", &self.rgVisibleCols).finish()
}
}
impl ::core::cmp::PartialEq for MMC_VISIBLE_COLUMNS {
fn eq(&self, other: &Self) -> bool {
self.nVisibleColumns == other.nVisibleColumns && self.rgVisibleCols == other.rgVisibleCols
}
}
impl ::core::cmp::Eq for MMC_VISIBLE_COLUMNS {}
unsafe impl ::windows::core::Abi for MMC_VISIBLE_COLUMNS {
type Abi = Self;
}
pub const MMC_WINDOW_COOKIE: i32 = -3i32;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct MenuItem(pub ::windows::core::IUnknown);
impl MenuItem {
pub unsafe fn DisplayName(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn LanguageIndependentName(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Path(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn LanguageIndependentPath(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Execute(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Enabled(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
}
unsafe impl ::windows::core::Interface for MenuItem {
type Vtable = MenuItem_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0178fad1_b361_4b27_96ad_67c57ebf2e1d);
}
impl ::core::convert::From<MenuItem> for ::windows::core::IUnknown {
fn from(value: MenuItem) -> Self {
value.0
}
}
impl ::core::convert::From<&MenuItem> for ::windows::core::IUnknown {
fn from(value: &MenuItem) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for MenuItem {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a MenuItem {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<MenuItem> for super::Com::IDispatch {
fn from(value: MenuItem) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&MenuItem> for super::Com::IDispatch {
fn from(value: &MenuItem) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for MenuItem {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &MenuItem {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct MenuItem_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, displayname: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, languageindependentname: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, path: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, languageindependentpath: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, enabled: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Node(pub ::windows::core::IUnknown);
impl Node {
pub unsafe fn Name(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Property<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, propertyname: Param0) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), propertyname.into_param().abi(), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Bookmark(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn IsScopeNode(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
pub unsafe fn Nodetype(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
}
unsafe impl ::windows::core::Interface for Node {
type Vtable = Node_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf81ed800_7839_4447_945d_8e15da59ca55);
}
impl ::core::convert::From<Node> for ::windows::core::IUnknown {
fn from(value: Node) -> Self {
value.0
}
}
impl ::core::convert::From<&Node> for ::windows::core::IUnknown {
fn from(value: &Node) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Node {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Node {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Node> for super::Com::IDispatch {
fn from(value: Node) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Node> for super::Com::IDispatch {
fn from(value: &Node) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Node {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Node {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Node_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, propertyname: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, propertyvalue: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, bookmark: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, isscopenode: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nodetype: *mut *mut u16) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Nodes(pub ::windows::core::IUnknown);
impl Nodes {
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn Item(&self, index: i32) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(index), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for Nodes {
type Vtable = Nodes_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x313b01df_b22f_4d42_b1b8_483cdcf51d35);
}
impl ::core::convert::From<Nodes> for ::windows::core::IUnknown {
fn from(value: Nodes) -> Self {
value.0
}
}
impl ::core::convert::From<&Nodes> for ::windows::core::IUnknown {
fn from(value: &Nodes) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Nodes {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Nodes {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Nodes> for super::Com::IDispatch {
fn from(value: Nodes) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Nodes> for super::Com::IDispatch {
fn from(value: &Nodes) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Nodes {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Nodes {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Nodes_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32, node: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Properties(pub ::windows::core::IUnknown);
impl Properties {
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Item<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, name: Param0) -> ::windows::core::Result<Property> {
let mut result__: <Property as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), name.into_param().abi(), &mut result__).from_abi::<Property>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Remove<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, name: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), name.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for Properties {
type Vtable = Properties_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2886abc2_a425_42b2_91c6_e25c0e04581c);
}
impl ::core::convert::From<Properties> for ::windows::core::IUnknown {
fn from(value: Properties) -> Self {
value.0
}
}
impl ::core::convert::From<&Properties> for ::windows::core::IUnknown {
fn from(value: &Properties) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Properties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Properties {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Properties> for super::Com::IDispatch {
fn from(value: Properties) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Properties> for super::Com::IDispatch {
fn from(value: &Properties) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Properties {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Properties {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Properties_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, property: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Property(pub ::windows::core::IUnknown);
impl Property {
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn Value(&self) -> ::windows::core::Result<super::Com::VARIANT> {
let mut result__: <super::Com::VARIANT as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::Com::VARIANT>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn SetValue<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, value: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), value.into_param().abi()).ok()
}
pub unsafe fn Name(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
}
unsafe impl ::windows::core::Interface for Property {
type Vtable = Property_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4600c3a5_e301_41d8_b6d0_ef2e4212e0ca);
}
impl ::core::convert::From<Property> for ::windows::core::IUnknown {
fn from(value: Property) -> Self {
value.0
}
}
impl ::core::convert::From<&Property> for ::windows::core::IUnknown {
fn from(value: &Property) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Property {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Property {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Property> for super::Com::IDispatch {
fn from(value: Property) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Property> for super::Com::IDispatch {
fn from(value: &Property) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Property {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Property {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Property_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut *mut u16) -> ::windows::core::HRESULT,
);
pub const RDCI_ScopeItem: u32 = 2147483648u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RDCOMPARE {
pub cbSize: u32,
pub dwFlags: u32,
pub nColumn: i32,
pub lUserParam: super::super::Foundation::LPARAM,
pub prdch1: *mut RDITEMHDR,
pub prdch2: *mut RDITEMHDR,
}
#[cfg(feature = "Win32_Foundation")]
impl RDCOMPARE {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RDCOMPARE {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RDCOMPARE {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("RDCOMPARE").field("cbSize", &self.cbSize).field("dwFlags", &self.dwFlags).field("nColumn", &self.nColumn).field("lUserParam", &self.lUserParam).field("prdch1", &self.prdch1).field("prdch2", &self.prdch2).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RDCOMPARE {
fn eq(&self, other: &Self) -> bool {
self.cbSize == other.cbSize && self.dwFlags == other.dwFlags && self.nColumn == other.nColumn && self.lUserParam == other.lUserParam && self.prdch1 == other.prdch1 && self.prdch2 == other.prdch2
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RDCOMPARE {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RDCOMPARE {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RDITEMHDR {
pub dwFlags: u32,
pub cookie: isize,
pub lpReserved: super::super::Foundation::LPARAM,
}
#[cfg(feature = "Win32_Foundation")]
impl RDITEMHDR {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RDITEMHDR {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RDITEMHDR {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("RDITEMHDR").field("dwFlags", &self.dwFlags).field("cookie", &self.cookie).field("lpReserved", &self.lpReserved).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RDITEMHDR {
fn eq(&self, other: &Self) -> bool {
self.dwFlags == other.dwFlags && self.cookie == other.cookie && self.lpReserved == other.lpReserved
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RDITEMHDR {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RDITEMHDR {
type Abi = Self;
}
pub const RDI_IMAGE: u32 = 4u32;
pub const RDI_INDENT: u32 = 64u32;
pub const RDI_INDEX: u32 = 32u32;
pub const RDI_PARAM: u32 = 16u32;
pub const RDI_STATE: u32 = 8u32;
pub const RDI_STR: u32 = 2u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RESULTDATAITEM {
pub mask: u32,
pub bScopeItem: super::super::Foundation::BOOL,
pub itemID: isize,
pub nIndex: i32,
pub nCol: i32,
pub str: super::super::Foundation::PWSTR,
pub nImage: i32,
pub nState: u32,
pub lParam: super::super::Foundation::LPARAM,
pub iIndent: i32,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULTDATAITEM {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULTDATAITEM {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RESULTDATAITEM {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("RESULTDATAITEM")
.field("mask", &self.mask)
.field("bScopeItem", &self.bScopeItem)
.field("itemID", &self.itemID)
.field("nIndex", &self.nIndex)
.field("nCol", &self.nCol)
.field("str", &self.str)
.field("nImage", &self.nImage)
.field("nState", &self.nState)
.field("lParam", &self.lParam)
.field("iIndent", &self.iIndent)
.finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULTDATAITEM {
fn eq(&self, other: &Self) -> bool {
self.mask == other.mask && self.bScopeItem == other.bScopeItem && self.itemID == other.itemID && self.nIndex == other.nIndex && self.nCol == other.nCol && self.str == other.str && self.nImage == other.nImage && self.nState == other.nState && self.lParam == other.lParam && self.iIndent == other.iIndent
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULTDATAITEM {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULTDATAITEM {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RESULTFINDINFO {
pub psz: super::super::Foundation::PWSTR,
pub nStart: i32,
pub dwOptions: u32,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULTFINDINFO {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULTFINDINFO {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RESULTFINDINFO {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("RESULTFINDINFO").field("psz", &self.psz).field("nStart", &self.nStart).field("dwOptions", &self.dwOptions).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULTFINDINFO {
fn eq(&self, other: &Self) -> bool {
self.psz == other.psz && self.nStart == other.nStart && self.dwOptions == other.dwOptions
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULTFINDINFO {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULTFINDINFO {
type Abi = Self;
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::clone::Clone for RESULT_VIEW_TYPE_INFO {
fn clone(&self) -> Self {
unimplemented!()
}
}
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RESULT_VIEW_TYPE_INFO {
pub pstrPersistableViewDescription: super::super::Foundation::PWSTR,
pub eViewType: MMC_VIEW_TYPE,
pub dwMiscOptions: u32,
pub Anonymous: RESULT_VIEW_TYPE_INFO_0,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULT_VIEW_TYPE_INFO {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULT_VIEW_TYPE_INFO {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULT_VIEW_TYPE_INFO {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULT_VIEW_TYPE_INFO {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULT_VIEW_TYPE_INFO {
type Abi = ::core::mem::ManuallyDrop<Self>;
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::clone::Clone for RESULT_VIEW_TYPE_INFO_0 {
fn clone(&self) -> Self {
unimplemented!()
}
}
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub union RESULT_VIEW_TYPE_INFO_0 {
pub dwListOptions: u32,
pub Anonymous1: RESULT_VIEW_TYPE_INFO_0_0,
pub Anonymous2: ::core::mem::ManuallyDrop<RESULT_VIEW_TYPE_INFO_0_1>,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULT_VIEW_TYPE_INFO_0 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULT_VIEW_TYPE_INFO_0 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULT_VIEW_TYPE_INFO_0 {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULT_VIEW_TYPE_INFO_0 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULT_VIEW_TYPE_INFO_0 {
type Abi = ::core::mem::ManuallyDrop<Self>;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RESULT_VIEW_TYPE_INFO_0_0 {
pub dwHTMLOptions: u32,
pub pstrURL: super::super::Foundation::PWSTR,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULT_VIEW_TYPE_INFO_0_0 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULT_VIEW_TYPE_INFO_0_0 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RESULT_VIEW_TYPE_INFO_0_0 {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("_Anonymous1_e__Struct").field("dwHTMLOptions", &self.dwHTMLOptions).field("pstrURL", &self.pstrURL).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULT_VIEW_TYPE_INFO_0_0 {
fn eq(&self, other: &Self) -> bool {
self.dwHTMLOptions == other.dwHTMLOptions && self.pstrURL == other.pstrURL
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULT_VIEW_TYPE_INFO_0_0 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULT_VIEW_TYPE_INFO_0_0 {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct RESULT_VIEW_TYPE_INFO_0_1 {
pub dwOCXOptions: u32,
pub pUnkControl: ::core::option::Option<::windows::core::IUnknown>,
}
#[cfg(feature = "Win32_Foundation")]
impl RESULT_VIEW_TYPE_INFO_0_1 {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for RESULT_VIEW_TYPE_INFO_0_1 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for RESULT_VIEW_TYPE_INFO_0_1 {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("_Anonymous2_e__Struct").field("dwOCXOptions", &self.dwOCXOptions).field("pUnkControl", &self.pUnkControl).finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for RESULT_VIEW_TYPE_INFO_0_1 {
fn eq(&self, other: &Self) -> bool {
self.dwOCXOptions == other.dwOCXOptions && self.pUnkControl == other.pUnkControl
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for RESULT_VIEW_TYPE_INFO_0_1 {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for RESULT_VIEW_TYPE_INFO_0_1 {
type Abi = ::core::mem::ManuallyDrop<Self>;
}
pub const RFI_PARTIAL: u32 = 1u32;
pub const RFI_WRAP: u32 = 2u32;
pub const RSI_DESCENDING: u32 = 1u32;
pub const RSI_NOSORTICON: u32 = 2u32;
pub const RVTI_HTML_OPTIONS_NOLISTVIEW: u32 = 1u32;
pub const RVTI_HTML_OPTIONS_NONE: u32 = 0u32;
pub const RVTI_LIST_OPTIONS_ALLOWPASTE: u32 = 256u32;
pub const RVTI_LIST_OPTIONS_EXCLUDE_SCOPE_ITEMS_FROM_LIST: u32 = 64u32;
pub const RVTI_LIST_OPTIONS_FILTERED: u32 = 8u32;
pub const RVTI_LIST_OPTIONS_LEXICAL_SORT: u32 = 128u32;
pub const RVTI_LIST_OPTIONS_MULTISELECT: u32 = 4u32;
pub const RVTI_LIST_OPTIONS_NONE: u32 = 0u32;
pub const RVTI_LIST_OPTIONS_OWNERDATALIST: u32 = 2u32;
pub const RVTI_LIST_OPTIONS_USEFONTLINKING: u32 = 32u32;
pub const RVTI_MISC_OPTIONS_NOLISTVIEWS: u32 = 1u32;
pub const RVTI_OCX_OPTIONS_CACHE_OCX: u32 = 2u32;
pub const RVTI_OCX_OPTIONS_NOLISTVIEW: u32 = 1u32;
pub const RVTI_OCX_OPTIONS_NONE: u32 = 0u32;
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
#[cfg(feature = "Win32_Foundation")]
pub struct SCOPEDATAITEM {
pub mask: u32,
pub displayname: super::super::Foundation::PWSTR,
pub nImage: i32,
pub nOpenImage: i32,
pub nState: u32,
pub cChildren: i32,
pub lParam: super::super::Foundation::LPARAM,
pub relativeID: isize,
pub ID: isize,
}
#[cfg(feature = "Win32_Foundation")]
impl SCOPEDATAITEM {}
#[cfg(feature = "Win32_Foundation")]
impl ::core::default::Default for SCOPEDATAITEM {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::fmt::Debug for SCOPEDATAITEM {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("SCOPEDATAITEM")
.field("mask", &self.mask)
.field("displayname", &self.displayname)
.field("nImage", &self.nImage)
.field("nOpenImage", &self.nOpenImage)
.field("nState", &self.nState)
.field("cChildren", &self.cChildren)
.field("lParam", &self.lParam)
.field("relativeID", &self.relativeID)
.field("ID", &self.ID)
.finish()
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::PartialEq for SCOPEDATAITEM {
fn eq(&self, other: &Self) -> bool {
self.mask == other.mask && self.displayname == other.displayname && self.nImage == other.nImage && self.nOpenImage == other.nOpenImage && self.nState == other.nState && self.cChildren == other.cChildren && self.lParam == other.lParam && self.relativeID == other.relativeID && self.ID == other.ID
}
}
#[cfg(feature = "Win32_Foundation")]
impl ::core::cmp::Eq for SCOPEDATAITEM {}
#[cfg(feature = "Win32_Foundation")]
unsafe impl ::windows::core::Abi for SCOPEDATAITEM {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct SColumnSetID {
pub dwFlags: u32,
pub cBytes: u32,
pub id: [u8; 1],
}
impl SColumnSetID {}
impl ::core::default::Default for SColumnSetID {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for SColumnSetID {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("SColumnSetID").field("dwFlags", &self.dwFlags).field("cBytes", &self.cBytes).field("id", &self.id).finish()
}
}
impl ::core::cmp::PartialEq for SColumnSetID {
fn eq(&self, other: &Self) -> bool {
self.dwFlags == other.dwFlags && self.cBytes == other.cBytes && self.id == other.id
}
}
impl ::core::cmp::Eq for SColumnSetID {}
unsafe impl ::windows::core::Abi for SColumnSetID {
type Abi = Self;
}
pub const SDI_CHILDREN: u32 = 64u32;
pub const SDI_FIRST: u32 = 134217728u32;
pub const SDI_IMAGE: u32 = 4u32;
pub const SDI_NEXT: u32 = 536870912u32;
pub const SDI_OPENIMAGE: u32 = 8u32;
pub const SDI_PARAM: u32 = 32u32;
pub const SDI_PARENT: u32 = 0u32;
pub const SDI_PREVIOUS: u32 = 268435456u32;
pub const SDI_STATE: u32 = 16u32;
pub const SDI_STR: u32 = 2u32;
#[derive(:: core :: clone :: Clone)]
#[repr(C)]
#[cfg(feature = "Win32_System_Com")]
pub struct SMMCDataObjects {
pub count: u32,
pub lpDataObject: [::core::option::Option<super::Com::IDataObject>; 1],
}
#[cfg(feature = "Win32_System_Com")]
impl SMMCDataObjects {}
#[cfg(feature = "Win32_System_Com")]
impl ::core::default::Default for SMMCDataObjects {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::cmp::PartialEq for SMMCDataObjects {
fn eq(&self, _other: &Self) -> bool {
unimplemented!()
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::cmp::Eq for SMMCDataObjects {}
#[cfg(feature = "Win32_System_Com")]
unsafe impl ::windows::core::Abi for SMMCDataObjects {
type Abi = ::core::mem::ManuallyDrop<Self>;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct SMMCObjectTypes {
pub count: u32,
pub guid: [::windows::core::GUID; 1],
}
impl SMMCObjectTypes {}
impl ::core::default::Default for SMMCObjectTypes {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for SMMCObjectTypes {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("SMMCObjectTypes").field("count", &self.count).field("guid", &self.guid).finish()
}
}
impl ::core::cmp::PartialEq for SMMCObjectTypes {
fn eq(&self, other: &Self) -> bool {
self.count == other.count && self.guid == other.guid
}
}
impl ::core::cmp::Eq for SMMCObjectTypes {}
unsafe impl ::windows::core::Abi for SMMCObjectTypes {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct SNodeID {
pub cBytes: u32,
pub id: [u8; 1],
}
impl SNodeID {}
impl ::core::default::Default for SNodeID {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for SNodeID {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("SNodeID").field("cBytes", &self.cBytes).field("id", &self.id).finish()
}
}
impl ::core::cmp::PartialEq for SNodeID {
fn eq(&self, other: &Self) -> bool {
self.cBytes == other.cBytes && self.id == other.id
}
}
impl ::core::cmp::Eq for SNodeID {}
unsafe impl ::windows::core::Abi for SNodeID {
type Abi = Self;
}
#[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)]
#[repr(C)]
pub struct SNodeID2 {
pub dwFlags: u32,
pub cBytes: u32,
pub id: [u8; 1],
}
impl SNodeID2 {}
impl ::core::default::Default for SNodeID2 {
fn default() -> Self {
unsafe { ::core::mem::zeroed() }
}
}
impl ::core::fmt::Debug for SNodeID2 {
fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
fmt.debug_struct("SNodeID2").field("dwFlags", &self.dwFlags).field("cBytes", &self.cBytes).field("id", &self.id).finish()
}
}
impl ::core::cmp::PartialEq for SNodeID2 {
fn eq(&self, other: &Self) -> bool {
self.dwFlags == other.dwFlags && self.cBytes == other.cBytes && self.id == other.id
}
}
impl ::core::cmp::Eq for SNodeID2 {}
unsafe impl ::windows::core::Abi for SNodeID2 {
type Abi = Self;
}
pub const SPECIAL_COOKIE_MAX: i32 = -1i32;
pub const SPECIAL_COOKIE_MIN: i32 = -10i32;
pub const SPECIAL_DOBJ_MAX: u32 = 0u32;
pub const SPECIAL_DOBJ_MIN: i32 = -10i32;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ScopeNamespace(pub ::windows::core::IUnknown);
impl ScopeNamespace {
pub unsafe fn GetParent<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), node.into_param().abi(), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn GetChild<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), node.into_param().abi(), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn GetNext<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), node.into_param().abi(), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn GetRoot(&self) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn Expand<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), node.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for ScopeNamespace {
type Vtable = ScopeNamespace_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xebbb48dc_1a3b_4d86_b786_c21b28389012);
}
impl ::core::convert::From<ScopeNamespace> for ::windows::core::IUnknown {
fn from(value: ScopeNamespace) -> Self {
value.0
}
}
impl ::core::convert::From<&ScopeNamespace> for ::windows::core::IUnknown {
fn from(value: &ScopeNamespace) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ScopeNamespace {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ScopeNamespace {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<ScopeNamespace> for super::Com::IDispatch {
fn from(value: ScopeNamespace) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&ScopeNamespace> for super::Com::IDispatch {
fn from(value: &ScopeNamespace) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for ScopeNamespace {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &ScopeNamespace {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ScopeNamespace_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, parent: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, child: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, next: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, root: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct SnapIn(pub ::windows::core::IUnknown);
impl SnapIn {
pub unsafe fn Name(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Vendor(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Version(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Extensions(&self) -> ::windows::core::Result<Extensions> {
let mut result__: <Extensions as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Extensions>(result__)
}
pub unsafe fn SnapinCLSID(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
pub unsafe fn Properties(&self) -> ::windows::core::Result<Properties> {
let mut result__: <Properties as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Properties>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn EnableAllExtensions<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, enable: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), enable.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for SnapIn {
type Vtable = SnapIn_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3be910f6_3459_49c6_a1bb_41e6be9df3ea);
}
impl ::core::convert::From<SnapIn> for ::windows::core::IUnknown {
fn from(value: SnapIn) -> Self {
value.0
}
}
impl ::core::convert::From<&SnapIn> for ::windows::core::IUnknown {
fn from(value: &SnapIn) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for SnapIn {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a SnapIn {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<SnapIn> for super::Com::IDispatch {
fn from(value: SnapIn) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&SnapIn> for super::Com::IDispatch {
fn from(value: &SnapIn) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for SnapIn {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &SnapIn {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct SnapIn_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, name: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, vendor: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, version: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, extensions: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, snapinclsid: *mut *mut u16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, properties: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, enable: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct SnapIns(pub ::windows::core::IUnknown);
impl SnapIns {
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
pub unsafe fn Item(&self, index: i32) -> ::windows::core::Result<SnapIn> {
let mut result__: <SnapIn as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), ::core::mem::transmute(index), &mut result__).from_abi::<SnapIn>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn Add<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param1: ::windows::core::IntoParam<'a, super::Com::VARIANT>, Param2: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, snapinnameorclsid: Param0, parentsnapin: Param1, properties: Param2) -> ::windows::core::Result<SnapIn> {
let mut result__: <SnapIn as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), snapinnameorclsid.into_param().abi(), parentsnapin.into_param().abi(), properties.into_param().abi(), &mut result__).from_abi::<SnapIn>(result__)
}
pub unsafe fn Remove<'a, Param0: ::windows::core::IntoParam<'a, SnapIn>>(&self, snapin: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), snapin.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for SnapIns {
type Vtable = SnapIns_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2ef3de1d_b12a_49d1_92c5_0b00798768f1);
}
impl ::core::convert::From<SnapIns> for ::windows::core::IUnknown {
fn from(value: SnapIns) -> Self {
value.0
}
}
impl ::core::convert::From<&SnapIns> for ::windows::core::IUnknown {
fn from(value: &SnapIns) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for SnapIns {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a SnapIns {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<SnapIns> for super::Com::IDispatch {
fn from(value: SnapIns) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&SnapIns> for super::Com::IDispatch {
fn from(value: &SnapIns) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for SnapIns {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &SnapIns {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct SnapIns_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32, snapin: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, snapinnameorclsid: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, parentsnapin: ::core::mem::ManuallyDrop<super::Com::VARIANT>, properties: ::core::mem::ManuallyDrop<super::Com::VARIANT>, snapin: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, snapin: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct View(pub ::windows::core::IUnknown);
impl View {
pub unsafe fn ActiveScopeNode(&self) -> ::windows::core::Result<Node> {
let mut result__: <Node as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Node>(result__)
}
pub unsafe fn SetActiveScopeNode<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), node.into_param().abi()).ok()
}
pub unsafe fn Selection(&self) -> ::windows::core::Result<Nodes> {
let mut result__: <Nodes as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Nodes>(result__)
}
pub unsafe fn ListItems(&self) -> ::windows::core::Result<Nodes> {
let mut result__: <Nodes as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Nodes>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn SnapinScopeObject<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<super::Com::IDispatch> {
let mut result__: <super::Com::IDispatch as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), scopenode.into_param().abi(), &mut result__).from_abi::<super::Com::IDispatch>(result__)
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn SnapinSelectionObject(&self) -> ::windows::core::Result<super::Com::IDispatch> {
let mut result__: <super::Com::IDispatch as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::Com::IDispatch>(result__)
}
pub unsafe fn Is<'a, Param0: ::windows::core::IntoParam<'a, View>>(&self, view: Param0) -> ::windows::core::Result<i16> {
let mut result__: <i16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), view.into_param().abi(), &mut result__).from_abi::<i16>(result__)
}
pub unsafe fn Document(&self) -> ::windows::core::Result<Document> {
let mut result__: <Document as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Document>(result__)
}
pub unsafe fn SelectAll(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Select<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), node.into_param().abi()).ok()
}
pub unsafe fn Deselect<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), node.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn IsSelected<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).18)(::core::mem::transmute_copy(self), node.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn DisplayScopeNodePropertySheet<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).19)(::core::mem::transmute_copy(self), scopenode.into_param().abi()).ok()
}
pub unsafe fn DisplaySelectionPropertySheet(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).20)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn CopyScopeNode<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).21)(::core::mem::transmute_copy(self), scopenode.into_param().abi()).ok()
}
pub unsafe fn CopySelection(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).22)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn DeleteScopeNode<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).23)(::core::mem::transmute_copy(self), scopenode.into_param().abi()).ok()
}
pub unsafe fn DeleteSelection(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).24)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn RenameScopeNode<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param1: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, newname: Param0, scopenode: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).25)(::core::mem::transmute_copy(self), newname.into_param().abi(), scopenode.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn RenameSelectedItem<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, newname: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).26)(::core::mem::transmute_copy(self), newname.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn ScopeNodeContextMenu<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<ContextMenu> {
let mut result__: <ContextMenu as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).27)(::core::mem::transmute_copy(self), scopenode.into_param().abi(), &mut result__).from_abi::<ContextMenu>(result__)
}
pub unsafe fn SelectionContextMenu(&self) -> ::windows::core::Result<ContextMenu> {
let mut result__: <ContextMenu as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).28)(::core::mem::transmute_copy(self), &mut result__).from_abi::<ContextMenu>(result__)
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn RefreshScopeNode<'a, Param0: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, scopenode: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).29)(::core::mem::transmute_copy(self), scopenode.into_param().abi()).ok()
}
pub unsafe fn RefreshSelection(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).30)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ExecuteSelectionMenuItem<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, menuitempath: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).31)(::core::mem::transmute_copy(self), menuitempath.into_param().abi()).ok()
}
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))]
pub unsafe fn ExecuteScopeNodeMenuItem<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param1: ::windows::core::IntoParam<'a, super::Com::VARIANT>>(&self, menuitempath: Param0, scopenode: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).32)(::core::mem::transmute_copy(self), menuitempath.into_param().abi(), scopenode.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ExecuteShellCommand<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, command: Param0, directory: Param1, parameters: Param2, windowstate: Param3) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).33)(::core::mem::transmute_copy(self), command.into_param().abi(), directory.into_param().abi(), parameters.into_param().abi(), windowstate.into_param().abi()).ok()
}
pub unsafe fn Frame(&self) -> ::windows::core::Result<Frame> {
let mut result__: <Frame as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).34)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Frame>(result__)
}
pub unsafe fn Close(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).35)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ScopeTreeVisible(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).36)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetScopeTreeVisible<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, visible: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).37)(::core::mem::transmute_copy(self), visible.into_param().abi()).ok()
}
pub unsafe fn Back(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).38)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Forward(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).39)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetStatusBarText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, statusbartext: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).40)(::core::mem::transmute_copy(self), statusbartext.into_param().abi()).ok()
}
pub unsafe fn Memento(&self) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).41)(::core::mem::transmute_copy(self), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ViewMemento<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, memento: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).42)(::core::mem::transmute_copy(self), memento.into_param().abi()).ok()
}
pub unsafe fn Columns(&self) -> ::windows::core::Result<Columns> {
let mut result__: <Columns as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).43)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Columns>(result__)
}
pub unsafe fn CellContents<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0, column: i32) -> ::windows::core::Result<*mut u16> {
let mut result__: <*mut u16 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).44)(::core::mem::transmute_copy(self), node.into_param().abi(), ::core::mem::transmute(column), &mut result__).from_abi::<*mut u16>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn ExportList<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, file: Param0, exportoptions: _ExportListOptions) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).45)(::core::mem::transmute_copy(self), file.into_param().abi(), ::core::mem::transmute(exportoptions)).ok()
}
pub unsafe fn ListViewMode(&self) -> ::windows::core::Result<_ListViewMode> {
let mut result__: <_ListViewMode as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).46)(::core::mem::transmute_copy(self), &mut result__).from_abi::<_ListViewMode>(result__)
}
pub unsafe fn SetListViewMode(&self, mode: _ListViewMode) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).47)(::core::mem::transmute_copy(self), ::core::mem::transmute(mode)).ok()
}
#[cfg(feature = "Win32_System_Com")]
pub unsafe fn ControlObject(&self) -> ::windows::core::Result<super::Com::IDispatch> {
let mut result__: <super::Com::IDispatch as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).48)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::Com::IDispatch>(result__)
}
}
unsafe impl ::windows::core::Interface for View {
type Vtable = View_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6efc2da2_b38c_457e_9abb_ed2d189b8c38);
}
impl ::core::convert::From<View> for ::windows::core::IUnknown {
fn from(value: View) -> Self {
value.0
}
}
impl ::core::convert::From<&View> for ::windows::core::IUnknown {
fn from(value: &View) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for View {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a View {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<View> for super::Com::IDispatch {
fn from(value: View) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&View> for super::Com::IDispatch {
fn from(value: &View) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for View {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &View {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct View_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nodes: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nodes: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>, scopenodeobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, selectionobject: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr, thesame: *mut i16) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, isselected: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, newname: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, newname: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>, contextmenu: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, contextmenu: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, menuitempath: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, menuitempath: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, scopenode: ::core::mem::ManuallyDrop<super::Com::VARIANT>) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, command: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, directory: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, parameters: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, windowstate: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, frame: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, visible: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, visible: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, statusbartext: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, memento: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, memento: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, columns: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, column: i32, cellcontents: *mut *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, file: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>, exportoptions: _ExportListOptions) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, mode: *mut _ListViewMode) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, mode: _ListViewMode) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, control: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Views(pub ::windows::core::IUnknown);
impl Views {
pub unsafe fn Item(&self, index: i32) -> ::windows::core::Result<View> {
let mut result__: <View as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), ::core::mem::transmute(index), &mut result__).from_abi::<View>(result__)
}
pub unsafe fn Count(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn Add<'a, Param0: ::windows::core::IntoParam<'a, Node>>(&self, node: Param0, viewoptions: _ViewOptions) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), node.into_param().abi(), ::core::mem::transmute(viewoptions)).ok()
}
pub unsafe fn _NewEnum(&self) -> ::windows::core::Result<::windows::core::IUnknown> {
let mut result__: <::windows::core::IUnknown as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), &mut result__).from_abi::<::windows::core::IUnknown>(result__)
}
}
unsafe impl ::windows::core::Interface for Views {
type Vtable = Views_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd6b8c29d_a1ff_4d72_aab0_e381e9b9338d);
}
impl ::core::convert::From<Views> for ::windows::core::IUnknown {
fn from(value: Views) -> Self {
value.0
}
}
impl ::core::convert::From<&Views> for ::windows::core::IUnknown {
fn from(value: &Views) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Views {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Views {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<Views> for super::Com::IDispatch {
fn from(value: Views) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&Views> for super::Com::IDispatch {
fn from(value: &Views) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for Views {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &Views {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct Views_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, index: i32, view: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, node: ::windows::core::RawPtr, viewoptions: _ViewOptions) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, retval: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct _AppEvents(pub ::windows::core::IUnknown);
impl _AppEvents {
pub unsafe fn OnQuit<'a, Param0: ::windows::core::IntoParam<'a, _Application>>(&self, application: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), application.into_param().abi()).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn OnDocumentOpen<'a, Param0: ::windows::core::IntoParam<'a, Document>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, document: Param0, new: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self), document.into_param().abi(), new.into_param().abi()).ok()
}
pub unsafe fn OnDocumentClose<'a, Param0: ::windows::core::IntoParam<'a, Document>>(&self, document: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), document.into_param().abi()).ok()
}
pub unsafe fn OnSnapInAdded<'a, Param0: ::windows::core::IntoParam<'a, Document>, Param1: ::windows::core::IntoParam<'a, SnapIn>>(&self, document: Param0, snapin: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), document.into_param().abi(), snapin.into_param().abi()).ok()
}
pub unsafe fn OnSnapInRemoved<'a, Param0: ::windows::core::IntoParam<'a, Document>, Param1: ::windows::core::IntoParam<'a, SnapIn>>(&self, document: Param0, snapin: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), document.into_param().abi(), snapin.into_param().abi()).ok()
}
pub unsafe fn OnNewView<'a, Param0: ::windows::core::IntoParam<'a, View>>(&self, view: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), view.into_param().abi()).ok()
}
pub unsafe fn OnViewClose<'a, Param0: ::windows::core::IntoParam<'a, View>>(&self, view: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self), view.into_param().abi()).ok()
}
pub unsafe fn OnViewChange<'a, Param0: ::windows::core::IntoParam<'a, View>, Param1: ::windows::core::IntoParam<'a, Node>>(&self, view: Param0, newownernode: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self), view.into_param().abi(), newownernode.into_param().abi()).ok()
}
pub unsafe fn OnSelectionChange<'a, Param0: ::windows::core::IntoParam<'a, View>, Param1: ::windows::core::IntoParam<'a, Nodes>>(&self, view: Param0, newnodes: Param1) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), view.into_param().abi(), newnodes.into_param().abi()).ok()
}
pub unsafe fn OnContextMenuExecuted<'a, Param0: ::windows::core::IntoParam<'a, MenuItem>>(&self, menuitem: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), menuitem.into_param().abi()).ok()
}
pub unsafe fn OnToolbarButtonClicked(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn OnListUpdated<'a, Param0: ::windows::core::IntoParam<'a, View>>(&self, view: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).18)(::core::mem::transmute_copy(self), view.into_param().abi()).ok()
}
}
unsafe impl ::windows::core::Interface for _AppEvents {
type Vtable = _AppEvents_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xde46cbdd_53f5_4635_af54_4fe71e923d3f);
}
impl ::core::convert::From<_AppEvents> for ::windows::core::IUnknown {
fn from(value: _AppEvents) -> Self {
value.0
}
}
impl ::core::convert::From<&_AppEvents> for ::windows::core::IUnknown {
fn from(value: &_AppEvents) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for _AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a _AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<_AppEvents> for super::Com::IDispatch {
fn from(value: _AppEvents) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&_AppEvents> for super::Com::IDispatch {
fn from(value: &_AppEvents) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for _AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &_AppEvents {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct _AppEvents_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, application: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: ::windows::core::RawPtr, new: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: ::windows::core::RawPtr, snapin: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: ::windows::core::RawPtr, snapin: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr, newownernode: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr, newnodes: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, menuitem: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, view: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct _Application(pub ::windows::core::IUnknown);
impl _Application {
pub unsafe fn Help(&self) {
::core::mem::transmute((::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self)))
}
pub unsafe fn Quit(&self) {
::core::mem::transmute((::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self)))
}
pub unsafe fn Document(&self) -> ::windows::core::Result<Document> {
let mut result__: <Document as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).9)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Document>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Load<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BSTR>>(&self, filename: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).10)(::core::mem::transmute_copy(self), filename.into_param().abi()).ok()
}
pub unsafe fn Frame(&self) -> ::windows::core::Result<Frame> {
let mut result__: <Frame as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).11)(::core::mem::transmute_copy(self), &mut result__).from_abi::<Frame>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn Visible(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).12)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
pub unsafe fn Show(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).13)(::core::mem::transmute_copy(self)).ok()
}
pub unsafe fn Hide(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).14)(::core::mem::transmute_copy(self)).ok()
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn UserControl(&self) -> ::windows::core::Result<super::super::Foundation::BOOL> {
let mut result__: <super::super::Foundation::BOOL as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).15)(::core::mem::transmute_copy(self), &mut result__).from_abi::<super::super::Foundation::BOOL>(result__)
}
#[cfg(feature = "Win32_Foundation")]
pub unsafe fn SetUserControl<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::BOOL>>(&self, usercontrol: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).16)(::core::mem::transmute_copy(self), usercontrol.into_param().abi()).ok()
}
pub unsafe fn VersionMajor(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).17)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
pub unsafe fn VersionMinor(&self) -> ::windows::core::Result<i32> {
let mut result__: <i32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed();
(::windows::core::Interface::vtable(self).18)(::core::mem::transmute_copy(self), &mut result__).from_abi::<i32>(result__)
}
}
unsafe impl ::windows::core::Interface for _Application {
type Vtable = _Application_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa3afb9cc_b653_4741_86ab_f0470ec1384c);
}
impl ::core::convert::From<_Application> for ::windows::core::IUnknown {
fn from(value: _Application) -> Self {
value.0
}
}
impl ::core::convert::From<&_Application> for ::windows::core::IUnknown {
fn from(value: &_Application) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for _Application {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a _Application {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<_Application> for super::Com::IDispatch {
fn from(value: _Application) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&_Application> for super::Com::IDispatch {
fn from(value: &_Application) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for _Application {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &_Application {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct _Application_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr),
pub unsafe extern "system" fn(this: ::windows::core::RawPtr),
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, document: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, filename: ::core::mem::ManuallyDrop<super::super::Foundation::BSTR>) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, frame: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, visible: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, usercontrol: *mut super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, usercontrol: super::super::Foundation::BOOL) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, versionmajor: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, versionminor: *mut i32) -> ::windows::core::HRESULT,
);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct _ColumnSortOrder(pub i32);
pub const SortOrder_Ascending: _ColumnSortOrder = _ColumnSortOrder(0i32);
pub const SortOrder_Descending: _ColumnSortOrder = _ColumnSortOrder(1i32);
impl ::core::convert::From<i32> for _ColumnSortOrder {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for _ColumnSortOrder {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct _DocumentMode(pub i32);
pub const DocumentMode_Author: _DocumentMode = _DocumentMode(0i32);
pub const DocumentMode_User: _DocumentMode = _DocumentMode(1i32);
pub const DocumentMode_User_MDI: _DocumentMode = _DocumentMode(2i32);
pub const DocumentMode_User_SDI: _DocumentMode = _DocumentMode(3i32);
impl ::core::convert::From<i32> for _DocumentMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for _DocumentMode {
type Abi = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct _EventConnector(pub ::windows::core::IUnknown);
impl _EventConnector {
pub unsafe fn ConnectTo<'a, Param0: ::windows::core::IntoParam<'a, _Application>>(&self, application: Param0) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).7)(::core::mem::transmute_copy(self), application.into_param().abi()).ok()
}
pub unsafe fn Disconnect(&self) -> ::windows::core::Result<()> {
(::windows::core::Interface::vtable(self).8)(::core::mem::transmute_copy(self)).ok()
}
}
unsafe impl ::windows::core::Interface for _EventConnector {
type Vtable = _EventConnector_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc0bccd30_de44_4528_8403_a05a6a1cc8ea);
}
impl ::core::convert::From<_EventConnector> for ::windows::core::IUnknown {
fn from(value: _EventConnector) -> Self {
value.0
}
}
impl ::core::convert::From<&_EventConnector> for ::windows::core::IUnknown {
fn from(value: &_EventConnector) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for _EventConnector {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a _EventConnector {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<_EventConnector> for super::Com::IDispatch {
fn from(value: _EventConnector) -> Self {
unsafe { ::core::mem::transmute(value) }
}
}
#[cfg(feature = "Win32_System_Com")]
impl ::core::convert::From<&_EventConnector> for super::Com::IDispatch {
fn from(value: &_EventConnector) -> Self {
::core::convert::From::from(::core::clone::Clone::clone(value))
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for _EventConnector {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) })
}
}
#[cfg(feature = "Win32_System_Com")]
impl<'a> ::windows::core::IntoParam<'a, super::Com::IDispatch> for &_EventConnector {
fn into_param(self) -> ::windows::core::Param<'a, super::Com::IDispatch> {
::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) })
}
}
#[repr(C)]
#[doc(hidden)]
pub struct _EventConnector_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, pctinfo: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Win32_System_Com")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, itinfo: u32, lcid: u32, pptinfo: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_System_Com"))] usize,
#[cfg(feature = "Win32_Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, riid: *const ::windows::core::GUID, rgsznames: *const super::super::Foundation::PWSTR, cnames: u32, lcid: u32, rgdispid: *mut i32) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Win32_Foundation"))] usize,
#[cfg(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, dispidmember: i32, riid: *const ::windows::core::GUID, lcid: u32, wflags: u16, pdispparams: *const super::Com::DISPPARAMS, pvarresult: *mut ::core::mem::ManuallyDrop<super::Com::VARIANT>, pexcepinfo: *mut ::core::mem::ManuallyDrop<super::Com::EXCEPINFO>, puargerr: *mut u32) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Win32_Foundation", feature = "Win32_System_Com", feature = "Win32_System_Ole")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, application: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct _ExportListOptions(pub i32);
pub const ExportListOptions_Default: _ExportListOptions = _ExportListOptions(0i32);
pub const ExportListOptions_Unicode: _ExportListOptions = _ExportListOptions(1i32);
pub const ExportListOptions_TabDelimited: _ExportListOptions = _ExportListOptions(2i32);
pub const ExportListOptions_SelectedItemsOnly: _ExportListOptions = _ExportListOptions(4i32);
impl ::core::convert::From<i32> for _ExportListOptions {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for _ExportListOptions {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct _ListViewMode(pub i32);
pub const ListMode_Small_Icons: _ListViewMode = _ListViewMode(0i32);
pub const ListMode_Large_Icons: _ListViewMode = _ListViewMode(1i32);
pub const ListMode_List: _ListViewMode = _ListViewMode(2i32);
pub const ListMode_Detail: _ListViewMode = _ListViewMode(3i32);
pub const ListMode_Filtered: _ListViewMode = _ListViewMode(4i32);
impl ::core::convert::From<i32> for _ListViewMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for _ListViewMode {
type Abi = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct _ViewOptions(pub i32);
pub const ViewOption_Default: _ViewOptions = _ViewOptions(0i32);
pub const ViewOption_ScopeTreeHidden: _ViewOptions = _ViewOptions(1i32);
pub const ViewOption_NoToolBars: _ViewOptions = _ViewOptions(2i32);
pub const ViewOption_NotPersistable: _ViewOptions = _ViewOptions(4i32);
pub const ViewOption_ActionPaneHidden: _ViewOptions = _ViewOptions(8i32);
impl ::core::convert::From<i32> for _ViewOptions {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for _ViewOptions {
type Abi = Self;
}
|
use glam::*;
use itertools::Itertools;
use std::collections::VecDeque;
pub type Point2 = Vec2;
type Vector2 = Vec2;
//Star class taken from table at
//https://de.wikipedia.org/wiki/Klassifizierung_der_Sterne
const CLASS_O: f32 = 60.0;
const CLASS_B: f32 = 18.0;
const CLASS_A: f32 = 3.2;
const CLASS_F: f32 = 1.7;
const CLASS_G: f32 = 1.1;
const CLASS_K: f32 = 0.8;
const CLASS_M: f32 = 0.3;
const G: f32 = 1_000.0;
const SUN_MAX_STARTING_VELOCITY: f32 = 100.0;
const SUN_MIN_MASS: f32 = CLASS_M;
const SUN_MAX_MASS: f32 = CLASS_O;
const SUN_DENSITY: f32 = 0.002; // higher density -> smaller radius
const TRACE_LEN: usize = 600; // number of points to be drawn as the body's path.
#[derive(Debug, Clone, Copy)]
enum ActorType {
Sun,
}
#[derive(Debug, Clone)]
pub struct Actor {
tag: ActorType,
id: u32,
pub pos: Point2,
pub trace: VecDeque<Point2>,
trace_cnt: u32,
pub radius: f32,
velocity: Vector2,
new_velocity: Vector2,
mass: f32,
pub color: u32,
}
fn color_from_mass(mass: f32) -> u32 {
if mass < CLASS_M {
0xfbc8_86ff
} else if mass < CLASS_K {
0xffd8_70ff
} else if mass < CLASS_G {
0xfdf9_b3ff
} else if mass < CLASS_F {
0xf9fa_e7ff
} else if mass < CLASS_A {
0xdadd_e6ff
} else if mass < CLASS_B {
0xaabf_ffff
} else if mass < CLASS_O {
0x9bb0_ffff
} else {
0xffff_ffff
}
}
fn vec_from_angle(angle: f32) -> Vector2 {
let x = angle.sin();
let y = angle.cos();
Vector2::new(x, y)
}
fn vec_from_points(from: Point2, to: Point2) -> Vector2 {
to - from
}
fn random_vec(max_magnitude: f32) -> Vector2 {
let angle = rand::random::<f32>() * 2.0 * std::f32::consts::PI;
let mag = rand::random::<f32>() * max_magnitude;
vec_from_angle(angle) * (mag)
}
fn total_momentum(bodys: &[Actor]) -> Vector2 {
//bodys.iter().map(|b| b.velocity * b.mass).sum()
let mut sum = Vector2::ZERO;
for b in bodys.iter() {
sum += b.velocity * b.mass;
}
sum
}
fn total_mass(bodys: &[Actor]) -> f32 {
bodys.iter().map(|b| b.mass).sum()
}
pub fn create_suns(num: u32, galaxy_radius: f32) -> Vec<Actor> {
let new_sun = |_| {
let m = SUN_MIN_MASS + rand::random::<f32>().powf(10.0) * (SUN_MAX_MASS - SUN_MIN_MASS);
Actor {
tag: ActorType::Sun,
id: rand::random::<u32>(),
pos: Point2::ZERO + random_vec(galaxy_radius),
trace: VecDeque::with_capacity(TRACE_LEN),
trace_cnt: 0,
velocity: random_vec(SUN_MAX_STARTING_VELOCITY),
new_velocity: Vector2::new(0.0, 0.0),
mass: m,
radius: (m / SUN_DENSITY * 0.75 / std::f32::consts::PI).cbrt(),
color: color_from_mass(m),
}
};
let mut suns: Vec<Actor> = (0..num).map(new_sun).collect();
//Adjust every suns velocity to keep the center of mass in the origin.
let total_velocity = total_momentum(&suns) / total_mass(&suns);
for s in &mut suns {
s.velocity -= total_velocity;
}
suns
}
fn elastic_collision(a1: &Actor, a2: &Actor) -> (Vector2, Vector2) {
fn v_afterwards(this: &Actor, that: &Actor) -> Vector2 {
this.velocity
- 2.0 * that.mass / (this.mass + that.mass)
* (this.velocity - that.velocity).dot(this.pos - that.pos)
/ (this.pos.distance_squared(that.pos))
* (this.pos - that.pos)
}
(v_afterwards(a1, a2), v_afterwards(a2, a1))
}
pub fn update_vel_and_pos(actors: &mut Vec<Actor>, dt: f32) {
for (a, b) in (0..actors.len()).tuple_combinations() {
let r_unit_vec = vec_from_points(actors[a].pos, actors[b].pos).normalize();
let dist_squ = actors[a].pos.distance_squared(actors[b].pos);
// check for collision
let touching_dist_squ = (actors[a].radius + actors[b].radius).powf(2.0);
if dist_squ < touching_dist_squ {
let (va, vb) = elastic_collision(&actors[a], &actors[b]);
actors[a].new_velocity = va;
actors[b].new_velocity = vb;
} else {
//apply gravity force fg
let fg = r_unit_vec * (G * actors[a].mass * actors[b].mass / dist_squ);
let delta_vg_a = fg / actors[a].mass;
let delta_vg_b = -fg / actors[b].mass;
actors[a].new_velocity += delta_vg_a;
actors[b].new_velocity += delta_vg_b;
}
}
//calculate new position for every actor
for a in actors.iter_mut() {
a.velocity = a.new_velocity;
a.pos += a.velocity * dt;
a.trace_cnt += 1;
if a.trace_cnt == 10 {
a.trace_cnt = 0;
a.trace.push_front(a.pos);
if a.trace.len() >= TRACE_LEN {
a.trace.pop_back();
}
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use assert_approx_eq::assert_approx_eq;
#[test]
fn test_collision_central_one_moving() {
let mut a = Actor {
tag: ActorType::Sun,
id: 1,
pos: Point2::new(0.0, 0.0),
trace: VecDeque::new(),
trace_cnt: 0,
radius: 100.0,
velocity: Vector2::new(10.0, 0.0),
new_velocity: Vector2::new(0.0, 0.0),
mass: 10.0,
color: 0x0000_0000,
};
let mut b = Actor {
tag: ActorType::Sun,
id: 2,
pos: Point2::new(200.0, 0.0),
trace: VecDeque::new(),
trace_cnt: 0,
radius: 100.0,
velocity: Vector2::new(0.0, 0.0),
new_velocity: Vector2::new(0.0, 0.0),
mass: 10.0,
color: 0x0000_0000,
};
let (v1, v2) = elastic_collision(&mut a, &mut b);
//test if both velocities have swaped.
assert_approx_eq!(v1.x, 0.0);
assert_approx_eq!(v2.x, 10.0);
}
#[test]
fn test_collision_central_both_moving() {
let mut a = Actor {
tag: ActorType::Sun,
id: 1,
pos: Point2::new(0.0, 0.0),
trace: VecDeque::new(),
trace_cnt: 0,
radius: 100.0,
velocity: Vector2::new(10.0, 0.0),
new_velocity: Vector2::new(0.0, 0.0),
mass: 10.0,
color: 0x0000_0000,
};
let mut b = Actor {
tag: ActorType::Sun,
id: 2,
pos: Point2::new(200.0, 0.0),
trace: VecDeque::new(),
trace_cnt: 0,
radius: 100.0,
velocity: Vector2::new(-10.0, 0.0),
new_velocity: Vector2::new(0.0, 0.0),
mass: 10.0,
color: 0x0000_0000,
};
let (v1, v2) = elastic_collision(&mut a, &mut b);
//test if both velocities have swaped.
assert_approx_eq!(v1.x, -10.0);
assert_approx_eq!(v2.x, 10.0);
}
}
|
use crate::measure;
use std::collections::VecDeque;
use std::io::BufRead;
pub fn run(input: impl BufRead) {
let monkeys = read_monkeys(input);
measure::duration(|| {
let mut monkeys = monkeys.clone();
println!("* Part 1: {}", play_keep_away(&mut monkeys, 20, |w| w / 3));
});
measure::duration(|| {
let mut monkeys = monkeys.clone();
let lcm: u128 = monkeys.iter().map(|m| &m.test).map(|t| t.divisor).product();
println!(
"* Part 2: {}",
play_keep_away(&mut monkeys, 10000, |w| w % lcm)
);
});
}
fn play_keep_away<W>(monkeys: &mut Vec<Monkey>, rounds: usize, worryfn: W) -> usize
where
W: Fn(u128) -> u128,
{
for _ in 0..rounds {
take_turns(monkeys, &worryfn);
}
let mut inspections: Vec<usize> = monkeys.iter().map(|m| m.inspections).collect();
inspections.sort();
inspections.iter().rev().take(2).product()
}
fn take_turns<W>(monkeys: &mut Vec<Monkey>, worryfn: W)
where
W: Fn(u128) -> u128,
{
for m in 0..monkeys.len() {
while let Some((item, catcher)) = monkeys[m].throw(&worryfn) {
monkeys[catcher].catch(item);
}
}
}
#[derive(Clone, Debug, PartialEq)]
struct Item(u128);
impl From<&str> for Item {
fn from(s: &str) -> Item {
Item(s.parse().expect("expected number for worry level"))
}
}
#[derive(Clone, Debug, PartialEq)]
enum Operation {
Multiply(u128),
Add(u128),
Square,
}
impl Operation {
fn perform(&self, old: u128) -> u128 {
match self {
Operation::Multiply(n) => old * n,
Operation::Add(n) => old + n,
Operation::Square => old * old,
}
}
}
impl From<&str> for Operation {
fn from(s: &str) -> Operation {
let mut parts = s.split_whitespace().skip(3);
let operator = parts.next().expect("expected operator");
let operand = parts.next().expect("expected operand");
match operator {
"+" => Operation::Add(operand.parse().expect("expected number for add")),
"*" if operand == "old" => Operation::Square,
"*" => Operation::Multiply(operand.parse().expect("expected number for multiply")),
_ => panic!("unknown operation: {}", s),
}
}
}
#[derive(Clone, Debug)]
struct Test {
divisor: u128,
if_true: usize,
if_false: usize,
}
impl Test {
fn read(lines: &mut impl Iterator<Item = String>) -> Test {
let divisor = lines
.next()
.expect("expected test line")
.split_whitespace()
.last()
.expect("expected divisor")
.parse()
.expect("expected divisor");
let if_true = lines
.next()
.expect("expected if true line")
.split_whitespace()
.last()
.expect("expected if true")
.parse()
.expect("expected monkey number");
let if_false = lines
.next()
.expect("expected if false line")
.split_whitespace()
.last()
.expect("expected if false")
.parse()
.expect("expected monkey number");
Test {
divisor,
if_true,
if_false,
}
}
fn perform(&self, worry: u128) -> usize {
if worry % self.divisor == 0 {
self.if_true
} else {
self.if_false
}
}
}
#[derive(Clone, Debug)]
struct Monkey {
items: VecDeque<Item>,
operation: Operation,
test: Test,
inspections: usize,
}
impl Monkey {
fn read(lines: &mut impl Iterator<Item = String>) -> Option<Monkey> {
// first line is the monkey number
if lines.next().is_none() {
return None;
}
let items = lines
.next()
.expect("expected starting items line")
.split(": ")
.nth(1)
.expect("expected starting items")
.split(", ")
.map(|s| s.into())
.collect();
let operation = lines
.next()
.expect("expected operation line")
.split(": ")
.nth(1)
.expect("expected operation")
.into();
let test = Test::read(lines);
// ignore blank line
lines.next();
Some(Monkey {
items,
operation,
test,
inspections: 0,
})
}
fn throw<W>(&mut self, worryfn: W) -> Option<(Item, usize)>
where
W: Fn(u128) -> u128,
{
self.items.pop_front().and_then(|Item(worry)| {
self.inspections += 1;
let worry = self.operation.perform(worry);
let worry = worryfn(worry);
let catcher = self.test.perform(worry);
Some((Item(worry), catcher))
})
}
fn catch(&mut self, item: Item) {
self.items.push_back(item)
}
}
fn read_monkeys(input: impl BufRead) -> Vec<Monkey> {
let mut monkeys = vec![];
let mut lines = input.lines().map(|l| l.expect("expected line"));
while let Some(monkey) = Monkey::read(&mut lines) {
monkeys.push(monkey);
}
return monkeys;
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &[u8] = b"Monkey 0:
Starting items: 79, 98
Operation: new = old * 19
Test: divisible by 23
If true: throw to monkey 2
If false: throw to monkey 3
Monkey 1:
Starting items: 54, 65, 75, 74
Operation: new = old + 6
Test: divisible by 19
If true: throw to monkey 2
If false: throw to monkey 0
Monkey 2:
Starting items: 79, 60, 97
Operation: new = old * old
Test: divisible by 13
If true: throw to monkey 1
If false: throw to monkey 3
Monkey 3:
Starting items: 74
Operation: new = old + 3
Test: divisible by 17
If true: throw to monkey 0
If false: throw to monkey 1
";
#[test]
fn test_item_from() {
assert_eq!(Item::from("79"), Item(79));
assert_eq!(Item::from("98"), Item(98));
}
#[test]
fn test_operation_from() {
assert_eq!(Operation::from("new = old * 19"), Operation::Multiply(19));
assert_eq!(Operation::from("new = old + 6"), Operation::Add(6));
assert_eq!(Operation::from("new = old * old"), Operation::Square);
}
#[test]
fn test_test_read() {
let lines = vec![
" Test: divisible by 23".to_string(),
" If true: throw to monkey 2".to_string(),
" If false: throw to monkey 3".to_string(),
];
let mut lines = lines.into_iter();
let test = Test::read(&mut lines);
assert_eq!(test.divisor, 23);
assert_eq!(test.if_true, 2);
assert_eq!(test.if_false, 3);
}
#[test]
fn test_read_monkeys() {
let monkeys = read_monkeys(INPUT);
assert_eq!(monkeys.len(), 4);
assert_eq!(monkeys[0].items, vec![Item(79), Item(98)]);
assert_eq!(monkeys[0].operation, Operation::Multiply(19));
assert_eq!(monkeys[0].test.divisor, 23);
assert_eq!(monkeys[0].test.if_true, 2);
assert_eq!(monkeys[0].test.if_false, 3);
assert_eq!(monkeys[0].inspections, 0);
assert_eq!(
monkeys[1].items,
vec![Item(54), Item(65), Item(75), Item(74)]
);
assert_eq!(monkeys[1].operation, Operation::Add(6));
assert_eq!(monkeys[1].test.divisor, 19);
assert_eq!(monkeys[1].test.if_true, 2);
assert_eq!(monkeys[1].test.if_false, 0);
assert_eq!(monkeys[1].inspections, 0);
assert_eq!(monkeys[2].items, vec![Item(79), Item(60), Item(97)]);
assert_eq!(monkeys[2].operation, Operation::Square);
assert_eq!(monkeys[2].test.divisor, 13);
assert_eq!(monkeys[2].test.if_true, 1);
assert_eq!(monkeys[2].test.if_false, 3);
assert_eq!(monkeys[2].inspections, 0);
assert_eq!(monkeys[3].items, vec![Item(74)]);
assert_eq!(monkeys[3].operation, Operation::Add(3));
assert_eq!(monkeys[3].test.divisor, 17);
assert_eq!(monkeys[3].test.if_true, 0);
assert_eq!(monkeys[3].test.if_false, 1);
assert_eq!(monkeys[3].inspections, 0);
}
#[test]
fn test_operation_perform() {
assert_eq!(Operation::Multiply(19).perform(79), 1501);
assert_eq!(Operation::Add(6).perform(54), 60);
assert_eq!(Operation::Square.perform(79), 6241);
}
#[test]
fn test_test_target() {
let test = Test {
divisor: 13,
if_true: 1,
if_false: 3,
};
assert_eq!(test.perform(2080), 1);
assert_eq!(test.perform(1200), 3);
}
#[test]
fn test_monkey_throw() {
let mut monkey = Monkey {
items: vec![Item(79), Item(60)].into(),
operation: Operation::Square,
test: Test {
divisor: 13,
if_true: 1,
if_false: 3,
},
inspections: 0,
};
let worryfn = |w| w / 3;
assert_eq!(
monkey.throw(worryfn).expect("expected throw"),
(Item(2080), 1)
);
assert_eq!(
monkey.throw(worryfn).expect("expected throw"),
(Item(1200), 3)
);
assert!(monkey.throw(worryfn).is_none());
assert_eq!(monkey.inspections, 2);
}
#[test]
fn test_monkey_catch() {
let mut monkey = Monkey {
items: VecDeque::new(),
operation: Operation::Add(6),
test: Test {
divisor: 19,
if_true: 2,
if_false: 0,
},
inspections: 0,
};
monkey.catch(Item(2080));
assert_eq!(monkey.items, vec![Item(2080)]);
}
#[test]
fn test_take_turns() {
let mut monkeys = read_monkeys(INPUT);
take_turns(&mut monkeys, |w| w / 3);
assert_eq!(
monkeys[0].items,
vec![Item(20), Item(23), Item(27), Item(26)]
);
assert_eq!(
monkeys[1].items,
vec![
Item(2080),
Item(25),
Item(167),
Item(207),
Item(401),
Item(1046)
]
);
assert_eq!(monkeys[2].items, vec![]);
assert_eq!(monkeys[3].items, vec![]);
}
#[test]
fn test_play_keep_away() {
let mut monkeys = read_monkeys(INPUT);
let monkey_business = play_keep_away(&mut monkeys, 20, |w| w / 3);
assert_eq!(
monkeys[0].items,
vec![Item(10), Item(12), Item(14), Item(26), Item(34)]
);
assert_eq!(monkeys[0].inspections, 101);
assert_eq!(
monkeys[1].items,
vec![Item(245), Item(93), Item(53), Item(199), Item(115)]
);
assert_eq!(monkeys[1].inspections, 95);
assert_eq!(monkeys[2].items, vec![]);
assert_eq!(monkeys[2].inspections, 7);
assert_eq!(monkeys[3].items, vec![]);
assert_eq!(monkeys[3].inspections, 105);
assert_eq!(monkey_business, 10_605);
}
#[test]
fn test_long_play_keep_away() {
let mut monkeys = read_monkeys(INPUT);
let lcm: u128 = monkeys.iter().map(|m| &m.test).map(|t| t.divisor).product();
let monkey_business = play_keep_away(&mut monkeys, 10_000, |w| w % lcm);
assert_eq!(monkey_business, 2_713_310_158);
}
}
|
// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
//
use std::collections::{HashMap, HashSet};
use serde_derive::{Deserialize, Serialize};
use gltf::json::mesh::Primitive;
use super::KHR_MATERIALS_VARIANTS;
use crate::{Result, Tag};
#[derive(Clone, Debug, Default, Deserialize, Serialize)]
pub struct FBMaterialVariantPrimitiveExtension {
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub mappings: Vec<FBMaterialVariantPrimitiveEntry>,
}
#[derive(Clone, PartialEq, Eq, PartialOrd, Ord, Debug, Default, Deserialize, Serialize)]
pub struct FBMaterialVariantPrimitiveEntry {
#[serde(default)]
pub material: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub variants: Vec<u32>,
}
/// Write the `tag_to_ix` mapping to the `Primitive' in `KHR_materials_variants` form.
///
/// This method guarantees a deterministic ordering of the output.
///
/// Please see [the `KHR_materials_variants`
/// spec](https://github.com/zellski/glTF/blob/ext/zell-fb-asset-variants/extensions/2.0/Khronos/KHR_materials_variants/README.md)
/// for further details.
pub fn write_variant_map(primitive: &mut Primitive, tag_to_ix: &HashMap<Tag, usize>, variant_ix_lookup: &HashMap<usize, Tag>) -> Result<()> {
if tag_to_ix.is_empty() {
if let Some(extensions) = &mut primitive.extensions {
extensions.others.remove(KHR_MATERIALS_VARIANTS);
}
return Ok(());
}
// invert the mapping tag->ix to a ix->set-of-tags one
let mut ix_to_tags = HashMap::new();
for (tag, &ix) in tag_to_ix {
ix_to_tags
.entry(ix)
.or_insert(HashSet::new())
.insert(tag.to_owned());
}
let mut mapping_entries: Vec<FBMaterialVariantPrimitiveEntry> = ix_to_tags
.iter()
.map(|(&ix, tags)| {
let mut tag_vec: Vec<Tag> = tags.iter().cloned().collect();
// order tags deterministically
tag_vec.sort_unstable();
let mut variants: Vec<u32> = tag_vec
.iter()
.map(|tag| {
let (&variant_ix, _) = variant_ix_lookup.iter().find(|(_k, v)| v == &tag).unwrap();
variant_ix as u32
})
.collect();
variants.sort_unstable();
FBMaterialVariantPrimitiveEntry {
material: ix as u32,
variants,
}
})
.collect();
// order entries deterministically
mapping_entries.sort_unstable();
// build structured extension data
let new_extension = FBMaterialVariantPrimitiveExtension {
mappings: mapping_entries,
};
// serialise to JSON string
let value = serde_json::to_string(&new_extension)
.and_then(|s| serde_json::from_str(&s))
.map_err(|e| {
format!(
"Failed to transform primitive extension {:#?}, with error: {}",
new_extension, e,
)
})?;
// and done
primitive
.extensions
.get_or_insert(Default::default())
.others
.insert(KHR_MATERIALS_VARIANTS.to_owned(), value);
Ok(())
}
/// Parses and returns the `KHR_materials_variants` data on a primitive, if any.
///
/// Please see [the `KHR_materials_variants`
/// spec](https://github.com/zellski/glTF/blob/ext/zell-fb-asset-variants/extensions/2.0/Khronos/KHR_materials_variants/README.md)
/// for further details
pub fn extract_variant_map(primitive: &Primitive, variant_ix_lookup: &HashMap<usize, Tag>) -> Result<HashMap<Tag, usize>> {
if let Some(extensions) = &primitive.extensions {
if let Some(boxed) = extensions.others.get(KHR_MATERIALS_VARIANTS) {
let json_string = &boxed.to_string();
let parse: serde_json::Result<FBMaterialVariantPrimitiveExtension> =
serde_json::from_str(json_string);
return match parse {
Ok(parse) => {
let mut result = HashMap::new();
for entry in parse.mappings {
for variant_ix in entry.variants {
let key = variant_ix as usize;
let variant_tag = &variant_ix_lookup[&key];
result.insert(variant_tag.to_owned(), entry.material as usize);
}
}
Ok(result)
}
Err(e) => Err(format!(
"Bad JSON in KHR_materials_variants extension: {}; json = {}",
e.to_string(),
json_string,
)),
};
}
}
Ok(HashMap::new())
}
|
/// Biz logic for the RealWorld backend API
///
/// See the [RealWorld API Spec](https://github.com/gothinkster/realworld/tree/master/api) for
/// more information on the API
pub mod api;
/// Database models and connectors
pub mod db;
|
use e2d2::headers::*;
use e2d2::operators::*;
use e2d2::scheduler::*;
use e2d2::utils::*;
use fnv::FnvHasher;
use std::collections::HashMap;
use std::convert::From;
use std::hash::BuildHasherDefault;
use std::net::Ipv4Addr;
#[derive(Clone, Default)]
struct Unit;
#[derive(Clone, Copy, Default)]
struct FlowUsed {
pub flow: Flow,
pub time: u64,
pub used: bool,
}
type FnvHash = BuildHasherDefault<FnvHasher>;
pub fn nat<T: 'static + Batch<Header = NullHeader>>(
parent: T,
_s: &mut Scheduler,
nat_ip: &Ipv4Addr,
) -> CompositionBatch {
let ip = u32::from(*nat_ip);
let mut port_hash = HashMap::<Flow, Flow, FnvHash>::with_capacity_and_hasher(65536, Default::default());
let mut flow_vec: Vec<FlowUsed> = (MIN_PORT..65535).map(|_| Default::default()).collect();
let mut next_port = 1024;
const MIN_PORT: u16 = 1024;
const MAX_PORT: u16 = 65535;
let pipeline = parent.parse::<MacHeader>().transform(box move |pkt| {
let hdr = pkt.get_mut_header();
hdr.swap_addresses();
let payload = pkt.get_mut_payload();
if let Some(flow) = ipv4_extract_flow(payload) {
let found = match port_hash.get(&flow) {
Some(s) => {
s.ipv4_stamp_flow(payload);
true
}
None => false,
};
if !found {
if next_port < MAX_PORT {
let assigned_port = next_port; //FIXME.
next_port += 1;
flow_vec[assigned_port as usize].flow = flow;
flow_vec[assigned_port as usize].used = true;
let mut outgoing_flow = flow.clone();
outgoing_flow.src_ip = ip;
outgoing_flow.src_port = assigned_port;
let rev_flow = outgoing_flow.reverse_flow();
port_hash.insert(flow, outgoing_flow);
port_hash.insert(rev_flow, flow.reverse_flow());
outgoing_flow.ipv4_stamp_flow(payload);
}
}
}
});
pipeline.compose()
}
|
use std::collections::BTreeMap;
use std::cell::RefCell;
use std::rc::Rc;
use scheme::value::Sexp;
type Env = BTreeMap<String, Rc<RefCell<Sexp>>>;
#[derive(Debug, Clone, PartialEq)]
pub struct Environment {
env: Rc<RefCell<Env>>,
up: Option<Rc<Environment>>,
}
impl Environment {
pub fn new(up: Option<Rc<Environment>>) -> Self {
Environment {
env: Rc::new(RefCell::new(Env::new())),
up,
}
}
pub fn is_global(&self) -> bool {
self.up.is_none()
}
pub fn lookup(&self, name: &str) -> Option<Rc<RefCell<Sexp>>> {
if let Some(val) = self.env.borrow().get(name) {
return Some(val.clone());
}
let mut current = self.up.clone();
while let Some(ctx) = current {
if let Some(val) = ctx.env.borrow().get(name) {
return Some(val.clone());
}
current = ctx.up.clone();
}
None
}
pub fn insert(&mut self, name: &str, expr: &Sexp) {
let val = Rc::new(RefCell::new(expr.clone()));
self.env.borrow_mut().insert(name.to_owned(), val);
}
pub fn insert_many(&mut self, keys: &[String], values: &[Sexp]) {
for (k, v) in keys.iter().zip(values) {
let val = Rc::new(RefCell::new(v.clone()));
self.env.borrow_mut().insert(k.to_string(), val);
}
}
pub fn assign(&mut self, name: &str, val: &Sexp) -> bool {
if let Some(var) = self.lookup(name) {
*var.borrow_mut() = val.clone();
true
} else {
false
}
}
}
|
fn double(x: i32) -> i32 {
x * 2
}
fn main() {
let a = 6;
let _a = double(a);
println!("{}, {}", a, _a);
}
|
use core::ops::{Add, AddAssign, Neg, Sub};
pub mod axis_order;
pub mod measurement;
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct Position {
pub x: i32,
pub y: i32,
}
impl Add<Position> for Position {
type Output = Position;
fn add(self, rhs: Position) -> Self::Output {
Position {
x: self.x + rhs.x,
y: self.y + rhs.y,
}
}
}
impl AddAssign<Position> for Position {
fn add_assign(&mut self, rhs: Position) {
*self = *self + rhs;
}
}
impl Sub<Position> for Position {
type Output = PositionDelta;
fn sub(self, rhs: Position) -> Self::Output {
PositionDelta {
x: self.x - rhs.x,
y: self.y - rhs.y,
}
}
}
impl Sub<PositionDelta> for Position {
type Output = Position;
fn sub(self, rhs: PositionDelta) -> Self::Output {
Position {
x: self.x - rhs.x,
y: self.y - rhs.y,
}
}
}
#[derive(Clone, Copy, Debug)]
pub struct PositionDelta {
pub x: i32,
pub y: i32,
}
impl Add<PositionDelta> for Position {
type Output = Position;
fn add(self, rhs: PositionDelta) -> Self::Output {
Position {
x: self.x + rhs.x,
y: self.y + rhs.y,
}
}
}
impl AddAssign<PositionDelta> for Position {
fn add_assign(&mut self, rhs: PositionDelta) {
*self = *self + rhs;
}
}
impl Neg for PositionDelta {
type Output = PositionDelta;
fn neg(self) -> Self::Output {
PositionDelta {
x: -self.x,
y: -self.y,
}
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct MeasuredSize {
pub width: u32,
pub height: u32,
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub struct BoundingBox {
pub position: Position,
pub size: MeasuredSize,
}
impl BoundingBox {
pub fn contains(&self, position: Position) -> bool {
position.x >= self.position.x
&& position.y >= self.position.y
&& position.x <= self.position.x + self.size.width as i32
&& position.y <= self.position.y + self.size.height as i32
}
pub fn translate(self, by: PositionDelta) -> BoundingBox {
BoundingBox {
position: self.position + by,
size: self.size,
}
}
}
impl Default for BoundingBox {
fn default() -> Self {
Self {
position: Position { x: 0, y: 0 },
size: MeasuredSize {
width: 0,
height: 0,
},
}
}
}
|
use std::str::FromStr;
use uuid::Uuid;
use crate::decode::Decode;
use crate::encode::Encode;
use crate::postgres::protocol::TypeId;
use crate::postgres::value::{PgData, PgValue};
use crate::postgres::{PgRawBuffer, PgTypeInfo, Postgres};
use crate::types::Type;
impl Type<Postgres> for Uuid {
fn type_info() -> PgTypeInfo {
PgTypeInfo::new(TypeId::UUID, "UUID")
}
}
impl Type<Postgres> for [Uuid] {
fn type_info() -> PgTypeInfo {
PgTypeInfo::new(TypeId::ARRAY_UUID, "UUID[]")
}
}
impl Type<Postgres> for Vec<Uuid> {
fn type_info() -> PgTypeInfo {
<[Uuid] as Type<Postgres>>::type_info()
}
}
impl Encode<Postgres> for Uuid {
fn encode(&self, buf: &mut PgRawBuffer) {
buf.extend_from_slice(self.as_bytes());
}
}
impl<'de> Decode<'de, Postgres> for Uuid {
fn decode(value: PgValue<'de>) -> crate::Result<Self> {
match value.try_get()? {
PgData::Binary(buf) => Uuid::from_slice(buf).map_err(crate::Error::decode),
PgData::Text(s) => Uuid::from_str(s).map_err(crate::Error::decode),
}
}
}
|
use geometry::Point;
use geometry::{Collide};
use geometry::Position;
pub struct Mouse {
pub point: Point,
}
impl Mouse{
/// Create a enemy with the given vector
pub fn new(x: f64, y: f64) -> Mouse {
Mouse {
point: Point::new(x, y)
}
}
}
impl Collide for Mouse {
fn radius(&self) -> f64 { 10.0 }
}
impl Position for Mouse {
fn x(&self) -> f64 {
self.point.x
}
fn x_mut(&mut self) -> &'_ mut f64 {
&mut self.point.x
}
fn y(&self) -> f64 {
self.point.y
}
fn y_mut(&mut self) -> &'_ mut f64 {
&mut self.point.y
}
fn position(&self) -> Point {
self.point
}
} |
pub(crate) mod systems;
mod entity;
mod plugin;
pub use entity::*;
pub use plugin::*;
game_lib::fix_bevy_derive!(game_lib::bevy);
|
#[macro_use]
extern crate failure;
use failure::Fail;
fn return_failure() -> Result<(), failure::Error> {
#[derive(Fail, Debug)]
#[fail(display = "my error")]
struct MyError;
let err = MyError;
Err(err.into())
}
fn return_error() -> Result<(), Box<std::error::Error>> {
return_failure()?;
Ok(())
}
fn return_error_send_sync() -> Result<(), Box<std::error::Error + Send + Sync>> {
return_failure()?;
Ok(())
}
#[test]
fn smoke_default_compat() {
let err = return_error();
assert!(err.is_err());
}
#[test]
fn smoke_compat_send_sync() {
let err = return_error_send_sync();
assert!(err.is_err());
}
|
/*!
This module is concerned with how `cargo-eval` extracts the manfiest from a script file.
*/
use std::collections::HashMap;
use std::path::Path;
use pulldown_cmark::{CodeBlockKind, Event, Options, Parser, Tag};
use regex::Regex;
use crate::error::{Blame, Result};
use crate::templates;
use crate::Input;
lazy_static! {
static ref RE_SHORT_MANIFEST: Regex =
Regex::new(r"^(?i)\s*//\s*cargo-deps\s*:(.*?)(\r\n|\n)").unwrap();
static ref RE_MARGIN: Regex = Regex::new(r"^\s*\*( |$)").unwrap();
static ref RE_SPACE: Regex = Regex::new(r"^(\s+)").unwrap();
static ref RE_NESTING: Regex = Regex::new(r"/\*|\*/").unwrap();
static ref RE_COMMENT: Regex = Regex::new(r"^\s*//!").unwrap();
static ref RE_HASHBANG: Regex = Regex::new(r"^#![^\[].*?(\r\n|\n)").unwrap();
static ref RE_CRATE_COMMENT: Regex = {
Regex::new(
r"(?x)
# We need to find the first `/*!` or `//!` that *isn't* preceeded by something that would make it apply to anything other than the crate itself. Because we can't do this accurately, we'll just require that the doc comment is the *first* thing in the file (after the optional hashbang, which should already have been stripped).
^\s*
(/\*!|//!)
"
).unwrap()
};
}
/**
Splits input into a complete Cargo manifest and unadultered Rust source.
Unless we have prelude items to inject, in which case it will be *slightly* adulterated.
*/
pub fn split_input(
input: &Input,
deps: &[(String, String)],
prelude_items: &[String],
) -> Result<(String, String)> {
let template_buf;
let (part_mani, source, template, sub_prelude) = match *input {
Input::File(_, _, content, _) => {
assert_eq!(prelude_items.len(), 0);
let content = strip_hashbang(content).trim_end();
let (manifest, source) =
find_embedded_manifest(content).unwrap_or((Manifest::Toml(""), content));
(manifest, source, templates::get_template("file")?, false)
}
Input::Expr("meaning-of-life", None) | Input::Expr("meaning_of_life", None) => (
Manifest::Toml(""),
r#"
println!("42");
std::process::exit(42);
"#,
templates::get_template("expr")?,
true,
),
Input::Expr(content, template) => {
template_buf = templates::get_template(template.unwrap_or("expr"))?;
let (manifest, template_src) = find_embedded_manifest(&template_buf)
.unwrap_or((Manifest::Toml(""), &template_buf));
(manifest, content, template_src.into(), true)
}
Input::Loop(content, count) => {
let templ = if count { "loop-count" } else { "loop" };
(
Manifest::Toml(""),
content,
templates::get_template(templ)?,
true,
)
}
};
let mut prelude_str;
let mut subs = HashMap::with_capacity(2);
subs.insert("script", &source[..]);
if sub_prelude {
prelude_str =
String::with_capacity(prelude_items.iter().map(|i| i.len() + 1).sum::<usize>());
for i in prelude_items {
prelude_str.push_str(i);
prelude_str.push_str("\n");
}
subs.insert("prelude", &prelude_str[..]);
}
let source = templates::expand(&template, &subs)?;
info!("part_mani: {:?}", part_mani);
info!("source: {:?}", source);
let part_mani = part_mani.into_toml()?;
info!("part_mani: {:?}", part_mani);
// It's-a mergin' time!
let def_mani = default_manifest(input)?;
let dep_mani = deps_manifest(deps)?;
let mani = merge_manifest(def_mani, part_mani)?;
let mani = merge_manifest(mani, dep_mani)?;
// Fix up relative paths.
let mani = fix_manifest_paths(mani, &input.base_path())?;
info!("mani: {:?}", mani);
let mani_str = format!("{}", toml::Value::Table(mani));
info!("mani_str: {}", mani_str);
Ok((mani_str, source))
}
#[test]
fn test_split_input() {
macro_rules! si {
($i:expr) => {
split_input(&$i, &[], &[]).ok()
};
}
let dummy_path: ::std::path::PathBuf = "p".into();
let dummy_path = &dummy_path;
let f = |c| Input::File("n", &dummy_path, c, 0);
macro_rules! r {
($m:expr, $r:expr) => {
Some(($m.into(), $r.into()))
};
}
assert_eq!(
si!(f(r#"fn main() {}"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"fn main() {}"#
)
);
// Ensure removed prefix manifests don't work.
assert_eq!(
si!(f(r#"
---
fn main() {}
"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"
---
fn main() {}"#
)
);
assert_eq!(
si!(f(r#"[dependencies]
time="0.1.25"
---
fn main() {}
"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"[dependencies]
time="0.1.25"
---
fn main() {}"#
)
);
assert_eq!(
si!(f(r#"
// Cargo-Deps: time="0.1.25"
fn main() {}
"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
time = "0.1.25"
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"
// Cargo-Deps: time="0.1.25"
fn main() {}"#
)
);
assert_eq!(
si!(f(r#"
// Cargo-Deps: time="0.1.25", libc="0.2.5"
fn main() {}
"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
libc = "0.2.5"
time = "0.1.25"
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"
// Cargo-Deps: time="0.1.25", libc="0.2.5"
fn main() {}"#
)
);
assert_eq!(
si!(f(r#"
/*!
Here is a manifest:
```cargo
[dependencies]
time = "0.1.25"
```
*/
fn main() {}
"#)),
r!(
r#"[[bin]]
name = "n"
path = "n.rs"
[dependencies]
time = "0.1.25"
[package]
authors = []
edition = "2018"
name = "n"
version = "0.1.0"
"#,
r#"
/*!
Here is a manifest:
```cargo
[dependencies]
time = "0.1.25"
```
*/
fn main() {}"#
)
);
}
/**
Returns a slice of the input string with the leading hashbang, if there is one, omitted.
*/
fn strip_hashbang(s: &str) -> &str {
match RE_HASHBANG.find(s) {
Some(m) => &s[m.end()..],
None => s,
}
}
#[test]
fn test_strip_hashbang() {
assert_eq!(
strip_hashbang(
"\
#!/usr/bin/env cargo eval --
and the rest
\
"
),
"\
and the rest
\
"
);
assert_eq!(
strip_hashbang(
"\
#![thingy]
and the rest
\
"
),
"\
#![thingy]
and the rest
\
"
);
}
/**
Represents the kind, and content of, an embedded manifest.
*/
#[derive(Debug, Eq, PartialEq)]
enum Manifest<'s> {
/// The manifest is a valid TOML fragment.
Toml(&'s str),
/// The manifest is a valid TOML fragment (owned).
// TODO: Change to Cow<'s, str>.
TomlOwned(String),
/// The manifest is a comma-delimited list of dependencies.
DepList(&'s str),
}
impl<'s> Manifest<'s> {
pub fn into_toml(self) -> Result<toml::value::Table> {
use self::Manifest::*;
match self {
Toml(s) => Ok(toml::from_str(s).map_err(|_| "could not parse embedded manifest")?),
TomlOwned(ref s) => {
Ok(toml::from_str(&s).map_err(|_| "could not parse embedded manifest")?)
}
DepList(s) => Manifest::dep_list_to_toml(s),
}
}
fn dep_list_to_toml(s: &str) -> Result<toml::value::Table> {
let mut r = String::new();
r.push_str("[dependencies]\n");
for dep in s.trim().split(',') {
// If there's no version specified, add one.
if dep.contains('=') {
r.push_str(dep);
r.push_str("\n");
} else {
r.push_str(dep);
r.push_str("=\"*\"\n");
}
}
Ok(toml::from_str(&r).map_err(|_| "could not parse embedded manifest")?)
}
}
/**
Locates a manifest embedded in Rust source.
Returns `Some((manifest, source))` if it finds a manifest, `None` otherwise.
*/
fn find_embedded_manifest(s: &str) -> Option<(Manifest, &str)> {
find_short_comment_manifest(s).or_else(|| find_code_block_manifest(s))
}
#[test]
fn test_find_embedded_manifest() {
use self::Manifest::*;
let fem = find_embedded_manifest;
assert_eq!(fem("fn main() {}"), None);
assert_eq!(
fem("
fn main() {}
"),
None
);
// Ensure removed prefix manifests don't work.
assert_eq!(
fem(r#"
---
fn main() {}
"#),
None
);
assert_eq!(
fem("[dependencies]
time = \"0.1.25\"
---
fn main() {}
"),
None
);
assert_eq!(
fem("[dependencies]
time = \"0.1.25\"
fn main() {}
"),
None
);
// Make sure we aren't just grabbing the *last* line.
assert_eq!(
fem("[dependencies]
time = \"0.1.25\"
fn main() {
println!(\"Hi!\");
}
"),
None
);
assert_eq!(
fem("// cargo-deps: time=\"0.1.25\"
fn main() {}
"),
Some((
DepList(" time=\"0.1.25\""),
"// cargo-deps: time=\"0.1.25\"
fn main() {}
"
))
);
assert_eq!(
fem("// cargo-deps: time=\"0.1.25\", libc=\"0.2.5\"
fn main() {}
"),
Some((
DepList(" time=\"0.1.25\", libc=\"0.2.5\""),
"// cargo-deps: time=\"0.1.25\", libc=\"0.2.5\"
fn main() {}
"
))
);
assert_eq!(
fem("
// cargo-deps: time=\"0.1.25\" \n\
fn main() {}
"),
Some((
DepList(" time=\"0.1.25\" "),
"
// cargo-deps: time=\"0.1.25\" \n\
fn main() {}
"
))
);
assert_eq!(
fem("/* cargo-deps: time=\"0.1.25\" */
fn main() {}
"),
None
);
assert_eq!(
fem(r#"//! [dependencies]
//! time = "0.1.25"
fn main() {}
"#),
None
);
assert_eq!(
fem(r#"//! ```Cargo
//! [dependencies]
//! time = "0.1.25"
//! ```
fn main() {}
"#),
Some((
TomlOwned(
r#"[dependencies]
time = "0.1.25"
"#
.into()
),
r#"//! ```Cargo
//! [dependencies]
//! time = "0.1.25"
//! ```
fn main() {}
"#
))
);
assert_eq!(
fem(r#"/*!
[dependencies]
time = "0.1.25"
*/
fn main() {}
"#),
None
);
assert_eq!(
fem(r#"/*!
```Cargo
[dependencies]
time = "0.1.25"
```
*/
fn main() {}
"#),
Some((
TomlOwned(
r#"[dependencies]
time = "0.1.25"
"#
.into()
),
r#"/*!
```Cargo
[dependencies]
time = "0.1.25"
```
*/
fn main() {}
"#
))
);
assert_eq!(
fem(r#"/*!
* [dependencies]
* time = "0.1.25"
*/
fn main() {}
"#),
None
);
assert_eq!(
fem(r#"/*!
* ```Cargo
* [dependencies]
* time = "0.1.25"
* ```
*/
fn main() {}
"#),
Some((
TomlOwned(
r#"[dependencies]
time = "0.1.25"
"#
.into()
),
r#"/*!
* ```Cargo
* [dependencies]
* time = "0.1.25"
* ```
*/
fn main() {}
"#
))
);
}
/**
Locates a "short comment manifest" in Rust source.
*/
fn find_short_comment_manifest(s: &str) -> Option<(Manifest, &str)> {
/*
This is pretty simple: the only valid syntax for this is for the first, non-blank line to contain a single-line comment whose first token is `cargo-deps:`. That's it.
*/
let re = &*RE_SHORT_MANIFEST;
if let Some(cap) = re.captures(s) {
if let Some(m) = cap.get(1) {
return Some((Manifest::DepList(m.as_str()), &s[..]));
}
}
None
}
/**
Locates a "code block manifest" in Rust source.
*/
fn find_code_block_manifest(s: &str) -> Option<(Manifest, &str)> {
/*
This has to happen in a few steps.
First, we will look for and slice out a contiguous, inner doc comment which must be *the very first thing* in the file. `#[doc(...)]` attributes *are not supported*. Multiple single-line comments cannot have any blank lines between them.
Then, we need to strip off the actual comment markers from the content. Including indentation removal, and taking out the (optional) leading line markers for block comments. *sigh*
Then, we need to take the contents of this doc comment and feed it to a Markdown parser. We are looking for *the first* fenced code block with a language token of `cargo`. This is extracted and pasted back together into the manifest.
*/
let start = match RE_CRATE_COMMENT.captures(s) {
Some(cap) => match cap.get(1) {
Some(m) => m.start(),
None => return None,
},
None => return None,
};
let comment = match extract_comment(&s[start..]) {
Ok(s) => s,
Err(err) => {
error!("error slicing comment: {}", err);
return None;
}
};
scrape_markdown_manifest(&comment).map(|m| (Manifest::TomlOwned(m), s))
}
/**
Extracts the first `Cargo` fenced code block from a chunk of Markdown.
*/
fn scrape_markdown_manifest(content: &str) -> Option<String> {
// To match `librustdoc/html/markdown.rs` `opts`.
let exts = Options::ENABLE_TABLES | Options::ENABLE_FOOTNOTES;
let md = Parser::new_ext(&content, exts);
let mut it = md.skip_while(|e| {
if let Event::Start(Tag::CodeBlock(CodeBlockKind::Fenced(ref info))) = e {
info.to_lowercase() != "cargo"
} else {
true
}
});
it.next()?;
let s = it
.take_while(|e| {
if let Event::End(Tag::CodeBlock(_)) = e {
false
} else {
true
}
})
.filter_map(|e| {
if let Event::Text(text) = e {
Some(text.into_string())
} else {
None
}
})
.collect::<String>();
Some(s)
}
#[test]
fn test_scrape_markdown_manifest() {
macro_rules! smm {
($c:expr) => {
scrape_markdown_manifest($c)
};
}
assert_eq!(
smm!(
r#"There is no manifest in this comment.
"#
),
None
);
assert_eq!(
smm!(
r#"There is no manifest in this comment.
```
This is not a manifest.
```
```rust
println!("Nor is this.");
```
Or this.
"#
),
None
);
assert_eq!(
smm!(
r#"This is a manifest:
```cargo
dependencies = { time = "*" }
```
"#
),
Some(
r#"dependencies = { time = "*" }
"#
.into()
)
);
assert_eq!(
smm!(
r#"This is *not* a manifest:
```
He's lying, I'm *totally* a manifest!
```
This *is*:
```cargo
dependencies = { time = "*" }
```
"#
),
Some(
r#"dependencies = { time = "*" }
"#
.into()
)
);
assert_eq!(
smm!(
r#"This is a manifest:
```cargo
dependencies = { time = "*" }
```
So is this, but it doesn't count:
```cargo
dependencies = { explode = true }
```
"#
),
Some(
r#"dependencies = { time = "*" }
"#
.into()
)
);
}
/**
Extracts the contents of a Rust doc comment.
*/
fn extract_comment(s: &str) -> Result<String> {
use std::cmp::min;
fn n_leading_spaces(s: &str, n: usize) -> Result<()> {
if !s.chars().take(n).all(|c| c == ' ') {
return Err(format!("leading {:?} chars aren't all spaces: {:?}", n, s).into());
}
Ok(())
}
fn extract_block(s: &str) -> Result<String> {
/*
On every line:
- update nesting level and detect end-of-comment
- if margin is None:
- if there appears to be a margin, set margin.
- strip off margin marker
- update the leading space counter
- strip leading space
- append content
*/
let mut r = String::new();
let margin_re = &*RE_MARGIN;
let space_re = &*RE_SPACE;
let nesting_re = &*RE_NESTING;
let mut leading_space = None;
let mut margin = None;
let mut depth: u32 = 1;
for line in s.lines() {
if depth == 0 {
break;
}
// Update nesting and look for end-of-comment.
let mut end_of_comment = None;
for (end, marker) in nesting_re.find_iter(line).map(|m| (m.start(), m.as_str())) {
match (marker, depth) {
("/*", _) => depth += 1,
("*/", 1) => {
end_of_comment = Some(end);
depth = 0;
break;
}
("*/", _) => depth -= 1,
_ => panic!("got a comment marker other than /* or */"),
}
}
let line = end_of_comment.map(|end| &line[..end]).unwrap_or(line);
// Detect and strip margin.
margin = margin.or_else(|| margin_re.find(line).map(|m| m.as_str()));
let line = if let Some(margin) = margin {
let end = line
.char_indices()
.take(margin.len())
.map(|(i, c)| i + c.len_utf8())
.last()
.unwrap_or(0);
&line[end..]
} else {
line
};
// Detect and strip leading indentation.
leading_space = leading_space.or_else(|| space_re.find(line).map(|m| m.end()));
/*
Make sure we have only leading spaces.
If we see a tab, fall over. I *would* expand them, but that gets into the question of how *many* spaces to expand them to, and *where* is the tab, because tabs are tab stops and not just N spaces.
Eurgh.
*/
n_leading_spaces(line, leading_space.unwrap_or(0))?;
let strip_len = min(leading_space.unwrap_or(0), line.len());
let line = &line[strip_len..];
// Done.
r.push_str(line);
// `lines` removes newlines. Ideally, it wouldn't do that, but hopefully this shouldn't cause any *real* problems.
r.push_str("\n");
}
Ok(r)
}
fn extract_line(s: &str) -> Result<String> {
let mut r = String::new();
let comment_re = &*RE_COMMENT;
let space_re = &*RE_SPACE;
let mut leading_space = None;
for line in s.lines() {
// Strip leading comment marker.
let content = match comment_re.find(line) {
Some(m) => &line[m.end()..],
None => break,
};
// Detect and strip leading indentation.
leading_space = leading_space.or_else(|| {
space_re
.captures(content)
.and_then(|c| c.get(1))
.map(|m| m.end())
});
/*
Make sure we have only leading spaces.
If we see a tab, fall over. I *would* expand them, but that gets into the question of how *many* spaces to expand them to, and *where* is the tab, because tabs are tab stops and not just N spaces.
Eurgh.
*/
n_leading_spaces(content, leading_space.unwrap_or(0))?;
let strip_len = min(leading_space.unwrap_or(0), content.len());
let content = &content[strip_len..];
// Done.
r.push_str(content);
// `lines` removes newlines. Ideally, it wouldn't do that, but hopefully this shouldn't cause any *real* problems.
r.push_str("\n");
}
Ok(r)
}
if s.starts_with("/*!") {
extract_block(&s[3..])
} else if s.starts_with("//!") {
extract_line(s)
} else {
Err("no doc comment found".into())
}
}
#[test]
fn test_extract_comment() {
macro_rules! ec {
($s:expr) => {
extract_comment($s).map_err(|e| e.to_string())
};
}
assert_eq!(ec!(r#"fn main () {}"#), Err("no doc comment found".into()));
assert_eq!(
ec!(r#"/*!
Here is a manifest:
```cargo
[dependencies]
time = "*"
```
*/
fn main() {}
"#),
Ok(r#"
Here is a manifest:
```cargo
[dependencies]
time = "*"
```
"#
.into())
);
assert_eq!(
ec!(r#"/*!
* Here is a manifest:
*
* ```cargo
* [dependencies]
* time = "*"
* ```
*/
fn main() {}
"#),
Ok(r#"
Here is a manifest:
```cargo
[dependencies]
time = "*"
```
"#
.into())
);
assert_eq!(
ec!(r#"//! Here is a manifest:
//!
//! ```cargo
//! [dependencies]
//! time = "*"
//! ```
fn main() {}
"#),
Ok(r#"Here is a manifest:
```cargo
[dependencies]
time = "*"
```
"#
.into())
);
}
/**
Generates a default Cargo manifest for the given input.
*/
fn default_manifest(input: &Input) -> Result<toml::value::Table> {
let mani_str = {
let pkg_name = input.package_name();
let mut subs = HashMap::with_capacity(2);
subs.insert("name", &*pkg_name);
subs.insert("file", &input.safe_name()[..]);
templates::expand(
include_str!("templates/default_manifest.toml").trim_end(),
&subs,
)?
};
toml::from_str(&mani_str).map_err(|_| "could not parse default manifest, somehow".into())
}
/**
Generates a partial Cargo manifest containing the specified dependencies.
*/
fn deps_manifest(deps: &[(String, String)]) -> Result<toml::value::Table> {
let mut mani_str = String::new();
mani_str.push_str("[dependencies]\n");
for &(ref name, ref ver) in deps {
mani_str.push_str(name);
mani_str.push_str("=");
// We only want to quote the version if it *isn't* a table.
let quotes = if ver.starts_with('{') { "" } else { "\"" };
mani_str.push_str(quotes);
mani_str.push_str(ver);
mani_str.push_str(quotes);
mani_str.push_str("\n");
}
toml::from_str(&mani_str).map_err(|_| "could not parse dependency manifest".into())
}
/**
Given two Cargo manifests, merges the second *into* the first.
Note that the "merge" in this case is relatively simple: only *top-level* tables are actually merged; everything else is just outright replaced.
*/
fn merge_manifest(
mut into_t: toml::value::Table,
from_t: toml::value::Table,
) -> Result<toml::value::Table> {
for (k, v) in from_t {
match v {
toml::Value::Table(from_t) => {
use toml::map::Entry::*;
// Merge.
match into_t.entry(k) {
Vacant(e) => {
e.insert(toml::Value::Table(from_t));
}
Occupied(e) => {
let into_t = as_table_mut(e.into_mut()).ok_or((
Blame::Human,
"cannot merge manifests: cannot merge \
table and non-table values",
))?;
into_t.extend(from_t);
}
}
}
v => {
// Just replace.
into_t.insert(k, v);
}
}
}
return Ok(into_t);
fn as_table_mut(t: &mut toml::Value) -> Option<&mut toml::value::Table> {
match *t {
toml::Value::Table(ref mut t) => Some(t),
_ => None,
}
}
}
/**
Given a Cargo manifest, attempts to rewrite relative file paths to absolute ones, allowing the manifest to be relocated.
*/
fn fix_manifest_paths(mani: toml::value::Table, base: &Path) -> Result<toml::value::Table> {
// Values that need to be rewritten:
let paths: &[&[&str]] = &[
&["build-dependencies", "*", "path"],
&["dependencies", "*", "path"],
&["dev-dependencies", "*", "path"],
&["package", "build"],
&["target", "*", "dependencies", "*", "path"],
];
let mut mani = toml::Value::Table(mani);
for path in paths {
iterate_toml_mut_path(&mut mani, path, &mut |v| {
if let toml::Value::String(ref mut s) = *v {
if Path::new(s).is_relative() {
if let Some(p) = base.join(&*s).to_str() {
*s = p.into();
}
}
}
Ok(())
})?
}
match mani {
toml::Value::Table(mani) => Ok(mani),
_ => unreachable!(),
}
}
/**
Iterates over the specified TOML values via a path specification.
*/
fn iterate_toml_mut_path<F>(base: &mut toml::Value, path: &[&str], on_each: &mut F) -> Result<()>
where
F: FnMut(&mut toml::Value) -> Result<()>,
{
if path.is_empty() {
return on_each(base);
}
let cur = path[0];
let tail = &path[1..];
if cur == "*" {
if let toml::Value::Table(ref mut tab) = *base {
for (_, v) in tab.iter_mut() {
iterate_toml_mut_path(v, tail, on_each)?;
}
}
} else if let toml::Value::Table(ref mut tab) = *base {
if let Some(v) = tab.get_mut(cur) {
iterate_toml_mut_path(v, tail, on_each)?;
}
}
Ok(())
}
|
/// Packed deltas within a Tuple Variation Store
use otspec::types::*;
use otspec::{read_field, read_field_counted, stateful_deserializer};
use serde::de::DeserializeSeed;
use serde::de::SeqAccess;
use serde::de::Visitor;
use serde::ser::SerializeSeq;
use serde::{Serialize, Serializer};
/// An array of packed deltas
///
/// This is the underlying storage for delta values in the cvt and gvar tables
#[derive(Debug, PartialEq)]
pub struct PackedDeltas(pub Vec<int16>);
/// In a run control byte, signifies that the deltas are two-byte values
const DELTAS_ARE_WORDS: u8 = 0x40;
/// In a run control byte, signifies that the deltas are zero and omitted
const DELTAS_ARE_ZERO: u8 = 0x80;
/// Mask off a run control byte to find the number of deltas in the run
const DELTA_RUN_COUNT_MASK: u8 = 0x3f;
stateful_deserializer!(
PackedDeltas,
PackedDeltasDeserializer,
{ num_points: usize },
fn visit_seq<A: SeqAccess<'de>>(self, mut seq: A) -> Result<Self::Value, A::Error> {
let mut res = vec![];
while res.len() < self.num_points {
let control_byte = read_field!(seq, u8, "a packed point control byte");
let deltas_are_words = (control_byte & DELTAS_ARE_WORDS) > 0;
// "The low 6 bits specify the number of delta values in the run minus 1."
// MINUS ONE.
let run_count = (control_byte & DELTA_RUN_COUNT_MASK) + 1;
let deltas: Vec<i16>;
if control_byte & DELTAS_ARE_ZERO > 0 {
deltas = std::iter::repeat(0).take(run_count as usize).collect();
} else if deltas_are_words {
deltas = read_field_counted!(seq, run_count, "packed points");
} else {
let delta_bytes: Vec<i8> = read_field_counted!(seq, run_count, "packed points");
deltas = delta_bytes.iter().map(|x| *x as i16).collect();
}
res.extend(deltas);
}
Ok(PackedDeltas(res))
}
);
impl Serialize for PackedDeltas {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
let mut seq = serializer.serialize_seq(None)?;
let mut pos = 0;
let deltas = &self.0;
while pos < deltas.len() {
let mut value = deltas[pos];
if value == 0 {
let mut run_length = 0;
while pos < deltas.len() && deltas[pos] == 0 {
run_length += 1;
pos += 1;
}
while run_length >= 64 {
seq.serialize_element(&(DELTAS_ARE_ZERO | 63_u8))?;
run_length -= 64;
}
if run_length > 0 {
seq.serialize_element(&((DELTAS_ARE_ZERO | (run_length - 1)) as u8))?;
}
} else if (-128..=127).contains(&value) {
// Runs of byte values
let mut start_of_run = pos;
while pos < deltas.len() {
value = deltas[pos];
if !(-128..=127).contains(&value) {
break;
}
// Avoid a sequence of more than one zero in a run.
if value == 0 && pos + 1 < deltas.len() && deltas[pos + 1] == 0 {
break;
}
pos += 1;
}
let mut run_length = pos - start_of_run;
while run_length >= 64 {
seq.serialize_element(&63_u8)?;
seq.serialize_element(&deltas[start_of_run..(start_of_run + 64)])?;
start_of_run += 64;
run_length -= 64;
}
if run_length > 0 {
seq.serialize_element(&((run_length - 1) as u8))?;
seq.serialize_element(
&(deltas[start_of_run..pos]
.iter()
.map(|x| *x as i8)
.collect::<Vec<i8>>()),
)?;
}
} else {
// Runs of word values
let mut start_of_run = pos;
while pos < deltas.len() {
value = deltas[pos];
// Avoid a single zero
if value == 0 {
break;
}
// Avoid a sequence of more than one byte-value in a run.
if (-128..=127).contains(&value)
&& pos + 1 < deltas.len()
&& (-128..=127).contains(&deltas[pos + 1])
{
break;
}
pos += 1;
}
let mut run_length = pos - start_of_run;
while run_length >= 64 {
seq.serialize_element(&(DELTAS_ARE_WORDS | 63))?;
seq.serialize_element(&deltas[start_of_run..(start_of_run + 64)])?;
start_of_run += 64;
run_length -= 64;
}
if run_length > 0 {
seq.serialize_element(&(DELTAS_ARE_WORDS | (run_length - 1) as u8))?;
seq.serialize_element(&deltas[start_of_run..pos])?;
}
}
}
seq.end()
}
}
/// Deserialize the packed deltas array from a binary buffer.
/// The number of points must be provided.
pub fn from_bytes(s: &[u8], num_points: usize) -> otspec::error::Result<PackedDeltas> {
let mut deserializer = otspec::de::Deserializer::from_bytes(s);
let cs = PackedDeltasDeserializer { num_points };
cs.deserialize(&mut deserializer)
}
#[cfg(test)]
mod tests {
use crate::otvar::packeddeltas::from_bytes;
use crate::otvar::packeddeltas::PackedDeltas;
#[test]
fn test_packed_delta_de() {
let packed = vec![
0x03, 0x0a, 0x97, 0x00, 0xc6, 0x87, 0x41, 0x10, 0x22, 0xfb, 0x34,
];
let expected = PackedDeltas(vec![10, -105, 0, -58, 0, 0, 0, 0, 0, 0, 0, 0, 4130, -1228]);
let deserialized: PackedDeltas = from_bytes(&packed, 14).unwrap();
assert_eq!(deserialized, expected);
}
#[test]
fn test_packed_delta_ser() {
let expected = vec![
0x03, 0x0a, 0x97, 0x00, 0xc6, 0x87, 0x41, 0x10, 0x22, 0xfb, 0x34,
];
let object = PackedDeltas(vec![10, -105, 0, -58, 0, 0, 0, 0, 0, 0, 0, 0, 4130, -1228]);
let serialized = otspec::ser::to_bytes(&object).unwrap();
assert_eq!(serialized, expected);
}
}
|
// 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 crate::message::{Message, MessageReturn};
use crate::node::Node;
use crate::types::Celsius;
use async_trait::async_trait;
use failure::{format_err, Error};
use fuchsia_zircon as zx;
use std::cell::RefCell;
use std::collections::HashMap;
use std::rc::Rc;
/// Node: TemperatureHandler
///
/// Summary: responds to temperature requests from other nodes by polling the
/// specified driver using the thermal FIDL protocol
///
/// Message Inputs:
/// - ReadTemperature
///
/// Message Outputs: N/A
///
/// FIDL: fidl_fuchsia_hardware_thermal
pub struct TemperatureHandler {
drivers: RefCell<HashMap<String, zx::Channel>>,
}
impl TemperatureHandler {
pub fn new() -> Rc<Self> {
Rc::new(Self { drivers: RefCell::new(HashMap::new()) })
}
fn connect_driver(&self, _path: &str) -> Result<(), Error> {
// TODO(pshickel): connect to driver and insert into hashmap
Err(format_err!("Failed to connect to driver"))
}
fn handle_read_temperature(&self, driver_path: &str) -> Result<MessageReturn, Error> {
let drivers = self.drivers.borrow();
if !drivers.contains_key(driver_path) {
self.connect_driver(driver_path)?;
}
let driver = drivers.get(driver_path).unwrap();
let temperature = self.read_temperature(driver)?;
Ok(MessageReturn::ReadTemperature(temperature))
}
fn read_temperature(&self, _driver: &zx::Channel) -> Result<Celsius, Error> {
// TODO(pshickel): implement this function once the temperature driver is ready
Ok(Celsius(0.0))
}
}
#[async_trait(?Send)]
impl Node for TemperatureHandler {
fn name(&self) -> &'static str {
"TemperatureHandler"
}
async fn handle_message(&self, msg: &Message<'_>) -> Result<MessageReturn, Error> {
match msg {
Message::ReadTemperature(driver) => self.handle_read_temperature(driver),
_ => Err(format_err!("Unsupported message: {:?}", msg)),
}
}
}
|
pub mod peer_messages;
pub mod trackers;
pub mod peer_protocol;
pub mod metainfo_files; |
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// 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.
//! Core Foundation Bundle Type
pub use core_foundation_sys::bundle::*;
use core_foundation_sys::base::CFRelease;
use std::mem;
use base::{TCFType};
/// A Bundle type.
pub struct CFBundle(CFBundleRef);
impl Drop for CFBundle {
fn drop(&mut self) {
unsafe {
CFRelease(self.as_CFTypeRef())
}
}
}
impl_TCFType!(CFBundle, CFBundleRef, CFBundleGetTypeID);
|
use alloc::{ collections::VecDeque, sync::Arc };
use spin::Mutex;
use crate::process;
use crate::sync::condvar::*;
use lazy_static::*;
pub struct Stdin {
// 字符队列
buf: Mutex<VecDeque<char>>,
// 条件变量
pushed: Condvar,
}
impl Stdin {
pub fn new() -> Self {
Stdin {
buf: Mutex::new(VecDeque::new()),
pushed: Condvar::new(),
}
}
// 生产者:输入字符
pub fn push(&self, ch: char) {
// 将字符加入字符队列
self.buf
.lock()
.push_back(ch);
// 如果此时有线程正在等待队列非空才能继续下去
// 将其唤醒
self.pushed.notify();
}
// 消费者:取出字符
// 运行在请求字符输入的线程上
pub fn pop(&self) -> char {
loop {
// 将代码放在 loop 里面防止再复制一遍
// 尝试获取队首字符
let ret = self.buf.lock().pop_front();
match ret {
Some(ch) => {
// 获取到了直接返回
return ch;
},
None => {
// 否则队列为空,通过 getc -> sys_read 获取字符的当前线程放弃 CPU 资源
// 进入阻塞状态等待唤醒
self.pushed.wait();
// 被唤醒后回到循环开头,此时可直接返回
}
}
}
}
}
lazy_static! {
pub static ref STDIN: Arc<Stdin> = Arc::new(Stdin::new());
} |
use pest::iterators::{Pair};
use template::{ComponentTemplate, TemplateAttribute, TemplateValue};
#[derive(Parser)]
#[grammar = "template/language.pest"]
pub struct TemplateParser;
pub fn parse_document(document_pair: Pair<Rule>) -> Result<Vec<ComponentTemplate>, String> {
assert_eq!(document_pair.as_rule(), Rule::template);
let mut components = Vec::new();
let mut parent_stack: Vec<ComponentTemplate> = Vec::new();
let mut last_indentation = 0;
for pair in document_pair.into_inner() {
let (component, indentation) = parse_component(pair.clone())?;
// Prevent first component starting at wrong indentation level
if components.len() == 0 && parent_stack.len() == 0 {
if indentation != 0 {
return Err("First component starts at wrong indentation".into())
}
}
// If we're at the same indentation level as the previous component,
// the previous component is our sibling, not parent
if indentation == last_indentation {
finish_sibling(&mut parent_stack, &mut components);
}
// If we are at lower indentation level, unroll the stack to the level we need to be at
if indentation < last_indentation {
let unroll_amount = last_indentation - indentation + 1;
for _ in 0..unroll_amount {
finish_sibling(&mut parent_stack, &mut components);
}
}
// If our indentation has increased by more than one, we need to give an error for that
if indentation > last_indentation && indentation - last_indentation > 1 {
let (line, _col) = pair.into_span().start_pos().line_col();
return Err(format!("Excessive increase in indentation at line {}", line))
}
parent_stack.push(component);
last_indentation = indentation;
}
// Unroll the stack into a final component
let mut last_component = None;
parent_stack.reverse();
for mut component in parent_stack {
if let Some(child_component) = last_component.take() {
component.children.push(child_component);
}
last_component = Some(component);
}
if let Some(component) = last_component {
components.push(component);
}
Ok(components)
}
fn finish_sibling(
parent_stack: &mut Vec<ComponentTemplate>, components: &mut Vec<ComponentTemplate>
) {
// If we don't have anything above us on the parent stack, that means we're the very
// first component in the file, so there's no previous component to add to anything
if let Some(sibling) = parent_stack.pop() {
// If we don't have a parent for the sibling, that means we're at the root of the
// file, so instead it needs to be added to the final components list
if let Some(mut parent) = parent_stack.pop() {
// However if both of those things are not the case, just add it to our parent
parent.children.push(sibling);
parent_stack.push(parent);
} else {
components.push(sibling);
}
}
}
fn parse_component(pair: Pair<Rule>) -> Result<(ComponentTemplate, usize), String> {
assert_eq!(pair.as_rule(), Rule::component);
let mut indentation = 0;
let mut class = None;
let mut style_class: Option<String> = None;
let mut attributes = None;
let (line, _col) = pair.clone().into_span().start_pos().line_col();
for pair in pair.into_inner() {
match pair.as_rule() {
Rule::indentation => indentation = parse_indentation(pair)?,
Rule::identifier => class = Some(pair.as_str().into()),
Rule::style_class => style_class = Some(pair.as_str()[1..].into()),
Rule::attributes => attributes = Some(parse_attributes(pair)?),
_ => {}
}
}
Ok((ComponentTemplate {
class: class.unwrap(),
style_class,
attributes: attributes.unwrap_or_else(|| Vec::new()),
children: Vec::new(),
line,
}, indentation))
}
fn parse_indentation(pair: Pair<Rule>) -> Result<usize, String> {
// Count the spacing, including tabs
let mut spacing = 0;
for c in pair.as_str().chars() {
match c {
' ' => spacing += 1,
'\t' => spacing += 4,
_ => unreachable!(),
}
}
// Fail indentation that isn't divisible by 4
if spacing % 4 != 0 {
let (line, _col) = pair.into_span().start_pos().line_col();
return Err(format!("Bad amount of indentation spacing, must be divisible by 4, at line {}", line))
}
Ok(spacing/4)
}
fn parse_attributes(pair: Pair<Rule>) -> Result<Vec<TemplateAttribute>, String> {
assert_eq!(pair.as_rule(), Rule::attributes);
let mut attributes: Vec<TemplateAttribute> = Vec::new();
for key_value_pair in pair.into_inner() {
assert_eq!(key_value_pair.as_rule(), Rule::key_value);
let mut key: Option<String> = None;
let mut value: Option<TemplateValue> = None;
let mut script_conditional: Option<String> = None;
for pair in key_value_pair.clone().into_inner() {
match pair.as_rule() {
Rule::identifier =>
key = Some(pair.as_str().into()),
Rule::value =>
value = Some(parse_value(pair)),
Rule::script_conditional => {
let pair_str = pair.as_str();
script_conditional = Some(pair_str[2..pair_str.len()-1].into());
}
_ => unreachable!(),
}
}
// We allow duplicate keys, when attributes are resolved it will pick the last one
attributes.push(TemplateAttribute {
key: key.unwrap(),
value: value.unwrap(),
script_conditional,
});
}
Ok(attributes)
}
fn parse_value(pair: Pair<Rule>) -> TemplateValue {
assert_eq!(pair.as_rule(), Rule::value);
let pair = pair.into_inner().next().unwrap();
let pair_str = pair.as_str();
match pair.as_rule() {
Rule::string =>
TemplateValue::String(pair_str[1..pair_str.len()-1].into()),
Rule::percentage =>
TemplateValue::Percentage(pair_str[0..pair_str.len()-1].parse().unwrap()),
Rule::integer =>
TemplateValue::Integer(pair_str.parse().unwrap()),
Rule::float =>
TemplateValue::Float(pair_str.parse().unwrap()),
Rule::tuple => {
let mut values = Vec::new();
for pair in pair.into_inner() {
values.push(parse_value(pair));
}
TemplateValue::Tuple(values)
},
Rule::default =>
TemplateValue::Default,
Rule::script_value =>
TemplateValue::ScriptValue(pair_str[2..pair_str.len()-1].into()),
Rule::script_statement =>
TemplateValue::ScriptStatement(pair_str[1..pair_str.len()-1].into()),
_ => unreachable!(),
}
}
|
use std::path::Path;
use std::sync::{mpsc, Arc, Mutex};
use std::time::Duration;
use getch_rs::{Getch, Key};
use crate::repl;
use crate::flag;
use crate::setting;
pub async fn run(
port_name: String,
baud_rate: u32,
mut flags: flag::Flags,
params: Option<setting::Params>,
){
let receiver = serialport::new(&port_name, baud_rate)
.timeout(Duration::from_millis(10))
.open()
.unwrap_or_else(|e| {
eprintln!("Failed to open \"{}\". Error: {}", port_name, e);
std::process::exit(1);
});
let transmitter = receiver.try_clone().expect("Failed to clone from receiver");
let (tx, rx) = mpsc::channel();
// If write_file is already exists
if let Some(write_file) = flags.write_file() {
if Path::new(&write_file).exists() {
if !*flags.append() {
let g = Getch::new();
println!("\"{}\" is already exists!", &write_file);
println!("Press ENTER to continue overwrite");
match g.getch() {
Ok(Key::Char('\r')) => (), // continue
_ => std::process::exit(0), // exit
}
}
} else if *flags.append() {
let g = Getch::new();
println!("\"{}\" is not exists!", &write_file);
println!("Press ENTER to create the file and continue");
match g.getch() {
Ok(Key::Char('\r')) => (), // continue
_ => std::process::exit(0), // exit
}
*flags.append_mut() = false;
}
}
// Check if params exists
if params.is_none() {
*flags.nocolor_mut() = true;
}
println!("Type \"~.\" to exit.");
println!("Connecting... {}", port_name);
let flags = Arc::new(Mutex::new(flags));
let flags_clone = flags.clone();
tokio::select! {
_ = tokio::spawn(repl::receiver(receiver, rx, flags_clone, params)) => {
println!("\n\x1b[0mDisconnected.");
std::process::exit(0);
}
_ = tokio::spawn(repl::transmitter(transmitter, tx, flags)) => {}
}
}
|
use shipyard::*;
use shipyard_scenegraph::init::init_scenegraph;
use crate::mainloop::UpdateTick;
use crate::renderer::{SceneRenderer, item::*};
use shipyard_scenegraph::prelude::*;
use crate::controller::{queue::InputQueue, Controller, controller_set_sys, controller_process_sys, controller_clear_sys};
use crate::renderer::render_sys;
use crate::physics::spin_sys;
use std::collections::HashMap;
use nalgebra::{Vector3, Matrix4, UnitQuaternion};
pub fn init_world(renderer:SceneRenderer) -> World {
let world = World::new();
world.add_unique(Controller::Waiting);
world.add_unique(InputQueue::new());
world.add_unique(UpdateTick::default());
world.add_unique(InteractableLookup(HashMap::new()));
world.add_unique_non_send_sync(renderer);
register_workloads(&world);
init_scenegraph::<Vector3<f64>, UnitQuaternion<f64>, Matrix4<f64>, f64>(&world);
world
}
pub const RENDER:&str = "RENDER";
pub const CONTROLLER:&str = "CONTROLLER";
pub const PHYSICS:&str = "PHYSICS";
pub const CLEANUP:&str = "CLEANUP";
pub fn register_workloads(world:&World) {
Workload::new(RENDER)
.with_system(local_transform_sys)
.with_system(world_transform_sys)
.with_system(render_sys)
.add_to_world(world)
.unwrap();
Workload::new(CONTROLLER)
.with_system(controller_set_sys)
.with_system(controller_process_sys)
.add_to_world(world)
.unwrap();
Workload::new(PHYSICS)
.with_system(spin_sys)
.add_to_world(world)
.unwrap();
Workload::new(CLEANUP)
.with_system(controller_clear_sys)
.add_to_world(world)
.unwrap();
}
|
use std::{collections::HashSet, string::String, vec::Vec};
use unicode_segmentation::UnicodeSegmentation;
use rand::{distributions::Alphanumeric, Rng};
pub struct StringUtils {}
impl StringUtils {
pub fn replace_default(s: &str) -> String {
let s = s.replace(
&[
'(', ')', '-', ',', '\"', '.', ';', ':', '\'', '"', '?', '”', '“', '!', '/', '[',
']', '{', '}', '=', '&', '$', '#', '*', '+', '%'
][..],
" ",
)
.to_lowercase();
Self::make_ascii(s.as_str())
}
fn is_first_char_normal_ascii(c: &str) -> bool {
c.as_bytes().get(0).map_or(false, |&c| c >= 32 && c <= 126)
}
pub fn make_ascii(s: &str) -> String {
UnicodeSegmentation::graphemes(s, true)
.map(|c| match c {
c if c.len() == 1 && Self::is_first_char_normal_ascii(c) => c, // normal printable range
"\t" => "\t",
"\r" | "\n" | "\r\n" => "\n", // normalize all newlines
"á" | "à" | "ã" => "a",
"é" | "è" => "e",
"í" | "ì" | "ĩ" => "i",
"ó" | "ò" | "õ" => "o",
"ú" | "ù" | "ũ" => "u",
"ñ" | "ń" => "n",
_ => {
// If the first character is a normal ascii character, then use it
if Self::is_first_char_normal_ascii(c) {
c.get(..1).unwrap_or("")
} else {
""
}
}
})
.collect()
}
pub fn random_string(len:usize) -> String {
rand::thread_rng()
.sample_iter(&Alphanumeric)
.take(len)
.map(char::from)
.collect()
}
pub fn serialize_set(set:&HashSet<String>) -> String {
let mut res = "[".to_owned();
for v in set {
res.push('\"');
res.push_str(v);
res.push('\"');
res.push(',')
}
let len = res.len();
if len > 1 {
res.pop();
}
res.push(']');
res
}
}
|
// Copyright 2022 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 anyerror::AnyError;
use serde::Deserialize;
use serde::Serialize;
/// Error occurs when managing meta service.
#[derive(thiserror::Error, Serialize, Deserialize, Debug, Clone, PartialEq, Eq)]
pub enum MetaManagementError {
#[error(transparent)]
Join(AnyError),
#[error(transparent)]
Leave(AnyError),
}
|
use std::error;
use fat;
pub fn detail_file(args: &[String])
-> Result<(), Box<error::Error>>
{
expect_args!(args, 2);
let image_fn = args[0].clone();
let image = fat::Image::from_file(image_fn)?;
let file_metadata = image.get_file_entry(args[1].clone())?;
println!("{:#?}", file_metadata);
// XXX: We ignore the u32 entry clusters for now and cast to u16.
// In the future we need to convert everything to u32 for FAT32 support.
let mut cluster_num = file_metadata.entry_cluster() as u16;
const CLUSTER_NUMS_PER_LINE: usize = 8;
'outer: loop {
for _ in 0 .. CLUSTER_NUMS_PER_LINE {
let next_cluster = image.get_fat_entry(cluster_num);
print!("{:#x}\t", cluster_num);
if !fat::cluster_num_is_valid(next_cluster) {
println!("\n{:#x}", next_cluster);
break 'outer;
}
cluster_num = next_cluster;
}
println!("");
}
Ok(())
}
|
// xfail-pretty
import rusti::ivec_len;
native "rust-intrinsic" mod rusti {
fn ivec_len[T](v: &T[]) -> uint;
}
fn main() {
let v: int[] = ~[];
assert (ivec_len(v) == 0u); // zero-length
let x = ~[1, 2];
assert (ivec_len(x) == 2u); // on stack
let y = ~[1, 2, 3, 4, 5];
assert (ivec_len(y) == 5u); // on heap
v += ~[];
assert (ivec_len(v) == 0u); // zero-length append
x += ~[3];
assert (ivec_len(x) == 3u); // on-stack append
y += ~[6, 7, 8, 9];
assert (ivec_len(y) == 9u); // on-heap append
let vv = v + v;
assert (ivec_len(vv) == 0u); // zero-length add
let xx = x + ~[4];
assert (ivec_len(xx) == 4u); // on-stack add
let yy = y + ~[10, 11];
assert (ivec_len(yy) == 11u); // on-heap add
}
|
use crate::{Extent3D, Origin3D};
use ash::vk;
pub fn has_zero_or_one_bits(bits: u32) -> bool {
let bits = bits as i32;
bits & (bits - 1) == 0
}
pub fn extent_3d(extent: Extent3D) -> vk::Extent3D {
vk::Extent3D {
width: extent.width,
height: extent.height,
depth: extent.depth,
}
}
pub fn offset_3d(origin: Origin3D) -> vk::Offset3D {
vk::Offset3D {
x: origin.x,
y: origin.y,
z: origin.z,
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_has_zero_or_one_bits() {
use crate::TextureUsageFlags;
assert!(super::has_zero_or_one_bits(TextureUsageFlags::NONE.bits()));
assert!(super::has_zero_or_one_bits(TextureUsageFlags::TRANSFER_SRC.bits()));
assert!(!super::has_zero_or_one_bits(
(TextureUsageFlags::TRANSFER_SRC | TextureUsageFlags::TRANSFER_DST).bits()
));
}
}
|
use std::{collections::VecDeque, fmt::Display};
use data_types::{CompactionLevel, ParquetFile};
use crate::file_group::{split_by_level, FilesTimeRange};
use super::FilesSplit;
#[derive(Debug)]
/// Split files into `[compact_files]` and `[non_overlapping_files]`
/// To have better and efficient compaction performance, eligible non-overlapped files
/// should not be compacted.
pub struct NonOverlapSplit {
/// undersized_threshold is the threshold for unnecessarily including & rewriting adjacent
/// small files. This does increase write amplification, so it shouldn't be too high, but
/// it also prevents leaving tiny L1/L2 files that will never be compacted, so it shouldn't
/// be too low.
undersized_threshold: u64,
}
impl NonOverlapSplit {
pub fn new(undersized_threshold: u64) -> Self {
Self {
undersized_threshold,
}
}
}
impl Display for NonOverlapSplit {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Non-overlapping split for TargetLevel version")
}
}
impl FilesSplit for NonOverlapSplit {
/// Return (`[compact_files]`, `[non_overlapping_files]`) of given files
/// such that after combining all `compact_files` into a new file, the new file will
/// have no overlap with any file in `non_overlapping_files`.
/// The non_overlapping_files must be in the target_level
///
/// Eligible non-overlapping files are files of the target level that do not
/// overlap on time range of all files in lower-level. All files in target level
/// are assumed to not overlap with each other and do not need to check
///
/// Example:
/// . Input:
/// |--L0.1--| |--L0.2--|
/// |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--|
///
/// (L1.1, L1.3, L1.4) do not overlap with any L0s but only (L1.1, L1.4) are eligible non-overlapping files.
/// (L1.2, L1.3) must be compacted with L0s to produce the right non-overlapping L1s.
///
/// . Output:
/// . compact_files: [L0.1, L0.2, L1.2, L1.3]
/// . non_overlapping_files: [L1.1, L1.4]
///
/// Algorithm:
/// The non-overlappings files are files from 2 ends of the target level files that are
/// completely ouside the time range of all lower level files
///
/// L0s |--L0.1--| |--L0.2--|
/// ==> L0s' time range: |-------L0's time range --------|
///
/// L1s |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--|
/// ==> Only L1.1 and L1.4 are completely outside the time range of L0s.
/// So L1.1 and L1.4 are usually not included in compact_files. However, if either of L1.1 or L1.4
/// are small (below undersized_threshold), they will be included in compact_files to avoid leaving
/// tiny L1 files behind. Note that the application of undersized_threshold can only contiguously
/// expand the set of min_time sorted target level files. So if there was a small L1.5 file, we
/// could not skip over a large L1.4 file to include L1.5 in compact_files.
///
fn apply(
&self,
files: Vec<ParquetFile>,
target_level: CompactionLevel,
) -> (Vec<ParquetFile>, Vec<ParquetFile>) {
// Panic if given wrong target level, L0
assert_ne!(target_level, CompactionLevel::Initial);
let num_files = files.len();
// Split files into levels
let prev_level = target_level.prev();
let (mut target_level_files, prev_level_files) =
split_by_level(files, target_level, prev_level);
// compute time range of prev_level_files
let prev_level_range = if let Some(r) = FilesTimeRange::try_new(&prev_level_files) {
r
} else {
// No prev_level_files, all target_level_files are non_overlapping_files
return (vec![], target_level_files);
};
// Split target_level_files into 3 parts, those before, during and after prev_level_files.
// Since target level files during the time range of prev_level_files must be compacted,
// they are the start of compact_files.
let mut before: Vec<ParquetFile>;
let mut compact_files: Vec<ParquetFile>;
let mut after: Vec<ParquetFile>;
let mut non_overlapping_files = Vec::with_capacity(num_files);
(before, compact_files, after) =
three_range_split(&mut target_level_files, prev_level_range);
// Closure that checks if a file is under the size threshold and adds it to compact_files
let mut check_undersize_and_add = |file: ParquetFile| -> bool {
let mut under = false;
// Check if file overlaps with (min_time, max_time)
if file.file_size_bytes <= self.undersized_threshold as i64 {
under = true;
compact_files.push(file);
} else {
non_overlapping_files.push(file);
}
under
};
// Contiguously add `before` files to the list to compact, so long as they're under the size threshold.
before.sort_by_key(|f| f.min_time);
let mut before = before.into_iter().collect::<VecDeque<_>>();
while let Some(file) = before.pop_back() {
if !check_undersize_and_add(file) {
break;
}
}
// Contiguously add `after` files to the list to compact, so long as they're under the size threshold.
after.sort_by_key(|f| f.min_time);
let mut after = after.into_iter().collect::<VecDeque<_>>();
while let Some(file) = after.pop_front() {
if !check_undersize_and_add(file) {
break;
}
}
compact_files.extend(prev_level_files);
// Add remaining files to non_overlapping_files.
non_overlapping_files.extend(before);
non_overlapping_files.extend(after);
(compact_files, non_overlapping_files)
}
}
// three_range_split splits the files into 3 vectors: before, during, after the specified time range.
pub fn three_range_split(
files: &mut Vec<ParquetFile>,
range: FilesTimeRange,
) -> (Vec<ParquetFile>, Vec<ParquetFile>, Vec<ParquetFile>) {
let num_files = files.len();
let mut before = Vec::with_capacity(num_files);
let mut during = Vec::with_capacity(num_files);
let mut after = Vec::with_capacity(num_files);
while let Some(file) = files.pop() {
if range.contains(&file) {
during.push(file);
} else if range.before(&file) {
before.push(file);
} else {
after.push(file);
}
}
(before, during, after)
}
#[cfg(test)]
mod tests {
use compactor_test_utils::{
create_l1_files, create_overlapped_files, create_overlapped_files_2,
create_overlapped_files_mix_sizes_1, create_overlapped_l0_l1_files,
create_overlapped_l1_l2_files, format_files, format_files_split,
};
use super::*;
#[test]
fn test_display() {
assert_eq!(
NonOverlapSplit::new(1024 * 1024).to_string(),
"Non-overlapping split for TargetLevel version"
);
}
#[test]
#[should_panic]
fn test_wrong_target_level() {
let files = create_overlapped_files();
let split = NonOverlapSplit::new(1024 * 1024);
split.apply(files, CompactionLevel::Initial);
}
#[test]
#[should_panic(
expected = "Unexpected compaction level. Expected CompactionLevel::L1 or CompactionLevel::L0 but got CompactionLevel::L2."
)]
fn test_unexpected_compaction_level_2() {
let files = create_overlapped_files();
let split = NonOverlapSplit::new(1024 * 1024);
// There are L2 files and will panic
split.apply(files, CompactionLevel::FileNonOverlapped);
}
#[test]
#[should_panic(
expected = "Unexpected compaction level. Expected CompactionLevel::L2 or CompactionLevel::L1 but got CompactionLevel::L0."
)]
fn test_unexpected_compaction_level_0() {
let files = create_overlapped_files();
let split = NonOverlapSplit::new(1024 * 1024);
// There are L0 files and will panic
split.apply(files, CompactionLevel::Final);
}
#[test]
fn test_apply_empty_files() {
let files = vec![];
let split = NonOverlapSplit::new(1024 * 1024);
let (overlap, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
assert_eq!(overlap.len(), 0);
assert_eq!(non_overlap.len(), 0);
}
#[test]
fn test_apply_one_level_empty() {
let files = create_l1_files(1);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L1, all files 1b "
- "L1.13[600,700] 0ns |------L1.13-------|"
- "L1.12[400,500] 0ns |------L1.12-------| "
- "L1.11[250,350] 0ns |------L1.11-------| "
"###
);
let split = NonOverlapSplit::new(0);
// Lower level is empty -> all files will be in non_overlapping_files
let (overlap, non_overlap) = split.apply(files.clone(), CompactionLevel::FileNonOverlapped);
assert_eq!(overlap.len(), 0);
assert_eq!(non_overlap.len(), 3);
// target level is empty -> all files will be in compact_files
let (overlap, non_overlap) = split.apply(files, CompactionLevel::Final);
assert_eq!(overlap.len(), 3);
assert_eq!(non_overlap.len(), 0);
}
#[test]
fn test_apply_mix_1() {
let files = create_overlapped_l0_l1_files(1);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L0, all files 1b "
- "L0.2[650,750] 180s |---L0.2----| "
- "L0.1[450,620] 120s |--------L0.1---------| "
- "L0.3[800,900] 300s |---L0.3----| "
- "L1, all files 1b "
- "L1.13[600,700] 60s |---L1.13---| "
- "L1.12[400,500] 60s |---L1.12---| "
- "L1.11[250,350] 60s |---L1.11---| "
"###
);
let split = NonOverlapSplit::new(0);
let (overlap, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
insta::assert_yaml_snapshot!(
format_files_split("overlap", &overlap, "non_overlap", &non_overlap),
@r###"
---
- overlap
- "L0, all files 1b "
- "L0.2[650,750] 180s |------L0.2------| "
- "L0.1[450,620] 120s |------------L0.1------------| "
- "L0.3[800,900] 300s |------L0.3------|"
- "L1, all files 1b "
- "L1.12[400,500] 60s |-----L1.12------| "
- "L1.13[600,700] 60s |-----L1.13------| "
- non_overlap
- "L1, all files 1b "
- "L1.11[250,350] 60s |-----------------------------------------L1.11------------------------------------------|"
"###
);
}
// |--L2.1--| |--L2.2--|
// |--L1.1--| |--L1.2--| |--L1.3--|
// |--L0.1--| |--L0.2--| |--L0.3--|
#[test]
fn test_apply_mix_2() {
let files = create_overlapped_l1_l2_files(1);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L1, all files 1b "
- "L1.13[600,700] 0ns |--L1.13---| "
- "L1.12[400,500] 0ns |--L1.12---| "
- "L1.11[250,350] 0ns |--L1.11---| "
- "L2, all files 1b "
- "L2.21[0,100] 0ns |--L2.21---| "
- "L2.22[200,300] 0ns |--L2.22---| "
"###
);
let split = NonOverlapSplit::new(0);
let (overlap, non_overlap) = split.apply(files, CompactionLevel::Final);
insta::assert_yaml_snapshot!(
format_files_split("overlap", &overlap, "non_overlap", &non_overlap),
@r###"
---
- overlap
- "L1, all files 1b "
- "L1.13[600,700] 0ns |-----L1.13------|"
- "L1.12[400,500] 0ns |-----L1.12------| "
- "L1.11[250,350] 0ns |-----L1.11------| "
- "L2, all files 1b "
- "L2.22[200,300] 0ns |-----L2.22------| "
- non_overlap
- "L2, all files 1b "
- "L2.21[0,100] 0ns |-----------------------------------------L2.21------------------------------------------|"
"###
);
}
#[test]
fn test_apply_mix_3() {
// Create files with levels and time ranges
// . Input:
// |--L0.1--| |--L0.2--|
// |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--|
//
// . Output: (overlap, non_overlap) = ( [L0.1, L0.2, L1.2, L1.3] , [L1.1, L1.4] )
let files = create_overlapped_files_2(1);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L0, all files 1b "
- "L0.2[520,550] 0ns |L0.2| "
- "L0.1[250,350] 0ns |---L0.1---| "
- "L1, all files 1b "
- "L1.13[400,500] 0ns |--L1.13---| "
- "L1.12[200,300] 0ns |--L1.12---| "
- "L1.11[0,100] 0ns |--L1.11---| "
- "L1.14[600,700] 0ns |--L1.14---| "
"###
);
let split = NonOverlapSplit::new(0);
let (overlap, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
insta::assert_yaml_snapshot!(
format_files_split("overlap", &overlap, "non_overlap", &non_overlap),
@r###"
---
- overlap
- "L0, all files 1b "
- "L0.2[520,550] 0ns |L0.2-| "
- "L0.1[250,350] 0ns |---------L0.1----------| "
- "L1, all files 1b "
- "L1.12[200,300] 0ns |---------L1.12---------| "
- "L1.13[400,500] 0ns |---------L1.13---------| "
- non_overlap
- "L1, all files 1b "
- "L1.11[0,100] 0ns |--L1.11---| "
- "L1.14[600,700] 0ns |--L1.14---| "
"###
);
}
#[test]
fn test_undersized_1() {
// Create files with levels and time ranges, where all L1 files are undersized.
// Input:
// |--L0.1--| |--L0.2--|
// |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--|
//
// Output: (compact, non_overlap) = ( [L0.1, L0.2, L1.1, L1.2, L1.3, L1.4] , [] )
// Since all the files are below the undersized threshold, they all get compacted, even though some
// don't overlap.
let files = create_overlapped_files_2(10);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L0, all files 10b "
- "L0.2[520,550] 0ns |L0.2| "
- "L0.1[250,350] 0ns |---L0.1---| "
- "L1, all files 10b "
- "L1.13[400,500] 0ns |--L1.13---| "
- "L1.12[200,300] 0ns |--L1.12---| "
- "L1.11[0,100] 0ns |--L1.11---| "
- "L1.14[600,700] 0ns |--L1.14---| "
"###
);
let split = NonOverlapSplit::new(11);
let (compact_files, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
insta::assert_yaml_snapshot!(
format_files_split("compact_files", &compact_files, "non_overlap", &non_overlap),
@r###"
---
- compact_files
- "L0, all files 10b "
- "L0.2[520,550] 0ns |L0.2| "
- "L0.1[250,350] 0ns |---L0.1---| "
- "L1, all files 10b "
- "L1.12[200,300] 0ns |--L1.12---| "
- "L1.13[400,500] 0ns |--L1.13---| "
- "L1.11[0,100] 0ns |--L1.11---| "
- "L1.14[600,700] 0ns |--L1.14---| "
- non_overlap
"###
);
}
#[test]
fn test_undersized_2() {
// Create files with levels and time ranges, where some non-overlapping L1 files are undersized.
// . Input:
// |--L0.1--| |-L0.2-|
// |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--| |--L1.5--| |--L1.6--| |--L1.7--| |--L1.8--|
// underized: no no yes x x yes no no
// Results:
// L1.4 and L1.5 are compacted regardless of their size because they overlap L0s.
// L1.3 and L1.6 are compacted because they are undersized and contiguous to the overlapping files.
// L1.1, L1.2, L1.7, and L1.8 are not compacted because they are not undersized.
//
let files = create_overlapped_files_mix_sizes_1(10, 20, 30);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L0 "
- "L0.2[820,850] 0ns 10b |L0.2| "
- "L0.1[650,750] 0ns 10b |L0.1| "
- "L1 "
- "L1.13[400,500] 0ns 10b |L1.13| "
- "L1.17[1200,1300] 0ns 30b |L1.17| "
- "L1.12[200,300] 0ns 30b |L1.12| "
- "L1.11[0,100] 0ns 20b |L1.11| "
- "L1.14[600,700] 0ns 20b |L1.14| "
- "L1.15[800,900] 0ns 20b |L1.15| "
- "L1.16[1000,1100] 0ns 10b |L1.16| "
- "L1.18[1400,1500] 0ns 20b |L1.18|"
"###
);
let split = NonOverlapSplit::new(11);
let (compact_files, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
insta::assert_yaml_snapshot!(
format_files_split("compact_files", &compact_files, "non_overlap", &non_overlap),
@r###"
---
- compact_files
- "L0 "
- "L0.2[820,850] 0ns 10b |L0.2| "
- "L0.1[650,750] 0ns 10b |---L0.1---| "
- "L1 "
- "L1.15[800,900] 0ns 20b |--L1.15---| "
- "L1.14[600,700] 0ns 20b |--L1.14---| "
- "L1.13[400,500] 0ns 10b |--L1.13---| "
- "L1.16[1000,1100] 0ns 10b |--L1.16---| "
- non_overlap
- "L1 "
- "L1.12[200,300] 0ns 30b |L1.12| "
- "L1.17[1200,1300] 0ns 30b |L1.17| "
- "L1.11[0,100] 0ns 20b |L1.11| "
- "L1.18[1400,1500] 0ns 20b |L1.18|"
"###
);
}
#[test]
fn test_undersized_3() {
// This case is like undersized 3, except that the outermost L1 files (L1 & L18) are also undersized. But since
// they're separated from the overlapping files by oversized files, they are not compacted.
// Input:
// |--L0.1--| |-L0.2-|
// |--L1.1--| |--L1.2--| |--L1.3--| |--L1.4--| |--L1.5--| |--L1.6--| |--L1.7--| |--L1.8--|
// underized: yes no yes x x yes no yes
// Results:
// L1.4 and L1.5 are compacted regardless of their size because they overlap.
// L1.3 and L1.6 are compacted because they are undersized and contiguous to the overlapping files.
// L1.2 and L1.7 are not compacted because they are not undersized.
// L1.1 and L1.8 are not compacted because even though they are undersized, they are not contiguous to the
// overlapping files.
//
let files = create_overlapped_files_mix_sizes_1(10, 20, 30);
insta::assert_yaml_snapshot!(
format_files("initial", &files),
@r###"
---
- initial
- "L0 "
- "L0.2[820,850] 0ns 10b |L0.2| "
- "L0.1[650,750] 0ns 10b |L0.1| "
- "L1 "
- "L1.13[400,500] 0ns 10b |L1.13| "
- "L1.17[1200,1300] 0ns 30b |L1.17| "
- "L1.12[200,300] 0ns 30b |L1.12| "
- "L1.11[0,100] 0ns 20b |L1.11| "
- "L1.14[600,700] 0ns 20b |L1.14| "
- "L1.15[800,900] 0ns 20b |L1.15| "
- "L1.16[1000,1100] 0ns 10b |L1.16| "
- "L1.18[1400,1500] 0ns 20b |L1.18|"
"###
);
let split = NonOverlapSplit::new(21);
let (compact_files, non_overlap) = split.apply(files, CompactionLevel::FileNonOverlapped);
insta::assert_yaml_snapshot!(
format_files_split("compact_files", &compact_files, "non_overlap", &non_overlap),
@r###"
---
- compact_files
- "L0 "
- "L0.2[820,850] 0ns 10b |L0.2| "
- "L0.1[650,750] 0ns 10b |---L0.1---| "
- "L1 "
- "L1.15[800,900] 0ns 20b |--L1.15---| "
- "L1.14[600,700] 0ns 20b |--L1.14---| "
- "L1.13[400,500] 0ns 10b |--L1.13---| "
- "L1.16[1000,1100] 0ns 10b |--L1.16---| "
- non_overlap
- "L1 "
- "L1.12[200,300] 0ns 30b |L1.12| "
- "L1.17[1200,1300] 0ns 30b |L1.17| "
- "L1.11[0,100] 0ns 20b |L1.11| "
- "L1.18[1400,1500] 0ns 20b |L1.18|"
"###
);
}
}
|
use id::Id;
/// Contains additional information about a zone, like what kind of zone it is.
#[derive(Debug, Clone)]
pub enum ZoneDetails {
Battlefield,
Hand {
player_id: Id,
},
}
/// Represents a single zone in the game.
#[derive(Debug, Clone)]
pub struct Zone {
pub id: Id,
pub details: ZoneDetails,
// TODO: Zone order -- should that be handled in ZoneDetails or in a field
// of Object?
}
impl Zone {
/// Create a version of the zone that contains only information that the
/// given player would have.
pub fn view_as_player(&self, _player_id: Id) -> Zone {
// In the future, more information might be needed about the player to
// correctly view a zone from their perspective.
// TODO
self.clone()
}
}
|
fn main() {
let stdin = std::io::stdin();
let mut rd = ProconReader::new(stdin.lock());
let x: String = rd.get();
let x: Vec<u64> = x.bytes().map(|b| (b - b'0') as u64).collect();
let m: u64 = rd.get();
if x.len() == 1 {
if x[0] <= m {
println!("1");
} else {
println!("0");
}
return;
}
let mut x = x;
x.reverse();
let le_m = |base: u64| {
let mut y = 0;
for (i, &x) in x.iter().enumerate() {
// y = base^i * x[i] + y
let nxt_y = base
.checked_pow(i as u32)
.and_then(|a| a.checked_mul(x))
.and_then(|a| a.checked_add(y));
match nxt_y {
Some(nxt_y) => {
y = nxt_y;
}
None => {
return false;
}
}
}
y <= m
};
let d = x.iter().copied().max().unwrap();
if !le_m(d + 1) {
println!("0");
return;
}
let mut ok = d + 1;
let mut ng = std::u64::MAX / 2;
while ng - ok > 1 {
let base = (ng + ok) / 2;
if le_m(base) {
ok = base;
} else {
ng = base;
}
}
println!("{}", ok - d);
}
pub struct ProconReader<R> {
r: R,
l: String,
i: usize,
}
impl<R: std::io::BufRead> ProconReader<R> {
pub fn new(reader: R) -> Self {
Self {
r: reader,
l: String::new(),
i: 0,
}
}
pub fn get<T>(&mut self) -> T
where
T: std::str::FromStr,
<T as std::str::FromStr>::Err: std::fmt::Debug,
{
self.skip_blanks();
assert!(self.i < self.l.len()); // remain some character
assert_ne!(&self.l[self.i..=self.i], " ");
let rest = &self.l[self.i..];
let len = rest.find(' ').unwrap_or_else(|| rest.len());
// parse self.l[self.i..(self.i + len)]
let val = rest[..len]
.parse()
.unwrap_or_else(|e| panic!("{:?}, attempt to read `{}`", e, rest));
self.i += len;
val
}
fn skip_blanks(&mut self) {
loop {
match self.l[self.i..].find(|ch| ch != ' ') {
Some(j) => {
self.i += j;
break;
}
None => {
let mut buf = String::new();
let num_bytes = self
.r
.read_line(&mut buf)
.unwrap_or_else(|_| panic!("invalid UTF-8"));
assert!(num_bytes > 0, "reached EOF :(");
self.l = buf
.trim_end_matches('\n')
.trim_end_matches('\r')
.to_string();
self.i = 0;
}
}
}
}
pub fn get_vec<T>(&mut self, n: usize) -> Vec<T>
where
T: std::str::FromStr,
<T as std::str::FromStr>::Err: std::fmt::Debug,
{
(0..n).map(|_| self.get()).collect()
}
pub fn get_chars(&mut self) -> Vec<char> {
self.get::<String>().chars().collect()
}
}
|
#[doc = "Reader of register HWCFGR2"]
pub type R = crate::R<u32, super::HWCFGR2>;
#[doc = "Reader of field `PTIONREG_OUT`"]
pub type PTIONREG_OUT_R = crate::R<u8, u8>;
#[doc = "Reader of field `TRUST_ZONE`"]
pub type TRUST_ZONE_R = crate::R<u8, u8>;
impl R {
#[doc = "Bits 0:7 - PTIONREG_OUT"]
#[inline(always)]
pub fn ptionreg_out(&self) -> PTIONREG_OUT_R {
PTIONREG_OUT_R::new((self.bits & 0xff) as u8)
}
#[doc = "Bits 8:11 - TRUST_ZONE"]
#[inline(always)]
pub fn trust_zone(&self) -> TRUST_ZONE_R {
TRUST_ZONE_R::new(((self.bits >> 8) & 0x0f) as u8)
}
}
|
//! Provides types and functionality for [Relationships](https://discord.com/developers/docs/game-sdk/relationships)
pub mod events;
pub mod state;
use crate::{user::User, Error};
use serde::Deserialize;
#[derive(Copy, Clone, Debug, PartialEq, serde_repr::Deserialize_repr)]
#[repr(u8)]
pub enum RelationKind {
/// User has no intrinsic relationship
None = 0,
/// User is a friend
Friend = 1,
/// User is blocked
Blocked = 2,
/// User has a pending incoming friend request to connected user
PendingIncoming = 3,
/// Current user has a pending outgoing friend request to user
PendingOutgoing = 4,
/// User is not friends, but interacts with current user often (frequency + recency)
Implicit = 5,
}
#[derive(Copy, Clone, Debug, PartialEq, Deserialize)]
#[serde(rename_all = "snake_case")]
pub enum RelationStatus {
/// The user is offline
Offline,
/// The user is online and active
Online,
/// The user is online, but inactive
Idle,
/// The user has set their status to Do Not Disturb
#[serde(rename = "dnd")]
DoNotDisturb,
}
#[derive(Debug, Clone, Deserialize)]
pub struct RelationshipPresence {
pub status: RelationStatus,
pub activity: Option<crate::activity::Activity>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Relationship {
/// What kind of relationship it is
#[serde(rename = "type")]
pub kind: RelationKind,
#[serde(deserialize_with = "crate::user::de_user")]
pub user: User,
pub presence: RelationshipPresence,
}
impl crate::Discord {
/// The regular Game SDK does not really expose this functionality directly,
/// but rather exposed via the "on refresh" event as described in the
/// [docs](https://discord.com/developers/docs/game-sdk/relationships#onrefresh).
///
/// Basically, this method should be used to bootstrap the relationships for
/// the current user, with updates to that list coming via the
/// [`RelationshipUpdate`](crate::Event::RelationshipUpdate) event
pub async fn get_relationships(&self) -> Result<Vec<Relationship>, Error> {
let rx = self.send_rpc(crate::proto::CommandKind::GetRelationships, ())?;
handle_response!(rx, crate::proto::Command::GetRelationships { relationships } => {
Ok(relationships)
})
}
}
|
use std::cmp;
/*
https://leetcode.com/problems/maximal-square/
*/
struct Solution;
impl Solution {
pub fn maximal_square(matrix: Vec<Vec<char>>) -> i32 {
let rows = matrix.len();
let cols = matrix[0].len();
let mut dp = vec![vec![0; cols + 1]; rows + 1];
let mut max_len: i32 = 0;
for row in 1..=rows {
for col in 1..=cols {
if matrix[row - 1][col - 1] == '1' {
dp[row][col] = 1 + cmp::min(
cmp::min(dp[row - 1][col - 1], dp[row - 1][col]),
dp[row][col - 1],
);
max_len = cmp::max(max_len, dp[row][col] as i32);
}
}
}
max_len * max_len
}
}
#[test]
fn test() {
assert_eq!(
4,
Solution::maximal_square(vec![
vec!['1', '0', '1', '0', '0'],
vec!['1', '0', '1', '1', '1'],
vec!['1', '1', '1', '1', '1'],
vec!['1', '0', '0', '1', '0'],
])
);
assert_eq!(
1,
Solution::maximal_square(vec![vec!['0', '1'], vec!['1', '0']])
);
assert_eq!(1, Solution::maximal_square(vec![vec!['1']]));
assert_eq!(0, Solution::maximal_square(vec![vec!['0']]));
}
|
use std::io;
use std::io::Write;
extern crate chrono;
use chrono::prelude::*;
fn main() {
let name = input(("What is your name? ").to_string());
let age = input(format!("How old are you, {}? ", name))
.parse().expect("Failed converting age to number");
let centennial_year = calculate_year_of_centennial(age);
println!("{}, you will turn 100 during the year {}!", name, centennial_year);
}
fn input(user_message: String) -> String {
// Print user_message & flush terminal output
print!("{}", user_message);
io::stdout().flush().unwrap();
// Get terminal input & set it to input
let mut input = String::new();
io::stdin().read_line(&mut input).expect("Failed reading line");
// Trim off whitespace
let input: String = input.trim().to_string();
// Return users input as String
input
}
fn calculate_year_of_centennial(age: i32) -> i32 {
// Get current year
let current_year = Utc::today().year();
current_year - age + 99
}
|
use crate::raw::{FidlType, Spanned};
use std::collections::HashMap;
lazy_static! {
pub static ref BUILTIN_SCHEMAS: HashMap<String, AttributeSchema> = {
let mut builtins = HashMap::new();
builtins.insert(
"Discoverable".to_string(),
AttributeSchema {
placements: vec![FidlType::ProtocolDecl],
allowed_value: None,
},
);
builtins.insert(
"Doc".to_string(),
AttributeSchema {
placements: Vec::new(),
allowed_value: None,
},
);
builtins.insert(
"FragileBase".to_string(),
AttributeSchema {
placements: vec![FidlType::ProtocolDecl],
allowed_value: Some("Simple".to_string()),
},
);
builtins.insert(
"MaxBytes".to_string(),
AttributeSchema {
placements: vec![
FidlType::ProtocolDecl,
FidlType::Method,
FidlType::StructDecl,
FidlType::TableDecl,
FidlType::UnionDecl,
],
allowed_value: None,
},
);
builtins.insert(
"MaxHandles".to_string(),
AttributeSchema {
placements: vec![
FidlType::ProtocolDecl,
FidlType::Method,
FidlType::StructDecl,
FidlType::TableDecl,
FidlType::UnionDecl,
],
allowed_value: None,
},
);
builtins.insert(
"Result".to_string(),
AttributeSchema {
placements: vec![FidlType::UnionDecl],
allowed_value: Some("".to_string()),
},
);
builtins.insert(
"Selector".to_string(),
AttributeSchema {
placements: vec![FidlType::Method],
allowed_value: None,
},
);
builtins.insert(
"Transport".to_string(),
AttributeSchema {
placements: vec![FidlType::ProtocolDecl],
allowed_value: None,
},
);
builtins
};
}
pub struct AttributeSchema {
placements: Vec<FidlType>,
allowed_value: Option<String>,
// TODO: check_constraint: fn() -> bool
}
impl AttributeSchema {
pub fn is_placement_valid(&self, placement: FidlType) -> bool {
self.placements.is_empty() || self.placements.contains(&placement)
}
pub fn is_value_valid(&self, value: &Option<Spanned<String>>) -> bool {
match self.allowed_value {
None => true,
// TODO: should Attribute.Value just be a String instead of
// Option<String> if it's treated the same as an empty string?
Some(ref allowed) => match value {
None => allowed == "",
Some(ref value) => allowed == &value.value,
},
}
}
}
|
use std::iter;
use crate::ast;
use crate::error::ParseError;
use crate::grammar;
use crate::lexer;
use crate::token;
pub struct Parser {
inner: grammar::FileInputParser,
}
impl Default for Parser {
fn default() -> Self {
Self {
inner: grammar::FileInputParser::new(),
}
}
}
impl Parser {
pub fn parse_file(&self, source: &str) -> Result<ast::File, ParseError> {
let lxr = lexer::make_tokenizer(source);
let marker_token = (
Default::default(),
token::Tok::StartFile,
Default::default(),
);
let tokenizer = iter::once(Ok(marker_token)).chain(lxr);
self.inner.parse(tokenizer).map_err(ParseError::from)
}
}
|
use raw_window_handle::HasRawWindowHandle;
use wgpu::TextureViewDescriptor;
use crate::render::render_target::{RenderScene, RenderTarget};
use super::triangles::TriangleScene;
pub struct WgpuRenderTarget {
device: wgpu::Device,
sc_desc: wgpu::SurfaceConfiguration,
swapchain_format: wgpu::TextureFormat,
queue: wgpu::Queue,
surface: wgpu::Surface,
}
impl WgpuRenderTarget {
pub fn new<T: HasRawWindowHandle>(window: &T) -> WgpuRenderTarget {
pollster::block_on(Self::new_async(window))
}
pub async fn new_async<T: HasRawWindowHandle>(window: &T) -> WgpuRenderTarget {
let instance = wgpu::Instance::new(wgpu::Backends::all());
let size = (1, 1);
let surface = unsafe { instance.create_surface(window) };
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::default(),
// Request an adapter which can render to our surface
compatible_surface: Some(&surface),
})
.await
.expect("Failed to find an appropriate adapter");
let (device, queue) = adapter
.request_device(
&wgpu::DeviceDescriptor {
label: None,
features: wgpu::Features::empty(),
limits: wgpu::Limits::default(),
},
None,
)
.await
.expect("Failed to create device");
let swapchain_format = surface.get_preferred_format(&adapter).unwrap();
let sc_desc = wgpu::SurfaceConfiguration {
usage: wgpu::TextureUsages::RENDER_ATTACHMENT,
format: swapchain_format,
width: size.0,
height: size.1,
present_mode: wgpu::PresentMode::Mailbox,
};
surface.configure(&device, &sc_desc);
WgpuRenderTarget {
device,
sc_desc,
swapchain_format,
queue,
surface,
}
}
pub fn get_init(&self) -> (&wgpu::Device, &wgpu::Queue, wgpu::TextureFormat) {
(&self.device, &self.queue, self.swapchain_format)
}
}
impl RenderTarget for WgpuRenderTarget {
type RenderScene<T: RenderScene> = TriangleScene<T>;
fn resize(&mut self, width: u32, height: u32) {
self.sc_desc.width = width;
self.sc_desc.height = height;
self.surface.configure(&self.device, &self.sc_desc);
}
fn get_size(&self) -> (u32, u32) {
(self.sc_desc.width, self.sc_desc.height)
}
fn new_scene<R: RenderScene>(&mut self, scene: R) -> TriangleScene<R> {
TriangleScene::new(scene, &self.device, &self.queue, self.swapchain_format)
}
fn render_one<'a, R: RenderScene>(
&'a mut self,
scene: &'a mut TriangleScene<R>,
context: R::Context<'a>,
) {
let frame = self
.surface
.get_current_frame()
.expect("Failed to acquire next swap chain texture")
.output;
scene.render_one(
context,
&self.device,
&self.queue,
&frame.texture.create_view(&TextureViewDescriptor::default()),
);
}
}
|
use crate::exchange::requests::{Order, OrderStatus};
use crate::exchange::filled::Trade;
use std::collections::HashMap;
use postgres::Client;
use crate::database;
use chrono::{DateTime, Utc};
use redis::{Commands, RedisError};
use crate::buffer::BufferCollection;
// Error types for authentication
pub enum AuthError<'a> {
NoUser(&'a String), // Username
BadPassword(Option<String>), // optional error msg
}
/* This struct stores the pending orders of an account,
* provides methods to access/update a pending order,
* and can inform us if we're storing all known orders
* on the exchange.
*
* Quick architecture note about pending.
* Format: { "symbol" => {"order_id" => Order} }
* This means we can find pending orders by first
* looking up the symbol, then the order ID.
* - Solves 2 problems at once
* 1. Very easy to check if a pending order has been filled.
* 2. Fast access to orders in each market (see validate_order function).
*
**/
#[derive(Debug, Clone)]
pub struct AccountPendingOrders {
pub pending: HashMap<String, HashMap<i32, Order>>, // Orders that have not been completely filled.
pub is_complete: bool // a simple bool that represents if this account has a full picture of their orders.
}
impl AccountPendingOrders {
pub fn new() -> Self {
let pending: HashMap<String, HashMap<i32, Order>> = HashMap::new();
AccountPendingOrders {
pending,
is_complete: false
}
}
/* Returns a mutable reference to a market of pending orders in an account. */
pub fn get_mut_market(&mut self, symbol: &str) -> &mut HashMap<i32, Order> {
self.pending.entry(symbol.clone().to_string()).or_insert(HashMap::new())
}
/* Insert an order into an accounts pending orders. */
pub fn insert_order(&mut self, order: Order) {
let market = self.get_mut_market(&order.symbol.as_str());
market.insert(order.order_id, order);
}
/* After we've fetched this accounts pending orders, we call this to update the
* state of the account. This just lets the program know we don't need to fetch
* the orders again until the account is evicted from the cache.
**/
pub fn update_after_fetch(&mut self) {
self.is_complete = true;
}
pub fn view_market(&self, symbol: &str) -> Option<&HashMap<i32, Order>> {
self.pending.get(symbol)
}
/* Gives an immutable reference to an accounts pending order in a specific market. */
pub fn get_order_in_market(&self, symbol: &str, id: i32) -> Option<&Order> {
if let Some(market) = self.view_market(symbol) {
return market.get(&id);
}
return None;
}
/* Removes a pending order from the Account.
* The order IS in a market.
**/
pub fn remove_order(&mut self, symbol: &str, id: i32) {
let market = self.get_mut_market(symbol);
market.remove(&id);
}
}
// Stores data about a user
#[derive(Debug, Clone)]
pub struct UserAccount {
pub username: String,
pub password: String,
pub id: Option<i32>,
pub pending_orders: AccountPendingOrders,
pub recent_trades: Vec<Trade>, // Trades that occured since the user was brought into cache
// recent_markets is: Market symbol followed by change in number of orders since user was cached.
// If 2 orders were filled, and one new order was placed and is still pending (same market), the overall diff
// is -1.
pub recent_markets: HashMap<String, i32>,
pub modified: bool // bool representing whether account has been modified since last batch write to DB
}
impl UserAccount {
pub fn from(username: &String, password: &String) -> Self {
UserAccount {
username: username.clone(),
password: password.clone(),
id: None, // We set this later
pending_orders: AccountPendingOrders::new(),
recent_trades: Vec::new(),
recent_markets: HashMap::new(),
modified: false,
}
}
/* Used when reading values from database.*/
pub fn direct(id: i32, username: &str, password: &str) -> Self {
UserAccount {
username: username.to_string().clone(),
password: password.to_string().clone(),
id: Some(id),
pending_orders: AccountPendingOrders::new(),
recent_trades: Vec::new(),
recent_markets: HashMap::new(),
modified: false,
}
}
// Sets this account's user id, and returns it.
fn set_id(&mut self, users: &Users) -> i32 {
self.id = Some(users.total + 1);
return self.id.unwrap();
}
/*
* Returns None if this order *CANNOT* fill any pending orders placed by
* this user. Otherwise, returns Some(Order) where Order is the pending order
* that would be filled.
*
* Consider the following scenario:
* - user places buy order for 10 shares of X at $10/share.
* - the order remains on the market and is not filled.
* - later, the same user places a sell order for 3 shares of X at n <= $10/share.
* - if there are no higher buy orders, the sell will fill the original buy.
* - That is, the user will fill their own order (Trade with themselves).
*
* We *could* check for this as we make trades, but I think it's better to make the user
* explicitly resubmit their order at a valid price.
*
* Note that this function can prevent an order from being placed, even if at the moment it was
* placed, other pending orders were present that would prevent the new order from filling an
* old one. This is because the program may be multi-threaded at some point, and so we cannot
* be sure of order execution in extremely small time frames. I'm effectively preventing future
* bugs.
*
**/
pub fn validate_order(&self, order: &Order) -> Option<Order> {
if !self.pending_orders.is_complete {
panic!("\
Well, you've done it again.
You called validate_order on an account with in-complete pending order data.");
}
match self.pending_orders.view_market(&order.symbol.as_str()) {
// We only care about the market that `order` is being submitted to.
Some(market) => {
let candidates = market.values().filter(|candidate| order.action.ne(&candidate.action));
match order.action.as_str() {
"BUY" => {
let result = candidates.min_by(|x, y| x.price.partial_cmp(&y.price).expect("Tried to compare NaN!"));
if let Some(lowest_offer) = result {
if lowest_offer.price <= order.price {
return Some(lowest_offer.clone());
}
}
},
"SELL" => {
let result = candidates.max_by(|x, y| x.price.partial_cmp(&y.price).expect("Tried to compare Nan!"));
if let Some(highest_bid) = result {
if order.price <= highest_bid.price {
return Some(highest_bid.clone());
}
}
},
_ => ()
}
},
None => ()
}
return None;
}
/* If the order is in the cache, we return its action (buy/sell), else None. */
fn check_pending_order_cache(&self, symbol: &String, id: i32) -> Option<String> {
if !self.pending_orders.is_complete {
panic!("Tried to check pending order cache but the account does not have up to date pending orders.");
}
if let Some(order) = self.pending_orders.get_order_in_market(symbol.as_str(), id) {
return Some(order.action.clone()); // buy or sell
}
return None;
}
/* Check if the user with the given username owns a pending order with this id.
* If they do, return the order's action.
**/
pub fn user_placed_pending_order(&self, symbol: &String, id: i32, conn: &mut Client) -> Option<String> {
match self.check_pending_order_cache(symbol, id) {
Some(action) => return Some(action),
/* TODO:
* Recurrent issue: If it's not in the cache, but it IS in the db,
* do we want to move it into the cache? Means we need
* a mutable ref to self. Is this situation even possible?
*/
None => {
// Doesn't update cache.
return database::read_match_pending_order(self.id.unwrap(), id, conn);
}
}
}
/* Removes a pending order from an account if it exists. */
pub fn remove_order_from_account(&mut self, symbol: &String, id: i32) {
self.pending_orders.remove_order(symbol.as_str(), id);
}
/* Prints the account information of this user
* if their account view is up to date.
**/
pub fn print_user(&self) {
if !self.pending_orders.is_complete {
panic!("Tried to print_user who doesn't have complete pending order info!");
}
println!("\nAccount information for user: {}", self.username);
if !self.pending_orders.pending.is_empty() {
println!("\n\tOrders Awaiting Execution");
for (_, market) in self.pending_orders.pending.iter() {
for (_, order) in market.iter() {
println!("\t\t{:?}", order);
}
}
} else {
println!("\n\tNo Orders awaiting Execution");
}
// TODO: Make a separate method/function that populates executed_trades, this is too many
// lines for this function IMO.
let client = redis::Client::open("redis://127.0.0.1/").expect("Failed to open redis");
let mut redis_conn = client.get_connection().expect("Failed to connect to redis");
let mut executed_trades: Vec<Trade> = Vec::new();
let filler_list = format!["filler:{}", self.id.unwrap()];
let filled_list = format!["filled:{}", self.id.unwrap()];
// We gather trades from both filled, and filler lists.
let lists = vec![filler_list, filled_list];
for list in lists {
let response: Result<Vec<String>, RedisError> = redis_conn.lrange(list, 0, -1);
match response {
Ok(trades) => {
// Redis response is a string.
// We parse it and extract the components.
for trade in trades {
let mut components = trade.split_whitespace();
let symbol: &str = components.next().unwrap();
let action: &str = components.next().unwrap();
let price: f64 = components.next().unwrap().to_string().trim().parse::<f64>().unwrap();
let filled_oid: i32 = components.next().unwrap().to_string().trim().parse::<i32>().unwrap();
let filled_uid: i32 = components.next().unwrap().to_string().trim().parse::<i32>().unwrap();
let filler_oid: i32 = components.next().unwrap().to_string().trim().parse::<i32>().unwrap();
let filler_uid: i32 = components.next().unwrap().to_string().trim().parse::<i32>().unwrap();
let exchanged: i32 = components.next().unwrap().to_string().trim().parse::<i32>().unwrap();
let execution_time:
DateTime<Utc> = DateTime::parse_from_rfc3339(&components.next().unwrap().to_string().as_str()).unwrap().with_timezone(&Utc);
// Build a Trade from the data and add it to the executed_trades.
executed_trades.push(Trade::direct(symbol,
action,
price,
filled_oid,
filled_uid,
filler_oid,
filler_uid,
exchanged,
execution_time));
}
},
Err(e) => {
eprintln!("{}", e);
}
}
}
// Get any trades that have occured since the user was cached.
if self.recent_trades.len() > 0 {
executed_trades.append(&mut (self.recent_trades.clone()));
}
if executed_trades.len() > 0 {
println!("\n\tExecuted Trades");
for order in executed_trades.iter() {
println!("\t\t{:?}", order);
}
} else {
println!("\n\tNo Executed Trades to show");
}
println!("\n");
}
/* Update the redis cache active_markets:user_id.
* If we decrement a market to 0, then we remove it from the sorted set.
**/
fn redis_update_active_markets(&self, redis_conn: &mut redis::Connection) {
for (market, diff) in self.recent_markets.iter() {
let mut delete_required = false;
let response: Result<String, RedisError> = redis_conn.zincr(format!["active_markets:{}", self.id.unwrap()], market, *diff);
match response {
Ok(count) => {
let count = count.trim().parse::<i32>().unwrap();
if count == 0 {
// Remove the value from the set.
delete_required = true;
} else if count < 0 {
eprintln!("There is a bug in active_markets:{}. There are {} pending orders in our redis cache.", self.id.unwrap(), count);
panic!("This is a bug, the programmer needs to find the bad logic!");
}
},
Err(e) => {
eprintln!("{}", e);
}
}
if delete_required {
let _: () = redis_conn.zrem(format!["active_markets:{}", self.id.unwrap()], market).unwrap();
}
}
}
/* Flush the user's recent trades to Redis.
* We call this when users are evicted from cache,
* including on program shutdown.
*
* TODO: Make 2 iterators, one for filled, one for filler,
* then batch insert all trades into each list, rather
* than do 1 request per trade.
**/
fn flush_trades_to_redis(self, redis_conn: &mut redis::Connection) {
let filler_trades = self.recent_trades.iter().cloned().filter(|trade| trade.filler_uid == self.id.unwrap());
let filled_trades = self.recent_trades.iter().cloned().filter(|trade| trade.filled_uid == self.id.unwrap());
// TODO: If we can figure out multiple item inserts, use these.
// let mut filler_args: Vec<String> = Vec::new();
// let mut filled_args: Vec<String> = Vec::new();
for trade in filler_trades {
let args = format!["{} {} {} {} {} {} {} {} {}", trade.symbol,
trade.action,
trade.price,
trade.filled_oid,
trade.filled_uid,
trade.filler_oid,
trade.filler_uid,
trade.exchanged,
trade.execution_time.to_rfc3339()];
let filler_response: Result<i32, RedisError> = redis_conn.lpush(&format!["filler:{}", self.id.unwrap()], args);
if let Err(e) = filler_response {
eprintln!("{}", e);
}
// filler_args.push(format!["{} {} {} {} {} {} {} {} {}", trade.symbol, trade.action, trade.price, trade.filled_oid, trade.filled_uid, trade.filler_oid, trade.filler_uid, trade.exchanged, time]);
}
for trade in filled_trades {
let args = format!["{} {} {} {} {} {} {} {} {}", trade.symbol,
trade.action,
trade.price,
trade.filled_oid,
trade.filled_uid,
trade.filler_oid,
trade.filler_uid,
trade.exchanged,
trade.execution_time.to_rfc3339()];
let filled_response: Result<i32, RedisError> = redis_conn.lpush(&format!["filled:{}", self.id.unwrap()], args);
if let Err(e) = filled_response {
eprintln!("{}", e);
}
// filled_args.push(format!["{} {} {} {} {} {} {} {} {}", trade.symbol, trade.action, trade.price, trade.filled_oid, trade.filled_uid, trade.filler_oid, trade.filler_uid, trade.exchanged, time]);
}
}
}
// Where we store all our users
// ------------------------------------------------------------------------------------------------------
// TODO:
// We have a bit of an issue.
//
// When we make a new account, the user doesn't know their ID.
// The ID is generated for them later, and so in subsequent request,
// the user will pass their Username/Password combo to do things on our exchange.
//
// Since orders (and eventually most things) are associated with users by user_ID,
// and the users don't know their ID until we have a proper frontend that can memorize
// that data, we'll need to change our data structures.
// ------------------------------------------------------------------------------------------------------
pub struct Users {
users: HashMap<String, UserAccount>,
// TODO: This should be an LRU cache eventually
id_map: HashMap<i32, String>, // maps user_id to username
pub redis_conn: redis::Connection,
total: i32,
}
impl Users {
pub fn new() -> Self {
// TODO: How do we want to decide what the max # users is?
let max_users = 1000;
let users: HashMap<String, UserAccount> = HashMap::with_capacity(max_users);
let id_map: HashMap<i32, String> = HashMap::with_capacity(max_users);
let client = redis::Client::open("redis://127.0.0.1/").expect("Failed to open redis");
let redis_conn = client.get_connection().expect("Failed to connect to redis");
Users {
users,
id_map,
redis_conn,
total: 0
}
}
/* Update the total user count. */
pub fn direct_update_total(&mut self, conn: &mut Client) {
self.total = database::read_total_accounts(conn);
}
/* Set all UserAccount's modified field to false. */
pub fn reset_users_modified(&mut self) {
for (_key, entry) in self.users.iter_mut() {
entry.modified = false;
}
}
/* TODO: Some later PR, create a new thread to make new accounts.
*
* If an account with this username exists, do nothing, otherwise
* add the account to the database and return it's ID.
*/
pub fn new_account(&mut self, account: UserAccount, conn: &mut Client) -> Option<i32> {
// User is cached already
if self.users.contains_key(&account.username) {
return None;
} else {
// Check if the user exists.
if let true = database::read_account_exists(&account.username, conn) {
return None;
}
// User doesn't exist, so create a new one.
let mut account = account;
self.total = account.set_id(&self);
// Insert to db
match database::write_insert_new_account(&account, conn) {
Ok(()) => {
return Some(self.total);
},
Err(()) => panic!("Something went wrong while inserting a new user!")
}
}
}
pub fn print_auth_error(err: AuthError) {
match err {
AuthError::NoUser(user) => println!("Authentication failed! User ({}) not found.", user),
AuthError::BadPassword(message) => if let Some(msg) = message {
eprintln!("{}", msg);
} else {
eprintln!("Authentication failed! Incorrect password!")
}
}
}
/* Stores a user in the programs cache.
* If a user is successfully added to the cache, we return true, otherwise, return false.
**/
fn cache_user(&mut self, account: UserAccount) {
// Evict a user if we don't have space.
let capacity: f64 = self.users.capacity() as f64;
let count: f64 = self.users.len() as f64;
if capacity * 0.9 <= count {
// If no one good eviction candidates, force evictions.
if !self.evict_user(false) {
self.evict_user(true);
}
}
self.id_map.insert(account.id.unwrap(), account.username.clone());
self.users.insert(account.username.clone(), account);
}
/* Evict a user from the cache.
* If a user was evicted successfully, return true, else return false.
*
* We can only evict users who's modified fields are set to false.
* This is the only constraint on our cache eviction policy.
*
* We can have extremely simple cache eviction, ex, random or
* evict first candidate found.
*
* We could have extremely complicated cache eviction, ex.
* - keep a ranking of users by likelihood they will be
* modified again. Track things like:
* - likelihood of an order being filled (track all orders in all markets).
* - likelihood of *placing an order* again soon
* - likelihood of cancelling an order soon
*
* It remains to be seen if a basic cache eviction policy is good enough.
*
* On cache eviction, write all recent_trades of the evicted user to Redis!
**/
fn evict_user(&mut self, force_evict: bool) -> bool {
// POLICY: Delete first candidate
// Itereate over all the entries, once we find one that's not modified, stop
// iterating, make note of the key, then delete the entry.
let mut key_to_evict: Option<i32> = None;
for (_name, entry) in self.users.iter() {
if (!entry.pending_orders.is_complete) || force_evict {
key_to_evict = entry.id;
break;
}
}
// If we found a user we can evict
if let Some(key) = key_to_evict {
let username = self.id_map.remove(&key).unwrap(); // returns the value (username)
let evicted = self.users.remove(&username).unwrap();
// Write the cached data to redis
evicted.redis_update_active_markets(&mut self.redis_conn);
evicted.flush_trades_to_redis(&mut self.redis_conn);
return true;
}
// Failed to evict a user.
return false;
}
/* On shutdown, we flush all recent_trades and recent_markets to Redis. */
pub fn flush_user_cache(&mut self) {
for user in self.users.values().cloned() {
user.redis_update_active_markets(&mut self.redis_conn);
user.flush_trades_to_redis(&mut self.redis_conn);
}
}
/* Check the redis cache for the user, on success we return Some(user),
* on failure we return None.
**/
fn check_redis_user_cache(&mut self, username: &str) -> Result<Option<UserAccount>, RedisError> {
let response: Result<HashMap<String, String>, RedisError> = self.redis_conn.hgetall(format!["user:{}", username]);
match response {
Ok(map) => {
let id: i32;
let mut password = String::new();
if let Some(val) = map.get("id") {
id = val.trim().parse::<i32>().unwrap();
password.push_str(map.get("password").unwrap());
return Ok(Some(UserAccount::direct(id, username, &password)));
}
return Ok(None);
},
// Otherwise we got an err
Err(e) => return Err(e)
}
}
/* Checks the user cache*/
fn auth_check_cache<'a>(&self, username: &'a String, password: & String) -> Result<(), AuthError<'a>> {
if let Some(account) = self.users.get(username) {
// Found user in cache
if *password == account.password {
return Ok(());
}
return Err(AuthError::BadPassword(None));
}
return Err(AuthError::NoUser(username));
}
/* If the username exists and the password is correct,
* we return the user account.
*
* If the user doesn't exist, or the user exists and the
* password is incorrect, we return an error.
*
* TODO: Maybe we can return some type of session token
* for the frontend to hold on to?
*
*/
pub fn authenticate<'a>(&mut self, username: &'a String, password: &String, conn: &mut Client) -> Result<&mut UserAccount, AuthError<'a>> {
// First, we check our in-memory cache
let mut cache_miss = true;
let mut redis_miss = true;
match self.auth_check_cache(username, password) {
Ok(()) => {
cache_miss = false;
redis_miss = false;
}
Err(e) => {
if let AuthError::BadPassword(_) = e {
return Err(e);
};
}
}
// On cache miss, check redis.
if cache_miss {
match self.check_redis_user_cache(username.as_str()) {
Ok(acc) => {
if let Some(account) = acc {
// TODO: I don't like that we read the password into the program.
// I would rather have it be checked in Redis like postgres does,
// since they may do security better. But then again, I've heard
// redis security isn't great.
if &account.password == password {
// Cache the user we found
self.cache_user(account.clone());
redis_miss = false;
} else {
return Err(AuthError::BadPassword(None));
}
}
},
Err(e) => {
eprintln!("{}", e);
panic!("Something went wrong with redis.");
}
}
}
// On redis cache miss, check the database.
if redis_miss {
match database::read_auth_user(username, password, conn) {
// We got an account, move it into the cache.
Ok(account) => {
// Copy of the id
let id = account.id.unwrap();
// If we fail to cache the user, flush the buffers so we can evict users.
self.cache_user(account.clone());
// Finally, cache the user in redis
let id = id.to_string();
let v = vec![ ("id", id.as_str()),
("username", username),
("password", password)];
let _: () = self.redis_conn.hset_multiple(format!["user:{}", username], &v[..]).unwrap();
},
Err(e) => return Err(e)
}
}
// TODO: we call get twice if it was a cache hit.
// This is clearly stupid, but Rust's borrow checker is mad at me again,
// so I will figure this out later.
//
// I believe this can be fixed by storing + accessing only 1 hashmap for a cache.
// Rather than taking &mut self, we can just take &mut HashMap.
// This will be fixed once I switch to userIDs instead of usernames.
return Ok(self.users.get_mut(username).unwrap());
}
/* Returns a reference to a user account if the user has been authenticated.
* Panic's if the account isn't found, since the user is not in the cache.
*
* Note: We don't do any database lookups here. The authentication function
* is always called right before, and that cache's the user!
*/
pub fn get<'a>(&mut self, username: &'a String, authenticated: bool) -> Result<&UserAccount, AuthError<'a>> {
if authenticated {
match self.users.get(username) {
// Cached
Some(account) => return Ok(account),
// In database
None => panic!("\
Attempted to get user that was not already cached.
Be sure to call authenticate() before trying to get a reference to a user!")
}
}
let err_msg = format!["Must authenticate before accessing account belonging to: ({})", username];
return Err(AuthError::BadPassword(Some(err_msg)));
}
/* Returns a reference to a user account if the user has been authenticated.
* Panic's if the account isn't found, since the user is not in the cache.
*
* Note: We don't do any database lookups here. The authentication function
* is always called right before, and that cache's the user!
*/
pub fn get_mut<'a>(&mut self, username: &'a String, authenticated: bool) -> Result<&mut UserAccount, AuthError<'a>> {
if authenticated {
match self.users.get_mut(username) {
Some(account) => return Ok(account),
None => panic!("\
Attempted to get user that was not already cached.
Be sure to call authenticate() before trying to get a reference to a user!")
}
}
let err_msg = format!["Must authenticate before accessing account belonging to: ({})", username];
return Err(AuthError::BadPassword(Some(err_msg)));
}
/* For internal use only.
*
* If the account is in the cache (active user), we return a mutable ref to the user.
* If the account is in the database, we construct a user, cache them, get the pending orders,
* then return the UserAccount to the calling function.
*/
fn _get_mut(&mut self, username: &String, conn: &mut Client) -> &mut UserAccount {
match self.users.get_mut(username) {
Some(_) => (),
None => {
// TODO: First check redis, then check DB if redis fails.
let account: UserAccount;
let redis_response = match self.check_redis_user_cache(username.as_str()) {
Ok(response) => response,
Err(e) => {
eprintln!("{}", e);
panic!("Something went wrong while trying to get a user from Redis!")
}
};
// If we didn't find the user in Redis, check DB.
if let None = redis_response {
account = match database::read_account(username, conn) {
Ok(acc) => acc,
Err(_) => panic!("Something went wrong while trying to get a user from the database!")
};
} else {
account = redis_response.unwrap();
}
self.cache_user(account.clone());
}
}
return self.users.get_mut(username).unwrap();
}
/* Returns a username if one is found. */
fn redis_get_id_map(&mut self, id: i32) -> Option<String> {
let response: Result<Option<String>, RedisError> = self.redis_conn.hget(format!["id:{}", id], "username");
if let Ok(potential_name) = response {
if let Some(name) = potential_name {
return Some(String::from(name));
}
}
return None;
}
/* Update this users pending_orders, and the Orders table.
* We have 2 cases to consider, as explained in update_account_orders().
**/
fn update_single_user(&mut self, buffers: &mut BufferCollection, id: i32, modified_orders: &Vec<Order>, trades: &Vec<Trade>, is_filler: bool, conn: &mut Client) {
// TODO:
// At some point, we want to get the username by calling some helper access function.
// This new function will
// 1. Check the id_map cache
// 2. If ID not found, check the database
// 3. Update the id_map cache (LRU)
let username: String = match self.id_map.get(&id) {
Some(name) => name.clone(),
None => {
// Check redis for the user id -> username map
let response = self.redis_get_id_map(id);
// wasn't in redis, check the database.
if let None = response {
let result = database::read_user_by_id(id, conn);
if let Err(_) = result {
panic!("Query to get user by id failed!");
};
// Store this in redis now.
let _: () = self.redis_conn.hset(format!["id:{}", id], "username", result.as_ref().unwrap()).unwrap();
result.unwrap()
} else {
// name found in redis
response.unwrap()
}
}
};
// Gives a mutable reference to cache.
let account = self._get_mut(&username, conn);
// PER-6 set account modified to true because we're modifying their orders.
account.modified = true;
// Since we can't remove entries while iterating, store the key's here.
// We know we won't need more than trade.len() entries.
let mut entries_to_remove: Vec<i32> = Vec::with_capacity(trades.len());
// constant strings
const BUY: &str = "BUY";
const SELL: &str = "SELL";
let account_market = account.pending_orders.get_mut_market(&trades[0].symbol.as_str());
// Iterate over the trades, storing them + modifying orders in the users
// respective accounts and the buffers.
for trade in trades.iter() {
let mut id = trade.filled_oid;
let mut update_trade = trade.clone();
// If this user submitted the order that was the filler,
// we need to access the filled_by id and switch order type.
if is_filler {
id = trade.filler_oid;
if trade.action.as_str() == "BUY" {
update_trade.action = SELL.to_string();
} else {
update_trade.action = BUY.to_string();
}
// Since this account is the filler, we know every trade belongs to them
account.recent_trades.push(update_trade);
} else {
// If this user placed the order that was filled,
// add the trade to their account.
if update_trade.filled_uid == account.id.unwrap() {
account.recent_trades.push(update_trade);
}
}
// After processing the order, move it to executed trades.
match account_market.get_mut(&id) {
Some(order) => {
// We don't want to modify the filler's order at all, as that is
// done earlier (when we first submitted it to the market).
if !is_filler && (trade.exchanged == (order.quantity - order.filled)) {
// Add/update this completed order in the database buffer.
order.status = OrderStatus::COMPLETE;
order.filled = order.quantity;
buffers.buffered_orders.add_or_update_entry_in_order_buffer(&order, true); // PER-5 update
entries_to_remove.push(order.order_id);
// Get the entry in the recent_markets map, we want to decrement it by 1.
let market_diff = account.recent_markets.entry(order.symbol.clone()).or_insert(0);
*market_diff -= 1;
} else if !is_filler {
// Don't update the filler's filled count,
// new orders are added to accounts in submit_order_to_market.
order.filled += trade.exchanged;
// Add/update this pre-existing pending order to the database buffer.
buffers.buffered_orders.add_or_update_entry_in_order_buffer(&order, true); // PER-5 update
}
},
// Order not found in users in-mem account, this is because
// the user hasn't placed/cancelled an order recently.
// This is fine, as we can read the order from the modified_orders vector.
None => {
for order in modified_orders.iter() {
if order.order_id == id {
let market_diff = account.recent_markets.entry(order.symbol.clone()).or_insert(0);
if let OrderStatus::PENDING = order.status {
account_market.insert(id, order.clone());
} else {
*market_diff -= 1;
}
buffers.buffered_orders.add_or_update_entry_in_order_buffer(&order, true);
break;
}
}
}
}
}
// Remove any completed orders from the accounts pending orders.
for i in &entries_to_remove {
account_market.remove(i);
}
}
/* Given a vector of Trades, update all the accounts
* that had orders filled.
*/
pub fn update_account_orders(&mut self, modified_orders: &mut Vec<Order>, trades: &mut Vec<Trade>, buffers: &mut BufferCollection, conn: &mut Client) {
/* All orders in the vector were filled by 1 new order,
* so we have to handle 2 cases.
* 1. Update all accounts who's orders were filled by new order.
* 2. Update account of user who's order filled the old orders.
**/
// Map of {users: freshly executed trades}
let mut update_map: HashMap<i32, Vec<Trade>> = HashMap::new();
// Fill update_map
for trade in trades.iter() {
let entry = update_map.entry(trade.filled_uid).or_insert(Vec::with_capacity(trades.len()));
entry.push(trade.clone());
}
// Case 1
// TODO: This is a good candidate for multithreading.
for (user_id, new_trades) in update_map.iter() {
self.update_single_user(buffers, *user_id, modified_orders, new_trades, false, conn);
}
// Case 2: update account who placed order that filled others.
self.update_single_user(buffers, trades[0].filler_uid, modified_orders, trades, true, conn);
// Add this trade to the trades database buffer.
buffers.buffered_trades.add_trades_to_buffer(trades); // PER-5 update
}
}
|
pub mod state_trait_objects;
pub mod state_type_encoded;
use state_trait_objects::run as t_obj_run;
use state_type_encoded::run as type_enc_run;
fn main() {
t_obj_run();
type_enc_run();
} |
// -*- rust -*-
use std;
import std::str;
#[test]
fn test() {
let s = "hello";
let sb = str::buf(s);
let s_cstr = str::str_from_cstr(sb);
assert (str::eq(s_cstr, s));
let s_buf = str::str_from_buf(sb, 5u);
assert (str::eq(s_buf, s));
} |
use connection::IMAPConnection;
use imaperror::IMAPError;
use response::{Response, parse_responses};
use validate_helpers::*;
use mailbox::{Mailbox, ReadOnly};
use rand::thread_rng;
use rand::Rng;
use std::fmt;
use std::mem;
use std::ptr;
#[derive(Debug)]
pub struct Tag {
tag_prefix: String,
tag: u32,
}
#[derive(Debug)]
pub struct NotAuthenticated {
connection: IMAPConnection,
parsed_responses: Vec<Response>,
tag: Tag,
}
#[derive(Debug)]
pub struct Authenticated {
connection: IMAPConnection,
parsed_responses: Vec<Response>,
tag: Tag,
}
#[derive(Debug)]
pub struct Selected {
connection: IMAPConnection,
parsed_responses: Vec<Response>,
mailbox: Mailbox,
tag: Tag,
}
#[derive(Debug)]
pub struct LoggedOut {
connection: IMAPConnection,
parsed_responses: Vec<Response>,
tag: Tag,
}
impl Tag {
fn new() -> Tag {
let mut rng = thread_rng();
let rstr: String = rng.gen_ascii_chars()
.take(4)
.collect();
Tag {
tag_prefix: rstr,
tag: rng.gen_ascii_chars().next().unwrap() as u32,
}
}
/// Increments and then returns the tag.
pub fn next_tag(mut self) -> Self {
self.tag += 1;
self
}
}
impl fmt::Display for Tag {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}{:04}", self.tag_prefix, self.tag)
}
}
impl NotAuthenticated {
pub fn new(connection: IMAPConnection) -> Result<NotAuthenticated, IMAPError> {
let mut connection = connection;
let raw_res = try!(connection.command(""));
let greeting = validate_greeting(&raw_res[..]);
Ok(NotAuthenticated {
connection: connection,
parsed_responses: parse_responses(&raw_res[..]),
tag: Tag::new(),
})
}
pub fn login(mut self,
username: &str,
passwd: &str)
-> Result<Authenticated, (NotAuthenticated, IMAPError)> {
let login_response = try_imap!(self,
self.connection
.command(&format!("{} LOGIN {} {}",
self.tag,
username,
passwd)));
let _ = try_imap!(self, validate_login(&login_response[..]));
Ok(Authenticated {
connection: self.connection,
parsed_responses: parse_responses(&login_response[..]),
tag: self.tag.next_tag(),
})
}
pub fn logout(mut self) -> Result<LoggedOut, (NotAuthenticated, IMAPError)> {
let logout_response = try_imap!(self, self.connection.command("fake login command"));
Ok(LoggedOut {
connection: self.connection,
parsed_responses: parse_responses(&logout_response[..]),
tag: self.tag.next_tag(),
})
}
}
impl Authenticated {
pub fn select(mut self, mailbox: &str) -> Result<Selected, (Authenticated, IMAPError)> {
let select_response = try_imap!(self,
self.connection
.command(&format!("{} SELECT {}", self.tag, mailbox)));
let _ = try_imap!(self, validate_select(&select_response[..]));
// This is unsfae due to the use of mem::uninitialized::<T>()
// Because we can not borrow &mut self.connection, as it is moved,
// we have to temporarily create an unsafe Selected, and then create
// a reference to *its* connection, to initialize the mailbox
let mut selected = unsafe {
let mut selected = Selected {
connection: self.connection,
parsed_responses: parse_responses(&select_response[..]),
mailbox: mem::uninitialized(),
tag: self.tag.next_tag(),
};
ptr::write(&mut selected.mailbox,
ReadOnly::new(&mut selected.connection));
selected
};
Ok(selected)
}
pub fn logout(mut self) -> Result<LoggedOut, (Authenticated, IMAPError)> {
let logout_response = try_imap!(self, self.connection.command("fake login command"));
Ok(LoggedOut {
connection: self.connection,
parsed_responses: parse_responses(&logout_response[..]),
tag: self.tag.next_tag(),
})
}
}
impl Selected {
pub fn borrow_mailbox(&mut self) -> &mut Mailbox {
&mut self.mailbox
}
pub fn logout(mut self) -> Result<LoggedOut, (Selected, IMAPError)> {
let logout_response = try_imap!(self, self.connection.command("fake logout command"));
Ok(LoggedOut {
connection: self.connection,
parsed_responses: parse_responses(&logout_response[..]),
tag: self.tag.next_tag(),
})
}
}
impl LoggedOut {}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {}
}
|
use crate::read_prefs::pobierz_ustawienia;
//use rocket::http::ext::IntoCollection;
//use std::borrow::Borrow;
use crate::web::struktura_chat::MessageChat;
//use std::sync::Mutex;
use crate::dbus::{Gracz, dbus_get_online_players};
pub fn _wypelnij_game_params_icons() -> String {
let mut wyjscie = String::new();
let mut wartosc;// = String::new();
wyjscie.push_str(format!(r#"<div id="CANVAS_1"><table id="_GAME_PARAMS_ICONS">"#).as_str());
//generujemy zawartosc tabeli
let settingsy = pobierz_ustawienia().property;
for p in settingsy {
match p.name.to_ascii_lowercase().as_str() {
"servervisibility" => {
wartosc = String::from(r#"<img src="/graphics/eye_hidden.svg" title="Hidden or Private Server" height="25">"#);
if p.value.as_str() == "2" { wartosc = String::from(r#"<img src="/graphics/eye_look.svg" title="Public Server" height="25">"#); }
wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Visibility:", wartosc).as_str())
}
"servermaxplayercount" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Max Players:", p.value).as_str()) }
"gameworld" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1"><div title="{}">{}</div></td></tr>"#, "World Type:", p.value, p.value).as_str()) }
"dropondeath" => {
wartosc = String::from(r#"<img src="/graphics/nope.svg" title="Nothing" height="25">"#);
if p.value.as_str() == "1" { wartosc = String::from(r#"<img src="/graphics/backpack_toolbelt.svg" title="Everything" height="25">"#); } else if p.value.as_str() == "2" { wartosc = String::from(r#"<img src="/graphics/toolbelt.svg" title="Toolbelt" height="25">"#); } else if p.value.as_str() == "3" { wartosc = String::from(r#"<img src="/graphics/backpack.svg" title="Backpack" height="25">"#); } else if p.value.as_str() == "4" { wartosc = String::from(r#"<img src="/graphics/trash.svg" title="Delete all" height="25">"#); }
wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Drop on death:", wartosc).as_str())
}
"enemydifficulty" => {
wartosc = String::from(r#"Normal"#);
if p.value.as_str() == "1" { wartosc = String::from(r#"Feral"#); }
wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Enemy Level:", wartosc).as_str())
}
//"dropondeath" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#,"Drop on Death:",p.value).as_str()) }
//"bedrollexpirytime" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#,"Bedroll Expiry:",p.value).as_str()) }
"gamedifficulty" => {
wartosc = String::from(r#"<img src="/graphics/difficulty_0.svg" title="Scavenger" height="20">"#);
if p.value.as_str() == "1" { wartosc = String::from(r#"<img src="/graphics/difficulty_1.svg" title="Adventurer" height="20">"#); } else if p.value.as_str() == "2" { wartosc = String::from(r#"<img src="/graphics/difficulty_2.svg" title="Nomad" height="20">"#); } else if p.value.as_str() == "3" { wartosc = String::from(r#"<img src="/graphics/difficulty_3.svg" title="Warrior" height="20">"#); } else if p.value.as_str() == "4" { wartosc = String::from(r#"<img src="/graphics/difficulty_4.svg" title="Survivalist" height="20">"#); } else if p.value.as_str() == "5" { wartosc = String::from(r#"<img src="/graphics/difficulty_5.svg" title="Insane!" height="20">"#); }
wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Difficulty:", wartosc).as_str())
}
"playerkillingmode" => {
wartosc = String::from(r#"<img src="/graphics/peace.svg" title="No Killing (PvE)" height="20">"#);
if p.value.as_str() == "1" { wartosc = String::from(r#"Kill Allies Only"#); } else if p.value.as_str() == "2" { wartosc = String::from(r#"Kill Strangers Only"#); } else if p.value.as_str() == "3" { wartosc = String::from(r#"Kill Everyone!"#); }
wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Player versus:", wartosc).as_str())
}
"landclaimexpirytime" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "LCB Time:", p.value).as_str()) }
"airdropfrequency" => { wyjscie.push_str(format!(r#"<tr><td>{}</td><td class="_td1">{}</td></tr>"#, "Airdrops:", p.value).as_str()) }
_ => {}
}
}
wyjscie.push_str(format!(r#"</table></div>"#).as_str());
wyjscie
}
//wypelniamy chat tablicą graczy online
pub fn _wypelnij_chat_users(mut users_vector: Vec<Gracz>) -> String {
let mut wyjscie = String::new();
#[allow(unused)]
let mut user_type = String::from("chat_user_player");
wyjscie.push_str(format!(r#"<div id="CANVAS_CHAT_USERS"><div id="CANVAS_CHAT_USERS_REF">"#).as_str());
users_vector.sort(); //TODO sprawdzic czy sortowanie dziala
for user in users_vector {
if user.is_admin == true { user_type = "chat_user_admin".to_string(); }
else {user_type = "chat_user_player".to_string();}
let title = format!("({})[{}]",&user.player_id, &user.nazwa);
wyjscie.push_str(format!(r#"<span title="{}" class="{}">{}</span><br>"#, title, user_type, &user.nazwa).as_str());
}
wyjscie.push_str(format!(r#"</div></div>"#).as_str());
wyjscie
}
//wypelniamy chat wiadomościami
pub fn _wypelnij_chat(chat_vector: &Vec<MessageChat>) -> String {
let mut wyjscie = String::new();
let userzy = dbus_get_online_players().unwrap_or_default();
wyjscie.push_str(format!(r#"<div id="CANVAS_CHAT"><div id="CANVAS_CHAT_REF">"#).as_str());
/* tutaj wywolujemy funkcję, ktora zwraca tablicę 1000 ostatnich wiadomości
tablicę formatujemy do html */
let mut chat_user = String::new();
//TODO rozwiazac kolorowanie skladni jesli pisze admin z gry
for wartosc in chat_vector {
if !String::is_empty(&wartosc.user) {
match wartosc.user.as_str() {
"Server" => {chat_user = String::from("chat_user_server");} //say command
"Admin" => {chat_user = String::from("chat_user_admin");} //from web
&_ => {
for gracz in &userzy { //jesli nazwa usera pasuje do nazwy gracza z listy i ten jest adminem
if gracz.nazwa == wartosc.user.as_str() && gracz.is_admin {
chat_user = String::from("chat_user_admin");
}
else if gracz.nazwa == wartosc.user.as_str() && !gracz.is_admin {
chat_user = String::from("chat_user_player");
}
/*if (gracz.is_admin) {chat_user = String::from("chat_user_admin");}
else {chat_user = String::from("chat_user_player");}*/
}
} //others - split to admins and players
}
wyjscie.push_str(format!(r#"
<span class="{}">{}</span>
<span class="chat_type">({})</span>
<span class="chat_date">({})</span><br>
<span class="chat_msg">{}</span><br>"#, chat_user, &wartosc.user, &wartosc.etype, &wartosc.date, &wartosc.message).as_str());
}
}
wyjscie.push_str(format!(r#"</div></div>"#).as_str());
wyjscie
} |
use failure::{bail, ensure, err_msg, Error, ResultExt};
use ffmpeg::frame::Video as VideoFrame;
use ffmpeg::{format, Rational};
use lazy_static::lazy_static;
use std::ops::Deref;
use std::result;
use std::sync::mpsc::{channel, Receiver, Sender, TryRecvError};
use std::sync::{Mutex, Once, RwLock, ONCE_INIT};
use std::thread;
use crate::encode::{Encoder, EncoderParameters};
use crate::engine::{Engine, MainThreadMarker};
use crate::fps_converter::*;
use crate::hooks::hw;
// use profiler::*;
use crate::utils::format_error;
type Result<T> = result::Result<T, Error>;
lazy_static! {
static ref CAPTURING: RwLock<bool> = RwLock::new(false);
/// Receives buffers to write pixels to.
static ref VIDEO_BUF_RECEIVER: Mutex<Option<Receiver<VideoBuffer>>> = Mutex::new(None);
/// Receives buffers to write samples to.
static ref AUDIO_BUF_RECEIVER: Mutex<Option<Receiver<AudioBuffer>>> = Mutex::new(None);
/// Receives various game thread-related events, such as console messages to print.
static ref GAME_THREAD_RECEIVER: Mutex<Option<Receiver<GameThreadEvent>>> = Mutex::new(None);
/// Sends events and frames to encode to the capture thread.
static ref SEND_TO_CAPTURE_THREAD: Mutex<Option<Sender<CaptureThreadEvent>>> = Mutex::new(None);
}
thread_local! {
// pub static GAME_THREAD_PROFILER: RefCell<Option<Profiler>> = RefCell::new(None);
// pub static AUDIO_PROFILER: RefCell<Option<Profiler>> = RefCell::new(None);
// pub static CAPTURE_THREAD_PROFILER: RefCell<Option<Profiler>> = RefCell::new(None);
}
pub struct CaptureParameters {
pub sampling_exposure: f64,
pub sampling_time_base: Option<Rational>,
pub sound_extra: f64,
pub time_base: Rational,
pub volume: f32,
}
enum CaptureThreadEvent {
CaptureStart(EncoderParameters),
CaptureStop,
VideoFrame((VideoBuffer, usize)),
AudioFrame(AudioBuffer),
}
pub enum GameThreadEvent {
Message(String),
EncoderPixelFormat(format::Pixel),
}
pub struct VideoBuffer {
data: Vec<u8>,
width: u32,
height: u32,
format: format::Pixel,
components: u8,
frame: VideoFrame,
data_is_in_frame: bool,
}
pub struct AudioBuffer {
data: Vec<(i16, i16)>,
}
struct SendOnDrop<'a, T> {
buffer: Option<T>,
channel: &'a Sender<T>,
}
impl VideoBuffer {
#[inline]
fn new() -> Self {
Self { data: Vec::new(),
width: 0,
height: 0,
format: format::Pixel::RGB24,
components: format::Pixel::RGB24.descriptor().unwrap().nb_components(),
frame: VideoFrame::empty(),
data_is_in_frame: false }
}
#[inline]
pub fn set_resolution(&mut self, width: u32, height: u32) {
if self.width != width || self.height != height {
println!("Changing resolution from {}×{} to {}×{}.",
self.width, self.height, width, height);
self.width = width;
self.height = height;
}
}
#[inline]
pub fn set_format(&mut self, format: format::Pixel) {
if self.format != format {
println!("Changing format from {:?} to {:?}", self.format, format);
self.format = format;
self.components = format.descriptor()
.expect("invalid pixel format")
.nb_components();
}
}
pub fn as_mut_slice(&mut self) -> &mut [u8] {
self.data_is_in_frame = false;
self.data
.resize((self.width * self.height * u32::from(self.components)) as usize,
0);
self.data.as_mut_slice()
}
pub fn get_frame(&mut self) -> &mut VideoFrame {
self.data_is_in_frame = true;
if self.width != self.frame.width()
|| self.height != self.frame.height()
|| self.format != self.frame.format()
{
self.frame = VideoFrame::new(self.format, self.width, self.height);
}
&mut self.frame
}
pub fn copy_to_frame(&self, frame: &mut VideoFrame) {
// Make sure the frame is of correct size.
if self.width != frame.width()
|| self.height != frame.height()
|| self.format != frame.format()
{
*frame = VideoFrame::new(self.format, self.width, self.height);
}
if self.data_is_in_frame {
for i in 0..frame.planes() {
frame.data_mut(i).copy_from_slice(self.frame.data(i));
}
} else {
let mut offset = 0;
let components_per_plane = if frame.planes() == 1 {
self.components
} else {
1
} as usize;
for i in 0..frame.planes() {
let stride = frame.stride(i);
let plane_width = frame.plane_width(i) as usize;
let plane_height = frame.plane_height(i) as usize;
let plane_data = frame.data_mut(i);
for y in 0..plane_height {
let plane_data_start = (plane_height - y - 1) * stride;
let length = plane_width * components_per_plane;
plane_data[plane_data_start..plane_data_start + length]
.copy_from_slice(&self.data[offset..offset + length]);
offset += length;
}
}
}
}
}
impl AudioBuffer {
#[inline]
fn new() -> Self {
Self { data: Vec::new() }
}
#[inline]
pub fn data(&self) -> &Vec<(i16, i16)> {
&self.data
}
#[inline]
pub fn data_mut(&mut self) -> &mut Vec<(i16, i16)> {
&mut self.data
}
}
impl<'a, T> SendOnDrop<'a, T> {
#[inline]
fn new(buffer: T, channel: &'a Sender<T>) -> Self {
Self { buffer: Some(buffer),
channel }
}
}
impl<T> Drop for SendOnDrop<'_, T> {
#[inline]
fn drop(&mut self) {
self.channel.send(self.buffer.take().unwrap()).unwrap();
}
}
impl<T> Deref for SendOnDrop<'_, T> {
type Target = T;
#[inline]
fn deref(&self) -> &T {
self.buffer.as_ref().unwrap()
}
}
fn capture_thread(video_buf_sender: &Sender<VideoBuffer>,
audio_buf_sender: &Sender<AudioBuffer>,
event_sender: &Sender<GameThreadEvent>,
event_receiver: &Receiver<CaptureThreadEvent>) {
// Send the buffers to the game thread right away.
video_buf_sender.send(VideoBuffer::new()).unwrap();
audio_buf_sender.send(AudioBuffer::new()).unwrap();
// This is our frame which will only be reallocated on resolution changes.
let mut frame = VideoFrame::empty();
// This is set to true on encoding error or cap_stop and reset on cap_start.
// When this is true, ignore any received frames.
let mut drop_frames = true;
// The encoder itself.
let mut encoder: Option<Encoder> = None;
// Event loop for the capture thread.
loop {
match event_receiver.recv().unwrap() {
CaptureThreadEvent::CaptureStart(params) => {
drop_frames = false;
encoder = Encoder::start(¶ms).context({
"could not start the encoder; check your terminal (Half-Life's \
standard output) for ffmpeg messages"
})
.map_err(|e| {
*CAPTURING.write().unwrap() = false;
drop_frames = true;
event_sender.send(GameThreadEvent::Message(format_error(&e.into())))
.unwrap();
})
.ok();
if let Some(ref encoder) = encoder {
event_sender.send(GameThreadEvent::EncoderPixelFormat(encoder.format()))
.unwrap();
}
}
CaptureThreadEvent::CaptureStop => {
stop_encoder(encoder.take(), event_sender);
drop_frames = true;
}
CaptureThreadEvent::VideoFrame((buffer, times)) => {
let buffer = SendOnDrop::new(buffer, video_buf_sender);
if drop_frames {
continue;
}
if let Err(e) = encode(&mut encoder, buffer, times, &mut frame) {
event_sender.send(GameThreadEvent::Message(format_error(&e)))
.unwrap();
*CAPTURING.write().unwrap() = false;
stop_encoder(encoder.take(), event_sender);
drop_frames = true;
}
}
CaptureThreadEvent::AudioFrame(buffer) => {
let buffer = SendOnDrop::new(buffer, audio_buf_sender);
if drop_frames {
continue;
}
// Encode the audio.
let result = encoder.as_mut().unwrap().take_audio(buffer.data());
drop(buffer);
if let Err(e) = result {
event_sender.send(GameThreadEvent::Message(format_error(&e)))
.unwrap();
*CAPTURING.write().unwrap() = false;
stop_encoder(encoder.take(), event_sender);
drop_frames = true;
}
}
}
}
}
fn encode(encoder: &mut Option<Encoder>,
buf: SendOnDrop<'_, VideoBuffer>,
times: usize,
frame: &mut VideoFrame)
-> Result<()> {
// Copy pixels into our video frame.
buf.copy_to_frame(frame);
// We're done with buf, now it can receive the next pack of pixels.
drop(buf);
let encoder = encoder.as_mut().unwrap();
ensure!((frame.width(), frame.height()) == (encoder.width(), encoder.height()),
"resolution changes are not supported");
// Encode the frame.
encoder.take(frame, times)
.context("could not encode the frame")?;
Ok(())
}
/// Properly closes and drops the encoder.
fn stop_encoder(encoder: Option<Encoder>, event_sender: &Sender<GameThreadEvent>) {
if let Some(mut encoder) = encoder {
if let Err(e) = encoder.finish() {
event_sender.send(GameThreadEvent::Message(format_error(&e)))
.unwrap();
}
drop(encoder);
}
}
pub fn initialize(_: MainThreadMarker<'_>) {
static INIT: Once = ONCE_INIT;
INIT.call_once(|| {
let (tx, rx) = channel::<VideoBuffer>();
let (tx2, rx2) = channel::<AudioBuffer>();
let (tx3, rx3) = channel::<GameThreadEvent>();
let (tx4, rx4) = channel::<CaptureThreadEvent>();
*VIDEO_BUF_RECEIVER.lock().unwrap() = Some(rx);
*AUDIO_BUF_RECEIVER.lock().unwrap() = Some(rx2);
*GAME_THREAD_RECEIVER.lock().unwrap() = Some(rx3);
*SEND_TO_CAPTURE_THREAD.lock().unwrap() = Some(tx4);
thread::spawn(move || capture_thread(&tx, &tx2, &tx3, &rx4));
});
}
#[inline]
pub fn get_buffer(_: MainThreadMarker<'_>, (width, height): (u32, u32)) -> VideoBuffer {
let mut buf = VIDEO_BUF_RECEIVER.lock()
.unwrap()
.as_ref()
.unwrap()
.recv()
.unwrap();
buf.set_resolution(width, height);
buf
}
#[inline]
pub fn get_audio_buffer(_: MainThreadMarker<'_>) -> AudioBuffer {
AUDIO_BUF_RECEIVER.lock()
.unwrap()
.as_ref()
.unwrap()
.recv()
.unwrap()
}
#[inline]
pub fn get_event(_: MainThreadMarker<'_>) -> Option<GameThreadEvent> {
match GAME_THREAD_RECEIVER.lock()
.unwrap()
.as_ref()
.unwrap()
.try_recv()
{
Ok(event) => Some(event),
Err(TryRecvError::Empty) => None,
Err(TryRecvError::Disconnected) => unreachable!(),
}
}
#[inline]
pub fn get_event_block(_: MainThreadMarker<'_>) -> GameThreadEvent {
GAME_THREAD_RECEIVER.lock()
.unwrap()
.as_ref()
.unwrap()
.recv()
.unwrap()
}
#[inline]
pub fn capture(_: MainThreadMarker<'_>, buf: VideoBuffer, times: usize) {
SEND_TO_CAPTURE_THREAD.lock()
.unwrap()
.as_ref()
.unwrap()
.send(CaptureThreadEvent::VideoFrame((buf, times)))
.unwrap();
}
#[inline]
pub fn capture_audio(_: MainThreadMarker<'_>, buf: AudioBuffer) {
SEND_TO_CAPTURE_THREAD.lock()
.unwrap()
.as_ref()
.unwrap()
.send(CaptureThreadEvent::AudioFrame(buf))
.unwrap();
}
#[inline]
pub fn is_capturing() -> bool {
*CAPTURING.read().unwrap()
}
#[inline]
pub fn get_capture_parameters(engine: &Engine) -> &CaptureParameters {
engine.data().capture_parameters.as_ref().unwrap()
}
pub fn stop(engine: &mut Engine) {
if !is_capturing() {
return;
}
hw::capture_remaining_sound(engine);
*CAPTURING.write().unwrap() = false;
engine.data_mut().fps_converter = None;
engine.data_mut().encoder_pixel_format = None;
SEND_TO_CAPTURE_THREAD.lock()
.unwrap()
.as_ref()
.unwrap()
.send(CaptureThreadEvent::CaptureStop)
.unwrap();
// GAME_THREAD_PROFILER.with(|p| if let Some(p) = p.borrow_mut().take() {
// if let Ok(data) = p.get_data() {
// let mut buf = format!("Captured {} frames. Game thread overhead: {:.3} msec:\n",
// data.lap_count,
// data.average_lap_time);
//
// for &(section, time) in &data.average_section_times {
// buf.push_str(&format!("- {:.3} msec: {}\n", time, section));
// }
//
// engine.con_print(&buf);
// }
// });
// AUDIO_PROFILER.with(|p| if let Some(p) = p.borrow_mut().take() {
// if let Ok(data) = p.get_data() {
// let mut buf = format!("Audio overhead: {:.3} msec:\n",
// data.average_lap_time);
//
// for &(section, time) in &data.average_section_times {
// buf.push_str(&format!("- {:.3} msec: {}\n", time, section));
// }
//
// engine.con_print(&buf);
// }
// });
}
/// Parses the given string and returns a time base.
///
/// The string can be in one of the two formats:
/// - `<i32 FPS>` - treated as an integer FPS value,
/// - `<i32 a> <i32 b>` - treated as a fractional `a/b` FPS value.
fn parse_fps(string: &str) -> Option<Rational> {
if let Ok(fps) = string.parse() {
if fps <= 0 {
return None;
}
return Some((1, fps).into());
}
let mut split = string.splitn(2, ' ');
if let Some(den) = split.next().and_then(|s| s.parse().ok()) {
if let Some(num) = split.next().and_then(|s| s.parse().ok()) {
if num <= 0 || den <= 0 {
return None;
}
return Some((num, den).into());
}
}
None
}
/// Parses the given string into a valid exposure value.
#[inline]
fn parse_exposure(string: &str) -> Result<f64> {
string.parse::<f64>()
.context("could not convert the string to a floating point value")
.map_err(|e| e.into())
.and_then(|x| {
if x > 0f64 && x <= 1f64 {
Ok(x)
} else {
bail!("allowed exposure values range \
from 0 (non-inclusive) to 1 (inclusive)")
}
})
}
/// Parses the given string into a pixel format.
#[inline]
fn parse_pixel_format(string: &str) -> Result<format::Pixel> {
if string.is_empty() {
Ok(format::Pixel::None)
} else {
Ok(string.parse::<format::Pixel>()
.context("could not convert the string to a pixel format")?)
}
}
macro_rules! to_string {
($engine:expr, $cvar:expr) => {
$cvar.to_string($engine)
.context(concat!("invalid ", stringify!($cvar)))?
};
}
macro_rules! parse {
($engine:expr, $cvar:expr) => {
$cvar.parse($engine)
.context(concat!("invalid ", stringify!($cvar)))?
};
($engine:expr, $cvar:expr, $type:ty) => {
$cvar.parse::<$type>($engine)
.context(concat!("invalid ", stringify!($cvar)))?
};
}
/// Parses the CVar values into `EncoderParameters`.
#[inline]
fn parse_encoder_parameters(engine: &mut Engine) -> Result<EncoderParameters> {
Ok(EncoderParameters {
audio_bitrate: parse!(engine, cap_audio_bitrate, usize) * 1000,
video_bitrate: parse!(engine, cap_video_bitrate, usize) * 1000,
crf: to_string!(engine, cap_crf),
filename: to_string!(engine, cap_filename),
muxer_settings: to_string!(engine, cap_muxer_settings),
pixel_format: parse_pixel_format(&to_string!(engine, cap_pixel_format))
.context("invalid cap_pixel_format")?,
preset: to_string!(engine, cap_x264_preset),
time_base: parse_fps(&to_string!(engine, cap_fps))
.ok_or_else(|| err_msg("invalid cap_fps"))?,
audio_encoder_settings: to_string!(engine, cap_audio_encoder_settings),
video_encoder_settings: to_string!(engine, cap_video_encoder_settings),
vpx_threads: to_string!(engine, cap_vpx_threads),
video_resolution: hw::get_resolution(engine.marker().1),
})
}
/// Parses the CVar values into `CaptureParameters`.
#[inline]
fn parse_capture_parameters(engine: &mut Engine) -> Result<CaptureParameters> {
Ok(CaptureParameters {
sampling_exposure: parse_exposure(&to_string!(engine, cap_sampling_exposure))
.context("invalid cap_sampling_exposure")?,
sampling_time_base: parse_fps(&to_string!(engine, cap_sampling_sps)),
sound_extra: parse!(engine, cap_sound_extra),
time_base: parse_fps(&to_string!(engine, cap_fps))
.ok_or_else(|| err_msg("invalid cap_fps"))?,
volume: parse!(engine, cap_volume),
})
}
/// Starts and stops the encoder.
fn test_encoder(parameters: &EncoderParameters) -> Result<()> {
let mut encoder = Encoder::start(parameters).context({
"could not start the encoder; check your terminal (Half-Life's \
standard output) for ffmpeg messages"
})?;
encoder.finish().context("could not finish the encoder")?;
Ok(())
}
command!(cap_start, |mut engine| {
if is_capturing() {
engine.con_print("Already capturing, please stop the capturing with cap_stop \
before starting it again.\n");
return;
}
let parameters = match parse_encoder_parameters(&mut engine) {
Ok(p) => p,
Err(ref e) => {
engine.con_print(&format_error(e));
return;
}
};
engine.data_mut().capture_parameters = match parse_capture_parameters(&mut engine) {
Ok(p) => Some(p),
Err(ref e) => {
engine.con_print(&format_error(e));
return;
}
};
engine.data_mut().fps_converter = if engine.data()
.capture_parameters
.as_ref()
.unwrap()
.sampling_time_base
.is_some()
{
Some(FPSConverters::Sampling(SamplingConverter::new(&mut engine,
parameters.time_base.into(),
parameters.video_resolution)))
} else {
Some(FPSConverters::Simple(SimpleConverter::new(parameters.time_base.into())))
};
*CAPTURING.write().unwrap() = true;
SEND_TO_CAPTURE_THREAD.lock()
.unwrap()
.as_ref()
.unwrap()
.send(CaptureThreadEvent::CaptureStart(parameters))
.unwrap();
// GAME_THREAD_PROFILER.with(|p| *p.borrow_mut() = Some(Profiler::new()));
// AUDIO_PROFILER.with(|p| *p.borrow_mut() = Some(Profiler::new()));
hw::reset_sound_capture_remainder(&mut engine);
});
command!(cap_stop, |mut engine| {
stop(&mut engine);
});
command!(cap_test, |mut engine| {
let parameters = match parse_encoder_parameters(&mut engine) {
Ok(p) => p,
Err(ref e) => {
engine.con_print(&format_error(e));
return;
}
};
let _capture_parameters = match parse_capture_parameters(&mut engine) {
Ok(p) => Some(p),
Err(ref e) => {
engine.con_print(&format_error(e));
return;
}
};
if let Err(ref e) = test_encoder(¶meters) {
engine.con_print(&format_error(e));
} else {
engine.con_print("Capture was started and stopped successfully.\n");
}
});
command!(cap_version, |engine| {
engine.con_print(concat!(env!("CARGO_PKG_NAME"),
" v",
env!("CARGO_PKG_VERSION"),
" by Ivan \"YaLTeR\" Molodetskikh\n"));
});
// Encoder parameters.
cvar!(cap_video_bitrate, "0");
cvar!(cap_audio_bitrate, "256");
cvar!(cap_crf, "15");
cvar!(cap_filename, "capture.mp4");
cvar!(cap_fps, "60");
cvar!(cap_muxer_settings, "movflags=+faststart");
cvar!(cap_pixel_format, "");
cvar!(cap_audio_encoder_settings, "");
cvar!(cap_video_encoder_settings, "");
cvar!(cap_vpx_threads, "8");
cvar!(cap_x264_preset, "veryfast");
// Capture parameters.
cvar!(cap_sampling_exposure, "0.5");
cvar!(cap_sampling_sps, "");
cvar!(cap_sound_extra, "0");
cvar!(cap_volume, "0.4");
|
use std::convert::TryInto;
use admin_controlled::{AdminControlled, Mask};
use near_contract_standards::fungible_token::metadata::FungibleTokenMetadata;
use near_contract_standards::storage_management::StorageBalance;
use near_sdk::borsh::{self, BorshDeserialize, BorshSerialize};
use near_sdk::collections::UnorderedSet;
use near_sdk::json_types::U128;
use near_sdk::{
env, ext_contract, near_bindgen, AccountId, Balance, Gas, PanicOnDefault, Promise,
PromiseOrValue,
};
use bridge_common::prover::{
ext_prover, validate_eth_address, EthAddress, Proof, FT_TRANSFER_CALL_GAS, FT_TRANSFER_GAS,
NO_DEPOSIT, PAUSE_DEPOSIT, STORAGE_BALANCE_CALL_GAS, VERIFY_LOG_ENTRY_GAS,
};
use bridge_common::{parse_recipient, result_types, Recipient};
use near_sdk_inner::collections::UnorderedMap;
use near_sdk_inner::BorshStorageKey;
use whitelist::WhitelistMode;
use crate::unlock_event::EthUnlockedEvent;
mod token_receiver;
mod unlock_event;
mod whitelist;
/// Gas to call finish withdraw method.
/// This doesn't cover the gas required for calling transfer method.
const FINISH_WITHDRAW_GAS: Gas = Gas(Gas::ONE_TERA.0 * 30);
/// Gas to call finish deposit method.
const FT_FINISH_DEPOSIT_GAS: Gas = Gas(Gas::ONE_TERA.0 * 10);
/// Gas for fetching metadata of token.
const FT_GET_METADATA_GAS: Gas = Gas(Gas::ONE_TERA.0 * 10);
/// Gas for emitting metadata info.
const FT_FINISH_LOG_METADATA_GAS: Gas = Gas(Gas::ONE_TERA.0 * 30);
/// Gas to call storage balance callback method.
const FT_STORAGE_BALANCE_CALLBACK_GAS: Gas = Gas(Gas::ONE_TERA.0 * 10);
#[derive(BorshSerialize, BorshStorageKey)]
enum StorageKey {
UsedEvents,
WhitelistTokens,
WhitelistAccounts,
}
#[near_bindgen]
#[derive(BorshDeserialize, BorshSerialize, PanicOnDefault)]
pub struct Contract {
/// The account of the prover that we can use to prove.
pub prover_account: AccountId,
/// Ethereum address of the token factory contract, in hex.
pub eth_factory_address: EthAddress,
/// Hashes of the events that were already used.
pub used_events: UnorderedSet<Vec<u8>>,
/// Mask determining all paused functions
paused: Mask,
/// Mapping whitelisted tokens to their mode
pub whitelist_tokens: UnorderedMap<AccountId, WhitelistMode>,
/// Mapping whitelisted accounts to their whitelisted tokens by using combined key {token}:{account}
pub whitelist_accounts: UnorderedSet<String>,
/// The mode of the whitelist check
pub is_whitelist_mode_enabled: bool,
}
#[ext_contract(ext_self)]
pub trait ExtContract {
#[result_serializer(borsh)]
fn finish_deposit(
&self,
#[serializer(borsh)] token: AccountId,
#[serializer(borsh)] amount: Balance,
#[serializer(borsh)] recipient: EthAddress,
) -> result_types::Lock;
#[result_serializer(borsh)]
fn finish_withdraw(
&self,
#[callback]
#[serializer(borsh)]
verification_success: bool,
#[serializer(borsh)] token: String,
#[serializer(borsh)] new_owner_id: String,
#[serializer(borsh)] amount: Balance,
#[serializer(borsh)] proof: Proof,
) -> Promise;
#[result_serializer(borsh)]
fn finish_log_metadata(
&self,
#[callback] metadata: FungibleTokenMetadata,
token_id: AccountId,
) -> result_types::Metadata;
fn storage_balance_callback(
&self,
#[callback] storage_balance: Option<StorageBalance>,
#[serializer(borsh)] proof: Proof,
#[serializer(borsh)] token: String,
#[serializer(borsh)] recipient: AccountId,
#[serializer(borsh)] amount: Balance,
);
}
#[ext_contract(ext_token)]
pub trait ExtToken {
fn ft_transfer(
&mut self,
receiver_id: AccountId,
amount: U128,
memo: Option<String>,
) -> PromiseOrValue<U128>;
fn ft_transfer_call(
&mut self,
receiver_id: AccountId,
amount: U128,
memo: Option<String>,
msg: String,
) -> PromiseOrValue<U128>;
fn ft_metadata(&self) -> FungibleTokenMetadata;
fn storage_balance_of(&mut self, account_id: Option<AccountId>) -> Option<StorageBalance>;
}
#[near_bindgen]
impl Contract {
#[init]
/// `prover_account`: NEAR account of the Near Prover contract;
/// `factory_address`: Ethereum address of the token factory contract, in hex.
pub fn new(prover_account: AccountId, factory_address: String) -> Self {
Self {
prover_account,
used_events: UnorderedSet::new(StorageKey::UsedEvents),
eth_factory_address: validate_eth_address(factory_address),
paused: Mask::default(),
whitelist_tokens: UnorderedMap::new(StorageKey::WhitelistTokens),
whitelist_accounts: UnorderedSet::new(StorageKey::WhitelistAccounts),
is_whitelist_mode_enabled: true,
}
}
/// Logs into the result of this transaction a Metadata for given token.
pub fn log_metadata(&self, token_id: AccountId) -> Promise {
ext_token::ext(token_id.clone())
.with_static_gas(FT_GET_METADATA_GAS)
.ft_metadata()
.then(
ext_self::ext(env::current_account_id())
.with_static_gas(FT_FINISH_LOG_METADATA_GAS)
.finish_log_metadata(token_id),
)
}
/// Emits `result_types::Metadata` with Metadata of the given token.
#[private]
#[result_serializer(borsh)]
pub fn finish_log_metadata(
&self,
#[callback] metadata: FungibleTokenMetadata,
token_id: AccountId,
) -> result_types::Metadata {
result_types::Metadata::new(
token_id.to_string(),
metadata.name,
metadata.symbol,
metadata.decimals,
env::block_height(),
)
}
/// Withdraw funds from NEAR Token Locker.
/// Receives proof of burning tokens on the other side. Validates it and releases funds.
#[payable]
pub fn withdraw(&mut self, #[serializer(borsh)] proof: Proof) -> Promise {
self.check_not_paused(PAUSE_DEPOSIT);
let event = EthUnlockedEvent::from_log_entry_data(&proof.log_entry_data);
assert_eq!(
event.eth_factory_address,
self.eth_factory_address,
"Event's address {} does not match eth factory address of this token {}",
hex::encode(&event.eth_factory_address),
hex::encode(&self.eth_factory_address),
);
let Recipient {
target: recipient_account_id,
message: _,
} = parse_recipient(event.recipient);
ext_token::ext(event.token.clone().try_into().unwrap())
.with_static_gas(STORAGE_BALANCE_CALL_GAS)
.storage_balance_of(Some(recipient_account_id.clone()))
.then(
ext_self::ext(env::current_account_id())
.with_static_gas(
FT_STORAGE_BALANCE_CALLBACK_GAS
+ FINISH_WITHDRAW_GAS
+ FT_TRANSFER_CALL_GAS,
)
.with_attached_deposit(env::attached_deposit())
.storage_balance_callback(
proof,
event.token,
recipient_account_id,
event.amount,
),
)
}
#[private]
pub fn storage_balance_callback(
&self,
#[callback] storage_balance: Option<StorageBalance>,
#[serializer(borsh)] proof: Proof,
#[serializer(borsh)] token: String,
#[serializer(borsh)] recipient: AccountId,
#[serializer(borsh)] amount: Balance,
) -> Promise {
assert!(
storage_balance.is_some(),
"The account {} is not registered",
recipient
);
let proof_1 = proof.clone();
ext_prover::ext(self.prover_account.clone())
.with_static_gas(VERIFY_LOG_ENTRY_GAS)
.with_attached_deposit(NO_DEPOSIT)
.verify_log_entry(
proof.log_index,
proof.log_entry_data,
proof.receipt_index,
proof.receipt_data,
proof.header_data,
proof.proof,
false, // Do not skip bridge call. This is only used for development and diagnostics.
)
.then(
ext_self::ext(env::current_account_id())
.with_attached_deposit(env::attached_deposit())
.with_static_gas(FINISH_WITHDRAW_GAS + FT_TRANSFER_CALL_GAS)
.finish_withdraw(token, recipient.to_string(), amount, proof_1),
)
}
#[private]
#[result_serializer(borsh)]
pub fn finish_deposit(
&self,
#[serializer(borsh)] token: AccountId,
#[serializer(borsh)] amount: Balance,
#[serializer(borsh)] recipient: EthAddress,
) -> result_types::Lock {
result_types::Lock::new(token.into(), amount, recipient)
}
#[private]
#[payable]
pub fn finish_withdraw(
&mut self,
#[callback]
#[serializer(borsh)]
verification_success: bool,
#[serializer(borsh)] token: String,
#[serializer(borsh)] new_owner_id: String,
#[serializer(borsh)] amount: Balance,
#[serializer(borsh)] proof: Proof,
) -> Promise {
assert!(verification_success, "Failed to verify the proof");
let required_deposit = self.record_proof(&proof);
assert!(env::attached_deposit() >= required_deposit);
let Recipient { target, message } = parse_recipient(new_owner_id);
env::log_str(
format!(
"Finish deposit. Token:{} Target:{} Message:{:?}",
token, target, message
)
.as_str(),
);
match message {
Some(message) => ext_token::ext(token.try_into().unwrap())
.with_attached_deposit(near_sdk::ONE_YOCTO)
.with_static_gas(FT_TRANSFER_CALL_GAS)
.ft_transfer_call(target, amount.into(), None, message),
None => ext_token::ext(token.try_into().unwrap())
.with_attached_deposit(near_sdk::ONE_YOCTO)
.with_static_gas(FT_TRANSFER_GAS)
.ft_transfer(target, amount.into(), None),
}
}
/// Checks whether the provided proof is already used.
pub fn is_used_proof(&self, #[serializer(borsh)] proof: Proof) -> bool {
self.used_events.contains(&proof.get_key())
}
/// Record proof to make sure it is not re-used later for anther withdrawal.
#[private]
fn record_proof(&mut self, proof: &Proof) -> Balance {
// TODO: Instead of sending the full proof (clone only relevant parts of the Proof)
// log_index / receipt_index / header_data
let initial_storage = env::storage_usage();
let proof_key = proof.get_key();
assert!(
!self.used_events.contains(&proof_key),
"Event cannot be reused for withdrawing."
);
self.used_events.insert(&proof_key);
let current_storage = env::storage_usage();
let required_deposit =
Balance::from(current_storage - initial_storage) * env::storage_byte_cost();
env::log_str(&format!("RecordProof:{}", hex::encode(proof_key)));
required_deposit
}
#[private]
pub fn update_factory_address(&mut self, factory_address: String) {
self.eth_factory_address = validate_eth_address(factory_address);
}
}
admin_controlled::impl_admin_controlled!(Contract, paused);
#[cfg(not(target_arch = "wasm32"))]
#[cfg(test)]
mod tests {
use std::convert::TryInto;
use std::panic;
use near_contract_standards::fungible_token::receiver::FungibleTokenReceiver;
use near_sdk::env::sha256;
use near_sdk::test_utils::{accounts, VMContextBuilder};
use near_sdk::testing_env;
use uint::rustc_hex::{FromHex, ToHex};
use super::*;
const UNPAUSE_ALL: Mask = 0;
macro_rules! inner_set_env {
($builder:ident) => {
$builder
};
($builder:ident, $key:ident:$value:expr $(,$key_tail:ident:$value_tail:expr)*) => {
{
$builder.$key($value.try_into().unwrap());
inner_set_env!($builder $(,$key_tail:$value_tail)*)
}
};
}
macro_rules! set_env {
($($key:ident:$value:expr),* $(,)?) => {
let mut builder = VMContextBuilder::new();
let mut builder = &mut builder;
builder = inner_set_env!(builder, $($key: $value),*);
testing_env!(builder.build());
};
}
fn prover() -> AccountId {
"prover".parse().unwrap()
}
fn bridge_token_factory() -> AccountId {
"bridge".parse().unwrap()
}
fn token_locker() -> String {
"6b175474e89094c44da98b954eedeac495271d0f".to_string()
}
/// Generate a valid ethereum address.
fn ethereum_address_from_id(id: u8) -> String {
let mut buffer = vec![id];
sha256(buffer.as_mut())
.into_iter()
.take(20)
.collect::<Vec<_>>()
.to_hex()
}
fn create_proof(locker: String, token: String, recipient: String) -> Proof {
let event_data = EthUnlockedEvent {
eth_factory_address: locker
.from_hex::<Vec<_>>()
.unwrap()
.as_slice()
.try_into()
.unwrap(),
token,
sender: "00005474e89094c44da98b954eedeac495271d0f".to_string(),
amount: 1000,
recipient,
token_eth_address: validate_eth_address(
"0123456789abcdefdeadbeef0123456789abcdef".to_string(),
),
};
Proof {
log_index: 0,
log_entry_data: event_data.to_log_entry_data(),
receipt_index: 0,
receipt_data: vec![],
header_data: vec![],
proof: vec![],
}
}
#[test]
fn test_lock_unlock_token() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
set_env!(predecessor_account_id: accounts(1));
contract.set_token_whitelist_mode(accounts(1), WhitelistMode::CheckToken);
contract.ft_on_transfer(accounts(2), U128(1_000_000), ethereum_address_from_id(0));
contract.finish_deposit(
accounts(1).into(),
1_000_000,
validate_eth_address(ethereum_address_from_id(0)),
);
let proof = create_proof(token_locker(), accounts(1).into(), "bob.near".to_string());
set_env!(attached_deposit: env::storage_byte_cost() * 1000);
contract.withdraw(proof.clone());
contract.finish_withdraw(
true,
accounts(1).into(),
accounts(2).into(),
1_000_000,
proof,
);
}
#[test]
fn test_lock_unlock_token_with_custom_recipient_message() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
set_env!(predecessor_account_id: accounts(1));
contract.set_token_whitelist_mode(accounts(1), WhitelistMode::CheckToken);
contract.ft_on_transfer(accounts(2), U128(1_000_000), ethereum_address_from_id(0));
contract.finish_deposit(
accounts(1).into(),
1_000_000,
validate_eth_address(ethereum_address_from_id(0)),
);
let proof = create_proof(
token_locker(),
accounts(1).into(),
"bob.near:some message".to_string(),
);
set_env!(attached_deposit: env::storage_byte_cost() * 1000);
contract.withdraw(proof.clone());
contract.finish_withdraw(
true,
accounts(1).into(),
accounts(2).into(),
1_000_000,
proof,
);
}
#[test]
fn test_only_admin_can_pause() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
// Admin can pause
set_env!(
current_account_id: bridge_token_factory(),
predecessor_account_id: bridge_token_factory(),
);
contract.set_paused(0b1111);
// Admin can unpause.
set_env!(
current_account_id: bridge_token_factory(),
predecessor_account_id: bridge_token_factory(),
);
contract.set_paused(UNPAUSE_ALL);
// Alice can't pause
set_env!(
current_account_id: bridge_token_factory(),
predecessor_account_id: accounts(0),
);
panic::catch_unwind(move || {
contract.set_paused(0);
})
.unwrap_err();
}
#[test]
#[should_panic(expected = "The token is blocked")]
fn test_blocked_token() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let token_account = accounts(1);
let sender_account = accounts(2);
set_env!(predecessor_account_id: token_account.clone());
contract.set_token_whitelist_mode(token_account, WhitelistMode::Blocked);
contract.ft_on_transfer(sender_account, U128(1_000_000), ethereum_address_from_id(0));
}
#[test]
#[should_panic(expected = "does not exist in the whitelist")]
fn test_account_not_in_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let token_account = accounts(1);
let sender_account = accounts(2);
set_env!(predecessor_account_id: token_account);
contract.set_token_whitelist_mode(accounts(1), WhitelistMode::CheckAccountAndToken);
contract.ft_on_transfer(sender_account, U128(1_000_000), ethereum_address_from_id(0));
}
#[test]
#[should_panic(expected = "The token is not whitelisted")]
fn test_token_not_in_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let token_account = accounts(1);
let sender_account = accounts(2);
set_env!(predecessor_account_id: token_account);
contract.ft_on_transfer(sender_account, U128(1_000_000), ethereum_address_from_id(0));
}
#[test]
fn test_account_in_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let token_account = accounts(1);
let sender_account = accounts(2);
contract
.set_token_whitelist_mode(token_account.clone(), WhitelistMode::CheckAccountAndToken);
contract.add_account_to_whitelist(token_account.clone(), sender_account.clone());
set_env!(predecessor_account_id: token_account);
contract.ft_on_transfer(sender_account, U128(1_000_000), ethereum_address_from_id(0));
}
#[test]
#[should_panic(expected = "does not exist in the whitelist")]
fn test_remove_account_from_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let token_account = accounts(1);
let sender_account = accounts(2);
contract
.set_token_whitelist_mode(token_account.clone(), WhitelistMode::CheckAccountAndToken);
contract.add_account_to_whitelist(token_account.clone(), sender_account.clone());
set_env!(predecessor_account_id: token_account.clone());
contract.ft_on_transfer(
sender_account.clone(),
U128(1_000_000),
ethereum_address_from_id(0),
);
contract.remove_account_from_whitelist(token_account.clone(), sender_account.clone());
contract.ft_on_transfer(
sender_account.clone(),
U128(1_000_000),
ethereum_address_from_id(0),
);
}
#[test]
fn test_tokens_in_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let whitelist_tokens = ["token1.near", "token2.near", "token3.near"];
for token_id in whitelist_tokens {
contract.set_token_whitelist_mode(token_id.parse().unwrap(), WhitelistMode::CheckToken);
}
for token_id in whitelist_tokens {
let token_account: AccountId = token_id.parse().unwrap();
let sender_account = accounts(2);
set_env!(predecessor_account_id: token_account);
contract.ft_on_transfer(sender_account, U128(1_000_000), ethereum_address_from_id(0));
}
}
#[test]
fn test_accounts_in_whitelist() {
set_env!(predecessor_account_id: accounts(0));
let mut contract = Contract::new(prover(), token_locker());
let whitelist_tokens = ["token1.near", "token2.near", "token3.near"];
let whitelist_accounts = ["account1.near", "account2.near", "account3.near"];
for token_id in whitelist_tokens {
let token_account: AccountId = token_id.parse().unwrap();
contract.set_token_whitelist_mode(
token_account.clone(),
WhitelistMode::CheckAccountAndToken,
);
for account_id in whitelist_accounts {
let sender_account: AccountId = account_id.parse().unwrap();
contract.add_account_to_whitelist(token_account.clone(), sender_account.clone());
}
}
for token_id in whitelist_tokens {
for account_id in whitelist_accounts {
let token_account: AccountId = token_id.parse().unwrap();
let sender_account: AccountId = account_id.parse().unwrap();
set_env!(predecessor_account_id: token_account);
contract.ft_on_transfer(
sender_account,
U128(1_000_000),
ethereum_address_from_id(0),
);
}
}
}
}
|
fn main() {
println!("🔓 Challenge 5");
println!("Try running: `cargo test repeating_xor`");
println!("Code in 'xor/src/lib.rs'");
}
|
use crate::structures::basic::ValType;
#[derive(Debug)]
pub struct FuncType {
inputs: Vec<ValType>,
outputs: Vec<ValType>,
}
impl FuncType {
pub fn from_reader() {
println!("This is func type...");
}
}
#[derive(Debug)]
pub struct ResultType;
#[derive(Debug)]
pub struct Func {}
#[derive(Debug)]
pub struct Limits {
min_num: u32,
max_num: u32,
}
#[derive(Debug)]
pub struct MemType {
limits: Limits,
}
#[derive(Debug)]
pub struct TableType;
#[derive(Debug)]
pub struct GlobalType;
#[derive(Debug)]
pub struct ExternType;
#[derive(Debug)]
pub struct Import {
module: String,
name: String,
desc: ImportDesc,
}
#[derive(Debug)]
pub struct ImportDesc {
func: Typeidx,
table: TableType,
mem: MemType,
global: GlobalType,
}
#[derive(Debug)]
pub struct Export {
module: String,
name: String,
desc: EmportDesc,
}
#[derive(Debug)]
pub struct EmportDesc {
func: Typeidx,
table: TableType,
mem: MemType,
global: GlobalType,
}
#[derive(Debug)]
pub struct Instruction {
code: u8,
}
|
pub struct Variable<'a, T> where T: PartialEq {
value: T,
listeners: Vec<Box<FnMut(&T) + 'a>>,
}
impl<'a, T> Variable<'a, T> where T: PartialEq {
pub fn new(value: T) -> Variable<'a, T> {
Variable { value, listeners: Vec::new() }
}
pub fn add_listener<L>(&mut self, listener: L) where L: FnMut(&T) + 'a {
self.listeners.push(Box::new(listener));
}
pub fn set_value(&mut self, val: T) {
if self.value != val {
for listener in &mut self.listeners {
listener(&val);
}
self.value = val;
}
}
pub fn value(&self) -> &T {
&self.value
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::cell::Cell;
#[test]
fn test_callbacks() {
let calls = Cell::new(0);
let mut var = Variable::new(42_f32);
var.add_listener(|_| calls.set(calls.get() + 1));
var.set_value(42_f32);
assert_eq!(0, calls.get());
var.set_value(12.34_f32);
assert_eq!(1, calls.get());
var.add_listener(|v| assert_eq!(-42_f32, *v));
var.set_value(12.34_f32);
assert_eq!(1, calls.get());
var.set_value(-42_f32);
assert_eq!(2, calls.get());
}
#[test]
fn test_value() {
let mut var = Variable::new(1_f32);
{
// Test getting the value of an immutable reference works
let reference = &var;
assert_eq!(1_f32, *reference.value());
}
var.set_value(42_f32);
assert_eq!(42_f32, *var.value());
}
} |
// Copyright (C) 2019 Frank Rehberger
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0>
// declared in Cargo.toml as "[build-dependencies]"
extern crate build_deps;
fn main() {
// Enumerate files in sub-folder "res/*", being relevant for the test-generation (as example)
// If function returns with error, exit with error message.
build_deps::rerun_if_changed_paths( "res/*/*" ).unwrap();
// Adding the parent directory "res" to the watch-list will capture new-files being added
build_deps::rerun_if_changed_paths( "res/*" ).unwrap();
}
|
use crate::simulation::trader_behavior;
use crate::order::{Order};
use crate::simulation::trader::Traders;
use crate::exchange::order_processing::JsonOrder;
use crate::controller::Task;
use crate::io::tcp_json;
use crate::io::ws_json;
use crate::utility::get_time;
use std::sync::Arc;
use std::thread;
pub struct RandBehavior {}
impl RandBehavior {
// Generates a random number of new traders on a fixed interval over tcp
pub fn tcp_arrival_interval(traders: Arc<Traders>, duration: u64, address: String) -> Task {
Task::rpt_task(move || {
// Make new random orders
let orders: Vec<Order> = trader_behavior::rand_enters(10);
println!("{} new arrivals!", orders.len());
// Send them over JSON
for order in &orders {
// Don't want a full clone of the order, just params to make json
let json_order = JsonOrder::order_to_json(order);
// Spawn the task to send json over tcp
let json_send_task = tcp_json::tcp_send_json(json_order, address.clone()).task;
tokio::spawn(json_send_task);
}
// Save new traders in the traders HashMap
traders.new_traders(orders);
println!("num_traders: {}", traders.num_traders());
}, duration)
}
// Updates a random number of existing traders on a fixed interval over tcp
pub fn tcp_update_interval(traders: Arc<Traders>, duration: u64, address: String) -> Task {
Task::rpt_task(move || {
let rng_upper = 10;
let update_orders = trader_behavior::gen_rand_updates(Arc::clone(&traders), rng_upper);
println!("updating {} traders", update_orders.len());
for order in update_orders {
let json_order = JsonOrder::params_to_json(order);
let json_send_task = tcp_json::tcp_send_json(json_order, address.clone()).task;
tokio::spawn(json_send_task);
}
}, duration)
}
// Cancels a random number of existing traders on a fixed interval over tcp
pub fn tcp_cancel_interval(traders: Arc<Traders>, duration: u64, address: String) -> Task {
Task::rpt_task(move || {
println!("cancel trader!");
let rng_upper = 10;
let cancel_orders = trader_behavior::gen_rand_cancels(Arc::clone(&traders), rng_upper);
println!("cancelling {} traders", cancel_orders.len());
for order in cancel_orders {
println!("time: {:?}, cancelling: {:?} ", get_time(), order.0);
let addr = address.clone();
// Send a cancel message after a delay
let send_cancel = Task::delay_task(move || {
let json_order = JsonOrder::params_to_json(order.clone());
let json_send_task = tcp_json::tcp_send_json(json_order, addr.clone()).task;
tokio::spawn(json_send_task);
}, 1000).task;
tokio::spawn(send_cancel);
}
}, duration)
}
// Generates a random number of new traders on a fixed interval over tcp
pub fn ws_arrival_interval(traders: Arc<Traders>, duration: u64, address: &'static str) -> Task {
Task::rpt_task(move || {
// Make new random orders
let orders: Vec<Order> = trader_behavior::rand_enters(10);
println!("{} new arrivals!", orders.len());
// Send them over JSON
for order in &orders {
let addr = address.clone();
// Don't want a full clone of the order, just params to make json
let json_order = JsonOrder::order_to_json(order);
// Spawn the task to send json over tcp
let _h = thread::spawn(move || {
ws_json::ws_send_json(json_order, addr);
});
}
// Save new traders in the traders HashMap
traders.new_traders(orders);
println!("num_traders: {}", traders.num_traders());
}, duration)
}
// Updates a random number of existing traders on a fixed interval over tcp
pub fn ws_update_interval(traders: Arc<Traders>, duration: u64, address: &'static str) -> Task {
Task::rpt_task(move || {
let rng_upper = 10;
let update_orders = trader_behavior::gen_rand_updates(Arc::clone(&traders), rng_upper);
println!("updating {} traders", update_orders.len());
for order in update_orders {
let addr = address.clone();
let json_order = JsonOrder::params_to_json(order);
let _h = thread::spawn(move || {
ws_json::ws_send_json(json_order, addr);
});
}
}, duration)
}
// Cancels a random number of existing traders on a fixed interval over tcp
pub fn ws_cancel_interval(traders: Arc<Traders>, duration: u64, address: &'static str) -> Task {
Task::rpt_task(move || {
println!("cancel trader!");
let rng_upper = 10;
let cancel_orders = trader_behavior::gen_rand_cancels(Arc::clone(&traders), rng_upper);
println!("cancelling {} traders", cancel_orders.len());
for order in cancel_orders {
println!("time: {:?}, cancelling: {:?} ", get_time(), order.0);
let addr = address.clone();
// Send a cancel message after a delay
let send_cancel = Task::delay_task(move || {
let addr = addr.clone();
let json_order = JsonOrder::params_to_json(order.clone());
let _h = thread::spawn(move || {
ws_json::ws_send_json(json_order, addr);
});
}, 1000).task;
tokio::spawn(send_cancel);
}
}, duration)
}
}
|
//! DLT (direct linear transform) algorithm for camera calibration
//!
//! This is typically used for calibrating cameras and requires a minimum of 6
//! corresponding pairs of 2D and 3D locations.
//!
//! # Testing
//!
//! ## Unit tests
//!
//! To run the unit tests:
//!
//! ```text
//! cargo test
//! ```
//!
//! ## Test for `no_std`
//!
//! Since the `thumbv7em-none-eabihf` target does not have `std` available, we
//! can build for it to check that our crate does not inadvertently pull in std.
//! The unit tests require std, so cannot be run on a `no_std` platform. The
//! following will fail if a std dependency is present:
//!
//! ```text
//! # install target with: "rustup target add thumbv7em-none-eabihf"
//! cargo build --no-default-features --target thumbv7em-none-eabihf
//! ```
//!
//! # Example
//!
//! ```
//! use dlt::{dlt_corresponding, CorrespondingPoint};
//!
//! let points: Vec<CorrespondingPoint<f64>> = vec![
//! CorrespondingPoint {
//! object_point: [-1., -2., -3.],
//! image_point: [219.700, 39.400],
//! },
//! CorrespondingPoint {
//! object_point: [0., 0., 0.],
//! image_point: [320.000, 240.000],
//! },
//! CorrespondingPoint {
//! object_point: [1., 2., 3.],
//! image_point: [420.300, 440.600],
//! },
//! CorrespondingPoint {
//! object_point: [1.1, 2.2, 3.3],
//! image_point: [430.330, 460.660],
//! },
//! CorrespondingPoint {
//! object_point: [4., 5., 6.],
//! image_point: [720.600, 741.200],
//! },
//! CorrespondingPoint {
//! object_point: [4.4, 5.5, 6.6],
//! image_point: [760.660, 791.320],
//! },
//! CorrespondingPoint {
//! object_point: [7., 8., 9.],
//! image_point: [1020.900, 1041.800],
//! },
//! CorrespondingPoint {
//! object_point: [7.7, 8.8, 9.9],
//! image_point: [1090.990, 1121.980],
//! },
//! ];
//!
//! let pmat = dlt_corresponding(&points, 1e-10).unwrap();
//! // could now call `cam_geom::Camera::from_perspective_matrix(&pmat)`
//! ```
//!
//! # See also
//!
//! You may also be interested in:
//!
//! - [`cam-geom`](https://crates.io/crates/cam-geom) - Rust crate with 3D
//! camera models which can use the calibration data from DLT.
//! - [`dlt-examples`](https://github.com/strawlab/dlt/blob/master/dlt-examples)
//! - Unpublished crate in the dlt repository which demonstrates usage with
//! cam-geom library.
#![deny(rust_2018_idioms, unsafe_code, missing_docs)]
#![cfg_attr(not(feature = "std"), no_std)]
use nalgebra::allocator::Allocator;
use nalgebra::{
DefaultAllocator, Dim, DimDiff, DimMin, DimMinimum, DimMul, DimProd, DimSub, OMatrix,
RealField, SMatrix, U1, U11, U2, U3,
};
#[cfg(feature = "serde-serialize")]
use serde::{Deserialize, Serialize};
#[allow(non_snake_case)]
struct Bc<R, N>
where
R: RealField,
N: DimMul<U2>,
DimProd<N, U2>: DimMin<U11>,
DefaultAllocator: Allocator<R, N, U3>
+ Allocator<R, N, U2>
+ Allocator<R, DimProd<N, U2>, U11>
+ Allocator<R, DimProd<N, U2>, U1>,
{
B: OMatrix<R, DimProd<N, U2>, U11>,
c: OMatrix<R, DimProd<N, U2>, U1>,
}
#[allow(non_snake_case)]
fn build_Bc<R, N>(world: &OMatrix<R, N, U3>, cam: &OMatrix<R, N, U2>) -> Bc<R, N>
where
R: RealField + Copy,
N: DimMul<U2>,
DimProd<N, U2>: DimMin<U11>,
DefaultAllocator: Allocator<R, N, U3>
+ Allocator<R, N, U2>
+ Allocator<R, DimProd<N, U2>, U11>
+ Allocator<R, DimProd<N, U2>, U1>,
{
let n_pts = world.nrows();
let n_pts2 = DimProd::<N, U2>::from_usize(n_pts * 2);
let mut B = OMatrix::zeros_generic(n_pts2, U11::from_usize(11));
let mut c = OMatrix::zeros_generic(n_pts2, U1::from_usize(1));
let zero = nalgebra::zero();
let one = nalgebra::one();
for i in 0..n_pts {
let X = world[(i, 0)];
let Y = world[(i, 1)];
let Z = world[(i, 2)];
let x = cam[(i, 0)];
let y = cam[(i, 1)];
let tmp = OMatrix::<R, U1, U11>::from_row_slice_generic(
U1::from_usize(1),
U11::from_usize(11),
&[X, Y, Z, one, zero, zero, zero, zero, -x * X, -x * Y, -x * Z],
);
B.row_mut(i * 2).copy_from(&tmp);
let tmp = OMatrix::<R, U1, U11>::from_row_slice_generic(
U1::from_usize(1),
U11::from_usize(11),
&[zero, zero, zero, zero, X, Y, Z, one, -y * X, -y * Y, -y * Z],
);
B.row_mut(i * 2 + 1).copy_from(&tmp);
c[i * 2] = x;
c[i * 2 + 1] = y;
}
Bc { B, c }
}
/// Direct Linear Transformation (DLT) to find a camera calibration matrix.
///
/// Takes `world`, a matrix of 3D world coordinates, and `cam` a matrix of 2D
/// camera coordinates, which is the image of the world coordinates via the
/// desired projection matrix. Generic over `N`, the number of points, which
/// must be at least `nalgebra::U6`, and can also be `nalgebra::Dynamic`. Also
/// generic over `R`, the data type, which must implement `nalgebra::RealField`.
///
/// You may find it more ergonomic to use the
/// [`dlt_corresponding`](fn.dlt_corresponding.html) function as a convenience
/// wrapper around this function.
///
/// Note that this approach is known to be "unstable" (see Hartley and
/// Zissermann). We should add normalization to fix it. Also, I don't like the
/// notation used by [kwon3d.com](http://www.kwon3d.com/theory/dlt/dlt.html) and
/// prefer that from Carl Olsson as seen
/// [here](http://www.maths.lth.se/matematiklth/personal/calle/datorseende13/notes/forelas3.pdf).
/// That said, kwon3d also suggests how to use the DLT to estimate distortion.
///
/// The DLT method will return intrinsic matrices with skew.
///
/// See
/// [http://www.kwon3d.com/theory/dlt/dlt.html](http://www.kwon3d.com/theory/dlt/dlt.html).
pub fn dlt<R, N>(
world: &OMatrix<R, N, U3>,
cam: &OMatrix<R, N, U2>,
epsilon: R,
) -> Result<SMatrix<R, 3, 4>, &'static str>
where
// These complicated trait bounds come from:
// - the matrix `B` that we create has shape (N*2, 11). Thus, everything
// with `DimProd<N, U2>, U11>`.
// - the vector `c` that we create has shape (N*2, 1). Thus, everything with
// `DimProd<N, U2>, U1>`.
// - the SVD operation has its own complicated trait bounds. I copied the
// trait bounds required from the SVD source and and then substituted
// `DimProd<N, U2>` for `R` (number of rows) and `U11` for `C` (number of
// columns).
R: RealField + Copy,
N: DimMul<U2>,
DimProd<N, U2>: DimMin<U11>,
DimMinimum<DimProd<N, U2>, U11>: DimSub<U1>,
DefaultAllocator: Allocator<R, N, U3>
+ Allocator<(usize, usize), <<N as DimMul<U2>>::Output as DimMin<U11>>::Output>
+ Allocator<(R, usize), <<N as DimMul<U2>>::Output as DimMin<U11>>::Output>
+ Allocator<R, N, U2>
+ Allocator<R, DimProd<N, U2>, U11>
+ Allocator<R, DimProd<N, U2>, U1>
+ Allocator<R, DimMinimum<DimProd<N, U2>, U11>, U11>
+ Allocator<R, DimProd<N, U2>, DimMinimum<DimProd<N, U2>, U11>>
+ Allocator<R, DimMinimum<DimProd<N, U2>, U11>, U1>
+ Allocator<R, DimDiff<DimMinimum<DimProd<N, U2>, U11>, U1>, U1>,
{
#[allow(non_snake_case)]
let Bc { B, c } = build_Bc(&world, &cam);
// calculate solution with epsilon
let svd = nalgebra::linalg::SVD::<R, DimProd<N, U2>, U11>::try_new(
B,
true,
true,
R::default_epsilon(),
0,
)
.ok_or("svd failed")?;
let solution = svd.solve(&c, epsilon)?;
let mut pmat_t = SMatrix::<R, 4, 3>::zeros();
pmat_t.as_mut_slice()[0..11].copy_from_slice(solution.as_slice());
pmat_t[(3, 2)] = nalgebra::one();
let pmat = pmat_t.transpose();
Ok(pmat)
}
/// A point with a view in image (2D) and world (3D) coordinates.
///
/// Used by the [`dlt_corresponding`](fn.dlt_corresponding.html) function as a
/// convenience compared to calling the [`dlt`](fn.dlt.html) function directly.
#[derive(Debug)]
#[cfg_attr(feature = "serde-serialize", derive(Serialize, Deserialize))]
pub struct CorrespondingPoint<R: RealField> {
/// the location of the point in 3D world coordinates
pub object_point: [R; 3],
/// the location of the point in 2D pixel coordinates
pub image_point: [R; 2],
}
#[cfg(feature = "std")]
/// Convenience wrapper around the [`dlt`](fn.dlt.html) function.
///
/// This allows using the [`CorrespondingPoint`](struct.CorrespondingPoint.html)
/// if you find that easier.
///
/// Requires the `std` feature.
pub fn dlt_corresponding<R: RealField + Copy>(
points: &[CorrespondingPoint<R>],
epsilon: R,
) -> Result<SMatrix<R, 3, 4>, &'static str> {
let nrows = nalgebra::Dynamic::from_usize(points.len());
// let u2 = nalgebra::Dynamic::from_usize(2);
let u2 = U2::from_usize(2);
// let u3 = nalgebra::Dynamic::from_usize(3);
let u3 = U3::from_usize(3);
let world_mat = nalgebra::OMatrix::from_fn_generic(nrows, u3, |i, j| points[i].object_point[j]);
let image_mat = nalgebra::OMatrix::from_fn_generic(nrows, u2, |i, j| points[i].image_point[j]);
// perform the DLT
dlt(&world_mat, &image_mat, epsilon)
}
#[cfg(test)]
mod tests {
use nalgebra::{Dynamic, OMatrix, U2, U3, U4, U8};
#[test]
fn test_dlt_corresponding() {
use crate::CorrespondingPoint;
let points: Vec<CorrespondingPoint<f64>> = vec![
CorrespondingPoint {
object_point: [-1., -2., -3.],
image_point: [219.700, 39.400],
},
CorrespondingPoint {
object_point: [0., 0., 0.],
image_point: [320.000, 240.000],
},
CorrespondingPoint {
object_point: [1., 2., 3.],
image_point: [420.300, 440.600],
},
CorrespondingPoint {
object_point: [1.1, 2.2, 3.3],
image_point: [430.330, 460.660],
},
CorrespondingPoint {
object_point: [4., 5., 6.],
image_point: [720.600, 741.200],
},
CorrespondingPoint {
object_point: [4.4, 5.5, 6.6],
image_point: [760.660, 791.320],
},
CorrespondingPoint {
object_point: [7., 8., 9.],
image_point: [1020.900, 1041.800],
},
CorrespondingPoint {
object_point: [7.7, 8.8, 9.9],
image_point: [1090.990, 1121.980],
},
];
crate::dlt_corresponding(&points, 1e-10).unwrap();
}
#[test]
fn test_dlt_dynamic() {
// homogeneous 3D coords
#[rustfmt::skip]
let x3dh_data: Vec<f64> = vec![
-1., -2., -3., 1.0,
0., 0., 0., 1.0,
1., 2., 3., 1.0,
1.1, 2.2, 3.3, 1.0,
4., 5., 6., 1.0,
4.4, 5.5, 6.6, 1.0,
7., 8., 9., 1.0,
7.7, 8.8, 9.9, 1.0,
];
let n_points = x3dh_data.len() / 4;
let x3dh = OMatrix::<_, Dynamic, U4>::from_row_slice(&x3dh_data);
// example camera calibration matrix
#[rustfmt::skip]
let pmat_data: Vec<f64> = vec![
100.0, 0.0, 0.1, 320.0,
0.0, 100.0, 0.2, 240.0,
0.0, 0.0, 0.0, 1.0,
];
let pmat = OMatrix::<_, U3, U4>::from_row_slice(&pmat_data);
// compute 2d coordinates of camera projection
let x2dh = pmat * x3dh.transpose();
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec::with_capacity(2 * n_points);
for i in 0..n_points {
let r = x2dh[(0, i)];
let s = x2dh[(1, i)];
let t = x2dh[(2, i)];
data.push(r / t);
data.push(s / t);
}
let x2d_expected = OMatrix::<_, Dynamic, U2>::from_row_slice(&data);
// convert homogeneous 3D coords into normal 3D coords
let x3d = x3dh.fixed_columns::<3>(0).into_owned();
// perform DLT
let dlt_results = crate::dlt(&x3d, &x2d_expected, 1e-10).unwrap();
// compute 2d coordinates of camera projection with DLT-found matrix
let x2dh2 = dlt_results * x3dh.transpose();
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec::with_capacity(2 * n_points);
for i in 0..n_points {
let r = x2dh2[(0, i)];
let s = x2dh2[(1, i)];
let t = x2dh2[(2, i)];
data.push(r / t);
data.push(s / t);
}
let x2d_actual = OMatrix::<_, Dynamic, U2>::from_row_slice(&data);
assert_eq!(x2d_expected.nrows(), x2d_actual.nrows());
assert_eq!(x2d_expected.ncols(), x2d_actual.ncols());
for i in 0..x2d_expected.nrows() {
for j in 0..x2d_expected.ncols() {
approx::assert_relative_eq!(
x2d_expected[(i, j)],
x2d_actual[(i, j)],
epsilon = 1e-10
);
}
}
}
#[test]
fn test_dlt_static() {
// homogeneous 3D coords
#[rustfmt::skip]
let x3dh_data: Vec<f64> = vec![
-1., -2., -3., 1.0,
0., 0., 0., 1.0,
1., 2., 3., 1.0,
1.1, 2.2, 3.3, 1.0,
4., 5., 6., 1.0,
4.4, 5.5, 6.6, 1.0,
7., 8., 9., 1.0,
7.7, 8.8, 9.9, 1.0,
];
let n_points = x3dh_data.len() / 4;
assert!(n_points == 8);
let x3dh = OMatrix::<_, U8, U4>::from_row_slice(&x3dh_data);
// example camera calibration matrix
#[rustfmt::skip]
let pmat_data: Vec<f64> = vec![
100.0, 0.0, 0.1, 320.0,
0.0, 100.0, 0.2, 240.0,
0.0, 0.0, 0.0, 1.0,
];
let pmat = OMatrix::<_, U3, U4>::from_row_slice(&pmat_data);
// compute 2d coordinates of camera projection
let x2dh = pmat * x3dh.transpose();
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec::with_capacity(2 * n_points);
for i in 0..n_points {
let r = x2dh[(0, i)];
let s = x2dh[(1, i)];
let t = x2dh[(2, i)];
data.push(r / t);
data.push(s / t);
}
let x2d_expected = OMatrix::<_, U8, U2>::from_row_slice(&data);
// convert homogeneous 3D coords into normal 3D coords
let x3d = x3dh.fixed_columns::<3>(0).into_owned();
// perform DLT
let dlt_results = crate::dlt(&x3d, &x2d_expected, 1e-10).unwrap();
// compute 2d coordinates of camera projection with DLT-found matrix
let x2dh2 = dlt_results * x3dh.transpose();
// convert 2D homogeneous coords into normal 2D coords
let mut data = Vec::with_capacity(2 * n_points);
for i in 0..n_points {
let r = x2dh2[(0, i)];
let s = x2dh2[(1, i)];
let t = x2dh2[(2, i)];
data.push(r / t);
data.push(s / t);
}
let x2d_actual = OMatrix::<_, U8, U2>::from_row_slice(&data);
assert_eq!(x2d_expected.nrows(), x2d_actual.nrows());
assert_eq!(x2d_expected.ncols(), x2d_actual.ncols());
for i in 0..x2d_expected.nrows() {
for j in 0..x2d_expected.ncols() {
approx::assert_relative_eq!(
x2d_expected[(i, j)],
x2d_actual[(i, j)],
epsilon = 1e-10
);
}
}
}
}
|
extern crate gdbs;
#[macro_use]
extern crate clap;
use std::process;
use clap::{App, Arg};
fn main() {
let app = App::new(crate_name!())
.version(crate_version!())
.author(crate_authors!())
.about(crate_description!())
.arg(Arg::with_name("type")
.help("peda, gef, pwndbg")
.required(true)
)
.arg(Arg::with_name("filename")
.help("input file name")
.short("i")
.long("input")
.takes_value(true)
);
let args = app.get_matches();
if let Err(e) = gdbs::run(args) {
eprintln!("Application error: {}", e);
process::exit(1);
}
} |
table! {
entries (id) {
id -> Int4,
pc_name -> Text,
cpu_usage -> Text,
mem_usage -> Text,
recorded_at -> Int8,
}
}
|
#![crate_name = "gfx_gl"]
#![crate_type = "lib"]
//! An OpenGL loader generated by [gl-rs](https://github.com/brendanzab/gl-rs).
//!
//! This is useful for directly accessing the underlying OpenGL API via the
//! `GlDevice::with_gl` method. It is also used internally by the `GlDevice`
//! implementation.
include!(concat!(env!("OUT_DIR"), "/gl_bindings.rs"));
|
extern crate regex;
macro_rules! mal_regex {
($re:expr) => {
Regex::new($re).unwrap()
};
}
#[macro_use]
extern crate log;
#[macro_use]
extern crate lazy_static;
pub mod core;
pub mod env;
pub mod printer;
pub mod reader;
pub mod types;
pub mod readline {
use std::io;
use std::io::Write;
/// Basic CLI readline utility.
pub fn read_line(prompt: &str, input: &mut String) {
input.clear();
print!("{}", prompt);
io::stdout().flush().expect("readline: output error");
io::stdin()
.read_line(input)
.expect("readline: failed to read line");
}
}
pub mod output {
use log::warn;
pub fn warning(message: &str) {
warn!("{}", message);
}
}
|
extern crate chrono;
use self::chrono::prelude::{DateTime, Utc};
use std::cell::Cell;
use direction::Direction;
use signal::Signal;
use signal::detector::{DetectSignal, DetectSignalError};
use symbol::SymbolId;
pub struct Once {
symbol_id: SymbolId,
direction: Direction,
detected: Cell<bool>
}
impl Once {
pub fn new(symbol_id: SymbolId, direction: Direction) -> Once {
Once {
symbol_id: symbol_id,
direction: direction,
detected: Cell::new(false)
}
}
}
impl DetectSignal for Once {
fn detect_signal(&self, datetime: &DateTime<Utc>) -> Result<Option<Signal>, DetectSignalError> {
if self.detected.get() {
Ok(None)
}
else {
let signal = Signal::new(
self.symbol_id.clone(),
self.direction.clone(),
datetime.clone(),
String::from("once")
);
self.detected.set(true);
Ok(Some(signal))
}
}
}
|
//! Utility functions for cpu efficient `wait` commands.
//! Uses the `libc::epoll_wait` that only works on linux systems.
#[cfg(target_os = "linux")]
use libc;
use std::os::unix::io::RawFd;
use std::time::{Duration, Instant};
/// Wait for until a condition `cond` is `true` or the `timeout` is reached.
/// If the `timeout` is `None` it will wait an infinite time.
/// The condition is checked when the `file` has changed.
///
/// # Arguments
/// * `file` - Listen to changes in this file
/// * `cond` - Condition that should become true
/// * `timeout` - Maximal timeout to wait for the condition or file changes
///
/// # Example
/// ```
/// use std::fs::File;
/// use std::os::unix::io::AsRawFd;
/// use std::time::Duration;
///
/// use ev3dev_lang_rust::wait;
///
/// if let Ok(file) = File::open("...") {
/// let cond = || {
/// // ...
/// true
/// };
/// let timeout = Duration::from_millis(2000);
///
/// wait::wait(file.as_raw_fd(), cond, Some(timeout));
/// }
/// ```
pub fn wait<F>(fd: RawFd, cond: F, timeout: Option<Duration>) -> bool
where
F: Fn() -> bool,
{
if cond() {
return true;
}
let start = Instant::now();
let mut t = timeout;
loop {
let wait_timeout = match t {
Some(duration) => duration.as_millis() as i32,
None => -1,
};
wait_file_changes(fd, wait_timeout);
if let Some(duration) = timeout {
let elapsed = start.elapsed();
if elapsed >= duration {
return false;
}
t = Some(duration - elapsed);
}
if cond() {
return true;
}
}
}
/// Wrapper for `libc::epoll_wait`
#[cfg(target_os = "linux")]
fn wait_file_changes(fd: RawFd, timeout: i32) -> bool {
let mut buf: [libc::epoll_event; 10] = [libc::epoll_event { events: 0, u64: 0 }; 10];
let result = unsafe {
libc::epoll_wait(
fd,
buf.as_mut_ptr() as *mut libc::epoll_event,
buf.len() as i32,
timeout,
) as i32
};
result > 0
}
/// Stub method for non linux os's
#[cfg(not(target_os = "linux"))]
fn wait_file_changes(_fd: RawFd, _timeout: i32) -> bool {
std::thread::sleep(Duration::from_millis(100));
false
}
|
//
// Local control plane.
//
// Can start, configure and stop postgres instances running as a local processes.
//
// Intended to be used in integration tests and in CLI tools for
// local installations.
//
use anyhow::{anyhow, bail, Context, Result};
use std::fs;
use std::path::Path;
pub mod compute;
pub mod local_env;
pub mod postgresql_conf;
pub mod storage;
/// Read a PID file
///
/// We expect a file that contains a single integer.
/// We return an i32 for compatibility with libc and nix.
pub fn read_pidfile(pidfile: &Path) -> Result<i32> {
let pid_str = fs::read_to_string(pidfile)
.with_context(|| format!("failed to read pidfile {:?}", pidfile))?;
let pid: i32 = pid_str
.parse()
.map_err(|_| anyhow!("failed to parse pidfile {:?}", pidfile))?;
if pid < 1 {
bail!("pidfile {:?} contained bad value '{}'", pidfile, pid);
}
Ok(pid)
}
|
#[doc = "Reader of register HB8CFG"]
pub type R = crate::R<u32, super::HB8CFG>;
#[doc = "Writer for register HB8CFG"]
pub type W = crate::W<u32, super::HB8CFG>;
#[doc = "Register HB8CFG `reset()`'s with value 0"]
impl crate::ResetValue for super::HB8CFG {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Host Bus Sub-Mode\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum MODE_A {
#[doc = "0: ADMUX - AD\\[7:0\\]"]
MUX = 0,
#[doc = "1: ADNONMUX - D\\[7:0\\]"]
NMUX = 1,
#[doc = "2: Continuous Read - D\\[7:0\\]"]
SRAM = 2,
#[doc = "3: XFIFO - D\\[7:0\\]"]
FIFO = 3,
}
impl From<MODE_A> for u8 {
#[inline(always)]
fn from(variant: MODE_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `MODE`"]
pub type MODE_R = crate::R<u8, MODE_A>;
impl MODE_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> MODE_A {
match self.bits {
0 => MODE_A::MUX,
1 => MODE_A::NMUX,
2 => MODE_A::SRAM,
3 => MODE_A::FIFO,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `MUX`"]
#[inline(always)]
pub fn is_mux(&self) -> bool {
*self == MODE_A::MUX
}
#[doc = "Checks if the value of the field is `NMUX`"]
#[inline(always)]
pub fn is_nmux(&self) -> bool {
*self == MODE_A::NMUX
}
#[doc = "Checks if the value of the field is `SRAM`"]
#[inline(always)]
pub fn is_sram(&self) -> bool {
*self == MODE_A::SRAM
}
#[doc = "Checks if the value of the field is `FIFO`"]
#[inline(always)]
pub fn is_fifo(&self) -> bool {
*self == MODE_A::FIFO
}
}
#[doc = "Write proxy for field `MODE`"]
pub struct MODE_W<'a> {
w: &'a mut W,
}
impl<'a> MODE_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: MODE_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "ADMUX - AD\\[7:0\\]"]
#[inline(always)]
pub fn mux(self) -> &'a mut W {
self.variant(MODE_A::MUX)
}
#[doc = "ADNONMUX - D\\[7:0\\]"]
#[inline(always)]
pub fn nmux(self) -> &'a mut W {
self.variant(MODE_A::NMUX)
}
#[doc = "Continuous Read - D\\[7:0\\]"]
#[inline(always)]
pub fn sram(self) -> &'a mut W {
self.variant(MODE_A::SRAM)
}
#[doc = "XFIFO - D\\[7:0\\]"]
#[inline(always)]
pub fn fifo(self) -> &'a mut W {
self.variant(MODE_A::FIFO)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !0x03) | ((value as u32) & 0x03);
self.w
}
}
#[doc = "Read Wait States\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum RDWS_A {
#[doc = "0: Active RDn is 2 EPI clocks"]
_2 = 0,
#[doc = "1: Active RDn is 4 EPI clocks"]
_4 = 1,
#[doc = "2: Active RDn is 6 EPI clocks"]
_6 = 2,
#[doc = "3: Active RDn is 8 EPI clocks"]
_8 = 3,
}
impl From<RDWS_A> for u8 {
#[inline(always)]
fn from(variant: RDWS_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `RDWS`"]
pub type RDWS_R = crate::R<u8, RDWS_A>;
impl RDWS_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> RDWS_A {
match self.bits {
0 => RDWS_A::_2,
1 => RDWS_A::_4,
2 => RDWS_A::_6,
3 => RDWS_A::_8,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `_2`"]
#[inline(always)]
pub fn is_2(&self) -> bool {
*self == RDWS_A::_2
}
#[doc = "Checks if the value of the field is `_4`"]
#[inline(always)]
pub fn is_4(&self) -> bool {
*self == RDWS_A::_4
}
#[doc = "Checks if the value of the field is `_6`"]
#[inline(always)]
pub fn is_6(&self) -> bool {
*self == RDWS_A::_6
}
#[doc = "Checks if the value of the field is `_8`"]
#[inline(always)]
pub fn is_8(&self) -> bool {
*self == RDWS_A::_8
}
}
#[doc = "Write proxy for field `RDWS`"]
pub struct RDWS_W<'a> {
w: &'a mut W,
}
impl<'a> RDWS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: RDWS_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "Active RDn is 2 EPI clocks"]
#[inline(always)]
pub fn _2(self) -> &'a mut W {
self.variant(RDWS_A::_2)
}
#[doc = "Active RDn is 4 EPI clocks"]
#[inline(always)]
pub fn _4(self) -> &'a mut W {
self.variant(RDWS_A::_4)
}
#[doc = "Active RDn is 6 EPI clocks"]
#[inline(always)]
pub fn _6(self) -> &'a mut W {
self.variant(RDWS_A::_6)
}
#[doc = "Active RDn is 8 EPI clocks"]
#[inline(always)]
pub fn _8(self) -> &'a mut W {
self.variant(RDWS_A::_8)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
self.w
}
}
#[doc = "Write Wait States\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum WRWS_A {
#[doc = "0: Active WRn is 2 EPI clocks"]
_2 = 0,
#[doc = "1: Active WRn is 4 EPI clocks"]
_4 = 1,
#[doc = "2: Active WRn is 6 EPI clocks"]
_6 = 2,
#[doc = "3: Active WRn is 8 EPI clocks"]
_8 = 3,
}
impl From<WRWS_A> for u8 {
#[inline(always)]
fn from(variant: WRWS_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `WRWS`"]
pub type WRWS_R = crate::R<u8, WRWS_A>;
impl WRWS_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> WRWS_A {
match self.bits {
0 => WRWS_A::_2,
1 => WRWS_A::_4,
2 => WRWS_A::_6,
3 => WRWS_A::_8,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `_2`"]
#[inline(always)]
pub fn is_2(&self) -> bool {
*self == WRWS_A::_2
}
#[doc = "Checks if the value of the field is `_4`"]
#[inline(always)]
pub fn is_4(&self) -> bool {
*self == WRWS_A::_4
}
#[doc = "Checks if the value of the field is `_6`"]
#[inline(always)]
pub fn is_6(&self) -> bool {
*self == WRWS_A::_6
}
#[doc = "Checks if the value of the field is `_8`"]
#[inline(always)]
pub fn is_8(&self) -> bool {
*self == WRWS_A::_8
}
}
#[doc = "Write proxy for field `WRWS`"]
pub struct WRWS_W<'a> {
w: &'a mut W,
}
impl<'a> WRWS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: WRWS_A) -> &'a mut W {
{
self.bits(variant.into())
}
}
#[doc = "Active WRn is 2 EPI clocks"]
#[inline(always)]
pub fn _2(self) -> &'a mut W {
self.variant(WRWS_A::_2)
}
#[doc = "Active WRn is 4 EPI clocks"]
#[inline(always)]
pub fn _4(self) -> &'a mut W {
self.variant(WRWS_A::_4)
}
#[doc = "Active WRn is 6 EPI clocks"]
#[inline(always)]
pub fn _6(self) -> &'a mut W {
self.variant(WRWS_A::_6)
}
#[doc = "Active WRn is 8 EPI clocks"]
#[inline(always)]
pub fn _8(self) -> &'a mut W {
self.variant(WRWS_A::_8)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u32) & 0x03) << 6);
self.w
}
}
#[doc = "Reader of field `MAXWAIT`"]
pub type MAXWAIT_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `MAXWAIT`"]
pub struct MAXWAIT_W<'a> {
w: &'a mut W,
}
impl<'a> MAXWAIT_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0xff << 8)) | (((value as u32) & 0xff) << 8);
self.w
}
}
#[doc = "Reader of field `ALEHIGH`"]
pub type ALEHIGH_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `ALEHIGH`"]
pub struct ALEHIGH_W<'a> {
w: &'a mut W,
}
impl<'a> ALEHIGH_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 `RDHIGH`"]
pub type RDHIGH_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RDHIGH`"]
pub struct RDHIGH_W<'a> {
w: &'a mut W,
}
impl<'a> RDHIGH_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 `WRHIGH`"]
pub type WRHIGH_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `WRHIGH`"]
pub struct WRHIGH_W<'a> {
w: &'a mut W,
}
impl<'a> WRHIGH_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 `XFEEN`"]
pub type XFEEN_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `XFEEN`"]
pub struct XFEEN_W<'a> {
w: &'a mut W,
}
impl<'a> XFEEN_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 `XFFEN`"]
pub type XFFEN_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `XFFEN`"]
pub struct XFFEN_W<'a> {
w: &'a mut W,
}
impl<'a> XFFEN_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 `IRDYINV`"]
pub type IRDYINV_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `IRDYINV`"]
pub struct IRDYINV_W<'a> {
w: &'a mut W,
}
impl<'a> IRDYINV_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 `RDYEN`"]
pub type RDYEN_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RDYEN`"]
pub struct RDYEN_W<'a> {
w: &'a mut W,
}
impl<'a> RDYEN_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 `CLKINV`"]
pub type CLKINV_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CLKINV`"]
pub struct CLKINV_W<'a> {
w: &'a mut W,
}
impl<'a> CLKINV_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 `CLKGATEI`"]
pub type CLKGATEI_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CLKGATEI`"]
pub struct CLKGATEI_W<'a> {
w: &'a mut W,
}
impl<'a> CLKGATEI_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 `CLKGATE`"]
pub type CLKGATE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CLKGATE`"]
pub struct CLKGATE_W<'a> {
w: &'a mut W,
}
impl<'a> CLKGATE_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 = "Bits 0:1 - Host Bus Sub-Mode"]
#[inline(always)]
pub fn mode(&self) -> MODE_R {
MODE_R::new((self.bits & 0x03) as u8)
}
#[doc = "Bits 4:5 - Read Wait States"]
#[inline(always)]
pub fn rdws(&self) -> RDWS_R {
RDWS_R::new(((self.bits >> 4) & 0x03) as u8)
}
#[doc = "Bits 6:7 - Write Wait States"]
#[inline(always)]
pub fn wrws(&self) -> WRWS_R {
WRWS_R::new(((self.bits >> 6) & 0x03) as u8)
}
#[doc = "Bits 8:15 - Maximum Wait"]
#[inline(always)]
pub fn maxwait(&self) -> MAXWAIT_R {
MAXWAIT_R::new(((self.bits >> 8) & 0xff) as u8)
}
#[doc = "Bit 19 - ALE Strobe Polarity"]
#[inline(always)]
pub fn alehigh(&self) -> ALEHIGH_R {
ALEHIGH_R::new(((self.bits >> 19) & 0x01) != 0)
}
#[doc = "Bit 20 - READ Strobe Polarity"]
#[inline(always)]
pub fn rdhigh(&self) -> RDHIGH_R {
RDHIGH_R::new(((self.bits >> 20) & 0x01) != 0)
}
#[doc = "Bit 21 - WRITE Strobe Polarity"]
#[inline(always)]
pub fn wrhigh(&self) -> WRHIGH_R {
WRHIGH_R::new(((self.bits >> 21) & 0x01) != 0)
}
#[doc = "Bit 22 - External FIFO EMPTY Enable"]
#[inline(always)]
pub fn xfeen(&self) -> XFEEN_R {
XFEEN_R::new(((self.bits >> 22) & 0x01) != 0)
}
#[doc = "Bit 23 - External FIFO FULL Enable"]
#[inline(always)]
pub fn xffen(&self) -> XFFEN_R {
XFFEN_R::new(((self.bits >> 23) & 0x01) != 0)
}
#[doc = "Bit 27 - Input Ready Invert"]
#[inline(always)]
pub fn irdyinv(&self) -> IRDYINV_R {
IRDYINV_R::new(((self.bits >> 27) & 0x01) != 0)
}
#[doc = "Bit 28 - Input Ready Enable"]
#[inline(always)]
pub fn rdyen(&self) -> RDYEN_R {
RDYEN_R::new(((self.bits >> 28) & 0x01) != 0)
}
#[doc = "Bit 29 - Invert Output Clock Enable"]
#[inline(always)]
pub fn clkinv(&self) -> CLKINV_R {
CLKINV_R::new(((self.bits >> 29) & 0x01) != 0)
}
#[doc = "Bit 30 - Clock Gated when Idle"]
#[inline(always)]
pub fn clkgatei(&self) -> CLKGATEI_R {
CLKGATEI_R::new(((self.bits >> 30) & 0x01) != 0)
}
#[doc = "Bit 31 - Clock Gated"]
#[inline(always)]
pub fn clkgate(&self) -> CLKGATE_R {
CLKGATE_R::new(((self.bits >> 31) & 0x01) != 0)
}
}
impl W {
#[doc = "Bits 0:1 - Host Bus Sub-Mode"]
#[inline(always)]
pub fn mode(&mut self) -> MODE_W {
MODE_W { w: self }
}
#[doc = "Bits 4:5 - Read Wait States"]
#[inline(always)]
pub fn rdws(&mut self) -> RDWS_W {
RDWS_W { w: self }
}
#[doc = "Bits 6:7 - Write Wait States"]
#[inline(always)]
pub fn wrws(&mut self) -> WRWS_W {
WRWS_W { w: self }
}
#[doc = "Bits 8:15 - Maximum Wait"]
#[inline(always)]
pub fn maxwait(&mut self) -> MAXWAIT_W {
MAXWAIT_W { w: self }
}
#[doc = "Bit 19 - ALE Strobe Polarity"]
#[inline(always)]
pub fn alehigh(&mut self) -> ALEHIGH_W {
ALEHIGH_W { w: self }
}
#[doc = "Bit 20 - READ Strobe Polarity"]
#[inline(always)]
pub fn rdhigh(&mut self) -> RDHIGH_W {
RDHIGH_W { w: self }
}
#[doc = "Bit 21 - WRITE Strobe Polarity"]
#[inline(always)]
pub fn wrhigh(&mut self) -> WRHIGH_W {
WRHIGH_W { w: self }
}
#[doc = "Bit 22 - External FIFO EMPTY Enable"]
#[inline(always)]
pub fn xfeen(&mut self) -> XFEEN_W {
XFEEN_W { w: self }
}
#[doc = "Bit 23 - External FIFO FULL Enable"]
#[inline(always)]
pub fn xffen(&mut self) -> XFFEN_W {
XFFEN_W { w: self }
}
#[doc = "Bit 27 - Input Ready Invert"]
#[inline(always)]
pub fn irdyinv(&mut self) -> IRDYINV_W {
IRDYINV_W { w: self }
}
#[doc = "Bit 28 - Input Ready Enable"]
#[inline(always)]
pub fn rdyen(&mut self) -> RDYEN_W {
RDYEN_W { w: self }
}
#[doc = "Bit 29 - Invert Output Clock Enable"]
#[inline(always)]
pub fn clkinv(&mut self) -> CLKINV_W {
CLKINV_W { w: self }
}
#[doc = "Bit 30 - Clock Gated when Idle"]
#[inline(always)]
pub fn clkgatei(&mut self) -> CLKGATEI_W {
CLKGATEI_W { w: self }
}
#[doc = "Bit 31 - Clock Gated"]
#[inline(always)]
pub fn clkgate(&mut self) -> CLKGATE_W {
CLKGATE_W { w: self }
}
}
|
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
const ten97: usize = 1000000007;
fn alphabet2idx(c: char) -> usize {
if c.is_ascii_lowercase() {
c as u8 as usize - 'a' as u8 as usize
} else if c.is_ascii_uppercase() {
c as u8 as usize - 'A' as u8 as usize
} else {
panic!("wtf")
}
}
fn main() {
let n: usize = parse_line().unwrap();
let mut aaa: Vec<Vec<usize>> = vec![];
aaa.push(vec![]);
for _ in 0..n {
aaa.push(parse_line().unwrap());
}
let m: usize = parse_line().unwrap();
let mut kankei: Vec<Vec<bool>> = vec![vec![true; n + 1]; n + 1];
for _ in 0..m {
let (x, y): (usize, usize) = parse_line().unwrap();
kankei[x][y] = false;
kankei[y][x] = false;
}
let mut hm = HashSet::new();
for i in 1..n + 1 {
hm.insert(i);
}
let mut ans = std::usize::MAX;
for last in 1..n + 1 {
let mut tmp = hm.clone();
tmp.remove(&last);
let a = dfs(n, n - 1, last, tmp, &aaa, &kankei);
if a == std::usize::MAX {
continue;
}
ans = min(ans, a + aaa[last][0]);
}
if ans == std::usize::MAX {
println!("-1");
} else {
println!("{}", ans);
}
}
fn dfs(
N: usize,
n: usize,
last: usize,
nokori: HashSet<usize>,
aaa: &Vec<Vec<usize>>,
kankei: &Vec<Vec<bool>>,
) -> usize {
if nokori.is_empty() {
return 0;
}
let mut ans = std::usize::MAX;
for next in nokori.iter() {
if !kankei[last][*next] {
continue;
}
let mut nn = nokori.clone();
nn.remove(next);
let tmp = dfs(N, n - 1, *next, nn, aaa, kankei);
if tmp == std::usize::MAX {
continue;
} else {
ans = min(ans, tmp + aaa[*next][N - n]);
}
}
ans
}
|
#[macro_use]
extern crate failure;
use failure::Error;
use std::{env, fs, path::Path};
fn main() -> Result<(), Error> {
let path = env::var("NIX_PATH")?;
let nixpkgs = path.split(':')
.find(|s| s.starts_with("nixpkgs="))
.ok_or_else(|| format_err!("no store path found"))?;
println!("Nix store path: {}", nixpkgs);
recurse(Path::new(&nixpkgs["nixpkgs=".len()..]))
}
fn recurse(path: &Path) -> Result<(), Error> {
if path.metadata()?.is_file() {
if path.extension().and_then(|s| s.to_str()) != Some("nix") {
return Ok(());
}
println!("Checking {}", path.display());
let original = fs::read_to_string(path)?;
let parsed = rnix::parse(&original)?.to_string();
if original != parsed {
eprintln!("Original input does not match parsed output!");
println!("Input:");
println!("----------");
println!("{}", original);
println!("----------");
println!("Output:");
println!("----------");
println!("{}", parsed);
println!("----------");
bail!("parsing error");
}
return Ok(());
} else {
for entry in path.read_dir()? {
let entry = entry?;
if entry.file_type()?.is_symlink() {
continue;
}
recurse(&entry.path())?;
}
}
Ok(())
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.