text stringlengths 8 4.13M |
|---|
use rand::Rng;
use std::cmp::{max, min};
use std::fmt;
// const DICE_CHARS: [char; 6] = ['⚀', '⚁', '⚂', '⚃', '⚄', '⚅'];
const DICE_CHARS: [char; 6] = ['1', '2', '3', '4', '5', '6'];
#[derive(Debug, PartialEq)]
pub struct Dice {
first: u8,
second: u8,
}
impl Dice {
pub fn make(first: u8, second: u8) -> Dice {
if !(1..=6).contains(&first) {
panic!("Invalid die value: {}", first);
}
if !(1..=6).contains(&second) {
panic!("Invalid die value: {}", second);
}
Dice {
first: max(first, second),
second: min(first, second),
}
}
pub fn roll() -> Dice {
let r = rand::thread_rng().gen_range(0..36);
Dice {
first: r % 6 + 1,
second: r / 6 + 1,
}
}
pub fn high(&self) -> u8 {
self.first
}
pub fn low(&self) -> u8 {
self.second
}
pub fn is_double(&self) -> bool {
self.first == self.second
}
}
impl fmt::Display for Dice {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(
f,
"{}-{}",
DICE_CHARS[usize::from(self.high() - 1)],
DICE_CHARS[usize::from(self.low() - 1)]
)
}
}
impl Eq for Dice {}
#[cfg(test)]
mod tests {
use super::*;
const TEST_ROLLS: u32 = 1_000_000;
#[test]
fn test_dist_1() -> () {
let mut d1_counts: [u32; 6] = [0; 6];
let mut d2_counts: [u32; 6] = [0; 6];
let mut sum_counts: [u32; 11] = [0; 11];
for _ in 0..TEST_ROLLS {
let r = Dice::roll();
d1_counts[usize::from(r.first - 1)] += 1;
d2_counts[usize::from(r.second - 1)] += 1;
sum_counts[usize::from(r.first + r.second) - 2] += 1;
}
for i in 0..6 {
let d1_ratio = f64::from(d1_counts[i]) / f64::from(TEST_ROLLS);
let d2_ratio = f64::from(d2_counts[i]) / f64::from(TEST_ROLLS);
assert!(d1_ratio >= 1.0 / 6.5 && d1_ratio <= 1.0 / 5.5);
assert!(d2_ratio >= 1.0 / 6.5 && d2_ratio <= 1.0 / 5.5);
}
let expected_dist: [f64; 11] = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 5.0, 4.0, 3.0, 2.0, 1.0];
for i in 0..11 {
let freq = 36.0 * f64::from(sum_counts[i]) / f64::from(TEST_ROLLS);
assert!(f64::abs(freq - expected_dist[i]) < 0.1);
}
}
}
|
pub mod test_new_filestream;
pub mod test_write;
pub mod test_rw;
pub mod test_read; |
/// A runtime module template with necessary imports
/// Feel free to remove or edit this file as needed.
/// If you change the name of this file, make sure to update its references in runtime/src/lib.rs
/// If you remove this file, you can remove those references
/// For more guidance on Substrate modules, see the example module
/// https://github.com/paritytech/substrate/blob/master/srml/example/src/lib.rs
use support::{decl_module, decl_storage, decl_event, StorageValue, dispatch::Result, Parameter, ensure, StorageMap};
use system::ensure_signed;
use sr_primitives::traits::{
Hash, SimpleArithmetic,
};
use codec::{Decode, Encode};
#[derive(Encode, Decode, Default, Clone, PartialEq)]
#[cfg_attr(feature = "std", derive(Debug))]
pub struct Kitty<Hash, AccountId, KittyId> {
id: KittyId,
dna: Hash,
owner: AccountId,
}
/// The module's configuration trait.
pub trait Trait: system::Trait {
// TODO: Add other types and constants required configure this module.
/// The overarching event type.
type Event: From<Event<Self>> + Into<<Self as system::Trait>::Event>;
type KittyId: Parameter + SimpleArithmetic + Default + Copy;
}
// This module's storage items.
decl_storage! {
trait Store for Module<T: Trait> as TemplateModule {
// Just a dummy storage item.
// Here we are declaring a StorageValue, `Something` as a Option<u32>
// `get(something)` is the default getter which returns either the stored `u32` or `None` if nothing stored
Kitties get(kitties): map T::KittyId => Kitty<T::Hash, T::AccountId, T::KittyId>;
KittyOwner get(kitty_owner): map T::KittyId => Option<T::AccountId>;
KittyCount get(kitty_count): u64;
OwnedKittyCount get(owned_kitty_count): map T::AccountId => u64;
OwnedKittyIndex get(owned_kitty_index): map (T::AccountId, u64) => T::KittyId; // 返回玩家第 u64 只猫在所有猫中的 KittyId
OwnedKittyId get(owned_kitty_id): map T::KittyId => (T::AccountId, u64); // 根据 KittyId 返回该猫在哪个玩家那里排名第几只。
NextKittyIndex get(next_kitty_index) config(): T::KittyId;
Nonce get(nonce): u64;
Admin get(admin) config(): T::AccountId;
}
}
// The module's dispatchable functions.
decl_module! {
/// The module declaration.
pub struct Module<T: Trait> for enum Call where origin: T::Origin {
// Initializing events
// this is needed only if you are using events in your module
fn deposit_event() = default;
// Just a dummy entry point.
// function that can be called by the external world as an extrinsics call
// takes a parameter of the type `AccountId`, stores it and emits an event
pub fn new_kitty(origin) -> Result {
// TODO: You only need this if you want to check it was signed.
let who = ensure_signed(origin)?;
ensure!(who == Self::admin(), "only Admin can new a kitty");
let nonce = <Nonce>::get();
let dna = (<system::Module<T>>::random_seed(), &who, nonce)
.using_encoded(<T as system::Trait>::Hashing::hash);
<Nonce>::mutate(|n| *n += 1);
let id = Self::next_kitty_index();
let _kitty = Kitty {
id: id,
dna: dna,
owner: who.clone(),
};
let _count = Self::kitty_count();
let _count = _count + 1;
let owned_count = Self::owned_kitty_count(&who);
let owned_count = owned_count + 1;
<Kitties<T>>::insert(id, _kitty);
<KittyOwner<T>>::insert(id, &who);
<KittyCount>::mutate(|n| *n += 1);
<OwnedKittyCount<T>>::insert(&who, owned_count);
<OwnedKittyIndex<T>>::insert((who.clone(), owned_count - 1), id);
<OwnedKittyId<T>>::insert(id, (who.clone(), owned_count -1 ));
let id = id + T::KittyId::from(1);
<NextKittyIndex<T>>::put(id);
// here we are raising the Something event
Self::deposit_event(RawEvent::NewKitty(who, id, dna));
Ok(())
}
}
}
decl_event!(
pub enum Event<T>
where
<T as system::Trait>::AccountId,
<T as system::Trait>::Hash,
<T as self::Trait>::KittyId,
{
// Just a dummy event.
// Event `Something` is declared with a parameter of the type `u32` and `AccountId`
// To emit this event, we call the deposit funtion, from our runtime funtions
NewKitty(AccountId, KittyId, Hash),
}
);
/// tests for this module
#[cfg(test)]
mod tests {
use super::*;
use runtime_io::with_externalities;
use primitives::{H256, Blake2Hasher};
use support::{impl_outer_origin, assert_ok, parameter_types};
use sr_primitives::{traits::{BlakeTwo256, IdentityLookup}, testing::Header};
use sr_primitives::weights::Weight;
use sr_primitives::Perbill;
impl_outer_origin! {
pub enum Origin for Test {}
}
// For testing the module, we construct most of a mock runtime. This means
// first constructing a configuration type (`Test`) which `impl`s each of the
// configuration traits of modules we want to use.
#[derive(Clone, Eq, PartialEq)]
pub struct Test;
parameter_types! {
pub const BlockHashCount: u64 = 250;
pub const MaximumBlockWeight: Weight = 1024;
pub const MaximumBlockLength: u32 = 2 * 1024;
pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);
}
impl system::Trait for Test {
type Origin = Origin;
type Call = ();
type Index = u64;
type BlockNumber = u64;
type Hash = H256;
type Hashing = BlakeTwo256;
type AccountId = u64;
type Lookup = IdentityLookup<Self::AccountId>;
type Header = Header;
type WeightMultiplierUpdate = ();
type Event = ();
type BlockHashCount = BlockHashCount;
type MaximumBlockWeight = MaximumBlockWeight;
type MaximumBlockLength = MaximumBlockLength;
type AvailableBlockRatio = AvailableBlockRatio;
type Version = ();
}
impl Trait for Test {
type Event = ();
}
type TemplateModule = Module<Test>;
// This function basically just builds a genesis storage key/value store according to
// our desired mockup.
fn new_test_ext() -> runtime_io::TestExternalities<Blake2Hasher> {
system::GenesisConfig::default().build_storage::<Test>().unwrap().into()
}
#[test]
fn it_works_for_default_value() {
with_externalities(&mut new_test_ext(), || {
// Just a dummy test for the dummy funtion `do_something`
// calling the `do_something` function with a value 42
assert_ok!(TemplateModule::do_something(Origin::signed(1), 42));
// asserting that the stored value is equal to what we stored
assert_eq!(TemplateModule::something(), Some(42));
});
}
}
|
use crate::datastructure::basic::BasicDataStructure;
use crate::postprocessors::gamma::Gamma;
use crate::raytracer::jmstrace::JMSTracer;
use crate::renderer::RendererBuilder;
use crate::scene::scene::SceneBuilder;
use crate::setup::Setup;
use crate::shader::vmcshader::VMcShader;
use crate::util::camera::Camera;
use crate::util::vector::Vector;
use std::path::Path;
use std::process;
pub struct GlowStoneGamma;
impl Setup for GlowStoneGamma {
fn run(&self) {
let tobj = tobj::load_obj("scenes/glowstone.obj".as_ref()).unwrap_or_else(|err| {
eprintln!("Couldn't open obj file: {}", err);
process::exit(1);
});
let scene = SceneBuilder::new()
.texturepath(Path::new("scenes"))
.build_from_tobj(tobj)
.unwrap_or_else(|err| {
eprintln!("Couldn't create scene: {:?}", err);
process::exit(1);
});
let ds = BasicDataStructure::new(&scene);
let renderer = RendererBuilder::new(&ds)
.with_shader(&VMcShader)
.with_tracer(&JMSTracer)
.with_postprocessor(&Gamma);
let camera = Camera::new(Vector::new(0.5, 2.2, 3.), 1000, 1000, 60f64);
renderer
.render(&camera)
.to_bmp()
.save("render.bmp")
.expect("Couldn't save");
}
}
|
use super::component_prelude::*;
pub struct Loader {
pub loading_distance: Vector,
}
impl Loader {
pub fn new(loading_distance: Vector) -> Self {
Self { loading_distance }
}
}
impl Component for Loader {
type Storage = VecStorage<Self>;
}
|
use crate::{FieldType, MessageType, MatchFieldTypeFn};
fn match_field_accelerometer_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Float32,
6 => FieldType::Float32,
7 => FieldType::Float32,
8 => FieldType::Sint16,
9 => FieldType::Sint16,
10 => FieldType::Sint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_activity(k: usize) -> FieldType {
match k {
0 => FieldType::Uint32,
1 => FieldType::Uint16,
2 => FieldType::Activity,
3 => FieldType::Event,
4 => FieldType::EventType,
5 => FieldType::Timestamp,
6 => FieldType::Uint8,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_ant_channel_id(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Uint8Z,
2 => FieldType::Uint16Z,
3 => FieldType::Uint8Z,
4 => FieldType::DeviceIndex,
_ => FieldType::None,
}
}
fn match_field_ant_rx(k: usize) -> FieldType {
match k {
0 => FieldType::Timestamp,
1 => FieldType::Byte,
2 => FieldType::Byte,
3 => FieldType::Uint8,
4 => FieldType::Byte,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_ant_tx(k: usize) -> FieldType {
match k {
0 => FieldType::Timestamp,
1 => FieldType::Byte,
2 => FieldType::Byte,
3 => FieldType::Uint8,
4 => FieldType::Byte,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_aviation_attitude(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint32,
2 => FieldType::Sint16,
3 => FieldType::Sint16,
4 => FieldType::Sint16,
5 => FieldType::Sint16,
6 => FieldType::Sint16,
7 => FieldType::AttitudeStage,
8 => FieldType::Uint8,
9 => FieldType::Uint16,
10 => FieldType::AttitudeValidity,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_barometer_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_bike_profile(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::Sport,
2 => FieldType::SubSport,
3 => FieldType::Uint32,
4 => FieldType::Uint16Z,
5 => FieldType::Uint16Z,
6 => FieldType::Uint16Z,
7 => FieldType::Uint16Z,
8 => FieldType::Uint16,
9 => FieldType::Uint16,
10 => FieldType::Uint16,
11 => FieldType::Uint16,
12 => FieldType::Bool,
13 => FieldType::Bool,
14 => FieldType::Uint8,
15 => FieldType::Bool,
16 => FieldType::Bool,
17 => FieldType::Bool,
18 => FieldType::Bool,
19 => FieldType::Uint8,
20 => FieldType::Bool,
21 => FieldType::Uint8Z,
22 => FieldType::Uint8Z,
23 => FieldType::Uint8Z,
24 => FieldType::Uint8Z,
37 => FieldType::Uint8,
38 => FieldType::Uint8Z,
39 => FieldType::Uint8Z,
40 => FieldType::Uint8Z,
41 => FieldType::Uint8Z,
44 => FieldType::Bool,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_blood_pressure(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Uint16,
6 => FieldType::Uint8,
7 => FieldType::HrType,
8 => FieldType::BpStatus,
9 => FieldType::MessageIndex,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_cadence_zone(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_camera_event(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::CameraEventType,
2 => FieldType::String,
3 => FieldType::CameraOrientationType,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_capabilities(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8Z,
1 => FieldType::SportBits0,
21 => FieldType::WorkoutCapabilities,
23 => FieldType::ConnectivityCapabilities,
_ => FieldType::None,
}
}
fn match_field_climb_pro(k: usize) -> FieldType {
match k {
0 => FieldType::Coordinates,
1 => FieldType::Coordinates,
2 => FieldType::ClimbProEvent,
3 => FieldType::Uint16,
4 => FieldType::Uint8,
5 => FieldType::Float32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_connectivity(k: usize) -> FieldType {
match k {
0 => FieldType::Bool,
1 => FieldType::Bool,
2 => FieldType::Bool,
3 => FieldType::String,
4 => FieldType::Bool,
5 => FieldType::Bool,
6 => FieldType::Bool,
7 => FieldType::Bool,
8 => FieldType::Bool,
9 => FieldType::Bool,
10 => FieldType::Bool,
11 => FieldType::Bool,
12 => FieldType::Bool,
_ => FieldType::None,
}
}
fn match_field_course(k: usize) -> FieldType {
match k {
4 => FieldType::Sport,
5 => FieldType::String,
6 => FieldType::CourseCapabilities,
7 => FieldType::SubSport,
_ => FieldType::None,
}
}
fn match_field_course_point(k: usize) -> FieldType {
match k {
1 => FieldType::Timestamp,
2 => FieldType::Coordinates,
3 => FieldType::Coordinates,
4 => FieldType::Uint32,
5 => FieldType::CoursePoint,
6 => FieldType::String,
8 => FieldType::Bool,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_developer_data_id(k: usize) -> FieldType {
match k {
0 => FieldType::Byte,
1 => FieldType::Byte,
2 => FieldType::Manufacturer,
3 => FieldType::Uint8,
4 => FieldType::Uint32,
_ => FieldType::None,
}
}
fn match_field_device_aux_battery_info(k: usize) -> FieldType {
match k {
0 => FieldType::DeviceIndex,
1 => FieldType::Uint16,
2 => FieldType::BatteryStatus,
3 => FieldType::Uint8,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_device_info(k: usize) -> FieldType {
match k {
0 => FieldType::DeviceIndex,
1 => FieldType::Uint8,
2 => FieldType::Manufacturer,
3 => FieldType::Uint32Z,
4 => FieldType::Uint16,
5 => FieldType::Uint16,
6 => FieldType::Uint8,
7 => FieldType::Uint32,
10 => FieldType::Uint16,
11 => FieldType::BatteryStatus,
18 => FieldType::BodyLocation,
19 => FieldType::String,
20 => FieldType::Uint8Z,
21 => FieldType::Uint16Z,
22 => FieldType::AntNetwork,
25 => FieldType::SourceType,
27 => FieldType::String,
32 => FieldType::Uint8,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_device_settings(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Uint32,
2 => FieldType::Uint32,
4 => FieldType::TimeMode,
5 => FieldType::Sint8,
12 => FieldType::BacklightMode,
36 => FieldType::Bool,
39 => FieldType::DateTime,
40 => FieldType::Uint16,
46 => FieldType::Bool,
47 => FieldType::DateMode,
55 => FieldType::DisplayOrientation,
56 => FieldType::Side,
57 => FieldType::Uint16,
58 => FieldType::Uint16,
59 => FieldType::Uint16,
80 => FieldType::Bool,
86 => FieldType::Bool,
89 => FieldType::AutoSyncFrequency,
90 => FieldType::AutoActivityDetect,
94 => FieldType::Uint8,
95 => FieldType::DisplayOrientation,
134 => FieldType::Switch,
174 => FieldType::TapSensitivity,
_ => FieldType::None,
}
}
fn match_field_dive_alarm(k: usize) -> FieldType {
match k {
0 => FieldType::Uint32,
1 => FieldType::Sint32,
2 => FieldType::Bool,
3 => FieldType::DiveAlarmType,
4 => FieldType::Tone,
5 => FieldType::SubSport,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_dive_gas(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Uint8,
2 => FieldType::DiveGasStatus,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_dive_settings(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::TissueModelType,
2 => FieldType::Uint8,
3 => FieldType::Uint8,
4 => FieldType::WaterType,
5 => FieldType::Float32,
6 => FieldType::Uint8,
7 => FieldType::Uint8,
8 => FieldType::Uint8,
9 => FieldType::Bool,
10 => FieldType::Float32,
11 => FieldType::Uint32,
12 => FieldType::Bool,
13 => FieldType::Uint32,
14 => FieldType::DiveBacklightMode,
15 => FieldType::Uint8,
16 => FieldType::BacklightTimeout,
17 => FieldType::Uint16,
18 => FieldType::Uint16,
19 => FieldType::SourceType,
20 => FieldType::Uint8,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_dive_summary(k: usize) -> FieldType {
match k {
0 => FieldType::MesgNum,
1 => FieldType::MessageIndex,
2 => FieldType::Uint32,
3 => FieldType::Uint32,
4 => FieldType::Uint32,
5 => FieldType::Uint8,
6 => FieldType::Uint8,
7 => FieldType::Uint16,
8 => FieldType::Uint16,
9 => FieldType::Uint16,
10 => FieldType::Uint32,
11 => FieldType::Uint32,
17 => FieldType::Sint32,
22 => FieldType::Uint32,
23 => FieldType::Uint32,
24 => FieldType::Uint32,
25 => FieldType::Uint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_event(k: usize) -> FieldType {
match k {
0 => FieldType::Event,
1 => FieldType::EventType,
2 => FieldType::Uint16,
3 => FieldType::Uint32,
4 => FieldType::Uint8,
7 => FieldType::Uint16,
8 => FieldType::Uint16,
9 => FieldType::Uint8Z,
10 => FieldType::Uint8Z,
11 => FieldType::Uint8Z,
12 => FieldType::Uint8Z,
13 => FieldType::DeviceIndex,
21 => FieldType::RadarThreatLevelType,
22 => FieldType::Uint8,
23 => FieldType::Uint8,
24 => FieldType::Uint8,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_exd_data_concept_configuration(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Byte,
2 => FieldType::Uint8,
3 => FieldType::Uint8,
4 => FieldType::Uint8,
5 => FieldType::Uint8,
6 => FieldType::Uint8,
8 => FieldType::ExdDataUnits,
9 => FieldType::ExdQualifiers,
10 => FieldType::ExdDescriptors,
11 => FieldType::Bool,
_ => FieldType::None,
}
}
fn match_field_exd_data_field_configuration(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Byte,
2 => FieldType::Uint8,
3 => FieldType::Uint8,
4 => FieldType::ExdDisplayType,
5 => FieldType::String,
_ => FieldType::None,
}
}
fn match_field_exd_screen_configuration(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Uint8,
2 => FieldType::ExdLayout,
3 => FieldType::Bool,
_ => FieldType::None,
}
}
fn match_field_exercise_title(k: usize) -> FieldType {
match k {
0 => FieldType::ExerciseCategory,
1 => FieldType::Uint16,
2 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_field_capabilities(k: usize) -> FieldType {
match k {
0 => FieldType::File,
1 => FieldType::MesgNum,
2 => FieldType::Uint8,
3 => FieldType::Uint16,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_field_description(k: usize) -> FieldType {
match k {
0 => FieldType::Uint8,
1 => FieldType::Uint8,
2 => FieldType::FitBaseType,
3 => FieldType::String,
4 => FieldType::Uint8,
5 => FieldType::String,
6 => FieldType::Uint8,
7 => FieldType::Sint8,
8 => FieldType::String,
9 => FieldType::String,
10 => FieldType::String,
13 => FieldType::FitBaseUnit,
14 => FieldType::MesgNum,
15 => FieldType::Uint8,
_ => FieldType::None,
}
}
fn match_field_file_capabilities(k: usize) -> FieldType {
match k {
0 => FieldType::File,
1 => FieldType::FileFlags,
2 => FieldType::String,
3 => FieldType::Uint16,
4 => FieldType::Uint32,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_file_creator(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint8,
_ => FieldType::None,
}
}
fn match_field_file_id(k: usize) -> FieldType {
match k {
0 => FieldType::File,
1 => FieldType::Manufacturer,
2 => FieldType::Uint16,
3 => FieldType::Uint32Z,
4 => FieldType::DateTime,
5 => FieldType::Uint16,
8 => FieldType::String,
_ => FieldType::None,
}
}
fn match_field_goal(k: usize) -> FieldType {
match k {
0 => FieldType::Sport,
1 => FieldType::SubSport,
2 => FieldType::DateTime,
3 => FieldType::DateTime,
4 => FieldType::Goal,
5 => FieldType::Uint32,
6 => FieldType::Bool,
7 => FieldType::Uint32,
8 => FieldType::GoalRecurrence,
9 => FieldType::Uint16,
10 => FieldType::Bool,
11 => FieldType::GoalSource,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_gps_metadata(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Coordinates,
2 => FieldType::Coordinates,
3 => FieldType::Uint32,
4 => FieldType::Uint32,
5 => FieldType::Uint16,
6 => FieldType::Timestamp,
7 => FieldType::Sint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_gyroscope_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Float32,
6 => FieldType::Float32,
7 => FieldType::Float32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_hr(k: usize) -> FieldType {
match k {
0 => FieldType::Timestamp,
1 => FieldType::Uint8,
6 => FieldType::Uint8,
9 => FieldType::Timestamp,
10 => FieldType::Byte,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_hr_zone(k: usize) -> FieldType {
match k {
1 => FieldType::Uint8,
2 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_hrm_profile(k: usize) -> FieldType {
match k {
0 => FieldType::Bool,
1 => FieldType::Uint16Z,
2 => FieldType::Bool,
3 => FieldType::Uint8Z,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_hrv(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
_ => FieldType::None,
}
}
fn match_field_jump(k: usize) -> FieldType {
match k {
0 => FieldType::Float32,
1 => FieldType::Float32,
2 => FieldType::Uint8,
3 => FieldType::Float32,
4 => FieldType::Float32,
5 => FieldType::Coordinates,
6 => FieldType::Coordinates,
7 => FieldType::Uint16,
8 => FieldType::Uint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_lap(k: usize) -> FieldType {
match k {
0 => FieldType::Event,
1 => FieldType::EventType,
2 => FieldType::DateTime,
3 => FieldType::Coordinates,
4 => FieldType::Coordinates,
5 => FieldType::Coordinates,
6 => FieldType::Coordinates,
7 => FieldType::Uint32,
8 => FieldType::Uint32,
9 => FieldType::Uint32,
10 => FieldType::Uint32,
11 => FieldType::Uint16,
12 => FieldType::Uint16,
13 => FieldType::Uint16,
14 => FieldType::Uint16,
15 => FieldType::Uint8,
16 => FieldType::Uint8,
17 => FieldType::Uint8,
18 => FieldType::Uint8,
19 => FieldType::Uint16,
20 => FieldType::Uint16,
21 => FieldType::Uint16,
22 => FieldType::Uint16,
23 => FieldType::Intensity,
24 => FieldType::LapTrigger,
25 => FieldType::Sport,
26 => FieldType::Uint8,
32 => FieldType::Uint16,
33 => FieldType::Uint16,
34 => FieldType::LeftRightBalance100,
35 => FieldType::Uint16,
37 => FieldType::Uint16,
38 => FieldType::SwimStroke,
39 => FieldType::SubSport,
40 => FieldType::Uint16,
41 => FieldType::Uint32,
42 => FieldType::Uint16,
43 => FieldType::Uint16,
44 => FieldType::Uint8,
45 => FieldType::Sint16,
46 => FieldType::Sint16,
47 => FieldType::Sint16,
48 => FieldType::Sint16,
49 => FieldType::Sint16,
50 => FieldType::Sint8,
51 => FieldType::Sint8,
52 => FieldType::Uint32,
53 => FieldType::Sint16,
54 => FieldType::Sint16,
55 => FieldType::Sint16,
56 => FieldType::Sint16,
57 => FieldType::Uint32,
58 => FieldType::Uint32,
59 => FieldType::Uint32,
60 => FieldType::Uint32,
61 => FieldType::Uint16,
62 => FieldType::Uint16,
63 => FieldType::Uint8,
71 => FieldType::MessageIndex,
74 => FieldType::Uint16,
75 => FieldType::Uint16,
76 => FieldType::Uint16,
77 => FieldType::Uint16,
78 => FieldType::Uint16,
79 => FieldType::Uint16,
80 => FieldType::Uint8,
81 => FieldType::Uint8,
82 => FieldType::Uint8,
83 => FieldType::Uint16,
84 => FieldType::Uint16,
85 => FieldType::Uint16,
86 => FieldType::Uint16,
87 => FieldType::Uint16,
88 => FieldType::Uint16,
89 => FieldType::Uint16,
91 => FieldType::Uint8,
92 => FieldType::Uint8,
93 => FieldType::Uint8,
94 => FieldType::Uint8,
95 => FieldType::Uint8,
98 => FieldType::Uint32,
99 => FieldType::Uint16,
100 => FieldType::Sint8,
101 => FieldType::Sint8,
102 => FieldType::Uint8,
103 => FieldType::Uint8,
104 => FieldType::Uint8,
105 => FieldType::Uint8,
106 => FieldType::Uint16,
107 => FieldType::Uint16,
108 => FieldType::Uint8,
109 => FieldType::Uint8,
110 => FieldType::Uint32,
111 => FieldType::Uint32,
112 => FieldType::Uint32,
113 => FieldType::Uint32,
114 => FieldType::Uint32,
115 => FieldType::Uint16,
116 => FieldType::Uint16,
117 => FieldType::Uint8,
118 => FieldType::Uint16,
119 => FieldType::Uint16,
120 => FieldType::Uint16,
121 => FieldType::Uint16,
149 => FieldType::Float32,
150 => FieldType::Float32,
151 => FieldType::Uint16,
153 => FieldType::Float32,
154 => FieldType::Float32,
156 => FieldType::Uint8,
157 => FieldType::Uint8,
158 => FieldType::Uint16,
159 => FieldType::Uint16,
160 => FieldType::Uint16,
253 => FieldType::Timestamp,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_length(k: usize) -> FieldType {
match k {
0 => FieldType::Event,
1 => FieldType::EventType,
2 => FieldType::DateTime,
3 => FieldType::Uint32,
4 => FieldType::Uint32,
5 => FieldType::Uint16,
6 => FieldType::Uint16,
7 => FieldType::SwimStroke,
9 => FieldType::Uint8,
10 => FieldType::Uint8,
11 => FieldType::Uint16,
12 => FieldType::LengthType,
18 => FieldType::Uint16,
19 => FieldType::Uint16,
20 => FieldType::Uint16,
21 => FieldType::Uint16,
253 => FieldType::Timestamp,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_magnetometer_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Float32,
6 => FieldType::Float32,
7 => FieldType::Float32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_memo_glob(k: usize) -> FieldType {
match k {
0 => FieldType::Byte,
1 => FieldType::Uint16,
2 => FieldType::MessageIndex,
250 => FieldType::Uint32,
_ => FieldType::None,
}
}
fn match_field_mesg_capabilities(k: usize) -> FieldType {
match k {
0 => FieldType::File,
1 => FieldType::MesgNum,
2 => FieldType::MesgCount,
3 => FieldType::Uint16,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_met_zone(k: usize) -> FieldType {
match k {
1 => FieldType::Uint8,
2 => FieldType::Uint16,
3 => FieldType::Uint8,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_monitoring(k: usize) -> FieldType {
match k {
0 => FieldType::DeviceIndex,
1 => FieldType::Uint16,
2 => FieldType::Uint32,
3 => FieldType::Uint32,
4 => FieldType::Uint32,
5 => FieldType::ActivityType,
6 => FieldType::ActivitySubtype,
7 => FieldType::ActivityLevel,
8 => FieldType::Uint16,
9 => FieldType::Uint16,
10 => FieldType::Uint16,
11 => FieldType::Timestamp,
12 => FieldType::Sint16,
14 => FieldType::Sint16,
15 => FieldType::Sint16,
16 => FieldType::Uint16,
19 => FieldType::Uint16,
24 => FieldType::Byte,
25 => FieldType::Uint8,
26 => FieldType::Uint16,
27 => FieldType::Uint8,
28 => FieldType::Uint8,
29 => FieldType::Uint16,
30 => FieldType::Uint32,
31 => FieldType::Uint32,
32 => FieldType::Uint32,
33 => FieldType::Uint16,
34 => FieldType::Uint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_monitoring_info(k: usize) -> FieldType {
match k {
0 => FieldType::Timestamp,
1 => FieldType::ActivityType,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Uint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_nmea_sentence(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::String,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_obdii_data(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint16,
2 => FieldType::Byte,
3 => FieldType::Byte,
4 => FieldType::Uint8,
5 => FieldType::Uint32,
6 => FieldType::Timestamp,
7 => FieldType::Uint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_ohr_settings(k: usize) -> FieldType {
match k {
0 => FieldType::Switch,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_one_d_sensor_calibration(k: usize) -> FieldType {
match k {
0 => FieldType::SensorType,
1 => FieldType::Uint32,
2 => FieldType::Uint32,
3 => FieldType::Uint32,
4 => FieldType::Sint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_power_zone(k: usize) -> FieldType {
match k {
1 => FieldType::Uint16,
2 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_record(k: usize) -> FieldType {
match k {
0 => FieldType::Coordinates,
1 => FieldType::Coordinates,
2 => FieldType::Uint16,
3 => FieldType::Uint8,
4 => FieldType::Uint8,
5 => FieldType::Uint32,
6 => FieldType::Uint16,
7 => FieldType::Uint16,
8 => FieldType::Byte,
9 => FieldType::Sint16,
10 => FieldType::Uint8,
11 => FieldType::Sint32,
12 => FieldType::Uint8,
13 => FieldType::Sint8,
17 => FieldType::Uint8,
18 => FieldType::Uint8,
19 => FieldType::Uint32,
28 => FieldType::Uint16,
29 => FieldType::Uint32,
30 => FieldType::LeftRightBalance,
31 => FieldType::Uint8,
32 => FieldType::Sint16,
33 => FieldType::Uint16,
39 => FieldType::Uint16,
40 => FieldType::Uint16,
41 => FieldType::Uint16,
42 => FieldType::ActivityType,
43 => FieldType::Uint8,
44 => FieldType::Uint8,
45 => FieldType::Uint8,
46 => FieldType::Uint8,
47 => FieldType::Uint8,
48 => FieldType::Uint8,
49 => FieldType::StrokeType,
50 => FieldType::Uint8,
51 => FieldType::Uint16,
52 => FieldType::Uint16,
53 => FieldType::Uint8,
54 => FieldType::Uint16,
55 => FieldType::Uint16,
56 => FieldType::Uint16,
57 => FieldType::Uint16,
58 => FieldType::Uint16,
59 => FieldType::Uint16,
62 => FieldType::DeviceIndex,
67 => FieldType::Sint8,
68 => FieldType::Sint8,
69 => FieldType::Uint8,
70 => FieldType::Uint8,
71 => FieldType::Uint8,
72 => FieldType::Uint8,
73 => FieldType::Uint32,
78 => FieldType::Uint32,
81 => FieldType::Uint8,
82 => FieldType::Uint16,
83 => FieldType::Uint16,
84 => FieldType::Uint16,
85 => FieldType::Uint16,
91 => FieldType::Uint32,
92 => FieldType::Uint32,
93 => FieldType::Uint32,
94 => FieldType::Uint32,
95 => FieldType::Uint32,
96 => FieldType::Uint32,
97 => FieldType::Uint8,
98 => FieldType::Uint16,
114 => FieldType::Float32,
115 => FieldType::Float32,
117 => FieldType::Uint16,
118 => FieldType::Uint8,
119 => FieldType::Uint8,
120 => FieldType::Uint8,
139 => FieldType::Uint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_schedule(k: usize) -> FieldType {
match k {
0 => FieldType::Manufacturer,
1 => FieldType::Uint16,
2 => FieldType::Uint32Z,
3 => FieldType::DateTime,
4 => FieldType::Bool,
5 => FieldType::Schedule,
6 => FieldType::LocalDateTime,
_ => FieldType::None,
}
}
fn match_field_sdm_profile(k: usize) -> FieldType {
match k {
0 => FieldType::Bool,
1 => FieldType::Uint16Z,
2 => FieldType::Uint16,
3 => FieldType::Uint32,
4 => FieldType::Bool,
5 => FieldType::Uint8Z,
7 => FieldType::Uint8,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_segment_file(k: usize) -> FieldType {
match k {
1 => FieldType::String,
3 => FieldType::Bool,
4 => FieldType::Uint32,
7 => FieldType::SegmentLeaderboardType,
8 => FieldType::Uint32,
9 => FieldType::Uint32,
10 => FieldType::String,
11 => FieldType::Uint8,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_segment_id(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::String,
2 => FieldType::Sport,
3 => FieldType::Bool,
4 => FieldType::Uint32,
5 => FieldType::Uint32,
6 => FieldType::Uint8,
7 => FieldType::SegmentDeleteStatus,
8 => FieldType::SegmentSelectionType,
_ => FieldType::None,
}
}
fn match_field_segment_lap(k: usize) -> FieldType {
match k {
0 => FieldType::Event,
1 => FieldType::EventType,
2 => FieldType::DateTime,
3 => FieldType::Coordinates,
4 => FieldType::Coordinates,
5 => FieldType::Coordinates,
6 => FieldType::Coordinates,
7 => FieldType::Uint32,
8 => FieldType::Uint32,
9 => FieldType::Uint32,
10 => FieldType::Uint32,
11 => FieldType::Uint16,
12 => FieldType::Uint16,
13 => FieldType::Uint16,
14 => FieldType::Uint16,
15 => FieldType::Uint8,
16 => FieldType::Uint8,
17 => FieldType::Uint8,
18 => FieldType::Uint8,
19 => FieldType::Uint16,
20 => FieldType::Uint16,
21 => FieldType::Uint16,
22 => FieldType::Uint16,
23 => FieldType::Sport,
24 => FieldType::Uint8,
25 => FieldType::Coordinates,
26 => FieldType::Coordinates,
27 => FieldType::Coordinates,
28 => FieldType::Coordinates,
29 => FieldType::String,
30 => FieldType::Uint16,
31 => FieldType::LeftRightBalance100,
32 => FieldType::SubSport,
33 => FieldType::Uint32,
34 => FieldType::Uint16,
35 => FieldType::Uint16,
36 => FieldType::Uint8,
37 => FieldType::Sint16,
38 => FieldType::Sint16,
39 => FieldType::Sint16,
40 => FieldType::Sint16,
41 => FieldType::Sint16,
42 => FieldType::Sint8,
43 => FieldType::Sint8,
44 => FieldType::Uint32,
45 => FieldType::Sint16,
46 => FieldType::Sint16,
47 => FieldType::Sint16,
48 => FieldType::Sint16,
49 => FieldType::Uint32,
50 => FieldType::Uint32,
51 => FieldType::Uint32,
52 => FieldType::Uint32,
53 => FieldType::Uint16,
54 => FieldType::Uint16,
55 => FieldType::Uint8,
56 => FieldType::Uint32,
57 => FieldType::MessageIndex,
58 => FieldType::SportEvent,
59 => FieldType::Uint8,
60 => FieldType::Uint8,
61 => FieldType::Uint8,
62 => FieldType::Uint8,
63 => FieldType::Uint8,
64 => FieldType::SegmentLapStatus,
65 => FieldType::String,
66 => FieldType::Uint8,
67 => FieldType::Uint8,
68 => FieldType::Uint8,
69 => FieldType::Uint16,
70 => FieldType::Uint16,
71 => FieldType::Uint32,
72 => FieldType::Uint16,
73 => FieldType::Sint8,
74 => FieldType::Sint8,
75 => FieldType::Uint8,
76 => FieldType::Uint8,
77 => FieldType::Uint8,
78 => FieldType::Uint8,
79 => FieldType::Uint16,
80 => FieldType::Uint16,
81 => FieldType::Uint8,
82 => FieldType::Uint8,
83 => FieldType::Manufacturer,
84 => FieldType::Float32,
85 => FieldType::Float32,
86 => FieldType::Float32,
87 => FieldType::Float32,
89 => FieldType::Uint8,
90 => FieldType::Uint8,
253 => FieldType::Timestamp,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_segment_leaderboard_entry(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::SegmentLeaderboardType,
2 => FieldType::Uint32,
3 => FieldType::Uint32,
4 => FieldType::Uint32,
5 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_segment_point(k: usize) -> FieldType {
match k {
1 => FieldType::Coordinates,
2 => FieldType::Coordinates,
3 => FieldType::Uint32,
4 => FieldType::Uint16,
5 => FieldType::Uint32,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_session(k: usize) -> FieldType {
match k {
0 => FieldType::Event,
1 => FieldType::EventType,
2 => FieldType::DateTime,
3 => FieldType::Coordinates,
4 => FieldType::Coordinates,
5 => FieldType::Sport,
6 => FieldType::SubSport,
7 => FieldType::Uint32,
8 => FieldType::Uint32,
9 => FieldType::Uint32,
10 => FieldType::Uint32,
11 => FieldType::Uint16,
13 => FieldType::Uint16,
14 => FieldType::Uint16,
15 => FieldType::Uint16,
16 => FieldType::Uint8,
17 => FieldType::Uint8,
18 => FieldType::Uint8,
19 => FieldType::Uint8,
20 => FieldType::Uint16,
21 => FieldType::Uint16,
22 => FieldType::Uint16,
23 => FieldType::Uint16,
24 => FieldType::Uint8,
25 => FieldType::Uint16,
26 => FieldType::Uint16,
27 => FieldType::Uint8,
28 => FieldType::SessionTrigger,
29 => FieldType::Coordinates,
30 => FieldType::Coordinates,
31 => FieldType::Coordinates,
32 => FieldType::Coordinates,
33 => FieldType::Uint16,
34 => FieldType::Uint16,
35 => FieldType::Uint16,
36 => FieldType::Uint16,
37 => FieldType::LeftRightBalance100,
41 => FieldType::Uint32,
42 => FieldType::Uint16,
43 => FieldType::SwimStroke,
44 => FieldType::Uint16,
45 => FieldType::Uint16,
46 => FieldType::DisplayMeasure,
47 => FieldType::Uint16,
48 => FieldType::Uint32,
49 => FieldType::Uint16,
50 => FieldType::Uint16,
51 => FieldType::Uint8,
52 => FieldType::Sint16,
53 => FieldType::Sint16,
54 => FieldType::Sint16,
55 => FieldType::Sint16,
56 => FieldType::Sint16,
57 => FieldType::Sint8,
58 => FieldType::Sint8,
59 => FieldType::Uint32,
60 => FieldType::Sint16,
61 => FieldType::Sint16,
62 => FieldType::Sint16,
63 => FieldType::Sint16,
64 => FieldType::Uint8,
65 => FieldType::Uint32,
66 => FieldType::Uint32,
67 => FieldType::Uint32,
68 => FieldType::Uint32,
69 => FieldType::Uint32,
70 => FieldType::Uint16,
71 => FieldType::Uint16,
82 => FieldType::Uint16,
83 => FieldType::Uint16,
84 => FieldType::String,
85 => FieldType::Uint16,
86 => FieldType::Uint16,
87 => FieldType::Uint16,
88 => FieldType::Uint16,
89 => FieldType::Uint16,
90 => FieldType::Uint16,
91 => FieldType::Uint16,
92 => FieldType::Uint8,
93 => FieldType::Uint8,
94 => FieldType::Uint8,
95 => FieldType::Uint16,
96 => FieldType::Uint16,
97 => FieldType::Uint16,
98 => FieldType::Uint16,
99 => FieldType::Uint16,
100 => FieldType::Uint16,
101 => FieldType::Uint8,
102 => FieldType::Uint8,
103 => FieldType::Uint8,
104 => FieldType::Uint8,
105 => FieldType::Uint8,
111 => FieldType::Uint8,
112 => FieldType::Uint32,
113 => FieldType::Uint16,
114 => FieldType::Sint8,
115 => FieldType::Sint8,
116 => FieldType::Uint8,
117 => FieldType::Uint8,
118 => FieldType::Uint8,
119 => FieldType::Uint8,
120 => FieldType::Uint16,
121 => FieldType::Uint16,
122 => FieldType::Uint8,
123 => FieldType::Uint8,
124 => FieldType::Uint32,
125 => FieldType::Uint32,
126 => FieldType::Uint32,
127 => FieldType::Uint32,
128 => FieldType::Uint32,
129 => FieldType::Uint16,
130 => FieldType::Uint16,
131 => FieldType::Uint8,
132 => FieldType::Uint16,
133 => FieldType::Uint16,
134 => FieldType::Uint16,
137 => FieldType::Uint8,
139 => FieldType::Uint16,
168 => FieldType::Sint32,
181 => FieldType::Float32,
182 => FieldType::Float32,
183 => FieldType::Uint16,
186 => FieldType::Float32,
187 => FieldType::Float32,
199 => FieldType::Uint8,
200 => FieldType::Uint8,
208 => FieldType::Uint16,
209 => FieldType::Uint16,
210 => FieldType::Uint16,
253 => FieldType::Timestamp,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_set(k: usize) -> FieldType {
match k {
0 => FieldType::Uint32,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::SetType,
6 => FieldType::DateTime,
7 => FieldType::ExerciseCategory,
8 => FieldType::Uint16,
9 => FieldType::FitBaseUnit,
10 => FieldType::MessageIndex,
11 => FieldType::MessageIndex,
254 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_slave_device(k: usize) -> FieldType {
match k {
0 => FieldType::Manufacturer,
1 => FieldType::Uint16,
_ => FieldType::None,
}
}
fn match_field_software(k: usize) -> FieldType {
match k {
3 => FieldType::Uint16,
5 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_speed_zone(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_sport(k: usize) -> FieldType {
match k {
0 => FieldType::Sport,
1 => FieldType::SubSport,
3 => FieldType::String,
_ => FieldType::None,
}
}
fn match_field_stress_level(k: usize) -> FieldType {
match k {
0 => FieldType::Sint16,
1 => FieldType::DateTime,
_ => FieldType::None,
}
}
fn match_field_three_d_sensor_calibration(k: usize) -> FieldType {
match k {
0 => FieldType::SensorType,
1 => FieldType::Uint32,
2 => FieldType::Uint32,
3 => FieldType::Uint32,
4 => FieldType::Sint32,
5 => FieldType::Sint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_timestamp_correlation(k: usize) -> FieldType {
match k {
0 => FieldType::Timestamp,
1 => FieldType::Timestamp,
2 => FieldType::Timestamp,
3 => FieldType::Timestamp,
4 => FieldType::Uint16,
5 => FieldType::Uint16,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_totals(k: usize) -> FieldType {
match k {
0 => FieldType::Uint32,
1 => FieldType::Uint32,
2 => FieldType::Uint32,
3 => FieldType::Sport,
4 => FieldType::Uint32,
5 => FieldType::Uint16,
6 => FieldType::Uint32,
9 => FieldType::Uint8,
253 => FieldType::Timestamp,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_training_file(k: usize) -> FieldType {
match k {
0 => FieldType::File,
1 => FieldType::Manufacturer,
2 => FieldType::Uint16,
3 => FieldType::Uint32Z,
4 => FieldType::DateTime,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_user_profile(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::Gender,
2 => FieldType::Uint8,
3 => FieldType::Uint8,
4 => FieldType::Uint16,
5 => FieldType::Language,
6 => FieldType::DisplayMeasure,
7 => FieldType::DisplayMeasure,
8 => FieldType::Uint8,
9 => FieldType::Uint8,
10 => FieldType::Uint8,
11 => FieldType::Uint8,
12 => FieldType::DisplayHeart,
13 => FieldType::DisplayMeasure,
14 => FieldType::DisplayMeasure,
16 => FieldType::DisplayPower,
17 => FieldType::ActivityClass,
18 => FieldType::DisplayPosition,
21 => FieldType::DisplayMeasure,
22 => FieldType::UserLocalId,
23 => FieldType::Byte,
28 => FieldType::LocaltimeIntoDay,
29 => FieldType::LocaltimeIntoDay,
30 => FieldType::DisplayMeasure,
31 => FieldType::Uint16,
32 => FieldType::Uint16,
47 => FieldType::DisplayMeasure,
49 => FieldType::Uint32,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_video(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::String,
2 => FieldType::Uint32,
_ => FieldType::None,
}
}
fn match_field_video_clip(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Timestamp,
2 => FieldType::Uint16,
3 => FieldType::Timestamp,
4 => FieldType::Uint16,
6 => FieldType::Uint32,
7 => FieldType::Uint32,
_ => FieldType::None,
}
}
fn match_field_video_description(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_video_frame(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::Uint32,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_video_title(k: usize) -> FieldType {
match k {
0 => FieldType::Uint16,
1 => FieldType::String,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_watchface_settings(k: usize) -> FieldType {
match k {
0 => FieldType::WatchfaceMode,
1 => FieldType::Byte,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_weather_alert(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::DateTime,
2 => FieldType::DateTime,
3 => FieldType::WeatherSeverity,
4 => FieldType::WeatherSevereType,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_weather_conditions(k: usize) -> FieldType {
match k {
0 => FieldType::WeatherReport,
1 => FieldType::Sint8,
2 => FieldType::WeatherStatus,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Uint8,
6 => FieldType::Sint8,
7 => FieldType::Uint8,
8 => FieldType::String,
9 => FieldType::DateTime,
10 => FieldType::Coordinates,
11 => FieldType::Coordinates,
12 => FieldType::DayOfWeek,
13 => FieldType::Sint8,
14 => FieldType::Sint8,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_weight_scale(k: usize) -> FieldType {
match k {
0 => FieldType::Weight,
1 => FieldType::Uint16,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::Uint16,
7 => FieldType::Uint16,
8 => FieldType::Uint8,
9 => FieldType::Uint16,
10 => FieldType::Uint8,
11 => FieldType::Uint8,
12 => FieldType::MessageIndex,
253 => FieldType::Timestamp,
_ => FieldType::None,
}
}
fn match_field_workout(k: usize) -> FieldType {
match k {
4 => FieldType::Sport,
5 => FieldType::WorkoutCapabilities,
6 => FieldType::Uint16,
8 => FieldType::String,
11 => FieldType::SubSport,
14 => FieldType::Uint16,
15 => FieldType::DisplayMeasure,
_ => FieldType::None,
}
}
fn match_field_workout_session(k: usize) -> FieldType {
match k {
0 => FieldType::Sport,
1 => FieldType::SubSport,
2 => FieldType::Uint16,
3 => FieldType::Uint16,
4 => FieldType::Uint16,
5 => FieldType::DisplayMeasure,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_workout_step(k: usize) -> FieldType {
match k {
0 => FieldType::String,
1 => FieldType::WktStepDuration,
2 => FieldType::Uint32,
3 => FieldType::WktStepTarget,
4 => FieldType::Uint32,
5 => FieldType::Uint32,
6 => FieldType::Uint32,
7 => FieldType::Intensity,
8 => FieldType::String,
9 => FieldType::WorkoutEquipment,
10 => FieldType::ExerciseCategory,
11 => FieldType::Uint16,
12 => FieldType::Uint16,
13 => FieldType::FitBaseUnit,
19 => FieldType::WktStepTarget,
20 => FieldType::Uint32,
21 => FieldType::Uint32,
22 => FieldType::Uint32,
254 => FieldType::MessageIndex,
_ => FieldType::None,
}
}
fn match_field_zones_target(k: usize) -> FieldType {
match k {
1 => FieldType::Uint8,
2 => FieldType::Uint8,
3 => FieldType::Uint16,
5 => FieldType::HrZoneCalc,
7 => FieldType::PwrZoneCalc,
_ => FieldType::None,
}
}
fn match_field_none(_: usize) -> FieldType {
return FieldType::None;
}
/// Determines a specific `FieldType` of any `MessageType`.
///
/// The method is called with a `MessageType` argument and returns a static closure
/// which is then called with a field_id `usize` and yields a `FieldType`.
/// Any field that is not defined will return a `FieldType::None` variant.
///
/// # Example
///
/// ```
/// let message_type = MessageType::WorkoutSession;
/// let parsed_value = 3;
/// let field_fn = match_message_field(message_type);
/// let field = field_fn(parsed_value);
/// assert_eq!(field, FieldType::Uint16);
/// ```
pub fn get_field_type_fn(m: MessageType) -> MatchFieldTypeFn {
match m {
MessageType::FileId => match_field_file_id,
MessageType::FileCreator => match_field_file_creator,
MessageType::TimestampCorrelation => match_field_timestamp_correlation,
MessageType::Software => match_field_software,
MessageType::SlaveDevice => match_field_slave_device,
MessageType::Capabilities => match_field_capabilities,
MessageType::FileCapabilities => match_field_file_capabilities,
MessageType::MesgCapabilities => match_field_mesg_capabilities,
MessageType::FieldCapabilities => match_field_field_capabilities,
MessageType::DeviceSettings => match_field_device_settings,
MessageType::UserProfile => match_field_user_profile,
MessageType::HrmProfile => match_field_hrm_profile,
MessageType::SdmProfile => match_field_sdm_profile,
MessageType::BikeProfile => match_field_bike_profile,
MessageType::Connectivity => match_field_connectivity,
MessageType::WatchfaceSettings => match_field_watchface_settings,
MessageType::OhrSettings => match_field_ohr_settings,
MessageType::ZonesTarget => match_field_zones_target,
MessageType::Sport => match_field_sport,
MessageType::HrZone => match_field_hr_zone,
MessageType::SpeedZone => match_field_speed_zone,
MessageType::CadenceZone => match_field_cadence_zone,
MessageType::PowerZone => match_field_power_zone,
MessageType::MetZone => match_field_met_zone,
MessageType::DiveSettings => match_field_dive_settings,
MessageType::DiveAlarm => match_field_dive_alarm,
MessageType::DiveGas => match_field_dive_gas,
MessageType::Goal => match_field_goal,
MessageType::Activity => match_field_activity,
MessageType::Session => match_field_session,
MessageType::Lap => match_field_lap,
MessageType::Length => match_field_length,
MessageType::Record => match_field_record,
MessageType::Event => match_field_event,
MessageType::DeviceInfo => match_field_device_info,
MessageType::DeviceAuxBatteryInfo => match_field_device_aux_battery_info,
MessageType::TrainingFile => match_field_training_file,
MessageType::WeatherConditions => match_field_weather_conditions,
MessageType::WeatherAlert => match_field_weather_alert,
MessageType::GpsMetadata => match_field_gps_metadata,
MessageType::CameraEvent => match_field_camera_event,
MessageType::GyroscopeData => match_field_gyroscope_data,
MessageType::AccelerometerData => match_field_accelerometer_data,
MessageType::MagnetometerData => match_field_magnetometer_data,
MessageType::BarometerData => match_field_barometer_data,
MessageType::ThreeDSensorCalibration => match_field_three_d_sensor_calibration,
MessageType::OneDSensorCalibration => match_field_one_d_sensor_calibration,
MessageType::VideoFrame => match_field_video_frame,
MessageType::ObdiiData => match_field_obdii_data,
MessageType::NmeaSentence => match_field_nmea_sentence,
MessageType::AviationAttitude => match_field_aviation_attitude,
MessageType::Video => match_field_video,
MessageType::VideoTitle => match_field_video_title,
MessageType::VideoDescription => match_field_video_description,
MessageType::VideoClip => match_field_video_clip,
MessageType::Set => match_field_set,
MessageType::Jump => match_field_jump,
MessageType::ClimbPro => match_field_climb_pro,
MessageType::FieldDescription => match_field_field_description,
MessageType::DeveloperDataId => match_field_developer_data_id,
MessageType::Course => match_field_course,
MessageType::CoursePoint => match_field_course_point,
MessageType::SegmentId => match_field_segment_id,
MessageType::SegmentLeaderboardEntry => match_field_segment_leaderboard_entry,
MessageType::SegmentPoint => match_field_segment_point,
MessageType::SegmentLap => match_field_segment_lap,
MessageType::SegmentFile => match_field_segment_file,
MessageType::Workout => match_field_workout,
MessageType::WorkoutSession => match_field_workout_session,
MessageType::WorkoutStep => match_field_workout_step,
MessageType::ExerciseTitle => match_field_exercise_title,
MessageType::Schedule => match_field_schedule,
MessageType::Totals => match_field_totals,
MessageType::WeightScale => match_field_weight_scale,
MessageType::BloodPressure => match_field_blood_pressure,
MessageType::MonitoringInfo => match_field_monitoring_info,
MessageType::Monitoring => match_field_monitoring,
MessageType::Hr => match_field_hr,
MessageType::StressLevel => match_field_stress_level,
MessageType::MemoGlob => match_field_memo_glob,
MessageType::AntChannelId => match_field_ant_channel_id,
MessageType::AntRx => match_field_ant_rx,
MessageType::AntTx => match_field_ant_tx,
MessageType::ExdScreenConfiguration => match_field_exd_screen_configuration,
MessageType::ExdDataFieldConfiguration => match_field_exd_data_field_configuration,
MessageType::ExdDataConceptConfiguration => match_field_exd_data_concept_configuration,
MessageType::DiveSummary => match_field_dive_summary,
MessageType::Hrv => match_field_hrv,
_ => match_field_none,
}
}
|
use clippy_utils::diagnostics::span_lint_and_sugg;
use clippy_utils::sugg::Sugg;
use clippy_utils::ty::is_type_diagnostic_item;
use if_chain::if_chain;
use rustc_errors::Applicability;
use rustc_hir::{def, Expr, ExprKind, PrimTy, QPath, TyKind};
use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty::Ty;
use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::symbol::sym;
declare_clippy_lint! {
/// ### What it does
///
/// Checks for function invocations of the form `primitive::from_str_radix(s, 10)`
///
/// ### Why is this bad?
///
/// This specific common use case can be rewritten as `s.parse::<primitive>()`
/// (and in most cases, the turbofish can be removed), which reduces code length
/// and complexity.
///
/// ### Known problems
///
/// This lint may suggest using (&<expression>).parse() instead of <expression>.parse() directly
/// in some cases, which is correct but adds unnecessary complexity to the code.
///
/// ### Example
/// ```ignore
/// let input: &str = get_input();
/// let num = u16::from_str_radix(input, 10)?;
/// ```
/// Use instead:
/// ```ignore
/// let input: &str = get_input();
/// let num: u16 = input.parse()?;
/// ```
#[clippy::version = "1.52.0"]
pub FROM_STR_RADIX_10,
style,
"from_str_radix with radix 10"
}
declare_lint_pass!(FromStrRadix10 => [FROM_STR_RADIX_10]);
impl LateLintPass<'tcx> for FromStrRadix10 {
fn check_expr(&mut self, cx: &LateContext<'tcx>, exp: &Expr<'tcx>) {
if_chain! {
if let ExprKind::Call(maybe_path, arguments) = &exp.kind;
if let ExprKind::Path(QPath::TypeRelative(ty, pathseg)) = &maybe_path.kind;
// check if the first part of the path is some integer primitive
if let TyKind::Path(ty_qpath) = &ty.kind;
let ty_res = cx.qpath_res(ty_qpath, ty.hir_id);
if let def::Res::PrimTy(prim_ty) = ty_res;
if matches!(prim_ty, PrimTy::Int(_) | PrimTy::Uint(_));
// check if the second part of the path indeed calls the associated
// function `from_str_radix`
if pathseg.ident.name.as_str() == "from_str_radix";
// check if the second argument is a primitive `10`
if arguments.len() == 2;
if let ExprKind::Lit(lit) = &arguments[1].kind;
if let rustc_ast::ast::LitKind::Int(10, _) = lit.node;
then {
let expr = if let ExprKind::AddrOf(_, _, expr) = &arguments[0].kind {
let ty = cx.typeck_results().expr_ty(expr);
if is_ty_stringish(cx, ty) {
expr
} else {
&arguments[0]
}
} else {
&arguments[0]
};
let sugg = Sugg::hir_with_applicability(
cx,
expr,
"<string>",
&mut Applicability::MachineApplicable
).maybe_par();
span_lint_and_sugg(
cx,
FROM_STR_RADIX_10,
exp.span,
"this call to `from_str_radix` can be replaced with a call to `str::parse`",
"try",
format!("{}.parse::<{}>()", sugg, prim_ty.name_str()),
Applicability::MaybeIncorrect
);
}
}
}
}
/// Checks if a Ty is `String` or `&str`
fn is_ty_stringish(cx: &LateContext<'_>, ty: Ty<'_>) -> bool {
is_type_diagnostic_item(cx, ty, sym::String) || is_type_diagnostic_item(cx, ty, sym::str)
}
|
use super::*;
use proptest::strategy::Strategy;
mod with_local_pid;
#[test]
fn without_pid_or_port_errors_badarg() {
run!(
|arc_process| {
(
Just(arc_process.clone()),
strategy::term::atom(),
strategy::term(arc_process.clone())
.prop_filter("Cannot be pid or port", |pid_or_port| {
!(pid_or_port.is_pid() || pid_or_port.is_port())
}),
)
},
|(arc_process, name, pid_or_port)| {
prop_assert_badarg!(
erlang::register_2::result(arc_process.clone(), name, pid_or_port),
format!("{} must be a local pid or port", pid_or_port)
);
Ok(())
},
);
}
|
use std::fs;
use std::path::{Path, PathBuf};
use morgan_kvstore::test::gen;
use morgan_kvstore::{Config, Key, KvStore};
const KB: usize = 1024;
const HALF_KB: usize = 512;
#[test]
fn test_put_get() {
let path = setup("test_put_get");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
..Config::default()
};
let lsm = KvStore::open(&path, cfg).unwrap();
let (key, bytes) = gen::pairs(HALF_KB).take(1).next().unwrap();
lsm.put(&key, &bytes).expect("put fail");
let out_bytes = lsm.get(&key).expect("get fail").expect("missing");
assert_eq!(bytes, out_bytes);
teardown(&path);
}
#[test]
fn test_put_get_many() {
let path = setup("test_put_get_many");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
..Config::default()
};
let lsm = KvStore::open(&path, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(HALF_KB).take(1024).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
lsm.put_many(pairs.clone().drain(..))
.expect("put_many fail");
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
#[test]
fn test_delete() {
let path = setup("test_delete");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
..Config::default()
};
let lsm = KvStore::open(&path, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(HALF_KB).take(64 * 6).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
for (k, i) in pairs.iter() {
lsm.put(k, i).expect("put fail");
}
// drain iterator deletes from `pairs`
for (k, _) in pairs.drain(64..128) {
lsm.delete(&k).expect("delete fail");
}
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
#[test]
fn test_delete_many() {
let path = setup("test_delete_many");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
..Config::default()
};
let lsm = KvStore::open(&path, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(HALF_KB).take(64 * 6).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
for (k, i) in pairs.iter() {
lsm.put(k, i).expect("put fail");
}
// drain iterator deletes from `pairs`
let keys_to_delete = pairs.drain(320..384).map(|(k, _)| k);
lsm.delete_many(keys_to_delete).expect("delete_many fail");
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
#[test]
fn test_close_reopen() {
let path = setup("test_close_reopen");
let cfg = Config::default();
let lsm = KvStore::open(&path, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(KB).take(1024).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
for (k, i) in pairs.iter() {
lsm.put(k, i).expect("put fail");
}
for (k, _) in pairs.drain(64..128) {
lsm.delete(&k).expect("delete fail");
}
// Drop and re-open
drop(lsm);
let lsm = KvStore::open(&path, cfg).unwrap();
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
#[test]
fn test_partitioned() {
let path = setup("test_partitioned");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
..Config::default()
};
let storage_dirs = (0..4)
.map(|i| path.join(format!("parition-{}", i)))
.collect::<Vec<_>>();
let lsm = KvStore::partitioned(&path, &storage_dirs, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(HALF_KB).take(64 * 12).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
lsm.put_many(pairs.iter()).expect("put_many fail");
// drain iterator deletes from `pairs`
let keys_to_delete = pairs.drain(320..384).map(|(k, _)| k);
lsm.delete_many(keys_to_delete).expect("delete_many fail");
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
#[test]
fn test_in_memory() {
let path = setup("test_in_memory");
let cfg = Config {
max_mem: 64 * KB,
max_tables: 5,
page_size: 64 * KB,
in_memory: true,
..Config::default()
};
let lsm = KvStore::open(&path, cfg).unwrap();
let mut pairs: Vec<_> = gen::pairs(HALF_KB).take(64 * 12).collect();
pairs.sort_unstable_by_key(|(k, _)| *k);
lsm.put_many(pairs.iter()).expect("put_many fail");
// drain iterator deletes from `pairs`
let keys_to_delete = pairs.drain(320..384).map(|(k, _)| k);
lsm.delete_many(keys_to_delete).expect("delete_many fail");
let retrieved: Vec<(Key, Vec<u8>)> =
lsm.range(Key::ALL_INCLUSIVE).expect("range fail").collect();
assert!(!retrieved.is_empty());
assert_eq!(pairs.len(), retrieved.len());
assert_eq!(pairs, retrieved);
teardown(&path);
}
fn setup(test_name: &str) -> PathBuf {
let dir = Path::new("kvstore-test").join(test_name);;
let _ig = fs::remove_dir_all(&dir);
fs::create_dir_all(&dir).unwrap();
dir
}
fn teardown(p: &Path) {
KvStore::destroy(p).expect("Expect successful store destruction");
}
|
use std::io;
fn main() {
println!("nth Fibonacci!");
println!("Enter n:");
let mut n = String::new();
io::stdin().read_line(&mut n).expect("Failed to read n");
let n: i32 = loop {
let n: i32 = match n.trim().parse() {
Ok(num) => num,
Err(_) => {
print!("Invalid input. ");
continue;
}
};
break n;
};
let mut fib = 0;
let mut last_n = 0;
let mut number = 0;
while number < n {
let last_fib = fib;
fib = last_n + fib + if number < 1 { 1 } else { 0 };
number = number + 1;
last_n = last_fib;
}
println!("nth fibonacci is: {}", fib);
}
|
use serde::{Deserialize, Serialize};
#[derive(Debug, Serialize, Deserialize)]
pub struct Hook {
pub (crate) _type: String,
pub (crate) method: String,
pub (crate) url: String
} |
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtCore/qprocess.h
// dst-file: /src/core/qprocess.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main block end
// use block begin =>
use super::qiodevice::*; // 773
use std::ops::Deref;
use super::qstringlist::*; // 773
use super::qstring::*; // 773
// use super::qprocess::QProcessEnvironment; // 773
use super::qbytearray::*; // 773
use super::qobject::*; // 773
use super::qobjectdefs::*; // 773
// <= use block end
// ext block begin =>
// #[link(name = "Qt5Core")]
// #[link(name = "Qt5Gui")]
// #[link(name = "Qt5Widgets")]
// #[link(name = "QtInline")]
extern {
fn QProcess_Class_Size() -> c_int;
// proto: void QProcess::close();
fn C_ZN8QProcess5closeEv(qthis: u64 /* *mut c_void*/);
// proto: void QProcess::setEnvironment(const QStringList & environment);
fn C_ZN8QProcess14setEnvironmentERK11QStringList(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: static bool QProcess::startDetached(const QString & program, const QStringList & arguments);
fn C_ZN8QProcess13startDetachedERK7QStringRK11QStringList(arg0: *mut c_void, arg1: *mut c_void) -> c_char;
// proto: static bool QProcess::startDetached(const QString & command);
fn C_ZN8QProcess13startDetachedERK7QString(arg0: *mut c_void) -> c_char;
// proto: bool QProcess::atEnd();
fn C_ZNK8QProcess5atEndEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: static QStringList QProcess::systemEnvironment();
fn C_ZN8QProcess17systemEnvironmentEv() -> *mut c_void;
// proto: void QProcess::setProcessEnvironment(const QProcessEnvironment & environment);
fn C_ZN8QProcess21setProcessEnvironmentERK19QProcessEnvironment(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: Q_PID QProcess::pid();
fn C_ZNK8QProcess3pidEv(qthis: u64 /* *mut c_void*/) -> c_longlong;
// proto: void QProcess::setArguments(const QStringList & arguments);
fn C_ZN8QProcess12setArgumentsERK11QStringList(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QProcess::~QProcess();
fn C_ZN8QProcessD2Ev(qthis: u64 /* *mut c_void*/);
// proto: static int QProcess::execute(const QString & command);
fn C_ZN8QProcess7executeERK7QString(arg0: *mut c_void) -> c_int;
// proto: void QProcess::closeWriteChannel();
fn C_ZN8QProcess17closeWriteChannelEv(qthis: u64 /* *mut c_void*/);
// proto: static bool QProcess::startDetached(const QString & program, const QStringList & arguments, const QString & workingDirectory, qint64 * pid);
fn C_ZN8QProcess13startDetachedERK7QStringRK11QStringListS2_Px(arg0: *mut c_void, arg1: *mut c_void, arg2: *mut c_void, arg3: *mut c_longlong) -> c_char;
// proto: QProcessEnvironment QProcess::processEnvironment();
fn C_ZNK8QProcess18processEnvironmentEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QByteArray QProcess::readAllStandardOutput();
fn C_ZN8QProcess21readAllStandardOutputEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: static QString QProcess::nullDevice();
fn C_ZN8QProcess10nullDeviceEv() -> *mut c_void;
// proto: static int QProcess::execute(const QString & program, const QStringList & arguments);
fn C_ZN8QProcess7executeERK7QStringRK11QStringList(arg0: *mut c_void, arg1: *mut c_void) -> c_int;
// proto: bool QProcess::waitForBytesWritten(int msecs);
fn C_ZN8QProcess19waitForBytesWrittenEi(qthis: u64 /* *mut c_void*/, arg0: c_int) -> c_char;
// proto: void QProcess::QProcess(QObject * parent);
fn C_ZN8QProcessC2EP7QObject(arg0: *mut c_void) -> u64;
// proto: QString QProcess::program();
fn C_ZNK8QProcess7programEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: qint64 QProcess::processId();
fn C_ZNK8QProcess9processIdEv(qthis: u64 /* *mut c_void*/) -> c_longlong;
// proto: QStringList QProcess::arguments();
fn C_ZNK8QProcess9argumentsEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QProcess::isSequential();
fn C_ZNK8QProcess12isSequentialEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: bool QProcess::waitForReadyRead(int msecs);
fn C_ZN8QProcess16waitForReadyReadEi(qthis: u64 /* *mut c_void*/, arg0: c_int) -> c_char;
// proto: void QProcess::setWorkingDirectory(const QString & dir);
fn C_ZN8QProcess19setWorkingDirectoryERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QProcess::terminate();
fn C_ZN8QProcess9terminateEv(qthis: u64 /* *mut c_void*/);
// proto: void QProcess::kill();
fn C_ZN8QProcess4killEv(qthis: u64 /* *mut c_void*/);
// proto: qint64 QProcess::bytesAvailable();
fn C_ZNK8QProcess14bytesAvailableEv(qthis: u64 /* *mut c_void*/) -> c_longlong;
// proto: const QMetaObject * QProcess::metaObject();
fn C_ZNK8QProcess10metaObjectEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QProcess::waitForStarted(int msecs);
fn C_ZN8QProcess14waitForStartedEi(qthis: u64 /* *mut c_void*/, arg0: c_int) -> c_char;
// proto: QByteArray QProcess::readAllStandardError();
fn C_ZN8QProcess20readAllStandardErrorEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: int QProcess::exitCode();
fn C_ZNK8QProcess8exitCodeEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: QStringList QProcess::environment();
fn C_ZNK8QProcess11environmentEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QProcess::canReadLine();
fn C_ZNK8QProcess11canReadLineEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: void QProcess::setStandardOutputProcess(QProcess * destination);
fn C_ZN8QProcess24setStandardOutputProcessEPS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: bool QProcess::waitForFinished(int msecs);
fn C_ZN8QProcess15waitForFinishedEi(qthis: u64 /* *mut c_void*/, arg0: c_int) -> c_char;
// proto: qint64 QProcess::bytesToWrite();
fn C_ZNK8QProcess12bytesToWriteEv(qthis: u64 /* *mut c_void*/) -> c_longlong;
// proto: QString QProcess::workingDirectory();
fn C_ZNK8QProcess16workingDirectoryEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QProcess::setProgram(const QString & program);
fn C_ZN8QProcess10setProgramERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QProcess::setStandardInputFile(const QString & fileName);
fn C_ZN8QProcess20setStandardInputFileERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
fn QProcessEnvironment_Class_Size() -> c_int;
// proto: bool QProcessEnvironment::contains(const QString & name);
fn C_ZNK19QProcessEnvironment8containsERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void) -> c_char;
// proto: QStringList QProcessEnvironment::keys();
fn C_ZNK19QProcessEnvironment4keysEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QProcessEnvironment::remove(const QString & name);
fn C_ZN19QProcessEnvironment6removeERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QProcessEnvironment::clear();
fn C_ZN19QProcessEnvironment5clearEv(qthis: u64 /* *mut c_void*/);
// proto: QString QProcessEnvironment::value(const QString & name, const QString & defaultValue);
fn C_ZNK19QProcessEnvironment5valueERK7QStringS2_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void, arg1: *mut c_void) -> *mut c_void;
// proto: bool QProcessEnvironment::isEmpty();
fn C_ZNK19QProcessEnvironment7isEmptyEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: void QProcessEnvironment::~QProcessEnvironment();
fn C_ZN19QProcessEnvironmentD2Ev(qthis: u64 /* *mut c_void*/);
// proto: void QProcessEnvironment::swap(QProcessEnvironment & other);
fn C_ZN19QProcessEnvironment4swapERS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QProcessEnvironment::QProcessEnvironment(const QProcessEnvironment & other);
fn C_ZN19QProcessEnvironmentC2ERKS_(arg0: *mut c_void) -> u64;
// proto: static QProcessEnvironment QProcessEnvironment::systemEnvironment();
fn C_ZN19QProcessEnvironment17systemEnvironmentEv() -> *mut c_void;
// proto: void QProcessEnvironment::insert(const QString & name, const QString & value);
fn C_ZN19QProcessEnvironment6insertERK7QStringS2_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void, arg1: *mut c_void);
// proto: QStringList QProcessEnvironment::toStringList();
fn C_ZNK19QProcessEnvironment12toStringListEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QProcessEnvironment::QProcessEnvironment();
fn C_ZN19QProcessEnvironmentC2Ev() -> u64;
// proto: void QProcessEnvironment::insert(const QProcessEnvironment & e);
fn C_ZN19QProcessEnvironment6insertERKS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
fn QProcess_SlotProxy_connect__ZN8QProcess8finishedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
} // <= ext block end
// body block begin =>
// class sizeof(QProcess)=1
#[derive(Default)]
pub struct QProcess {
qbase: QIODevice,
pub qclsinst: u64 /* *mut c_void*/,
pub _stateChanged: QProcess_stateChanged_signal,
pub _started: QProcess_started_signal,
pub _finished: QProcess_finished_signal,
pub _readyReadStandardError: QProcess_readyReadStandardError_signal,
pub _error: QProcess_error_signal,
pub _readyReadStandardOutput: QProcess_readyReadStandardOutput_signal,
}
// class sizeof(QProcessEnvironment)=1
#[derive(Default)]
pub struct QProcessEnvironment {
// qbase: None,
pub qclsinst: u64 /* *mut c_void*/,
}
impl /*struct*/ QProcess {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QProcess {
return QProcess{qbase: QIODevice::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
}
}
impl Deref for QProcess {
type Target = QIODevice;
fn deref(&self) -> &QIODevice {
return & self.qbase;
}
}
impl AsRef<QIODevice> for QProcess {
fn as_ref(& self) -> & QIODevice {
return & self.qbase;
}
}
// proto: void QProcess::close();
impl /*struct*/ QProcess {
pub fn close<RetType, T: QProcess_close<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.close(self);
// return 1;
}
}
pub trait QProcess_close<RetType> {
fn close(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::close();
impl<'a> /*trait*/ QProcess_close<()> for () {
fn close(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess5closeEv()};
unsafe {C_ZN8QProcess5closeEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QProcess::setEnvironment(const QStringList & environment);
impl /*struct*/ QProcess {
pub fn setEnvironment<RetType, T: QProcess_setEnvironment<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setEnvironment(self);
// return 1;
}
}
pub trait QProcess_setEnvironment<RetType> {
fn setEnvironment(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setEnvironment(const QStringList & environment);
impl<'a> /*trait*/ QProcess_setEnvironment<()> for (&'a QStringList) {
fn setEnvironment(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess14setEnvironmentERK11QStringList()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess14setEnvironmentERK11QStringList(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: static bool QProcess::startDetached(const QString & program, const QStringList & arguments);
impl /*struct*/ QProcess {
pub fn startDetached_s<RetType, T: QProcess_startDetached_s<RetType>>( overload_args: T) -> RetType {
return overload_args.startDetached_s();
// return 1;
}
}
pub trait QProcess_startDetached_s<RetType> {
fn startDetached_s(self ) -> RetType;
}
// proto: static bool QProcess::startDetached(const QString & program, const QStringList & arguments);
impl<'a> /*trait*/ QProcess_startDetached_s<i8> for (&'a QString, &'a QStringList) {
fn startDetached_s(self ) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess13startDetachedERK7QStringRK11QStringList()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = self.1.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZN8QProcess13startDetachedERK7QStringRK11QStringList(arg0, arg1)};
return ret as i8; // 1
// return 1;
}
}
// proto: static bool QProcess::startDetached(const QString & command);
impl<'a> /*trait*/ QProcess_startDetached_s<i8> for (&'a QString) {
fn startDetached_s(self ) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess13startDetachedERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZN8QProcess13startDetachedERK7QString(arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: bool QProcess::atEnd();
impl /*struct*/ QProcess {
pub fn atEnd<RetType, T: QProcess_atEnd<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.atEnd(self);
// return 1;
}
}
pub trait QProcess_atEnd<RetType> {
fn atEnd(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::atEnd();
impl<'a> /*trait*/ QProcess_atEnd<i8> for () {
fn atEnd(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess5atEndEv()};
let mut ret = unsafe {C_ZNK8QProcess5atEndEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: static QStringList QProcess::systemEnvironment();
impl /*struct*/ QProcess {
pub fn systemEnvironment_s<RetType, T: QProcess_systemEnvironment_s<RetType>>( overload_args: T) -> RetType {
return overload_args.systemEnvironment_s();
// return 1;
}
}
pub trait QProcess_systemEnvironment_s<RetType> {
fn systemEnvironment_s(self ) -> RetType;
}
// proto: static QStringList QProcess::systemEnvironment();
impl<'a> /*trait*/ QProcess_systemEnvironment_s<QStringList> for () {
fn systemEnvironment_s(self ) -> QStringList {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess17systemEnvironmentEv()};
let mut ret = unsafe {C_ZN8QProcess17systemEnvironmentEv()};
let mut ret1 = QStringList::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QProcess::setProcessEnvironment(const QProcessEnvironment & environment);
impl /*struct*/ QProcess {
pub fn setProcessEnvironment<RetType, T: QProcess_setProcessEnvironment<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setProcessEnvironment(self);
// return 1;
}
}
pub trait QProcess_setProcessEnvironment<RetType> {
fn setProcessEnvironment(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setProcessEnvironment(const QProcessEnvironment & environment);
impl<'a> /*trait*/ QProcess_setProcessEnvironment<()> for (&'a QProcessEnvironment) {
fn setProcessEnvironment(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess21setProcessEnvironmentERK19QProcessEnvironment()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess21setProcessEnvironmentERK19QProcessEnvironment(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: Q_PID QProcess::pid();
impl /*struct*/ QProcess {
pub fn pid<RetType, T: QProcess_pid<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.pid(self);
// return 1;
}
}
pub trait QProcess_pid<RetType> {
fn pid(self , rsthis: & QProcess) -> RetType;
}
// proto: Q_PID QProcess::pid();
impl<'a> /*trait*/ QProcess_pid<i64> for () {
fn pid(self , rsthis: & QProcess) -> i64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess3pidEv()};
let mut ret = unsafe {C_ZNK8QProcess3pidEv(rsthis.qclsinst)};
return ret as i64; // 1
// return 1;
}
}
// proto: void QProcess::setArguments(const QStringList & arguments);
impl /*struct*/ QProcess {
pub fn setArguments<RetType, T: QProcess_setArguments<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setArguments(self);
// return 1;
}
}
pub trait QProcess_setArguments<RetType> {
fn setArguments(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setArguments(const QStringList & arguments);
impl<'a> /*trait*/ QProcess_setArguments<()> for (&'a QStringList) {
fn setArguments(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess12setArgumentsERK11QStringList()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess12setArgumentsERK11QStringList(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QProcess::~QProcess();
impl /*struct*/ QProcess {
pub fn free<RetType, T: QProcess_free<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.free(self);
// return 1;
}
}
pub trait QProcess_free<RetType> {
fn free(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::~QProcess();
impl<'a> /*trait*/ QProcess_free<()> for () {
fn free(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcessD2Ev()};
unsafe {C_ZN8QProcessD2Ev(rsthis.qclsinst)};
// return 1;
}
}
// proto: static int QProcess::execute(const QString & command);
impl /*struct*/ QProcess {
pub fn execute_s<RetType, T: QProcess_execute_s<RetType>>( overload_args: T) -> RetType {
return overload_args.execute_s();
// return 1;
}
}
pub trait QProcess_execute_s<RetType> {
fn execute_s(self ) -> RetType;
}
// proto: static int QProcess::execute(const QString & command);
impl<'a> /*trait*/ QProcess_execute_s<i32> for (&'a QString) {
fn execute_s(self ) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess7executeERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZN8QProcess7executeERK7QString(arg0)};
return ret as i32; // 1
// return 1;
}
}
// proto: void QProcess::closeWriteChannel();
impl /*struct*/ QProcess {
pub fn closeWriteChannel<RetType, T: QProcess_closeWriteChannel<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.closeWriteChannel(self);
// return 1;
}
}
pub trait QProcess_closeWriteChannel<RetType> {
fn closeWriteChannel(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::closeWriteChannel();
impl<'a> /*trait*/ QProcess_closeWriteChannel<()> for () {
fn closeWriteChannel(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess17closeWriteChannelEv()};
unsafe {C_ZN8QProcess17closeWriteChannelEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: static bool QProcess::startDetached(const QString & program, const QStringList & arguments, const QString & workingDirectory, qint64 * pid);
impl<'a> /*trait*/ QProcess_startDetached_s<i8> for (&'a QString, &'a QStringList, &'a QString, Option<&'a mut Vec<i64>>) {
fn startDetached_s(self ) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess13startDetachedERK7QStringRK11QStringListS2_Px()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = self.1.qclsinst as *mut c_void;
let arg2 = self.2.qclsinst as *mut c_void;
let arg3 = (if self.3.is_none() {0 as *const i64} else {self.3.unwrap().as_ptr()}) as *mut c_longlong;
let mut ret = unsafe {C_ZN8QProcess13startDetachedERK7QStringRK11QStringListS2_Px(arg0, arg1, arg2, arg3)};
return ret as i8; // 1
// return 1;
}
}
// proto: QProcessEnvironment QProcess::processEnvironment();
impl /*struct*/ QProcess {
pub fn processEnvironment<RetType, T: QProcess_processEnvironment<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.processEnvironment(self);
// return 1;
}
}
pub trait QProcess_processEnvironment<RetType> {
fn processEnvironment(self , rsthis: & QProcess) -> RetType;
}
// proto: QProcessEnvironment QProcess::processEnvironment();
impl<'a> /*trait*/ QProcess_processEnvironment<QProcessEnvironment> for () {
fn processEnvironment(self , rsthis: & QProcess) -> QProcessEnvironment {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess18processEnvironmentEv()};
let mut ret = unsafe {C_ZNK8QProcess18processEnvironmentEv(rsthis.qclsinst)};
let mut ret1 = QProcessEnvironment::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QByteArray QProcess::readAllStandardOutput();
impl /*struct*/ QProcess {
pub fn readAllStandardOutput<RetType, T: QProcess_readAllStandardOutput<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.readAllStandardOutput(self);
// return 1;
}
}
pub trait QProcess_readAllStandardOutput<RetType> {
fn readAllStandardOutput(self , rsthis: & QProcess) -> RetType;
}
// proto: QByteArray QProcess::readAllStandardOutput();
impl<'a> /*trait*/ QProcess_readAllStandardOutput<QByteArray> for () {
fn readAllStandardOutput(self , rsthis: & QProcess) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess21readAllStandardOutputEv()};
let mut ret = unsafe {C_ZN8QProcess21readAllStandardOutputEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: static QString QProcess::nullDevice();
impl /*struct*/ QProcess {
pub fn nullDevice_s<RetType, T: QProcess_nullDevice_s<RetType>>( overload_args: T) -> RetType {
return overload_args.nullDevice_s();
// return 1;
}
}
pub trait QProcess_nullDevice_s<RetType> {
fn nullDevice_s(self ) -> RetType;
}
// proto: static QString QProcess::nullDevice();
impl<'a> /*trait*/ QProcess_nullDevice_s<QString> for () {
fn nullDevice_s(self ) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess10nullDeviceEv()};
let mut ret = unsafe {C_ZN8QProcess10nullDeviceEv()};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: static int QProcess::execute(const QString & program, const QStringList & arguments);
impl<'a> /*trait*/ QProcess_execute_s<i32> for (&'a QString, &'a QStringList) {
fn execute_s(self ) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess7executeERK7QStringRK11QStringList()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = self.1.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZN8QProcess7executeERK7QStringRK11QStringList(arg0, arg1)};
return ret as i32; // 1
// return 1;
}
}
// proto: bool QProcess::waitForBytesWritten(int msecs);
impl /*struct*/ QProcess {
pub fn waitForBytesWritten<RetType, T: QProcess_waitForBytesWritten<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.waitForBytesWritten(self);
// return 1;
}
}
pub trait QProcess_waitForBytesWritten<RetType> {
fn waitForBytesWritten(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::waitForBytesWritten(int msecs);
impl<'a> /*trait*/ QProcess_waitForBytesWritten<i8> for (Option<i32>) {
fn waitForBytesWritten(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess19waitForBytesWrittenEi()};
let arg0 = (if self.is_none() {30000} else {self.unwrap()}) as c_int;
let mut ret = unsafe {C_ZN8QProcess19waitForBytesWrittenEi(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QProcess::QProcess(QObject * parent);
impl /*struct*/ QProcess {
pub fn new<T: QProcess_new>(value: T) -> QProcess {
let rsthis = value.new();
return rsthis;
// return 1;
}
}
pub trait QProcess_new {
fn new(self) -> QProcess;
}
// proto: void QProcess::QProcess(QObject * parent);
impl<'a> /*trait*/ QProcess_new for (Option<&'a QObject>) {
fn new(self) -> QProcess {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcessC2EP7QObject()};
let ctysz: c_int = unsafe{QProcess_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let arg0 = (if self.is_none() {0} else {self.unwrap().qclsinst}) as *mut c_void;
let qthis: u64 = unsafe {C_ZN8QProcessC2EP7QObject(arg0)};
let rsthis = QProcess{qbase: QIODevice::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: QString QProcess::program();
impl /*struct*/ QProcess {
pub fn program<RetType, T: QProcess_program<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.program(self);
// return 1;
}
}
pub trait QProcess_program<RetType> {
fn program(self , rsthis: & QProcess) -> RetType;
}
// proto: QString QProcess::program();
impl<'a> /*trait*/ QProcess_program<QString> for () {
fn program(self , rsthis: & QProcess) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess7programEv()};
let mut ret = unsafe {C_ZNK8QProcess7programEv(rsthis.qclsinst)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: qint64 QProcess::processId();
impl /*struct*/ QProcess {
pub fn processId<RetType, T: QProcess_processId<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.processId(self);
// return 1;
}
}
pub trait QProcess_processId<RetType> {
fn processId(self , rsthis: & QProcess) -> RetType;
}
// proto: qint64 QProcess::processId();
impl<'a> /*trait*/ QProcess_processId<i64> for () {
fn processId(self , rsthis: & QProcess) -> i64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess9processIdEv()};
let mut ret = unsafe {C_ZNK8QProcess9processIdEv(rsthis.qclsinst)};
return ret as i64; // 1
// return 1;
}
}
// proto: QStringList QProcess::arguments();
impl /*struct*/ QProcess {
pub fn arguments<RetType, T: QProcess_arguments<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.arguments(self);
// return 1;
}
}
pub trait QProcess_arguments<RetType> {
fn arguments(self , rsthis: & QProcess) -> RetType;
}
// proto: QStringList QProcess::arguments();
impl<'a> /*trait*/ QProcess_arguments<QStringList> for () {
fn arguments(self , rsthis: & QProcess) -> QStringList {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess9argumentsEv()};
let mut ret = unsafe {C_ZNK8QProcess9argumentsEv(rsthis.qclsinst)};
let mut ret1 = QStringList::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QProcess::isSequential();
impl /*struct*/ QProcess {
pub fn isSequential<RetType, T: QProcess_isSequential<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isSequential(self);
// return 1;
}
}
pub trait QProcess_isSequential<RetType> {
fn isSequential(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::isSequential();
impl<'a> /*trait*/ QProcess_isSequential<i8> for () {
fn isSequential(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess12isSequentialEv()};
let mut ret = unsafe {C_ZNK8QProcess12isSequentialEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: bool QProcess::waitForReadyRead(int msecs);
impl /*struct*/ QProcess {
pub fn waitForReadyRead<RetType, T: QProcess_waitForReadyRead<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.waitForReadyRead(self);
// return 1;
}
}
pub trait QProcess_waitForReadyRead<RetType> {
fn waitForReadyRead(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::waitForReadyRead(int msecs);
impl<'a> /*trait*/ QProcess_waitForReadyRead<i8> for (Option<i32>) {
fn waitForReadyRead(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess16waitForReadyReadEi()};
let arg0 = (if self.is_none() {30000} else {self.unwrap()}) as c_int;
let mut ret = unsafe {C_ZN8QProcess16waitForReadyReadEi(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QProcess::setWorkingDirectory(const QString & dir);
impl /*struct*/ QProcess {
pub fn setWorkingDirectory<RetType, T: QProcess_setWorkingDirectory<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setWorkingDirectory(self);
// return 1;
}
}
pub trait QProcess_setWorkingDirectory<RetType> {
fn setWorkingDirectory(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setWorkingDirectory(const QString & dir);
impl<'a> /*trait*/ QProcess_setWorkingDirectory<()> for (&'a QString) {
fn setWorkingDirectory(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess19setWorkingDirectoryERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess19setWorkingDirectoryERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QProcess::terminate();
impl /*struct*/ QProcess {
pub fn terminate<RetType, T: QProcess_terminate<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.terminate(self);
// return 1;
}
}
pub trait QProcess_terminate<RetType> {
fn terminate(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::terminate();
impl<'a> /*trait*/ QProcess_terminate<()> for () {
fn terminate(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess9terminateEv()};
unsafe {C_ZN8QProcess9terminateEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QProcess::kill();
impl /*struct*/ QProcess {
pub fn kill<RetType, T: QProcess_kill<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.kill(self);
// return 1;
}
}
pub trait QProcess_kill<RetType> {
fn kill(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::kill();
impl<'a> /*trait*/ QProcess_kill<()> for () {
fn kill(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess4killEv()};
unsafe {C_ZN8QProcess4killEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: qint64 QProcess::bytesAvailable();
impl /*struct*/ QProcess {
pub fn bytesAvailable<RetType, T: QProcess_bytesAvailable<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.bytesAvailable(self);
// return 1;
}
}
pub trait QProcess_bytesAvailable<RetType> {
fn bytesAvailable(self , rsthis: & QProcess) -> RetType;
}
// proto: qint64 QProcess::bytesAvailable();
impl<'a> /*trait*/ QProcess_bytesAvailable<i64> for () {
fn bytesAvailable(self , rsthis: & QProcess) -> i64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess14bytesAvailableEv()};
let mut ret = unsafe {C_ZNK8QProcess14bytesAvailableEv(rsthis.qclsinst)};
return ret as i64; // 1
// return 1;
}
}
// proto: const QMetaObject * QProcess::metaObject();
impl /*struct*/ QProcess {
pub fn metaObject<RetType, T: QProcess_metaObject<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.metaObject(self);
// return 1;
}
}
pub trait QProcess_metaObject<RetType> {
fn metaObject(self , rsthis: & QProcess) -> RetType;
}
// proto: const QMetaObject * QProcess::metaObject();
impl<'a> /*trait*/ QProcess_metaObject<QMetaObject> for () {
fn metaObject(self , rsthis: & QProcess) -> QMetaObject {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess10metaObjectEv()};
let mut ret = unsafe {C_ZNK8QProcess10metaObjectEv(rsthis.qclsinst)};
let mut ret1 = QMetaObject::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QProcess::waitForStarted(int msecs);
impl /*struct*/ QProcess {
pub fn waitForStarted<RetType, T: QProcess_waitForStarted<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.waitForStarted(self);
// return 1;
}
}
pub trait QProcess_waitForStarted<RetType> {
fn waitForStarted(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::waitForStarted(int msecs);
impl<'a> /*trait*/ QProcess_waitForStarted<i8> for (Option<i32>) {
fn waitForStarted(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess14waitForStartedEi()};
let arg0 = (if self.is_none() {30000} else {self.unwrap()}) as c_int;
let mut ret = unsafe {C_ZN8QProcess14waitForStartedEi(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: QByteArray QProcess::readAllStandardError();
impl /*struct*/ QProcess {
pub fn readAllStandardError<RetType, T: QProcess_readAllStandardError<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.readAllStandardError(self);
// return 1;
}
}
pub trait QProcess_readAllStandardError<RetType> {
fn readAllStandardError(self , rsthis: & QProcess) -> RetType;
}
// proto: QByteArray QProcess::readAllStandardError();
impl<'a> /*trait*/ QProcess_readAllStandardError<QByteArray> for () {
fn readAllStandardError(self , rsthis: & QProcess) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess20readAllStandardErrorEv()};
let mut ret = unsafe {C_ZN8QProcess20readAllStandardErrorEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: int QProcess::exitCode();
impl /*struct*/ QProcess {
pub fn exitCode<RetType, T: QProcess_exitCode<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.exitCode(self);
// return 1;
}
}
pub trait QProcess_exitCode<RetType> {
fn exitCode(self , rsthis: & QProcess) -> RetType;
}
// proto: int QProcess::exitCode();
impl<'a> /*trait*/ QProcess_exitCode<i32> for () {
fn exitCode(self , rsthis: & QProcess) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess8exitCodeEv()};
let mut ret = unsafe {C_ZNK8QProcess8exitCodeEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: QStringList QProcess::environment();
impl /*struct*/ QProcess {
pub fn environment<RetType, T: QProcess_environment<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.environment(self);
// return 1;
}
}
pub trait QProcess_environment<RetType> {
fn environment(self , rsthis: & QProcess) -> RetType;
}
// proto: QStringList QProcess::environment();
impl<'a> /*trait*/ QProcess_environment<QStringList> for () {
fn environment(self , rsthis: & QProcess) -> QStringList {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess11environmentEv()};
let mut ret = unsafe {C_ZNK8QProcess11environmentEv(rsthis.qclsinst)};
let mut ret1 = QStringList::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QProcess::canReadLine();
impl /*struct*/ QProcess {
pub fn canReadLine<RetType, T: QProcess_canReadLine<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.canReadLine(self);
// return 1;
}
}
pub trait QProcess_canReadLine<RetType> {
fn canReadLine(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::canReadLine();
impl<'a> /*trait*/ QProcess_canReadLine<i8> for () {
fn canReadLine(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess11canReadLineEv()};
let mut ret = unsafe {C_ZNK8QProcess11canReadLineEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QProcess::setStandardOutputProcess(QProcess * destination);
impl /*struct*/ QProcess {
pub fn setStandardOutputProcess<RetType, T: QProcess_setStandardOutputProcess<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setStandardOutputProcess(self);
// return 1;
}
}
pub trait QProcess_setStandardOutputProcess<RetType> {
fn setStandardOutputProcess(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setStandardOutputProcess(QProcess * destination);
impl<'a> /*trait*/ QProcess_setStandardOutputProcess<()> for (&'a QProcess) {
fn setStandardOutputProcess(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess24setStandardOutputProcessEPS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess24setStandardOutputProcessEPS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: bool QProcess::waitForFinished(int msecs);
impl /*struct*/ QProcess {
pub fn waitForFinished<RetType, T: QProcess_waitForFinished<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.waitForFinished(self);
// return 1;
}
}
pub trait QProcess_waitForFinished<RetType> {
fn waitForFinished(self , rsthis: & QProcess) -> RetType;
}
// proto: bool QProcess::waitForFinished(int msecs);
impl<'a> /*trait*/ QProcess_waitForFinished<i8> for (Option<i32>) {
fn waitForFinished(self , rsthis: & QProcess) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess15waitForFinishedEi()};
let arg0 = (if self.is_none() {30000} else {self.unwrap()}) as c_int;
let mut ret = unsafe {C_ZN8QProcess15waitForFinishedEi(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: qint64 QProcess::bytesToWrite();
impl /*struct*/ QProcess {
pub fn bytesToWrite<RetType, T: QProcess_bytesToWrite<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.bytesToWrite(self);
// return 1;
}
}
pub trait QProcess_bytesToWrite<RetType> {
fn bytesToWrite(self , rsthis: & QProcess) -> RetType;
}
// proto: qint64 QProcess::bytesToWrite();
impl<'a> /*trait*/ QProcess_bytesToWrite<i64> for () {
fn bytesToWrite(self , rsthis: & QProcess) -> i64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess12bytesToWriteEv()};
let mut ret = unsafe {C_ZNK8QProcess12bytesToWriteEv(rsthis.qclsinst)};
return ret as i64; // 1
// return 1;
}
}
// proto: QString QProcess::workingDirectory();
impl /*struct*/ QProcess {
pub fn workingDirectory<RetType, T: QProcess_workingDirectory<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.workingDirectory(self);
// return 1;
}
}
pub trait QProcess_workingDirectory<RetType> {
fn workingDirectory(self , rsthis: & QProcess) -> RetType;
}
// proto: QString QProcess::workingDirectory();
impl<'a> /*trait*/ QProcess_workingDirectory<QString> for () {
fn workingDirectory(self , rsthis: & QProcess) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK8QProcess16workingDirectoryEv()};
let mut ret = unsafe {C_ZNK8QProcess16workingDirectoryEv(rsthis.qclsinst)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QProcess::setProgram(const QString & program);
impl /*struct*/ QProcess {
pub fn setProgram<RetType, T: QProcess_setProgram<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setProgram(self);
// return 1;
}
}
pub trait QProcess_setProgram<RetType> {
fn setProgram(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setProgram(const QString & program);
impl<'a> /*trait*/ QProcess_setProgram<()> for (&'a QString) {
fn setProgram(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess10setProgramERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess10setProgramERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QProcess::setStandardInputFile(const QString & fileName);
impl /*struct*/ QProcess {
pub fn setStandardInputFile<RetType, T: QProcess_setStandardInputFile<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setStandardInputFile(self);
// return 1;
}
}
pub trait QProcess_setStandardInputFile<RetType> {
fn setStandardInputFile(self , rsthis: & QProcess) -> RetType;
}
// proto: void QProcess::setStandardInputFile(const QString & fileName);
impl<'a> /*trait*/ QProcess_setStandardInputFile<()> for (&'a QString) {
fn setStandardInputFile(self , rsthis: & QProcess) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN8QProcess20setStandardInputFileERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN8QProcess20setStandardInputFileERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
impl /*struct*/ QProcessEnvironment {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QProcessEnvironment {
return QProcessEnvironment{qclsinst: qthis, ..Default::default()};
}
}
// proto: bool QProcessEnvironment::contains(const QString & name);
impl /*struct*/ QProcessEnvironment {
pub fn contains<RetType, T: QProcessEnvironment_contains<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.contains(self);
// return 1;
}
}
pub trait QProcessEnvironment_contains<RetType> {
fn contains(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: bool QProcessEnvironment::contains(const QString & name);
impl<'a> /*trait*/ QProcessEnvironment_contains<i8> for (&'a QString) {
fn contains(self , rsthis: & QProcessEnvironment) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK19QProcessEnvironment8containsERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZNK19QProcessEnvironment8containsERK7QString(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: QStringList QProcessEnvironment::keys();
impl /*struct*/ QProcessEnvironment {
pub fn keys<RetType, T: QProcessEnvironment_keys<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.keys(self);
// return 1;
}
}
pub trait QProcessEnvironment_keys<RetType> {
fn keys(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: QStringList QProcessEnvironment::keys();
impl<'a> /*trait*/ QProcessEnvironment_keys<QStringList> for () {
fn keys(self , rsthis: & QProcessEnvironment) -> QStringList {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK19QProcessEnvironment4keysEv()};
let mut ret = unsafe {C_ZNK19QProcessEnvironment4keysEv(rsthis.qclsinst)};
let mut ret1 = QStringList::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QProcessEnvironment::remove(const QString & name);
impl /*struct*/ QProcessEnvironment {
pub fn remove<RetType, T: QProcessEnvironment_remove<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.remove(self);
// return 1;
}
}
pub trait QProcessEnvironment_remove<RetType> {
fn remove(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: void QProcessEnvironment::remove(const QString & name);
impl<'a> /*trait*/ QProcessEnvironment_remove<()> for (&'a QString) {
fn remove(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment6removeERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN19QProcessEnvironment6removeERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QProcessEnvironment::clear();
impl /*struct*/ QProcessEnvironment {
pub fn clear<RetType, T: QProcessEnvironment_clear<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.clear(self);
// return 1;
}
}
pub trait QProcessEnvironment_clear<RetType> {
fn clear(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: void QProcessEnvironment::clear();
impl<'a> /*trait*/ QProcessEnvironment_clear<()> for () {
fn clear(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment5clearEv()};
unsafe {C_ZN19QProcessEnvironment5clearEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QString QProcessEnvironment::value(const QString & name, const QString & defaultValue);
impl /*struct*/ QProcessEnvironment {
pub fn value<RetType, T: QProcessEnvironment_value<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.value(self);
// return 1;
}
}
pub trait QProcessEnvironment_value<RetType> {
fn value(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: QString QProcessEnvironment::value(const QString & name, const QString & defaultValue);
impl<'a> /*trait*/ QProcessEnvironment_value<QString> for (&'a QString, Option<&'a QString>) {
fn value(self , rsthis: & QProcessEnvironment) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK19QProcessEnvironment5valueERK7QStringS2_()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = (if self.1.is_none() {QString::new(()).qclsinst} else {self.1.unwrap().qclsinst}) as *mut c_void;
let mut ret = unsafe {C_ZNK19QProcessEnvironment5valueERK7QStringS2_(rsthis.qclsinst, arg0, arg1)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QProcessEnvironment::isEmpty();
impl /*struct*/ QProcessEnvironment {
pub fn isEmpty<RetType, T: QProcessEnvironment_isEmpty<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isEmpty(self);
// return 1;
}
}
pub trait QProcessEnvironment_isEmpty<RetType> {
fn isEmpty(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: bool QProcessEnvironment::isEmpty();
impl<'a> /*trait*/ QProcessEnvironment_isEmpty<i8> for () {
fn isEmpty(self , rsthis: & QProcessEnvironment) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK19QProcessEnvironment7isEmptyEv()};
let mut ret = unsafe {C_ZNK19QProcessEnvironment7isEmptyEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QProcessEnvironment::~QProcessEnvironment();
impl /*struct*/ QProcessEnvironment {
pub fn free<RetType, T: QProcessEnvironment_free<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.free(self);
// return 1;
}
}
pub trait QProcessEnvironment_free<RetType> {
fn free(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: void QProcessEnvironment::~QProcessEnvironment();
impl<'a> /*trait*/ QProcessEnvironment_free<()> for () {
fn free(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironmentD2Ev()};
unsafe {C_ZN19QProcessEnvironmentD2Ev(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QProcessEnvironment::swap(QProcessEnvironment & other);
impl /*struct*/ QProcessEnvironment {
pub fn swap<RetType, T: QProcessEnvironment_swap<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.swap(self);
// return 1;
}
}
pub trait QProcessEnvironment_swap<RetType> {
fn swap(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: void QProcessEnvironment::swap(QProcessEnvironment & other);
impl<'a> /*trait*/ QProcessEnvironment_swap<()> for (&'a QProcessEnvironment) {
fn swap(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment4swapERS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN19QProcessEnvironment4swapERS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QProcessEnvironment::QProcessEnvironment(const QProcessEnvironment & other);
impl /*struct*/ QProcessEnvironment {
pub fn new<T: QProcessEnvironment_new>(value: T) -> QProcessEnvironment {
let rsthis = value.new();
return rsthis;
// return 1;
}
}
pub trait QProcessEnvironment_new {
fn new(self) -> QProcessEnvironment;
}
// proto: void QProcessEnvironment::QProcessEnvironment(const QProcessEnvironment & other);
impl<'a> /*trait*/ QProcessEnvironment_new for (&'a QProcessEnvironment) {
fn new(self) -> QProcessEnvironment {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironmentC2ERKS_()};
let ctysz: c_int = unsafe{QProcessEnvironment_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let arg0 = self.qclsinst as *mut c_void;
let qthis: u64 = unsafe {C_ZN19QProcessEnvironmentC2ERKS_(arg0)};
let rsthis = QProcessEnvironment{qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: static QProcessEnvironment QProcessEnvironment::systemEnvironment();
impl /*struct*/ QProcessEnvironment {
pub fn systemEnvironment_s<RetType, T: QProcessEnvironment_systemEnvironment_s<RetType>>( overload_args: T) -> RetType {
return overload_args.systemEnvironment_s();
// return 1;
}
}
pub trait QProcessEnvironment_systemEnvironment_s<RetType> {
fn systemEnvironment_s(self ) -> RetType;
}
// proto: static QProcessEnvironment QProcessEnvironment::systemEnvironment();
impl<'a> /*trait*/ QProcessEnvironment_systemEnvironment_s<QProcessEnvironment> for () {
fn systemEnvironment_s(self ) -> QProcessEnvironment {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment17systemEnvironmentEv()};
let mut ret = unsafe {C_ZN19QProcessEnvironment17systemEnvironmentEv()};
let mut ret1 = QProcessEnvironment::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QProcessEnvironment::insert(const QString & name, const QString & value);
impl /*struct*/ QProcessEnvironment {
pub fn insert<RetType, T: QProcessEnvironment_insert<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.insert(self);
// return 1;
}
}
pub trait QProcessEnvironment_insert<RetType> {
fn insert(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: void QProcessEnvironment::insert(const QString & name, const QString & value);
impl<'a> /*trait*/ QProcessEnvironment_insert<()> for (&'a QString, &'a QString) {
fn insert(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment6insertERK7QStringS2_()};
let arg0 = self.0.qclsinst as *mut c_void;
let arg1 = self.1.qclsinst as *mut c_void;
unsafe {C_ZN19QProcessEnvironment6insertERK7QStringS2_(rsthis.qclsinst, arg0, arg1)};
// return 1;
}
}
// proto: QStringList QProcessEnvironment::toStringList();
impl /*struct*/ QProcessEnvironment {
pub fn toStringList<RetType, T: QProcessEnvironment_toStringList<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.toStringList(self);
// return 1;
}
}
pub trait QProcessEnvironment_toStringList<RetType> {
fn toStringList(self , rsthis: & QProcessEnvironment) -> RetType;
}
// proto: QStringList QProcessEnvironment::toStringList();
impl<'a> /*trait*/ QProcessEnvironment_toStringList<QStringList> for () {
fn toStringList(self , rsthis: & QProcessEnvironment) -> QStringList {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK19QProcessEnvironment12toStringListEv()};
let mut ret = unsafe {C_ZNK19QProcessEnvironment12toStringListEv(rsthis.qclsinst)};
let mut ret1 = QStringList::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QProcessEnvironment::QProcessEnvironment();
impl<'a> /*trait*/ QProcessEnvironment_new for () {
fn new(self) -> QProcessEnvironment {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironmentC2Ev()};
let ctysz: c_int = unsafe{QProcessEnvironment_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let qthis: u64 = unsafe {C_ZN19QProcessEnvironmentC2Ev()};
let rsthis = QProcessEnvironment{qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: void QProcessEnvironment::insert(const QProcessEnvironment & e);
impl<'a> /*trait*/ QProcessEnvironment_insert<()> for (&'a QProcessEnvironment) {
fn insert(self , rsthis: & QProcessEnvironment) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN19QProcessEnvironment6insertERKS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN19QProcessEnvironment6insertERKS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
#[derive(Default)] // for QProcess_stateChanged
pub struct QProcess_stateChanged_signal{poi:u64}
impl /* struct */ QProcess {
pub fn stateChanged(&self) -> QProcess_stateChanged_signal {
return QProcess_stateChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_stateChanged_signal {
pub fn connect<T: QProcess_stateChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_stateChanged_signal_connect {
fn connect(self, sigthis: QProcess_stateChanged_signal);
}
#[derive(Default)] // for QProcess_started
pub struct QProcess_started_signal{poi:u64}
impl /* struct */ QProcess {
pub fn started(&self) -> QProcess_started_signal {
return QProcess_started_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_started_signal {
pub fn connect<T: QProcess_started_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_started_signal_connect {
fn connect(self, sigthis: QProcess_started_signal);
}
#[derive(Default)] // for QProcess_finished
pub struct QProcess_finished_signal{poi:u64}
impl /* struct */ QProcess {
pub fn finished(&self) -> QProcess_finished_signal {
return QProcess_finished_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_finished_signal {
pub fn connect<T: QProcess_finished_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_finished_signal_connect {
fn connect(self, sigthis: QProcess_finished_signal);
}
#[derive(Default)] // for QProcess_readyReadStandardError
pub struct QProcess_readyReadStandardError_signal{poi:u64}
impl /* struct */ QProcess {
pub fn readyReadStandardError(&self) -> QProcess_readyReadStandardError_signal {
return QProcess_readyReadStandardError_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_readyReadStandardError_signal {
pub fn connect<T: QProcess_readyReadStandardError_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_readyReadStandardError_signal_connect {
fn connect(self, sigthis: QProcess_readyReadStandardError_signal);
}
#[derive(Default)] // for QProcess_error
pub struct QProcess_error_signal{poi:u64}
impl /* struct */ QProcess {
pub fn error(&self) -> QProcess_error_signal {
return QProcess_error_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_error_signal {
pub fn connect<T: QProcess_error_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_error_signal_connect {
fn connect(self, sigthis: QProcess_error_signal);
}
#[derive(Default)] // for QProcess_readyReadStandardOutput
pub struct QProcess_readyReadStandardOutput_signal{poi:u64}
impl /* struct */ QProcess {
pub fn readyReadStandardOutput(&self) -> QProcess_readyReadStandardOutput_signal {
return QProcess_readyReadStandardOutput_signal{poi:self.qclsinst};
}
}
impl /* struct */ QProcess_readyReadStandardOutput_signal {
pub fn connect<T: QProcess_readyReadStandardOutput_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QProcess_readyReadStandardOutput_signal_connect {
fn connect(self, sigthis: QProcess_readyReadStandardOutput_signal);
}
// finished(int)
extern fn QProcess_finished_signal_connect_cb_0(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QProcess_finished_signal_connect_cb_box_0(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QProcess_finished_signal_connect for fn(i32) {
fn connect(self, sigthis: QProcess_finished_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QProcess_finished_signal_connect_cb_0 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QProcess_SlotProxy_connect__ZN8QProcess8finishedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QProcess_finished_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QProcess_finished_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QProcess_finished_signal_connect_cb_box_0 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QProcess_SlotProxy_connect__ZN8QProcess8finishedEi(arg0, arg1, arg2)};
}
}
// <= body block end
|
pub mod stream_reader;
pub mod stream_writer;
pub enum EndianType {
LittleEndian,
BigEndian,
}
fn swap_i16(i: &i16) -> i16 {
let ff: i16 = 0xff;
(i & ff) << 8 | ((i >> 8) & ff)
}
fn swap_i32(i: &i32) -> i32 {
let ff: i32 = 0xffff;
let v = *i as i16;
let c = (i >> 0x10) as i16;
let d1 = swap_i16(&v) as i32;
let d2 = swap_i16(&c) as i32;
((d1 & ff) << 0x10) | (d2 & ff)
}
fn swap_i64(i: &i64) -> i64 {
let ff: i64 = 0xffffffff;
let v = *i as i32;
let c = (i >> 0x20) as i32;
let d1 = swap_i32(&v) as i64;
let d2 = swap_i32(&c) as i64;
((d1 & ff) << 0x20) | (d2 & ff)
}
fn swap_u16(i: &u16) -> u16 {
let ff: u16 = 0xff;
(i & ff) << 8 | ((i >> 8) & ff)
}
fn swap_u32(i: &u32) -> u32 {
let ff: u32 = 0xffff;
let v = *i as u16;
let c = (i >> 0x10) as u16;
let d1 = swap_u16(&v) as u32;
let d2 = swap_u16(&c) as u32;
((d1 & ff) << 0x10) | (d2 & ff)
}
fn swap_u64(i: &u64) -> u64 {
let ff: u64 = 0xffffffff;
let v = *i as u32;
let c = (i >> 0x20) as u32;
let d1 = swap_u32(&v) as u64;
let d2 = swap_u32(&c) as u64;
((d1 & ff) << 0x20) | (d2 & ff)
}
|
// Copyright 2023 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use std::sync::Arc;
use common_exception::Result;
use common_expression::types::DataType;
use common_expression::types::NumberDataType;
use common_expression::types::NumberScalar;
use common_expression::BlockEntry;
use common_expression::DataBlock;
use common_expression::Scalar;
use common_expression::Value;
use common_pipeline_core::processors::port::InputPort;
use common_pipeline_core::processors::port::OutputPort;
use common_pipeline_core::processors::processor::ProcessorPtr;
use common_pipeline_transforms::processors::transforms::Transform;
use common_pipeline_transforms::processors::transforms::Transformer;
pub struct TransformExpandGroupingSets {
group_bys: Vec<(usize, DataType)>,
grouping_ids: Vec<usize>,
}
impl TransformExpandGroupingSets {
pub fn create(
input: Arc<InputPort>,
output: Arc<OutputPort>,
group_bys: Vec<(usize, DataType)>,
grouping_ids: Vec<usize>,
) -> ProcessorPtr {
ProcessorPtr::create(Transformer::create(
input,
output,
TransformExpandGroupingSets {
grouping_ids,
group_bys,
},
))
}
}
impl Transform for TransformExpandGroupingSets {
const NAME: &'static str = "TransformExpandGroupingSets";
fn transform(&mut self, data: DataBlock) -> Result<DataBlock> {
let num_rows = data.num_rows();
let num_group_bys = self.group_bys.len();
let mut output_blocks = Vec::with_capacity(self.grouping_ids.len());
for &id in &self.grouping_ids {
// Repeat data for each grouping set.
let grouping_column = BlockEntry {
data_type: DataType::Number(NumberDataType::UInt32),
value: Value::Scalar(Scalar::Number(NumberScalar::UInt32(id as u32))),
};
let mut columns = data
.columns()
.iter()
.cloned()
.chain(vec![grouping_column])
.collect::<Vec<_>>();
let bits = !id;
for i in 0..num_group_bys {
let entry = unsafe {
let offset = self.group_bys.get_unchecked(i).0;
columns.get_unchecked_mut(offset)
};
if bits & (1 << i) == 0 {
// This column should be set to NULLs.
*entry = BlockEntry {
data_type: entry.data_type.wrap_nullable(),
value: Value::Scalar(Scalar::Null),
}
} else {
*entry = BlockEntry {
data_type: entry.data_type.wrap_nullable(),
value: entry.value.clone().wrap_nullable(),
}
}
}
output_blocks.push(DataBlock::new(columns, num_rows));
}
DataBlock::concat(&output_blocks)
}
}
|
//!
//!
//! Create a single or collection of generics/trait bounds for functions and other
//! objects.
//!
use serde::{Deserialize, Serialize};
use tera::{Context, Tera};
use crate::internal;
use crate::traits::SrcCode;
/// Represent a single trait bound
///
/// Example
/// -------
/// ```
/// use proffer::*;
///
/// let generic = Generic::new("T").add_trait_bound("ToString");
/// ```
#[derive(Serialize, Deserialize, Default, Clone)]
pub struct Generic {
name: String,
traits: Vec<String>,
}
impl Generic {
/// Create a new `Generic`
pub fn new(name: impl ToString) -> Self {
Self {
name: name.to_string(),
..Self::default()
}
}
/// Get the name of the generic
pub fn name(&self) -> &str {
self.name.as_str()
}
}
impl internal::TraitBounds for Generic {
fn trait_bounds_mut(&mut self) -> &mut Vec<String> {
&mut self.traits
}
}
impl SrcCode for Vec<Generic> {
fn generate(&self) -> String {
if !self.is_empty() {
let template = r#"<{{ generic_keys | join(sep=", ") }}>
where
{% for generic in generics %}{{ generic.name }}: {{ generic.traits | join(sep=" + ") }},
{% endfor %}
"#;
let mut context = Context::new();
context.insert(
"generic_keys",
&self.iter().map(|g| g.name()).collect::<Vec<&str>>(),
);
context.insert("generics", &self);
Tera::one_off(template, &context, false).unwrap()
} else {
"".to_string()
}
}
}
|
use crate::alloc;
use alloc::{Alloc, AllocErr};
use std::alloc::{self as system_alloc, Layout};
#[derive(Debug)]
pub struct BPFAllocator {
allocated: usize,
size: usize,
}
impl BPFAllocator {
pub fn new(heap: Vec<u8>) -> Self {
Self {
allocated: 0,
size: heap.len(),
}
}
}
impl Alloc for BPFAllocator {
fn alloc(&mut self, layout: Layout) -> Result<*mut u8, AllocErr> {
if self.allocated + layout.size() <= self.size {
let ptr = unsafe { system_alloc::alloc(layout) };
if !ptr.is_null() {
self.allocated += layout.size();
return Ok(ptr);
}
}
Err(AllocErr)
}
#[allow(clippy::not_unsafe_ptr_arg_deref)]
fn dealloc(&mut self, ptr: *mut u8, layout: Layout) {
self.allocated -= layout.size();
unsafe {
system_alloc::dealloc(ptr, layout);
}
}
}
|
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::RIS {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
self.register.set(f(&R { bits }, &mut W { bits }).bits);
}
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::reset_value(),
})
.bits,
);
}
#[doc = r"Reset value of the register"]
#[inline(always)]
pub const fn reset_value() -> u32 {
0
}
#[doc = r"Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
}
#[doc = r"Value of the field"]
pub struct QEI_RIS_INDEXR {
bits: bool,
}
impl QEI_RIS_INDEXR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _QEI_RIS_INDEXW<'a> {
w: &'a mut W,
}
impl<'a> _QEI_RIS_INDEXW<'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 &= !(1 << 0);
self.w.bits |= ((value as u32) & 1) << 0;
self.w
}
}
#[doc = r"Value of the field"]
pub struct QEI_RIS_TIMERR {
bits: bool,
}
impl QEI_RIS_TIMERR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _QEI_RIS_TIMERW<'a> {
w: &'a mut W,
}
impl<'a> _QEI_RIS_TIMERW<'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 &= !(1 << 1);
self.w.bits |= ((value as u32) & 1) << 1;
self.w
}
}
#[doc = r"Value of the field"]
pub struct QEI_RIS_DIRR {
bits: bool,
}
impl QEI_RIS_DIRR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _QEI_RIS_DIRW<'a> {
w: &'a mut W,
}
impl<'a> _QEI_RIS_DIRW<'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 &= !(1 << 2);
self.w.bits |= ((value as u32) & 1) << 2;
self.w
}
}
#[doc = r"Value of the field"]
pub struct QEI_RIS_ERRORR {
bits: bool,
}
impl QEI_RIS_ERRORR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _QEI_RIS_ERRORW<'a> {
w: &'a mut W,
}
impl<'a> _QEI_RIS_ERRORW<'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 &= !(1 << 3);
self.w.bits |= ((value as u32) & 1) << 3;
self.w
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bit 0 - Index Pulse Asserted"]
#[inline(always)]
pub fn qei_ris_index(&self) -> QEI_RIS_INDEXR {
let bits = ((self.bits >> 0) & 1) != 0;
QEI_RIS_INDEXR { bits }
}
#[doc = "Bit 1 - Velocity Timer Expired"]
#[inline(always)]
pub fn qei_ris_timer(&self) -> QEI_RIS_TIMERR {
let bits = ((self.bits >> 1) & 1) != 0;
QEI_RIS_TIMERR { bits }
}
#[doc = "Bit 2 - Direction Change Detected"]
#[inline(always)]
pub fn qei_ris_dir(&self) -> QEI_RIS_DIRR {
let bits = ((self.bits >> 2) & 1) != 0;
QEI_RIS_DIRR { bits }
}
#[doc = "Bit 3 - Phase Error Detected"]
#[inline(always)]
pub fn qei_ris_error(&self) -> QEI_RIS_ERRORR {
let bits = ((self.bits >> 3) & 1) != 0;
QEI_RIS_ERRORR { bits }
}
}
impl W {
#[doc = r"Writes raw bits to the register"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bit 0 - Index Pulse Asserted"]
#[inline(always)]
pub fn qei_ris_index(&mut self) -> _QEI_RIS_INDEXW {
_QEI_RIS_INDEXW { w: self }
}
#[doc = "Bit 1 - Velocity Timer Expired"]
#[inline(always)]
pub fn qei_ris_timer(&mut self) -> _QEI_RIS_TIMERW {
_QEI_RIS_TIMERW { w: self }
}
#[doc = "Bit 2 - Direction Change Detected"]
#[inline(always)]
pub fn qei_ris_dir(&mut self) -> _QEI_RIS_DIRW {
_QEI_RIS_DIRW { w: self }
}
#[doc = "Bit 3 - Phase Error Detected"]
#[inline(always)]
pub fn qei_ris_error(&mut self) -> _QEI_RIS_ERRORW {
_QEI_RIS_ERRORW { w: self }
}
}
|
use assert_cmd::prelude::*; // Add methods on commands
use predicates::prelude::*; // Used for writing assertions
use std::process::Command;
const BIN: &str = "musign";
// secp256k1_ecdsa_signature_serialize_der
// secp256k1_ecdsa_signature_parse_compact
#[test]
fn help_subcommand() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("sign").arg("-h");
cmd.assert()
.success()
.stdout(predicate::str::contains("USAGE"));
Ok(())
}
#[test]
fn generate_keypair_ecdsa() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
// Generate ECDSA keypair
let seed = "7694c743a0159ebfb79a65aae8970fcc5be5e9db8efa1ebf70218ae00bb1f29b";
//let privkey = "7694c743a0159ebfb79a65aae8970fcc5be5e9db8efa1ebf70218ae00bb1f29b";
let pubkey = "03dc5a4faf89ad7187933042bcc0fd028b3296f82e7a0f17eecceb4f787ae33f59";
cmd.arg("generate").arg(seed);
cmd.assert()
.success()
.stdout(predicate::str::contains(pubkey));
Ok(())
}
#[test]
fn sign_verify_ecdsa() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
let privkey = "e6dd32f8761625f105c39a39f19370b3521d845a12456d60ce44debd0a362641";
let msg_data = "Hello world!";
let sig = "a834a9596c3021524305faa75a83a545780260e059832128d9617f447987661336bc08f2aed098d1e598106ab1439d4bcdbed127db73072358a4ca21f3dbd4f2";
let pubkey = "03c2805489921b22854b1381e32a1d7c4452a4fd12f6c3f13cab9dc899216a6bd1";
cmd.arg("sign").arg(msg_data).arg("-s").arg(privkey);
cmd.assert().success().stdout(predicate::str::contains(sig));
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg(sig)
.arg(msg_data)
.arg("-p")
.arg(pubkey.to_string());
cmd.assert()
.success()
.stdout(predicate::str::contains("true"));
// Change the message to fail the signature verification
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg(sig)
.arg(msg_data.to_owned() + " ")
.arg("-p")
.arg(pubkey.to_string());
cmd.assert()
.success()
.stdout(predicate::str::contains("false"));
// source: https://github.com/paulmillr/noble-secp256k1/blob/master/test/vectors/ecdsa.json
// test vector 1:
let privkey = "0000000000000000000000000000000000000000000000000000000000000001";
let msg_data = "Everything should be made as simple as possible, but not simpler.";
let sig = "33a69cd2065432a30f3d1ce4eb0d59b8ab58c74f27c41a7fdb5696ad4e6108c96f807982866f785d3f6418d24163ddae117b7db4d5fdf0071de069fa54342262";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("sign").arg(msg_data).arg("-s").arg(privkey);
cmd.assert().success().stdout(predicate::str::contains(sig));
// test vector 2:
let privkey = "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364140";
let msg_data = "Equations are more important to me, because politics is for the present, but an equation is something for eternity.";
let sig = "54c4a33c6423d689378f160a7ff8b61330444abb58fb470f96ea16d99d4a2fed07082304410efa6b2943111b6a4e0aaa7b7db55a07e9861d1fb3cb1f421044a5";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("sign").arg(msg_data).arg("-s").arg(privkey);
cmd.assert().success().stdout(predicate::str::contains(sig));
// test vector 3:
let privkey = "ab51604553e2a35df7e0fd32169a5a3e5dfa1bdf2455667a15aa3eb8696a3d16";
let msg_data =
"Computer science is no more about computers than astronomy is about telescopes.";
let sig = "06a02f42890eabc89401448debc5525b98f3cafe9f800d34179f1108cdcfcaec225c46d5280244429866d50446b4664c19f72a5f25ccad982fc54b9500a03c3e";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("sign").arg(msg_data).arg("-s").arg(privkey);
cmd.assert().success().stdout(predicate::str::contains(sig));
// test vector 4:
let privkey = "fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141";
let msg_data = "Private key >= G";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("sign").arg(msg_data).arg("-s").arg(privkey);
cmd.assert()
.failure()
.stderr(predicate::str::contains("panicked"));
// test vector 5:
let msg_data = "Bad sequence prefix";
let sig = "00000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000001";
let pubkey = "040000000000000000000000000000000000000000000000000000000000000001";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg(sig)
.arg(msg_data.to_owned() + " ")
.arg("-p")
.arg(pubkey.to_string());
cmd.assert()
.failure()
.stderr(predicate::str::contains("malformed public key"));
cmd.assert()
.failure()
.stderr(predicate::str::contains("malformed public key"));
Ok(())
}
#[test]
fn generate_keypair_schnorr() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
let seed = "7694c743a0159ebfb79a65aae8970fcc5be5e9db8efa1ebf70218ae00bb1f29b";
//let privkey = "7694c743a0159ebfb79a65aae8970fcc5be5e9db8efa1ebf70218ae00bb1f29b";
let pubkey = "dc5a4faf89ad7187933042bcc0fd028b3296f82e7a0f17eecceb4f787ae33f59";
cmd.arg("generate").arg(seed);
cmd.assert()
.success()
.stdout(predicate::str::contains(pubkey));
Ok(())
}
#[test]
fn sign_verify_schnorr() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
let privkey = "e6dd32f8761625f105c39a39f19370b3521d845a12456d60ce44debd0a362641";
let pubkey = "c2805489921b22854b1381e32a1d7c4452a4fd12f6c3f13cab9dc899216a6bd1";
let msg_data = "Hello world!";
let sig = "453e36a7c2b4fd163eee89d8de226f85172ee6a6657f07782f59a939b9ab3f432fe0fb69c62723bc830c5bb0dce8ddeb6ca34043d7b880a1342a479000271095";
cmd.arg("sign")
.arg("-t")
.arg("schnorr")
.arg(msg_data)
.arg("-s")
.arg(privkey);
cmd.assert().success().stdout(predicate::str::contains(sig));
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg("-t")
.arg("schnorr")
.arg(sig)
.arg(msg_data)
.arg("-p")
.arg(pubkey.to_string());
cmd.assert()
.success()
.stdout(predicate::str::contains("true"));
// change the message to fail the signature verification
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg("-t")
.arg("schnorr")
.arg(sig)
.arg(msg_data.to_owned() + " ")
.arg("-p")
.arg(pubkey.to_string());
cmd.assert()
.success()
.stdout(predicate::str::contains("false"));
Ok(())
}
#[test]
fn btc_sign_verify_btc_legacy() -> Result<(), Box<dyn std::error::Error>> {
let mut cmd = Command::cargo_bin(BIN)?;
let msg = "Hello world!";
let seed = "7694c743a0159ebfb79a65aae8970fcc5be5e9db8efa1ebf70218ae00bb1f29b";
//let pubkey = "dc5a4faf89ad7187933042bcc0fd028b3296f82e7a0f17eecceb4f787ae33f59";
let address = "12dR2srvCmffup7yBu5fdb3qkhFudTBnvZ"; // legacy
let sig_expected =
"IJIhzsY2hAFo613hTg9Gz4qc3ffWKVz3A+Wux8lwYSj5Vm1Mxqn5i7VTdhSuysrNAexNcSMBlkHyqOym77IiC/0=";
//cmd.arg(BIN).arg(seed).arg(msg);
cmd.arg("sign")
.arg("-t")
.arg("btc-legacy")
.arg("-s")
.arg(seed)
.arg(msg);
cmd.assert()
.success()
.stdout(predicate::str::contains(sig_expected));
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg(sig_expected)
.arg(msg)
.arg("-t")
.arg("btc-legacy")
.arg("-a")
.arg(address);
cmd.assert()
.success()
.stdout(predicate::str::contains("true"));
// negative test case: wrong address
let address = "1PYdSSwsXgJe1MGMzkeXCdshxjMfDP64wi";
let mut cmd = Command::cargo_bin(BIN)?;
cmd.arg("verify")
.arg(sig_expected)
.arg("-t")
.arg("btc-legacy")
.arg(msg)
.arg("-a")
.arg(address);
cmd.assert()
.success()
.stdout(predicate::str::contains("false"));
Ok(())
}
|
use std::{fmt::Debug, ops::Mul, rc::Rc};
use cxx::UniquePtr;
use crate::{sys, Term};
#[derive(Clone)]
pub struct Variable {
var: Rc<UniquePtr<sys::Variable>>,
}
impl Variable {
pub fn new(name: &str) -> Self {
cxx::let_cxx_string!(name = name);
Self {
var: Rc::new(unsafe { sys::new_variable(&name) }),
}
}
pub fn value(&self) -> f64 {
self.var.value()
}
pub fn name(&self) -> &str {
unsafe { std::str::from_utf8_unchecked(self.var.name().as_bytes()) }
}
pub(crate) fn var(&self) -> &UniquePtr<sys::Variable> {
&self.var
}
}
impl From<Variable> for Term {
fn from(val: Variable) -> Self {
Term::new(&val, 1.0)
}
}
impl Debug for Variable {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Variable({:?})", self.name())
}
}
impl<'a> Mul<f64> for &'a Variable {
type Output = Term;
fn mul(self, rhs: f64) -> Self::Output {
Term::new(self, rhs)
}
}
impl Mul<f64> for Variable {
type Output = Term;
fn mul(self, rhs: f64) -> Self::Output {
Term::new(&self, rhs)
}
}
impl<'a> Mul<&'a Variable> for f64 {
type Output = Term;
fn mul(self, rhs: &'a Variable) -> Self::Output {
Term::new(rhs, self)
}
}
impl Mul<Variable> for f64 {
type Output = Term;
fn mul(self, rhs: Variable) -> Self::Output {
Term::new(&rhs, self)
}
}
|
use super::android::{
back, content_options_positons, draw, get_ime, input, set_ime, sleep, tap, Xpath,
};
use super::config::Rules;
use super::db::*;
pub struct Daily {
ime: String,
daily_delay: u64,
daily_forever: bool,
rules: Rules,
db: DB,
bank: Bank,
has_bank: bool,
submit_position: Option<(usize, usize)>,
}
impl std::ops::Deref for Daily {
type Target = Rules;
fn deref(&self) -> &Self::Target {
&self.rules
}
}
impl Drop for Daily {
fn drop(&mut self) {
set_ime(&self.ime);
}
}
impl Daily {
pub fn new(database_uri: String, daily_delay: u64, daily_forever: bool, rules: Rules) -> Self {
let ime = get_ime().unwrap();
set_ime("com.android.adbkeyboard/.AdbIME");
Self {
ime,
daily_delay: daily_delay,
daily_forever: daily_forever,
rules: rules,
bank: Bank::new(),
db: DB::new(&database_uri),
has_bank: false,
submit_position: None,
}
}
fn return_home(&self) {
let mut ptns = self.rule_bottom_work.positions();
while ptns.len() < 1 {
back();
ptns = self.rule_bottom_work.positions();
}
let (x, y) = ptns[0];
tap(x, y);
}
pub fn run(&mut self) {
println!("开始每日答题");
self.return_home();
let count = 5;
let daily_delay = self.daily_delay;
self.rule_bottom_mine.click();
self.rule_quiz_entry.click();
self.rule_daily_entry.click();
let mut group = 1;
'out: loop {
println!("\n<----正在答题,第 {} 组---->", group);
for _ in 0..count {
if let Err(_) = self.submit() {
back();
self.rule_exit.click();
self.rule_daily_entry.click();
continue 'out;
}
}
if self.daily_forever && self.rule_score_reached.texts().len() > 0 {
println!("大战{}回合,终于分数达标咯,告辞!", group);
self.return_home();
return;
}
println!("再来一组");
sleep(daily_delay);
self.rule_next.click();
group += 1
}
}
fn submit(&mut self) -> Result<(), ()> {
self.has_bank = false;
self.bank.clear();
self.bank.category.push_str(&self.rule_type.texts()[0]);
match self.bank.category.as_str() {
"填空题" => self.blank(),
"单选题" => self.radio(),
"多选题" => self.check(),
_ => {
println!("category: {}", &self.bank.category);
panic!("未知题目类型")
}
}
if let Some((x, y)) = self.submit_position {
tap(x, y);
} else {
let submit_position = self.rule_submit.positions();
if submit_position.len() != 1 {
return Err(());
}
let (x, y) = submit_position[0];
self.submit_position = Some((x, y));
tap(x, y);
}
// # 填好空格或选中选项后
// 提交答案后,获取答案解析,若为空,则回答正确,否则,返回正确答案
if let [des, ..] = &*self.rule_desc.texts() {
self.bank.answer = des.replace(r"正确答案:", "");
println!("正确答案:{}", &self.bank.answer);
self.bank.notes.push_str(&self.rule_note.texts()[0]);
let (x, y) = self.submit_position.unwrap();
tap(x, y);
// 删除错误数据
self.db.delete(&self.bank);
self.db.add(&self.bank);
} else {
println!("回答正确");
// #保存数据
if !self.has_bank {
self.db.add(&self.bank);
}
}
Ok(())
}
fn blank(&mut self) {
self.bank.content = self.rule_blank_content.texts().join("");
let edits = self.rule_edits.positions();
self.bank.options = edits.len().to_string();
if let [b, ..] = &*self.db.query(&self.bank) {
self.has_bank = true;
self.bank.answer.push_str(&b.answer);
println!("{}", &self.bank);
println!("自动提交答案 {}", &self.bank.answer);
let mut answer = self.bank.answer.replace(" ", "");
if answer == "" {
answer = "不忘初心牢记使命".to_string();
}
for (answer, (x, y)) in answer.chars().zip(edits) {
tap(x, y);
input(&answer.to_string());
}
} else {
self.has_bank = false;
println!("{}", &self.bank);
println!("默认提交答案: 不忘初心牢记使命");
for (answer, (x, y)) in "不忘初心牢记使命".chars().zip(edits) {
tap(x, y);
input(&answer.to_string());
}
}
}
fn radio(&mut self) {
let (content, options, mut ptns) = content_options_positons(
&self.rule_content,
&self.rule_radio_options_content,
&self.rule_options,
);
self.bank.content = content;
self.bank.options = options;
if let [b, ..] = &*self.db.query(&self.bank) {
self.has_bank = true;
self.bank.answer.push_str(&b.answer);
println!("{}", &self.bank);
println!("自动提交答案 {}", &self.bank.answer);
} else {
self.has_bank = false;
println!("{}", &self.bank);
println!("默认提交答案: A");
self.bank.answer.push('A');
}
let cursor = self.bank.answer.chars().nth(0).unwrap() as usize - 65;
while (0, 0) == ptns[cursor] {
draw();
ptns = self.rule_challenge_options_bounds.positions();
}
let (x, y) = ptns[cursor];
tap(x, y);
}
fn check(&mut self) {
let (content, options, mut ptns) = content_options_positons(
&self.rule_content,
&self.rule_radio_options_content,
&self.rule_options,
);
self.bank.content = content;
self.bank.options = options;
let answers: String;
if let [b, ..] = &*self.db.query(&self.bank) {
self.has_bank = true;
self.bank.answer.push_str(&b.answer);
println!("{}", &self.bank);
println!("自动提交答案 {}", &self.bank.answer);
answers = self.bank.answer.clone();
} else {
self.has_bank = false;
println!("{}", &self.bank);
println!("默认提交答案: 全选");
answers = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"[..ptns.len()].to_string();
self.bank.answer.push_str(&answers);
}
for c in answers.chars() {
let cursor = c as usize - 65;
while (0, 0) == ptns[cursor] {
draw();
ptns = self.rule_challenge_options_bounds.positions();
}
let (x, y) = ptns[cursor];
tap(x, y);
}
}
}
|
use std::fmt;
use std::ops;
use std::mem;
use std::slice;
use approx;
use num;
use angle::{FromAngle, Angle, IntoAngle, Deg};
use angle;
use channel::{PosNormalBoundedChannel, AngularChannel, ChannelFormatCast, ChannelCast,
PosNormalChannelScalar, AngularChannelScalar, ColorChannel};
use alpha::Alpha;
use convert;
use convert::GetChroma;
use color;
use color::{Color, FromTuple};
use rgb::Rgb;
pub struct HslTag;
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd, Hash)]
pub struct Hsl<T, A = Deg<T>> {
pub hue: AngularChannel<A>,
pub saturation: PosNormalBoundedChannel<T>,
pub lightness: PosNormalBoundedChannel<T>,
}
pub type Hsla<T, A> = Alpha<T, Hsl<T, A>>;
impl<T, A> Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
pub fn from_channels(hue: A, saturation: T, lightness: T) -> Self {
Hsl {
hue: AngularChannel::new(hue),
saturation: PosNormalBoundedChannel::new(saturation),
lightness: PosNormalBoundedChannel::new(lightness),
}
}
impl_color_color_cast_angular!(Hsl {hue, saturation, lightness},
chan_traits={PosNormalChannelScalar});
pub fn hue(&self) -> A {
self.hue.0.clone()
}
pub fn saturation(&self) -> T {
self.saturation.0.clone()
}
pub fn lightness(&self) -> T {
self.lightness.0.clone()
}
pub fn hue_mut(&mut self) -> &mut A {
&mut self.hue.0
}
pub fn saturation_mut(&mut self) -> &mut T {
&mut self.saturation.0
}
pub fn lightness_mut(&mut self) -> &mut T {
&mut self.lightness.0
}
pub fn set_hue(&mut self, val: A) {
self.hue.0 = val;
}
pub fn set_saturation(&mut self, val: T) {
self.saturation.0 = val;
}
pub fn set_lightness(&mut self, val: T) {
self.lightness.0 = val;
}
}
impl<T, A> Color for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
type Tag = HslTag;
type ChannelsTuple = (A, T, T);
fn num_channels() -> u32 {
3
}
fn to_tuple(self) -> Self::ChannelsTuple {
(self.hue.0, self.saturation.0, self.lightness.0)
}
}
impl<T, A> FromTuple for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
fn from_tuple(values: Self::ChannelsTuple) -> Self {
Hsl::from_channels(values.0, values.1, values.2)
}
}
impl<T, A> color::PolarColor for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
type Angular = A;
type Cartesian = T;
}
impl<T, A> color::Invert for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
impl_color_invert!(Hsl {hue, saturation, lightness});
}
impl<T, A> color::Lerp for Hsl<T, A>
where T: PosNormalChannelScalar + color::Lerp,
A: AngularChannelScalar + color::Lerp
{
type Position = A::Position;
impl_color_lerp_angular!(Hsl<T> {hue, saturation, lightness});
}
impl<T, A> color::Bounded for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
impl_color_bounded!(Hsl {hue, saturation, lightness});
}
impl<T, A> color::Flatten for Hsl<T, A>
where T: PosNormalChannelScalar + num::Float,
A: AngularChannelScalar + Angle<Scalar = T> + FromAngle<angle::Turns<T>>
{
type ScalarFormat = T;
impl_color_as_slice!(T);
impl_color_from_slice_angular!(Hsl<T, A> {hue:AngularChannel - 0,
saturation:PosNormalBoundedChannel - 1, lightness:PosNormalBoundedChannel - 2});
}
impl<T, A> approx::ApproxEq for Hsl<T, A>
where T: PosNormalChannelScalar + approx::ApproxEq<Epsilon = A::Epsilon>,
A: AngularChannelScalar + approx::ApproxEq,
A::Epsilon: Clone + num::Float
{
impl_approx_eq!({hue, saturation, lightness});
}
impl<T, A> Default for Hsl<T, A>
where T: PosNormalChannelScalar + num::Zero,
A: AngularChannelScalar + num::Zero
{
impl_color_default!(Hsl {
hue:AngularChannel, saturation:PosNormalBoundedChannel,
lightness:PosNormalBoundedChannel});
}
impl<T, A> fmt::Display for Hsl<T, A>
where T: PosNormalChannelScalar + fmt::Display,
A: AngularChannelScalar + fmt::Display
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Hsl({}, {}, {})", self.hue, self.saturation, self.lightness)
}
}
impl<T, A> convert::GetChroma for Hsl<T, A>
where T: PosNormalChannelScalar + ops::Mul<T, Output = T> + num::Float,
A: AngularChannelScalar
{
type ChromaType = T;
fn get_chroma(&self) -> T {
let one: T = num::cast(1.0).unwrap();
let scaled_lightness: T = (num::cast::<_, T>(2.0).unwrap() * self.lightness() - one).abs();
(one - scaled_lightness) * self.saturation()
}
}
impl<T, A> convert::GetHue for Hsl<T, A>
where T: PosNormalChannelScalar,
A: AngularChannelScalar
{
impl_color_get_hue_angular!(Hsl);
}
impl<T, A> convert::FromColor<Hsl<T, A>> for Rgb<T>
where T: PosNormalChannelScalar + num::Float,
A: AngularChannelScalar
{
fn from_color(from: &Hsl<T, A>) -> Self {
let (hue_seg, hue_frac) = convert::decompose_hue_segment(from);
let one_half: T = num::cast(0.5).unwrap();
let hue_frac_t: T = num::cast(hue_frac).unwrap();
let chroma = from.get_chroma();
let channel_min = from.lightness() - num::cast::<_, T>(0.5).unwrap() * chroma;
let channel_max = channel_min + chroma;
match hue_seg {
0 => {
let g = chroma * (hue_frac_t - one_half) + from.lightness();
Rgb::from_channels(channel_max, g, channel_min)
}
1 => {
let r = chroma * (one_half - hue_frac_t) + from.lightness();
Rgb::from_channels(r, channel_max, channel_min)
}
2 => {
let b = chroma * (hue_frac_t - one_half) + from.lightness();
Rgb::from_channels(channel_min, channel_max, b)
}
3 => {
let g = chroma * (one_half - hue_frac_t) + from.lightness();
Rgb::from_channels(channel_min, g, channel_max)
}
4 => {
let r = chroma * (hue_frac_t - one_half) + from.lightness();
Rgb::from_channels(r, channel_min, channel_max)
}
5 => {
let b = chroma * (one_half - hue_frac_t) + from.lightness();
Rgb::from_channels(channel_max, channel_min, b)
}
_ => unreachable!(),
}
}
}
#[cfg(test)]
mod test {
use super::*;
use std::f32::consts;
use angle::*;
use color::*;
use convert::*;
use rgb::Rgb;
use test;
#[test]
fn test_construct() {
let c1 = Hsl::from_channels(Deg(90.0), 0.5, 0.25);
assert_eq!(c1.hue(), Deg(90.0));
assert_eq!(c1.saturation(), 0.5);
assert_eq!(c1.lightness(), 0.25);
assert_eq!(c1.to_tuple(), (Deg(90.0), 0.5, 0.25));
assert_eq!(Hsl::from_tuple(c1.to_tuple()), c1);
let c2 = Hsl::from_channels(Rad(consts::PI), 0.20f32, 0.90f32);
assert_eq!(c2.hue(), Rad(consts::PI));
assert_eq!(c2.saturation(), 0.2);
assert_eq!(c2.lightness(), 0.90);
assert_eq!(c2.as_slice(), &[consts::PI, 0.20f32, 0.90]);
}
#[test]
fn test_chroma() {
let test_data = test::build_hs_test_data();
for item in test_data.iter() {
let chroma = item.hsl.get_chroma();
assert_relative_eq!(chroma, item.chroma, epsilon=1e-3);
}
}
#[test]
fn test_invert() {
let c1 = Hsl::from_channels(Deg(100f32), 0.77f32, 0.5);
assert_relative_eq!(c1.clone().invert().invert(), c1);
assert_relative_eq!(c1.invert(), Hsl::from_channels(Deg(280f32), 0.23f32, 0.5));
let c2 = Hsl::from_channels(Turns(0.10), 0.11, 0.55);
assert_relative_eq!(c2.clone().invert().invert(), c2);
assert_relative_eq!(c2.invert(), Hsl::from_channels(Turns(0.60), 0.89, 0.45));
}
#[test]
fn test_lerp() {
let c1 = Hsl::from_channels(Turns(0.2), 0.25, 0.80);
let c2 = Hsl::from_channels(Turns(0.8), 0.75, 0.30);
assert_relative_eq!(c1.lerp(&c2, 0.0), c1);
assert_relative_eq!(c1.lerp(&c2, 1.0), c2);
assert_relative_eq!(c1.lerp(&c2, 0.5), Hsl::from_channels(Turns(0.0), 0.5, 0.55));
}
#[test]
fn test_hsl_to_rgb() {
let test_data = test::build_hs_test_data();
for item in test_data.iter() {
let rgb = Rgb::from_color(&item.hsl);
assert_relative_eq!(rgb, item.rgb, epsilon=1e-3);
let hsl = Hsl::from_color(&rgb);
assert_relative_eq!(hsl, item.hsl, epsilon=1e-3);
}
}
#[test]
fn test_color_cast() {
let c1 = Hsl::from_channels(Deg(90.0), 0.23, 0.45);
assert_relative_eq!(c1.color_cast(),
Hsl::from_channels(Turns(0.25f32), 0.23f32, 0.45f32));
assert_relative_eq!(c1.color_cast(), c1, epsilon=1e-7);
assert_relative_eq!(c1.color_cast::<f32, Rad<f32>>().color_cast(), c1, epsilon=1e-7);
}
}
|
// auto generated, do not modify.
// created: Mon Feb 22 23:57:02 2016
// src-file: /QtGui/qwindow.h
// dst-file: /src/gui/qwindow.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main block end
// use block begin =>
use super::super::core::qobject::*; // 771
use std::ops::Deref;
use super::qscreen::*; // 773
use super::super::core::qsize::*; // 771
use super::qsurfaceformat::*; // 773
use super::qicon::*; // 773
use super::super::core::qstring::*; // 771
use super::super::core::qpoint::*; // 771
use super::super::core::qmargins::*; // 771
use super::super::core::qrect::*; // 771
use super::qcursor::*; // 773
use super::qregion::*; // 773
use super::super::core::qobjectdefs::*; // 771
// use super::qplatformwindow::*; // 775
use super::qaccessible::*; // 773
// <= use block end
// ext block begin =>
// #[link(name = "Qt5Core")]
// #[link(name = "Qt5Gui")]
// #[link(name = "Qt5Widgets")]
// #[link(name = "QtInline")]
extern {
fn QWindow_Class_Size() -> c_int;
// proto: void QWindow::unsetCursor();
fn C_ZN7QWindow11unsetCursorEv(qthis: u64 /* *mut c_void*/);
// proto: bool QWindow::isVisible();
fn C_ZNK7QWindow9isVisibleEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: void QWindow::setScreen(QScreen * screen);
fn C_ZN7QWindow9setScreenEP7QScreen(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: QSize QWindow::maximumSize();
fn C_ZNK7QWindow11maximumSizeEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setTransientParent(QWindow * parent);
fn C_ZN7QWindow18setTransientParentEPS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: QSurfaceFormat QWindow::format();
fn C_ZNK7QWindow6formatEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QWindow::isTopLevel();
fn C_ZNK7QWindow10isTopLevelEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: void QWindow::setIcon(const QIcon & icon);
fn C_ZN7QWindow7setIconERK5QIcon(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: qreal QWindow::opacity();
fn C_ZNK7QWindow7opacityEv(qthis: u64 /* *mut c_void*/) -> c_double;
// proto: void QWindow::setMinimumSize(const QSize & size);
fn C_ZN7QWindow14setMinimumSizeERK5QSize(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: int QWindow::minimumHeight();
fn C_ZNK7QWindow13minimumHeightEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: QSize QWindow::sizeIncrement();
fn C_ZNK7QWindow13sizeIncrementEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::resize(const QSize & newSize);
fn C_ZN7QWindow6resizeERK5QSize(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::setTitle(const QString & );
fn C_ZN7QWindow8setTitleERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::raise();
fn C_ZN7QWindow5raiseEv(qthis: u64 /* *mut c_void*/);
// proto: QSize QWindow::minimumSize();
fn C_ZNK7QWindow11minimumSizeEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QPoint QWindow::mapToGlobal(const QPoint & pos);
fn C_ZNK7QWindow11mapToGlobalERK6QPoint(qthis: u64 /* *mut c_void*/, arg0: *mut c_void) -> *mut c_void;
// proto: static QWindow * QWindow::fromWinId(WId id);
fn C_ZN7QWindow9fromWinIdEi(arg0: c_int) -> *mut c_void;
// proto: QMargins QWindow::frameMargins();
fn C_ZNK7QWindow12frameMarginsEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setMaximumWidth(int w);
fn C_ZN7QWindow15setMaximumWidthEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: int QWindow::maximumHeight();
fn C_ZNK7QWindow13maximumHeightEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: bool QWindow::isModal();
fn C_ZNK7QWindow7isModalEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: QRect QWindow::geometry();
fn C_ZNK7QWindow8geometryEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setParent(QWindow * parent);
fn C_ZN7QWindow9setParentEPS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: QRect QWindow::frameGeometry();
fn C_ZNK7QWindow13frameGeometryEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QSurfaceFormat QWindow::requestedFormat();
fn C_ZNK7QWindow15requestedFormatEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setHeight(int arg);
fn C_ZN7QWindow9setHeightEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: void QWindow::requestActivate();
fn C_ZN7QWindow15requestActivateEv(qthis: u64 /* *mut c_void*/);
// proto: QPoint QWindow::mapFromGlobal(const QPoint & pos);
fn C_ZNK7QWindow13mapFromGlobalERK6QPoint(qthis: u64 /* *mut c_void*/, arg0: *mut c_void) -> *mut c_void;
// proto: int QWindow::y();
fn C_ZNK7QWindow1yEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: int QWindow::width();
fn C_ZNK7QWindow5widthEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: void QWindow::setFilePath(const QString & filePath);
fn C_ZN7QWindow11setFilePathERK7QString(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::setCursor(const QCursor & );
fn C_ZN7QWindow9setCursorERK7QCursor(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::setVisible(bool visible);
fn C_ZN7QWindow10setVisibleEb(qthis: u64 /* *mut c_void*/, arg0: c_char);
// proto: void QWindow::~QWindow();
fn C_ZN7QWindowD2Ev(qthis: u64 /* *mut c_void*/);
// proto: bool QWindow::setMouseGrabEnabled(bool grab);
fn C_ZN7QWindow19setMouseGrabEnabledEb(qthis: u64 /* *mut c_void*/, arg0: c_char) -> c_char;
// proto: bool QWindow::isExposed();
fn C_ZNK7QWindow9isExposedEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: int QWindow::minimumWidth();
fn C_ZNK7QWindow12minimumWidthEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: void QWindow::setPosition(const QPoint & pt);
fn C_ZN7QWindow11setPositionERK6QPoint(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: bool QWindow::close();
fn C_ZN7QWindow5closeEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: int QWindow::x();
fn C_ZNK7QWindow1xEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: void QWindow::setMinimumWidth(int w);
fn C_ZN7QWindow15setMinimumWidthEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: QRegion QWindow::mask();
fn C_ZNK7QWindow4maskEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QWindow * QWindow::parent();
fn C_ZNK7QWindow6parentEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setFramePosition(const QPoint & point);
fn C_ZN7QWindow16setFramePositionERK6QPoint(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::QWindow(QScreen * screen);
fn C_ZN7QWindowC2EP7QScreen(arg0: *mut c_void) -> u64;
// proto: void QWindow::setGeometry(int posx, int posy, int w, int h);
fn C_ZN7QWindow11setGeometryEiiii(qthis: u64 /* *mut c_void*/, arg0: c_int, arg1: c_int, arg2: c_int, arg3: c_int);
// proto: bool QWindow::setKeyboardGrabEnabled(bool grab);
fn C_ZN7QWindow22setKeyboardGrabEnabledEb(qthis: u64 /* *mut c_void*/, arg0: c_char) -> c_char;
// proto: const QMetaObject * QWindow::metaObject();
fn C_ZNK7QWindow10metaObjectEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::QWindow(QWindow * parent);
fn C_ZN7QWindowC2EPS_(arg0: *mut c_void) -> u64;
// proto: void QWindow::setWidth(int arg);
fn C_ZN7QWindow8setWidthEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: void QWindow::setY(int arg);
fn C_ZN7QWindow4setYEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: qreal QWindow::devicePixelRatio();
fn C_ZNK7QWindow16devicePixelRatioEv(qthis: u64 /* *mut c_void*/) -> c_double;
// proto: void QWindow::setBaseSize(const QSize & size);
fn C_ZN7QWindow11setBaseSizeERK5QSize(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::alert(int msec);
fn C_ZN7QWindow5alertEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: QPlatformWindow * QWindow::handle();
fn C_ZNK7QWindow6handleEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::destroy();
fn C_ZN7QWindow7destroyEv(qthis: u64 /* *mut c_void*/);
// proto: QWindow * QWindow::transientParent();
fn C_ZNK7QWindow15transientParentEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setMinimumHeight(int h);
fn C_ZN7QWindow16setMinimumHeightEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: void QWindow::show();
fn C_ZN7QWindow4showEv(qthis: u64 /* *mut c_void*/);
// proto: QSize QWindow::baseSize();
fn C_ZNK7QWindow8baseSizeEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QString QWindow::title();
fn C_ZNK7QWindow5titleEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::showMaximized();
fn C_ZN7QWindow13showMaximizedEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::create();
fn C_ZN7QWindow6createEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::resize(int w, int h);
fn C_ZN7QWindow6resizeEii(qthis: u64 /* *mut c_void*/, arg0: c_int, arg1: c_int);
// proto: QScreen * QWindow::screen();
fn C_ZNK7QWindow6screenEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setPosition(int posx, int posy);
fn C_ZN7QWindow11setPositionEii(qthis: u64 /* *mut c_void*/, arg0: c_int, arg1: c_int);
// proto: void QWindow::setOpacity(qreal level);
fn C_ZN7QWindow10setOpacityEd(qthis: u64 /* *mut c_void*/, arg0: c_double);
// proto: void QWindow::setGeometry(const QRect & rect);
fn C_ZN7QWindow11setGeometryERK5QRect(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::setSizeIncrement(const QSize & size);
fn C_ZN7QWindow16setSizeIncrementERK5QSize(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::showMinimized();
fn C_ZN7QWindow13showMinimizedEv(qthis: u64 /* *mut c_void*/);
// proto: QObject * QWindow::focusObject();
fn C_ZNK7QWindow11focusObjectEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QWindow::isActive();
fn C_ZNK7QWindow8isActiveEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: QAccessibleInterface * QWindow::accessibleRoot();
fn C_ZNK7QWindow14accessibleRootEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QCursor QWindow::cursor();
fn C_ZNK7QWindow6cursorEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setFormat(const QSurfaceFormat & format);
fn C_ZN7QWindow9setFormatERK14QSurfaceFormat(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::showFullScreen();
fn C_ZN7QWindow14showFullScreenEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::setX(int arg);
fn C_ZN7QWindow4setXEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: void QWindow::lower();
fn C_ZN7QWindow5lowerEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::requestUpdate();
fn C_ZN7QWindow13requestUpdateEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::hide();
fn C_ZN7QWindow4hideEv(qthis: u64 /* *mut c_void*/);
// proto: void QWindow::setMask(const QRegion & region);
fn C_ZN7QWindow7setMaskERK7QRegion(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QWindow::setMaximumSize(const QSize & size);
fn C_ZN7QWindow14setMaximumSizeERK5QSize(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: int QWindow::height();
fn C_ZNK7QWindow6heightEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: QSize QWindow::size();
fn C_ZNK7QWindow4sizeEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: int QWindow::maximumWidth();
fn C_ZNK7QWindow12maximumWidthEv(qthis: u64 /* *mut c_void*/) -> c_int;
// proto: QPoint QWindow::position();
fn C_ZNK7QWindow8positionEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::setMaximumHeight(int h);
fn C_ZN7QWindow16setMaximumHeightEi(qthis: u64 /* *mut c_void*/, arg0: c_int);
// proto: QString QWindow::filePath();
fn C_ZNK7QWindow8filePathEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QWindow::showNormal();
fn C_ZN7QWindow10showNormalEv(qthis: u64 /* *mut c_void*/);
// proto: QPoint QWindow::framePosition();
fn C_ZNK7QWindow13framePositionEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QIcon QWindow::icon();
fn C_ZNK7QWindow4iconEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
fn QWindow_SlotProxy_connect__ZN7QWindow8xChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow12widthChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow14opacityChangedEd(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow8yChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow20minimumHeightChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow13heightChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow19maximumWidthChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow13screenChangedEP7QScreen(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow19minimumWidthChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow18windowTitleChangedERK7QString(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow18focusObjectChangedEP7QObject(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow14visibleChangedEb(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow20maximumHeightChangedEi(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
fn QWindow_SlotProxy_connect__ZN7QWindow13activeChangedEv(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
} // <= ext block end
// body block begin =>
// class sizeof(QWindow)=1
#[derive(Default)]
pub struct QWindow {
qbase: QObject,
pub qclsinst: u64 /* *mut c_void*/,
pub _modalityChanged: QWindow_modalityChanged_signal,
pub _activeChanged: QWindow_activeChanged_signal,
pub _heightChanged: QWindow_heightChanged_signal,
pub _contentOrientationChanged: QWindow_contentOrientationChanged_signal,
pub _minimumWidthChanged: QWindow_minimumWidthChanged_signal,
pub _opacityChanged: QWindow_opacityChanged_signal,
pub _visibleChanged: QWindow_visibleChanged_signal,
pub _screenChanged: QWindow_screenChanged_signal,
pub _maximumHeightChanged: QWindow_maximumHeightChanged_signal,
pub _yChanged: QWindow_yChanged_signal,
pub _widthChanged: QWindow_widthChanged_signal,
pub _windowStateChanged: QWindow_windowStateChanged_signal,
pub _windowTitleChanged: QWindow_windowTitleChanged_signal,
pub _visibilityChanged: QWindow_visibilityChanged_signal,
pub _minimumHeightChanged: QWindow_minimumHeightChanged_signal,
pub _xChanged: QWindow_xChanged_signal,
pub _focusObjectChanged: QWindow_focusObjectChanged_signal,
pub _maximumWidthChanged: QWindow_maximumWidthChanged_signal,
}
impl /*struct*/ QWindow {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QWindow {
return QWindow{qbase: QObject::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
}
}
impl Deref for QWindow {
type Target = QObject;
fn deref(&self) -> &QObject {
return & self.qbase;
}
}
impl AsRef<QObject> for QWindow {
fn as_ref(& self) -> & QObject {
return & self.qbase;
}
}
// proto: void QWindow::unsetCursor();
impl /*struct*/ QWindow {
pub fn unsetCursor<RetType, T: QWindow_unsetCursor<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.unsetCursor(self);
// return 1;
}
}
pub trait QWindow_unsetCursor<RetType> {
fn unsetCursor(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::unsetCursor();
impl<'a> /*trait*/ QWindow_unsetCursor<()> for () {
fn unsetCursor(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11unsetCursorEv()};
unsafe {C_ZN7QWindow11unsetCursorEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: bool QWindow::isVisible();
impl /*struct*/ QWindow {
pub fn isVisible<RetType, T: QWindow_isVisible<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isVisible(self);
// return 1;
}
}
pub trait QWindow_isVisible<RetType> {
fn isVisible(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::isVisible();
impl<'a> /*trait*/ QWindow_isVisible<i8> for () {
fn isVisible(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow9isVisibleEv()};
let mut ret = unsafe {C_ZNK7QWindow9isVisibleEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QWindow::setScreen(QScreen * screen);
impl /*struct*/ QWindow {
pub fn setScreen<RetType, T: QWindow_setScreen<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setScreen(self);
// return 1;
}
}
pub trait QWindow_setScreen<RetType> {
fn setScreen(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setScreen(QScreen * screen);
impl<'a> /*trait*/ QWindow_setScreen<()> for (&'a QScreen) {
fn setScreen(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9setScreenEP7QScreen()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow9setScreenEP7QScreen(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QSize QWindow::maximumSize();
impl /*struct*/ QWindow {
pub fn maximumSize<RetType, T: QWindow_maximumSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.maximumSize(self);
// return 1;
}
}
pub trait QWindow_maximumSize<RetType> {
fn maximumSize(self , rsthis: & QWindow) -> RetType;
}
// proto: QSize QWindow::maximumSize();
impl<'a> /*trait*/ QWindow_maximumSize<QSize> for () {
fn maximumSize(self , rsthis: & QWindow) -> QSize {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow11maximumSizeEv()};
let mut ret = unsafe {C_ZNK7QWindow11maximumSizeEv(rsthis.qclsinst)};
let mut ret1 = QSize::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setTransientParent(QWindow * parent);
impl /*struct*/ QWindow {
pub fn setTransientParent<RetType, T: QWindow_setTransientParent<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setTransientParent(self);
// return 1;
}
}
pub trait QWindow_setTransientParent<RetType> {
fn setTransientParent(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setTransientParent(QWindow * parent);
impl<'a> /*trait*/ QWindow_setTransientParent<()> for (&'a QWindow) {
fn setTransientParent(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow18setTransientParentEPS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow18setTransientParentEPS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QSurfaceFormat QWindow::format();
impl /*struct*/ QWindow {
pub fn format<RetType, T: QWindow_format<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.format(self);
// return 1;
}
}
pub trait QWindow_format<RetType> {
fn format(self , rsthis: & QWindow) -> RetType;
}
// proto: QSurfaceFormat QWindow::format();
impl<'a> /*trait*/ QWindow_format<QSurfaceFormat> for () {
fn format(self , rsthis: & QWindow) -> QSurfaceFormat {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6formatEv()};
let mut ret = unsafe {C_ZNK7QWindow6formatEv(rsthis.qclsinst)};
let mut ret1 = QSurfaceFormat::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QWindow::isTopLevel();
impl /*struct*/ QWindow {
pub fn isTopLevel<RetType, T: QWindow_isTopLevel<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isTopLevel(self);
// return 1;
}
}
pub trait QWindow_isTopLevel<RetType> {
fn isTopLevel(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::isTopLevel();
impl<'a> /*trait*/ QWindow_isTopLevel<i8> for () {
fn isTopLevel(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow10isTopLevelEv()};
let mut ret = unsafe {C_ZNK7QWindow10isTopLevelEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: void QWindow::setIcon(const QIcon & icon);
impl /*struct*/ QWindow {
pub fn setIcon<RetType, T: QWindow_setIcon<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setIcon(self);
// return 1;
}
}
pub trait QWindow_setIcon<RetType> {
fn setIcon(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setIcon(const QIcon & icon);
impl<'a> /*trait*/ QWindow_setIcon<()> for (&'a QIcon) {
fn setIcon(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow7setIconERK5QIcon()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow7setIconERK5QIcon(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: qreal QWindow::opacity();
impl /*struct*/ QWindow {
pub fn opacity<RetType, T: QWindow_opacity<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.opacity(self);
// return 1;
}
}
pub trait QWindow_opacity<RetType> {
fn opacity(self , rsthis: & QWindow) -> RetType;
}
// proto: qreal QWindow::opacity();
impl<'a> /*trait*/ QWindow_opacity<f64> for () {
fn opacity(self , rsthis: & QWindow) -> f64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow7opacityEv()};
let mut ret = unsafe {C_ZNK7QWindow7opacityEv(rsthis.qclsinst)};
return ret as f64; // 1
// return 1;
}
}
// proto: void QWindow::setMinimumSize(const QSize & size);
impl /*struct*/ QWindow {
pub fn setMinimumSize<RetType, T: QWindow_setMinimumSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMinimumSize(self);
// return 1;
}
}
pub trait QWindow_setMinimumSize<RetType> {
fn setMinimumSize(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMinimumSize(const QSize & size);
impl<'a> /*trait*/ QWindow_setMinimumSize<()> for (&'a QSize) {
fn setMinimumSize(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow14setMinimumSizeERK5QSize()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow14setMinimumSizeERK5QSize(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: int QWindow::minimumHeight();
impl /*struct*/ QWindow {
pub fn minimumHeight<RetType, T: QWindow_minimumHeight<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.minimumHeight(self);
// return 1;
}
}
pub trait QWindow_minimumHeight<RetType> {
fn minimumHeight(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::minimumHeight();
impl<'a> /*trait*/ QWindow_minimumHeight<i32> for () {
fn minimumHeight(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13minimumHeightEv()};
let mut ret = unsafe {C_ZNK7QWindow13minimumHeightEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: QSize QWindow::sizeIncrement();
impl /*struct*/ QWindow {
pub fn sizeIncrement<RetType, T: QWindow_sizeIncrement<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.sizeIncrement(self);
// return 1;
}
}
pub trait QWindow_sizeIncrement<RetType> {
fn sizeIncrement(self , rsthis: & QWindow) -> RetType;
}
// proto: QSize QWindow::sizeIncrement();
impl<'a> /*trait*/ QWindow_sizeIncrement<QSize> for () {
fn sizeIncrement(self , rsthis: & QWindow) -> QSize {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13sizeIncrementEv()};
let mut ret = unsafe {C_ZNK7QWindow13sizeIncrementEv(rsthis.qclsinst)};
let mut ret1 = QSize::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::resize(const QSize & newSize);
impl /*struct*/ QWindow {
pub fn resize<RetType, T: QWindow_resize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.resize(self);
// return 1;
}
}
pub trait QWindow_resize<RetType> {
fn resize(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::resize(const QSize & newSize);
impl<'a> /*trait*/ QWindow_resize<()> for (&'a QSize) {
fn resize(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow6resizeERK5QSize()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow6resizeERK5QSize(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setTitle(const QString & );
impl /*struct*/ QWindow {
pub fn setTitle<RetType, T: QWindow_setTitle<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setTitle(self);
// return 1;
}
}
pub trait QWindow_setTitle<RetType> {
fn setTitle(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setTitle(const QString & );
impl<'a> /*trait*/ QWindow_setTitle<()> for (&'a QString) {
fn setTitle(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow8setTitleERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow8setTitleERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::raise();
impl /*struct*/ QWindow {
pub fn raise<RetType, T: QWindow_raise<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.raise(self);
// return 1;
}
}
pub trait QWindow_raise<RetType> {
fn raise(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::raise();
impl<'a> /*trait*/ QWindow_raise<()> for () {
fn raise(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow5raiseEv()};
unsafe {C_ZN7QWindow5raiseEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QSize QWindow::minimumSize();
impl /*struct*/ QWindow {
pub fn minimumSize<RetType, T: QWindow_minimumSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.minimumSize(self);
// return 1;
}
}
pub trait QWindow_minimumSize<RetType> {
fn minimumSize(self , rsthis: & QWindow) -> RetType;
}
// proto: QSize QWindow::minimumSize();
impl<'a> /*trait*/ QWindow_minimumSize<QSize> for () {
fn minimumSize(self , rsthis: & QWindow) -> QSize {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow11minimumSizeEv()};
let mut ret = unsafe {C_ZNK7QWindow11minimumSizeEv(rsthis.qclsinst)};
let mut ret1 = QSize::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QPoint QWindow::mapToGlobal(const QPoint & pos);
impl /*struct*/ QWindow {
pub fn mapToGlobal<RetType, T: QWindow_mapToGlobal<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.mapToGlobal(self);
// return 1;
}
}
pub trait QWindow_mapToGlobal<RetType> {
fn mapToGlobal(self , rsthis: & QWindow) -> RetType;
}
// proto: QPoint QWindow::mapToGlobal(const QPoint & pos);
impl<'a> /*trait*/ QWindow_mapToGlobal<QPoint> for (&'a QPoint) {
fn mapToGlobal(self , rsthis: & QWindow) -> QPoint {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow11mapToGlobalERK6QPoint()};
let arg0 = self.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZNK7QWindow11mapToGlobalERK6QPoint(rsthis.qclsinst, arg0)};
let mut ret1 = QPoint::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: static QWindow * QWindow::fromWinId(WId id);
impl /*struct*/ QWindow {
pub fn fromWinId_s<RetType, T: QWindow_fromWinId_s<RetType>>( overload_args: T) -> RetType {
return overload_args.fromWinId_s();
// return 1;
}
}
pub trait QWindow_fromWinId_s<RetType> {
fn fromWinId_s(self ) -> RetType;
}
// proto: static QWindow * QWindow::fromWinId(WId id);
impl<'a> /*trait*/ QWindow_fromWinId_s<QWindow> for (*mut i32) {
fn fromWinId_s(self ) -> QWindow {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9fromWinIdEi()};
let arg0 = self as c_int;
let mut ret = unsafe {C_ZN7QWindow9fromWinIdEi(arg0)};
let mut ret1 = QWindow::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QMargins QWindow::frameMargins();
impl /*struct*/ QWindow {
pub fn frameMargins<RetType, T: QWindow_frameMargins<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.frameMargins(self);
// return 1;
}
}
pub trait QWindow_frameMargins<RetType> {
fn frameMargins(self , rsthis: & QWindow) -> RetType;
}
// proto: QMargins QWindow::frameMargins();
impl<'a> /*trait*/ QWindow_frameMargins<QMargins> for () {
fn frameMargins(self , rsthis: & QWindow) -> QMargins {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow12frameMarginsEv()};
let mut ret = unsafe {C_ZNK7QWindow12frameMarginsEv(rsthis.qclsinst)};
let mut ret1 = QMargins::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setMaximumWidth(int w);
impl /*struct*/ QWindow {
pub fn setMaximumWidth<RetType, T: QWindow_setMaximumWidth<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMaximumWidth(self);
// return 1;
}
}
pub trait QWindow_setMaximumWidth<RetType> {
fn setMaximumWidth(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMaximumWidth(int w);
impl<'a> /*trait*/ QWindow_setMaximumWidth<()> for (i32) {
fn setMaximumWidth(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow15setMaximumWidthEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow15setMaximumWidthEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: int QWindow::maximumHeight();
impl /*struct*/ QWindow {
pub fn maximumHeight<RetType, T: QWindow_maximumHeight<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.maximumHeight(self);
// return 1;
}
}
pub trait QWindow_maximumHeight<RetType> {
fn maximumHeight(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::maximumHeight();
impl<'a> /*trait*/ QWindow_maximumHeight<i32> for () {
fn maximumHeight(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13maximumHeightEv()};
let mut ret = unsafe {C_ZNK7QWindow13maximumHeightEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: bool QWindow::isModal();
impl /*struct*/ QWindow {
pub fn isModal<RetType, T: QWindow_isModal<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isModal(self);
// return 1;
}
}
pub trait QWindow_isModal<RetType> {
fn isModal(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::isModal();
impl<'a> /*trait*/ QWindow_isModal<i8> for () {
fn isModal(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow7isModalEv()};
let mut ret = unsafe {C_ZNK7QWindow7isModalEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: QRect QWindow::geometry();
impl /*struct*/ QWindow {
pub fn geometry<RetType, T: QWindow_geometry<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.geometry(self);
// return 1;
}
}
pub trait QWindow_geometry<RetType> {
fn geometry(self , rsthis: & QWindow) -> RetType;
}
// proto: QRect QWindow::geometry();
impl<'a> /*trait*/ QWindow_geometry<QRect> for () {
fn geometry(self , rsthis: & QWindow) -> QRect {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow8geometryEv()};
let mut ret = unsafe {C_ZNK7QWindow8geometryEv(rsthis.qclsinst)};
let mut ret1 = QRect::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setParent(QWindow * parent);
impl /*struct*/ QWindow {
pub fn setParent<RetType, T: QWindow_setParent<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setParent(self);
// return 1;
}
}
pub trait QWindow_setParent<RetType> {
fn setParent(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setParent(QWindow * parent);
impl<'a> /*trait*/ QWindow_setParent<()> for (&'a QWindow) {
fn setParent(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9setParentEPS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow9setParentEPS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QRect QWindow::frameGeometry();
impl /*struct*/ QWindow {
pub fn frameGeometry<RetType, T: QWindow_frameGeometry<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.frameGeometry(self);
// return 1;
}
}
pub trait QWindow_frameGeometry<RetType> {
fn frameGeometry(self , rsthis: & QWindow) -> RetType;
}
// proto: QRect QWindow::frameGeometry();
impl<'a> /*trait*/ QWindow_frameGeometry<QRect> for () {
fn frameGeometry(self , rsthis: & QWindow) -> QRect {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13frameGeometryEv()};
let mut ret = unsafe {C_ZNK7QWindow13frameGeometryEv(rsthis.qclsinst)};
let mut ret1 = QRect::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QSurfaceFormat QWindow::requestedFormat();
impl /*struct*/ QWindow {
pub fn requestedFormat<RetType, T: QWindow_requestedFormat<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.requestedFormat(self);
// return 1;
}
}
pub trait QWindow_requestedFormat<RetType> {
fn requestedFormat(self , rsthis: & QWindow) -> RetType;
}
// proto: QSurfaceFormat QWindow::requestedFormat();
impl<'a> /*trait*/ QWindow_requestedFormat<QSurfaceFormat> for () {
fn requestedFormat(self , rsthis: & QWindow) -> QSurfaceFormat {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow15requestedFormatEv()};
let mut ret = unsafe {C_ZNK7QWindow15requestedFormatEv(rsthis.qclsinst)};
let mut ret1 = QSurfaceFormat::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setHeight(int arg);
impl /*struct*/ QWindow {
pub fn setHeight<RetType, T: QWindow_setHeight<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setHeight(self);
// return 1;
}
}
pub trait QWindow_setHeight<RetType> {
fn setHeight(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setHeight(int arg);
impl<'a> /*trait*/ QWindow_setHeight<()> for (i32) {
fn setHeight(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9setHeightEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow9setHeightEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::requestActivate();
impl /*struct*/ QWindow {
pub fn requestActivate<RetType, T: QWindow_requestActivate<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.requestActivate(self);
// return 1;
}
}
pub trait QWindow_requestActivate<RetType> {
fn requestActivate(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::requestActivate();
impl<'a> /*trait*/ QWindow_requestActivate<()> for () {
fn requestActivate(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow15requestActivateEv()};
unsafe {C_ZN7QWindow15requestActivateEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QPoint QWindow::mapFromGlobal(const QPoint & pos);
impl /*struct*/ QWindow {
pub fn mapFromGlobal<RetType, T: QWindow_mapFromGlobal<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.mapFromGlobal(self);
// return 1;
}
}
pub trait QWindow_mapFromGlobal<RetType> {
fn mapFromGlobal(self , rsthis: & QWindow) -> RetType;
}
// proto: QPoint QWindow::mapFromGlobal(const QPoint & pos);
impl<'a> /*trait*/ QWindow_mapFromGlobal<QPoint> for (&'a QPoint) {
fn mapFromGlobal(self , rsthis: & QWindow) -> QPoint {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13mapFromGlobalERK6QPoint()};
let arg0 = self.qclsinst as *mut c_void;
let mut ret = unsafe {C_ZNK7QWindow13mapFromGlobalERK6QPoint(rsthis.qclsinst, arg0)};
let mut ret1 = QPoint::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: int QWindow::y();
impl /*struct*/ QWindow {
pub fn y<RetType, T: QWindow_y<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.y(self);
// return 1;
}
}
pub trait QWindow_y<RetType> {
fn y(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::y();
impl<'a> /*trait*/ QWindow_y<i32> for () {
fn y(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow1yEv()};
let mut ret = unsafe {C_ZNK7QWindow1yEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: int QWindow::width();
impl /*struct*/ QWindow {
pub fn width<RetType, T: QWindow_width<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.width(self);
// return 1;
}
}
pub trait QWindow_width<RetType> {
fn width(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::width();
impl<'a> /*trait*/ QWindow_width<i32> for () {
fn width(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow5widthEv()};
let mut ret = unsafe {C_ZNK7QWindow5widthEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: void QWindow::setFilePath(const QString & filePath);
impl /*struct*/ QWindow {
pub fn setFilePath<RetType, T: QWindow_setFilePath<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setFilePath(self);
// return 1;
}
}
pub trait QWindow_setFilePath<RetType> {
fn setFilePath(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setFilePath(const QString & filePath);
impl<'a> /*trait*/ QWindow_setFilePath<()> for (&'a QString) {
fn setFilePath(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setFilePathERK7QString()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow11setFilePathERK7QString(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setCursor(const QCursor & );
impl /*struct*/ QWindow {
pub fn setCursor<RetType, T: QWindow_setCursor<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setCursor(self);
// return 1;
}
}
pub trait QWindow_setCursor<RetType> {
fn setCursor(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setCursor(const QCursor & );
impl<'a> /*trait*/ QWindow_setCursor<()> for (&'a QCursor) {
fn setCursor(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9setCursorERK7QCursor()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow9setCursorERK7QCursor(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setVisible(bool visible);
impl /*struct*/ QWindow {
pub fn setVisible<RetType, T: QWindow_setVisible<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setVisible(self);
// return 1;
}
}
pub trait QWindow_setVisible<RetType> {
fn setVisible(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setVisible(bool visible);
impl<'a> /*trait*/ QWindow_setVisible<()> for (i8) {
fn setVisible(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow10setVisibleEb()};
let arg0 = self as c_char;
unsafe {C_ZN7QWindow10setVisibleEb(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::~QWindow();
impl /*struct*/ QWindow {
pub fn free<RetType, T: QWindow_free<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.free(self);
// return 1;
}
}
pub trait QWindow_free<RetType> {
fn free(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::~QWindow();
impl<'a> /*trait*/ QWindow_free<()> for () {
fn free(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindowD2Ev()};
unsafe {C_ZN7QWindowD2Ev(rsthis.qclsinst)};
// return 1;
}
}
// proto: bool QWindow::setMouseGrabEnabled(bool grab);
impl /*struct*/ QWindow {
pub fn setMouseGrabEnabled<RetType, T: QWindow_setMouseGrabEnabled<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMouseGrabEnabled(self);
// return 1;
}
}
pub trait QWindow_setMouseGrabEnabled<RetType> {
fn setMouseGrabEnabled(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::setMouseGrabEnabled(bool grab);
impl<'a> /*trait*/ QWindow_setMouseGrabEnabled<i8> for (i8) {
fn setMouseGrabEnabled(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow19setMouseGrabEnabledEb()};
let arg0 = self as c_char;
let mut ret = unsafe {C_ZN7QWindow19setMouseGrabEnabledEb(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: bool QWindow::isExposed();
impl /*struct*/ QWindow {
pub fn isExposed<RetType, T: QWindow_isExposed<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isExposed(self);
// return 1;
}
}
pub trait QWindow_isExposed<RetType> {
fn isExposed(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::isExposed();
impl<'a> /*trait*/ QWindow_isExposed<i8> for () {
fn isExposed(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow9isExposedEv()};
let mut ret = unsafe {C_ZNK7QWindow9isExposedEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: int QWindow::minimumWidth();
impl /*struct*/ QWindow {
pub fn minimumWidth<RetType, T: QWindow_minimumWidth<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.minimumWidth(self);
// return 1;
}
}
pub trait QWindow_minimumWidth<RetType> {
fn minimumWidth(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::minimumWidth();
impl<'a> /*trait*/ QWindow_minimumWidth<i32> for () {
fn minimumWidth(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow12minimumWidthEv()};
let mut ret = unsafe {C_ZNK7QWindow12minimumWidthEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: void QWindow::setPosition(const QPoint & pt);
impl /*struct*/ QWindow {
pub fn setPosition<RetType, T: QWindow_setPosition<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setPosition(self);
// return 1;
}
}
pub trait QWindow_setPosition<RetType> {
fn setPosition(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setPosition(const QPoint & pt);
impl<'a> /*trait*/ QWindow_setPosition<()> for (&'a QPoint) {
fn setPosition(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setPositionERK6QPoint()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow11setPositionERK6QPoint(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: bool QWindow::close();
impl /*struct*/ QWindow {
pub fn close<RetType, T: QWindow_close<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.close(self);
// return 1;
}
}
pub trait QWindow_close<RetType> {
fn close(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::close();
impl<'a> /*trait*/ QWindow_close<i8> for () {
fn close(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow5closeEv()};
let mut ret = unsafe {C_ZN7QWindow5closeEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: int QWindow::x();
impl /*struct*/ QWindow {
pub fn x<RetType, T: QWindow_x<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.x(self);
// return 1;
}
}
pub trait QWindow_x<RetType> {
fn x(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::x();
impl<'a> /*trait*/ QWindow_x<i32> for () {
fn x(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow1xEv()};
let mut ret = unsafe {C_ZNK7QWindow1xEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: void QWindow::setMinimumWidth(int w);
impl /*struct*/ QWindow {
pub fn setMinimumWidth<RetType, T: QWindow_setMinimumWidth<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMinimumWidth(self);
// return 1;
}
}
pub trait QWindow_setMinimumWidth<RetType> {
fn setMinimumWidth(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMinimumWidth(int w);
impl<'a> /*trait*/ QWindow_setMinimumWidth<()> for (i32) {
fn setMinimumWidth(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow15setMinimumWidthEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow15setMinimumWidthEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QRegion QWindow::mask();
impl /*struct*/ QWindow {
pub fn mask<RetType, T: QWindow_mask<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.mask(self);
// return 1;
}
}
pub trait QWindow_mask<RetType> {
fn mask(self , rsthis: & QWindow) -> RetType;
}
// proto: QRegion QWindow::mask();
impl<'a> /*trait*/ QWindow_mask<QRegion> for () {
fn mask(self , rsthis: & QWindow) -> QRegion {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow4maskEv()};
let mut ret = unsafe {C_ZNK7QWindow4maskEv(rsthis.qclsinst)};
let mut ret1 = QRegion::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QWindow * QWindow::parent();
impl /*struct*/ QWindow {
pub fn parent<RetType, T: QWindow_parent<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.parent(self);
// return 1;
}
}
pub trait QWindow_parent<RetType> {
fn parent(self , rsthis: & QWindow) -> RetType;
}
// proto: QWindow * QWindow::parent();
impl<'a> /*trait*/ QWindow_parent<QWindow> for () {
fn parent(self , rsthis: & QWindow) -> QWindow {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6parentEv()};
let mut ret = unsafe {C_ZNK7QWindow6parentEv(rsthis.qclsinst)};
let mut ret1 = QWindow::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setFramePosition(const QPoint & point);
impl /*struct*/ QWindow {
pub fn setFramePosition<RetType, T: QWindow_setFramePosition<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setFramePosition(self);
// return 1;
}
}
pub trait QWindow_setFramePosition<RetType> {
fn setFramePosition(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setFramePosition(const QPoint & point);
impl<'a> /*trait*/ QWindow_setFramePosition<()> for (&'a QPoint) {
fn setFramePosition(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow16setFramePositionERK6QPoint()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow16setFramePositionERK6QPoint(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::QWindow(QScreen * screen);
impl /*struct*/ QWindow {
pub fn new<T: QWindow_new>(value: T) -> QWindow {
let rsthis = value.new();
return rsthis;
// return 1;
}
}
pub trait QWindow_new {
fn new(self) -> QWindow;
}
// proto: void QWindow::QWindow(QScreen * screen);
impl<'a> /*trait*/ QWindow_new for (Option<&'a QScreen>) {
fn new(self) -> QWindow {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindowC2EP7QScreen()};
let ctysz: c_int = unsafe{QWindow_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let arg0 = (if self.is_none() {0} else {self.unwrap().qclsinst}) as *mut c_void;
let qthis: u64 = unsafe {C_ZN7QWindowC2EP7QScreen(arg0)};
let rsthis = QWindow{qbase: QObject::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: void QWindow::setGeometry(int posx, int posy, int w, int h);
impl /*struct*/ QWindow {
pub fn setGeometry<RetType, T: QWindow_setGeometry<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setGeometry(self);
// return 1;
}
}
pub trait QWindow_setGeometry<RetType> {
fn setGeometry(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setGeometry(int posx, int posy, int w, int h);
impl<'a> /*trait*/ QWindow_setGeometry<()> for (i32, i32, i32, i32) {
fn setGeometry(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setGeometryEiiii()};
let arg0 = self.0 as c_int;
let arg1 = self.1 as c_int;
let arg2 = self.2 as c_int;
let arg3 = self.3 as c_int;
unsafe {C_ZN7QWindow11setGeometryEiiii(rsthis.qclsinst, arg0, arg1, arg2, arg3)};
// return 1;
}
}
// proto: bool QWindow::setKeyboardGrabEnabled(bool grab);
impl /*struct*/ QWindow {
pub fn setKeyboardGrabEnabled<RetType, T: QWindow_setKeyboardGrabEnabled<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setKeyboardGrabEnabled(self);
// return 1;
}
}
pub trait QWindow_setKeyboardGrabEnabled<RetType> {
fn setKeyboardGrabEnabled(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::setKeyboardGrabEnabled(bool grab);
impl<'a> /*trait*/ QWindow_setKeyboardGrabEnabled<i8> for (i8) {
fn setKeyboardGrabEnabled(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow22setKeyboardGrabEnabledEb()};
let arg0 = self as c_char;
let mut ret = unsafe {C_ZN7QWindow22setKeyboardGrabEnabledEb(rsthis.qclsinst, arg0)};
return ret as i8; // 1
// return 1;
}
}
// proto: const QMetaObject * QWindow::metaObject();
impl /*struct*/ QWindow {
pub fn metaObject<RetType, T: QWindow_metaObject<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.metaObject(self);
// return 1;
}
}
pub trait QWindow_metaObject<RetType> {
fn metaObject(self , rsthis: & QWindow) -> RetType;
}
// proto: const QMetaObject * QWindow::metaObject();
impl<'a> /*trait*/ QWindow_metaObject<QMetaObject> for () {
fn metaObject(self , rsthis: & QWindow) -> QMetaObject {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow10metaObjectEv()};
let mut ret = unsafe {C_ZNK7QWindow10metaObjectEv(rsthis.qclsinst)};
let mut ret1 = QMetaObject::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::QWindow(QWindow * parent);
impl<'a> /*trait*/ QWindow_new for (&'a QWindow) {
fn new(self) -> QWindow {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindowC2EPS_()};
let ctysz: c_int = unsafe{QWindow_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let arg0 = self.qclsinst as *mut c_void;
let qthis: u64 = unsafe {C_ZN7QWindowC2EPS_(arg0)};
let rsthis = QWindow{qbase: QObject::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: void QWindow::setWidth(int arg);
impl /*struct*/ QWindow {
pub fn setWidth<RetType, T: QWindow_setWidth<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setWidth(self);
// return 1;
}
}
pub trait QWindow_setWidth<RetType> {
fn setWidth(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setWidth(int arg);
impl<'a> /*trait*/ QWindow_setWidth<()> for (i32) {
fn setWidth(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow8setWidthEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow8setWidthEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setY(int arg);
impl /*struct*/ QWindow {
pub fn setY<RetType, T: QWindow_setY<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setY(self);
// return 1;
}
}
pub trait QWindow_setY<RetType> {
fn setY(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setY(int arg);
impl<'a> /*trait*/ QWindow_setY<()> for (i32) {
fn setY(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow4setYEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow4setYEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: qreal QWindow::devicePixelRatio();
impl /*struct*/ QWindow {
pub fn devicePixelRatio<RetType, T: QWindow_devicePixelRatio<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.devicePixelRatio(self);
// return 1;
}
}
pub trait QWindow_devicePixelRatio<RetType> {
fn devicePixelRatio(self , rsthis: & QWindow) -> RetType;
}
// proto: qreal QWindow::devicePixelRatio();
impl<'a> /*trait*/ QWindow_devicePixelRatio<f64> for () {
fn devicePixelRatio(self , rsthis: & QWindow) -> f64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow16devicePixelRatioEv()};
let mut ret = unsafe {C_ZNK7QWindow16devicePixelRatioEv(rsthis.qclsinst)};
return ret as f64; // 1
// return 1;
}
}
// proto: void QWindow::setBaseSize(const QSize & size);
impl /*struct*/ QWindow {
pub fn setBaseSize<RetType, T: QWindow_setBaseSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setBaseSize(self);
// return 1;
}
}
pub trait QWindow_setBaseSize<RetType> {
fn setBaseSize(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setBaseSize(const QSize & size);
impl<'a> /*trait*/ QWindow_setBaseSize<()> for (&'a QSize) {
fn setBaseSize(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setBaseSizeERK5QSize()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow11setBaseSizeERK5QSize(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::alert(int msec);
impl /*struct*/ QWindow {
pub fn alert<RetType, T: QWindow_alert<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.alert(self);
// return 1;
}
}
pub trait QWindow_alert<RetType> {
fn alert(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::alert(int msec);
impl<'a> /*trait*/ QWindow_alert<()> for (i32) {
fn alert(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow5alertEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow5alertEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QPlatformWindow * QWindow::handle();
impl /*struct*/ QWindow {
pub fn handle<RetType, T: QWindow_handle<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.handle(self);
// return 1;
}
}
pub trait QWindow_handle<RetType> {
fn handle(self , rsthis: & QWindow) -> RetType;
}
// proto: QPlatformWindow * QWindow::handle();
impl<'a> /*trait*/ QWindow_handle<u64> for () {
fn handle(self , rsthis: & QWindow) -> u64 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6handleEv()};
let mut ret = unsafe {C_ZNK7QWindow6handleEv(rsthis.qclsinst)};
return ret as u64; // 4
// return 1;
}
}
// proto: void QWindow::destroy();
impl /*struct*/ QWindow {
pub fn destroy<RetType, T: QWindow_destroy<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.destroy(self);
// return 1;
}
}
pub trait QWindow_destroy<RetType> {
fn destroy(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::destroy();
impl<'a> /*trait*/ QWindow_destroy<()> for () {
fn destroy(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow7destroyEv()};
unsafe {C_ZN7QWindow7destroyEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QWindow * QWindow::transientParent();
impl /*struct*/ QWindow {
pub fn transientParent<RetType, T: QWindow_transientParent<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.transientParent(self);
// return 1;
}
}
pub trait QWindow_transientParent<RetType> {
fn transientParent(self , rsthis: & QWindow) -> RetType;
}
// proto: QWindow * QWindow::transientParent();
impl<'a> /*trait*/ QWindow_transientParent<QWindow> for () {
fn transientParent(self , rsthis: & QWindow) -> QWindow {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow15transientParentEv()};
let mut ret = unsafe {C_ZNK7QWindow15transientParentEv(rsthis.qclsinst)};
let mut ret1 = QWindow::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setMinimumHeight(int h);
impl /*struct*/ QWindow {
pub fn setMinimumHeight<RetType, T: QWindow_setMinimumHeight<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMinimumHeight(self);
// return 1;
}
}
pub trait QWindow_setMinimumHeight<RetType> {
fn setMinimumHeight(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMinimumHeight(int h);
impl<'a> /*trait*/ QWindow_setMinimumHeight<()> for (i32) {
fn setMinimumHeight(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow16setMinimumHeightEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow16setMinimumHeightEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::show();
impl /*struct*/ QWindow {
pub fn show<RetType, T: QWindow_show<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.show(self);
// return 1;
}
}
pub trait QWindow_show<RetType> {
fn show(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::show();
impl<'a> /*trait*/ QWindow_show<()> for () {
fn show(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow4showEv()};
unsafe {C_ZN7QWindow4showEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QSize QWindow::baseSize();
impl /*struct*/ QWindow {
pub fn baseSize<RetType, T: QWindow_baseSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.baseSize(self);
// return 1;
}
}
pub trait QWindow_baseSize<RetType> {
fn baseSize(self , rsthis: & QWindow) -> RetType;
}
// proto: QSize QWindow::baseSize();
impl<'a> /*trait*/ QWindow_baseSize<QSize> for () {
fn baseSize(self , rsthis: & QWindow) -> QSize {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow8baseSizeEv()};
let mut ret = unsafe {C_ZNK7QWindow8baseSizeEv(rsthis.qclsinst)};
let mut ret1 = QSize::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QString QWindow::title();
impl /*struct*/ QWindow {
pub fn title<RetType, T: QWindow_title<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.title(self);
// return 1;
}
}
pub trait QWindow_title<RetType> {
fn title(self , rsthis: & QWindow) -> RetType;
}
// proto: QString QWindow::title();
impl<'a> /*trait*/ QWindow_title<QString> for () {
fn title(self , rsthis: & QWindow) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow5titleEv()};
let mut ret = unsafe {C_ZNK7QWindow5titleEv(rsthis.qclsinst)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::showMaximized();
impl /*struct*/ QWindow {
pub fn showMaximized<RetType, T: QWindow_showMaximized<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.showMaximized(self);
// return 1;
}
}
pub trait QWindow_showMaximized<RetType> {
fn showMaximized(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::showMaximized();
impl<'a> /*trait*/ QWindow_showMaximized<()> for () {
fn showMaximized(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow13showMaximizedEv()};
unsafe {C_ZN7QWindow13showMaximizedEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::create();
impl /*struct*/ QWindow {
pub fn create<RetType, T: QWindow_create<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.create(self);
// return 1;
}
}
pub trait QWindow_create<RetType> {
fn create(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::create();
impl<'a> /*trait*/ QWindow_create<()> for () {
fn create(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow6createEv()};
unsafe {C_ZN7QWindow6createEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::resize(int w, int h);
impl<'a> /*trait*/ QWindow_resize<()> for (i32, i32) {
fn resize(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow6resizeEii()};
let arg0 = self.0 as c_int;
let arg1 = self.1 as c_int;
unsafe {C_ZN7QWindow6resizeEii(rsthis.qclsinst, arg0, arg1)};
// return 1;
}
}
// proto: QScreen * QWindow::screen();
impl /*struct*/ QWindow {
pub fn screen<RetType, T: QWindow_screen<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.screen(self);
// return 1;
}
}
pub trait QWindow_screen<RetType> {
fn screen(self , rsthis: & QWindow) -> RetType;
}
// proto: QScreen * QWindow::screen();
impl<'a> /*trait*/ QWindow_screen<QScreen> for () {
fn screen(self , rsthis: & QWindow) -> QScreen {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6screenEv()};
let mut ret = unsafe {C_ZNK7QWindow6screenEv(rsthis.qclsinst)};
let mut ret1 = QScreen::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setPosition(int posx, int posy);
impl<'a> /*trait*/ QWindow_setPosition<()> for (i32, i32) {
fn setPosition(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setPositionEii()};
let arg0 = self.0 as c_int;
let arg1 = self.1 as c_int;
unsafe {C_ZN7QWindow11setPositionEii(rsthis.qclsinst, arg0, arg1)};
// return 1;
}
}
// proto: void QWindow::setOpacity(qreal level);
impl /*struct*/ QWindow {
pub fn setOpacity<RetType, T: QWindow_setOpacity<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setOpacity(self);
// return 1;
}
}
pub trait QWindow_setOpacity<RetType> {
fn setOpacity(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setOpacity(qreal level);
impl<'a> /*trait*/ QWindow_setOpacity<()> for (f64) {
fn setOpacity(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow10setOpacityEd()};
let arg0 = self as c_double;
unsafe {C_ZN7QWindow10setOpacityEd(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setGeometry(const QRect & rect);
impl<'a> /*trait*/ QWindow_setGeometry<()> for (&'a QRect) {
fn setGeometry(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow11setGeometryERK5QRect()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow11setGeometryERK5QRect(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setSizeIncrement(const QSize & size);
impl /*struct*/ QWindow {
pub fn setSizeIncrement<RetType, T: QWindow_setSizeIncrement<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setSizeIncrement(self);
// return 1;
}
}
pub trait QWindow_setSizeIncrement<RetType> {
fn setSizeIncrement(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setSizeIncrement(const QSize & size);
impl<'a> /*trait*/ QWindow_setSizeIncrement<()> for (&'a QSize) {
fn setSizeIncrement(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow16setSizeIncrementERK5QSize()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow16setSizeIncrementERK5QSize(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::showMinimized();
impl /*struct*/ QWindow {
pub fn showMinimized<RetType, T: QWindow_showMinimized<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.showMinimized(self);
// return 1;
}
}
pub trait QWindow_showMinimized<RetType> {
fn showMinimized(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::showMinimized();
impl<'a> /*trait*/ QWindow_showMinimized<()> for () {
fn showMinimized(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow13showMinimizedEv()};
unsafe {C_ZN7QWindow13showMinimizedEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QObject * QWindow::focusObject();
impl /*struct*/ QWindow {
pub fn focusObject<RetType, T: QWindow_focusObject<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.focusObject(self);
// return 1;
}
}
pub trait QWindow_focusObject<RetType> {
fn focusObject(self , rsthis: & QWindow) -> RetType;
}
// proto: QObject * QWindow::focusObject();
impl<'a> /*trait*/ QWindow_focusObject<QObject> for () {
fn focusObject(self , rsthis: & QWindow) -> QObject {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow11focusObjectEv()};
let mut ret = unsafe {C_ZNK7QWindow11focusObjectEv(rsthis.qclsinst)};
let mut ret1 = QObject::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QWindow::isActive();
impl /*struct*/ QWindow {
pub fn isActive<RetType, T: QWindow_isActive<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isActive(self);
// return 1;
}
}
pub trait QWindow_isActive<RetType> {
fn isActive(self , rsthis: & QWindow) -> RetType;
}
// proto: bool QWindow::isActive();
impl<'a> /*trait*/ QWindow_isActive<i8> for () {
fn isActive(self , rsthis: & QWindow) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow8isActiveEv()};
let mut ret = unsafe {C_ZNK7QWindow8isActiveEv(rsthis.qclsinst)};
return ret as i8; // 1
// return 1;
}
}
// proto: QAccessibleInterface * QWindow::accessibleRoot();
impl /*struct*/ QWindow {
pub fn accessibleRoot<RetType, T: QWindow_accessibleRoot<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.accessibleRoot(self);
// return 1;
}
}
pub trait QWindow_accessibleRoot<RetType> {
fn accessibleRoot(self , rsthis: & QWindow) -> RetType;
}
// proto: QAccessibleInterface * QWindow::accessibleRoot();
impl<'a> /*trait*/ QWindow_accessibleRoot<QAccessibleInterface> for () {
fn accessibleRoot(self , rsthis: & QWindow) -> QAccessibleInterface {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow14accessibleRootEv()};
let mut ret = unsafe {C_ZNK7QWindow14accessibleRootEv(rsthis.qclsinst)};
let mut ret1 = QAccessibleInterface::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QCursor QWindow::cursor();
impl /*struct*/ QWindow {
pub fn cursor<RetType, T: QWindow_cursor<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.cursor(self);
// return 1;
}
}
pub trait QWindow_cursor<RetType> {
fn cursor(self , rsthis: & QWindow) -> RetType;
}
// proto: QCursor QWindow::cursor();
impl<'a> /*trait*/ QWindow_cursor<QCursor> for () {
fn cursor(self , rsthis: & QWindow) -> QCursor {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6cursorEv()};
let mut ret = unsafe {C_ZNK7QWindow6cursorEv(rsthis.qclsinst)};
let mut ret1 = QCursor::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setFormat(const QSurfaceFormat & format);
impl /*struct*/ QWindow {
pub fn setFormat<RetType, T: QWindow_setFormat<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setFormat(self);
// return 1;
}
}
pub trait QWindow_setFormat<RetType> {
fn setFormat(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setFormat(const QSurfaceFormat & format);
impl<'a> /*trait*/ QWindow_setFormat<()> for (&'a QSurfaceFormat) {
fn setFormat(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow9setFormatERK14QSurfaceFormat()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow9setFormatERK14QSurfaceFormat(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::showFullScreen();
impl /*struct*/ QWindow {
pub fn showFullScreen<RetType, T: QWindow_showFullScreen<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.showFullScreen(self);
// return 1;
}
}
pub trait QWindow_showFullScreen<RetType> {
fn showFullScreen(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::showFullScreen();
impl<'a> /*trait*/ QWindow_showFullScreen<()> for () {
fn showFullScreen(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow14showFullScreenEv()};
unsafe {C_ZN7QWindow14showFullScreenEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::setX(int arg);
impl /*struct*/ QWindow {
pub fn setX<RetType, T: QWindow_setX<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setX(self);
// return 1;
}
}
pub trait QWindow_setX<RetType> {
fn setX(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setX(int arg);
impl<'a> /*trait*/ QWindow_setX<()> for (i32) {
fn setX(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow4setXEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow4setXEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::lower();
impl /*struct*/ QWindow {
pub fn lower<RetType, T: QWindow_lower<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.lower(self);
// return 1;
}
}
pub trait QWindow_lower<RetType> {
fn lower(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::lower();
impl<'a> /*trait*/ QWindow_lower<()> for () {
fn lower(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow5lowerEv()};
unsafe {C_ZN7QWindow5lowerEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::requestUpdate();
impl /*struct*/ QWindow {
pub fn requestUpdate<RetType, T: QWindow_requestUpdate<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.requestUpdate(self);
// return 1;
}
}
pub trait QWindow_requestUpdate<RetType> {
fn requestUpdate(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::requestUpdate();
impl<'a> /*trait*/ QWindow_requestUpdate<()> for () {
fn requestUpdate(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow13requestUpdateEv()};
unsafe {C_ZN7QWindow13requestUpdateEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::hide();
impl /*struct*/ QWindow {
pub fn hide<RetType, T: QWindow_hide<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.hide(self);
// return 1;
}
}
pub trait QWindow_hide<RetType> {
fn hide(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::hide();
impl<'a> /*trait*/ QWindow_hide<()> for () {
fn hide(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow4hideEv()};
unsafe {C_ZN7QWindow4hideEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: void QWindow::setMask(const QRegion & region);
impl /*struct*/ QWindow {
pub fn setMask<RetType, T: QWindow_setMask<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMask(self);
// return 1;
}
}
pub trait QWindow_setMask<RetType> {
fn setMask(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMask(const QRegion & region);
impl<'a> /*trait*/ QWindow_setMask<()> for (&'a QRegion) {
fn setMask(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow7setMaskERK7QRegion()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow7setMaskERK7QRegion(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QWindow::setMaximumSize(const QSize & size);
impl /*struct*/ QWindow {
pub fn setMaximumSize<RetType, T: QWindow_setMaximumSize<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMaximumSize(self);
// return 1;
}
}
pub trait QWindow_setMaximumSize<RetType> {
fn setMaximumSize(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMaximumSize(const QSize & size);
impl<'a> /*trait*/ QWindow_setMaximumSize<()> for (&'a QSize) {
fn setMaximumSize(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow14setMaximumSizeERK5QSize()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {C_ZN7QWindow14setMaximumSizeERK5QSize(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: int QWindow::height();
impl /*struct*/ QWindow {
pub fn height<RetType, T: QWindow_height<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.height(self);
// return 1;
}
}
pub trait QWindow_height<RetType> {
fn height(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::height();
impl<'a> /*trait*/ QWindow_height<i32> for () {
fn height(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow6heightEv()};
let mut ret = unsafe {C_ZNK7QWindow6heightEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: QSize QWindow::size();
impl /*struct*/ QWindow {
pub fn size<RetType, T: QWindow_size<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.size(self);
// return 1;
}
}
pub trait QWindow_size<RetType> {
fn size(self , rsthis: & QWindow) -> RetType;
}
// proto: QSize QWindow::size();
impl<'a> /*trait*/ QWindow_size<QSize> for () {
fn size(self , rsthis: & QWindow) -> QSize {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow4sizeEv()};
let mut ret = unsafe {C_ZNK7QWindow4sizeEv(rsthis.qclsinst)};
let mut ret1 = QSize::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: int QWindow::maximumWidth();
impl /*struct*/ QWindow {
pub fn maximumWidth<RetType, T: QWindow_maximumWidth<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.maximumWidth(self);
// return 1;
}
}
pub trait QWindow_maximumWidth<RetType> {
fn maximumWidth(self , rsthis: & QWindow) -> RetType;
}
// proto: int QWindow::maximumWidth();
impl<'a> /*trait*/ QWindow_maximumWidth<i32> for () {
fn maximumWidth(self , rsthis: & QWindow) -> i32 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow12maximumWidthEv()};
let mut ret = unsafe {C_ZNK7QWindow12maximumWidthEv(rsthis.qclsinst)};
return ret as i32; // 1
// return 1;
}
}
// proto: QPoint QWindow::position();
impl /*struct*/ QWindow {
pub fn position<RetType, T: QWindow_position<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.position(self);
// return 1;
}
}
pub trait QWindow_position<RetType> {
fn position(self , rsthis: & QWindow) -> RetType;
}
// proto: QPoint QWindow::position();
impl<'a> /*trait*/ QWindow_position<QPoint> for () {
fn position(self , rsthis: & QWindow) -> QPoint {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow8positionEv()};
let mut ret = unsafe {C_ZNK7QWindow8positionEv(rsthis.qclsinst)};
let mut ret1 = QPoint::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::setMaximumHeight(int h);
impl /*struct*/ QWindow {
pub fn setMaximumHeight<RetType, T: QWindow_setMaximumHeight<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.setMaximumHeight(self);
// return 1;
}
}
pub trait QWindow_setMaximumHeight<RetType> {
fn setMaximumHeight(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::setMaximumHeight(int h);
impl<'a> /*trait*/ QWindow_setMaximumHeight<()> for (i32) {
fn setMaximumHeight(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow16setMaximumHeightEi()};
let arg0 = self as c_int;
unsafe {C_ZN7QWindow16setMaximumHeightEi(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QString QWindow::filePath();
impl /*struct*/ QWindow {
pub fn filePath<RetType, T: QWindow_filePath<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.filePath(self);
// return 1;
}
}
pub trait QWindow_filePath<RetType> {
fn filePath(self , rsthis: & QWindow) -> RetType;
}
// proto: QString QWindow::filePath();
impl<'a> /*trait*/ QWindow_filePath<QString> for () {
fn filePath(self , rsthis: & QWindow) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow8filePathEv()};
let mut ret = unsafe {C_ZNK7QWindow8filePathEv(rsthis.qclsinst)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QWindow::showNormal();
impl /*struct*/ QWindow {
pub fn showNormal<RetType, T: QWindow_showNormal<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.showNormal(self);
// return 1;
}
}
pub trait QWindow_showNormal<RetType> {
fn showNormal(self , rsthis: & QWindow) -> RetType;
}
// proto: void QWindow::showNormal();
impl<'a> /*trait*/ QWindow_showNormal<()> for () {
fn showNormal(self , rsthis: & QWindow) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN7QWindow10showNormalEv()};
unsafe {C_ZN7QWindow10showNormalEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QPoint QWindow::framePosition();
impl /*struct*/ QWindow {
pub fn framePosition<RetType, T: QWindow_framePosition<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.framePosition(self);
// return 1;
}
}
pub trait QWindow_framePosition<RetType> {
fn framePosition(self , rsthis: & QWindow) -> RetType;
}
// proto: QPoint QWindow::framePosition();
impl<'a> /*trait*/ QWindow_framePosition<QPoint> for () {
fn framePosition(self , rsthis: & QWindow) -> QPoint {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow13framePositionEv()};
let mut ret = unsafe {C_ZNK7QWindow13framePositionEv(rsthis.qclsinst)};
let mut ret1 = QPoint::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QIcon QWindow::icon();
impl /*struct*/ QWindow {
pub fn icon<RetType, T: QWindow_icon<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.icon(self);
// return 1;
}
}
pub trait QWindow_icon<RetType> {
fn icon(self , rsthis: & QWindow) -> RetType;
}
// proto: QIcon QWindow::icon();
impl<'a> /*trait*/ QWindow_icon<QIcon> for () {
fn icon(self , rsthis: & QWindow) -> QIcon {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK7QWindow4iconEv()};
let mut ret = unsafe {C_ZNK7QWindow4iconEv(rsthis.qclsinst)};
let mut ret1 = QIcon::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
#[derive(Default)] // for QWindow_modalityChanged
pub struct QWindow_modalityChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn modalityChanged(&self) -> QWindow_modalityChanged_signal {
return QWindow_modalityChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_modalityChanged_signal {
pub fn connect<T: QWindow_modalityChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_modalityChanged_signal_connect {
fn connect(self, sigthis: QWindow_modalityChanged_signal);
}
#[derive(Default)] // for QWindow_activeChanged
pub struct QWindow_activeChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn activeChanged(&self) -> QWindow_activeChanged_signal {
return QWindow_activeChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_activeChanged_signal {
pub fn connect<T: QWindow_activeChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_activeChanged_signal_connect {
fn connect(self, sigthis: QWindow_activeChanged_signal);
}
#[derive(Default)] // for QWindow_heightChanged
pub struct QWindow_heightChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn heightChanged(&self) -> QWindow_heightChanged_signal {
return QWindow_heightChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_heightChanged_signal {
pub fn connect<T: QWindow_heightChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_heightChanged_signal_connect {
fn connect(self, sigthis: QWindow_heightChanged_signal);
}
#[derive(Default)] // for QWindow_contentOrientationChanged
pub struct QWindow_contentOrientationChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn contentOrientationChanged(&self) -> QWindow_contentOrientationChanged_signal {
return QWindow_contentOrientationChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_contentOrientationChanged_signal {
pub fn connect<T: QWindow_contentOrientationChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_contentOrientationChanged_signal_connect {
fn connect(self, sigthis: QWindow_contentOrientationChanged_signal);
}
#[derive(Default)] // for QWindow_minimumWidthChanged
pub struct QWindow_minimumWidthChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn minimumWidthChanged(&self) -> QWindow_minimumWidthChanged_signal {
return QWindow_minimumWidthChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_minimumWidthChanged_signal {
pub fn connect<T: QWindow_minimumWidthChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_minimumWidthChanged_signal_connect {
fn connect(self, sigthis: QWindow_minimumWidthChanged_signal);
}
#[derive(Default)] // for QWindow_opacityChanged
pub struct QWindow_opacityChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn opacityChanged(&self) -> QWindow_opacityChanged_signal {
return QWindow_opacityChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_opacityChanged_signal {
pub fn connect<T: QWindow_opacityChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_opacityChanged_signal_connect {
fn connect(self, sigthis: QWindow_opacityChanged_signal);
}
#[derive(Default)] // for QWindow_visibleChanged
pub struct QWindow_visibleChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn visibleChanged(&self) -> QWindow_visibleChanged_signal {
return QWindow_visibleChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_visibleChanged_signal {
pub fn connect<T: QWindow_visibleChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_visibleChanged_signal_connect {
fn connect(self, sigthis: QWindow_visibleChanged_signal);
}
#[derive(Default)] // for QWindow_screenChanged
pub struct QWindow_screenChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn screenChanged(&self) -> QWindow_screenChanged_signal {
return QWindow_screenChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_screenChanged_signal {
pub fn connect<T: QWindow_screenChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_screenChanged_signal_connect {
fn connect(self, sigthis: QWindow_screenChanged_signal);
}
#[derive(Default)] // for QWindow_maximumHeightChanged
pub struct QWindow_maximumHeightChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn maximumHeightChanged(&self) -> QWindow_maximumHeightChanged_signal {
return QWindow_maximumHeightChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_maximumHeightChanged_signal {
pub fn connect<T: QWindow_maximumHeightChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_maximumHeightChanged_signal_connect {
fn connect(self, sigthis: QWindow_maximumHeightChanged_signal);
}
#[derive(Default)] // for QWindow_yChanged
pub struct QWindow_yChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn yChanged(&self) -> QWindow_yChanged_signal {
return QWindow_yChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_yChanged_signal {
pub fn connect<T: QWindow_yChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_yChanged_signal_connect {
fn connect(self, sigthis: QWindow_yChanged_signal);
}
#[derive(Default)] // for QWindow_widthChanged
pub struct QWindow_widthChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn widthChanged(&self) -> QWindow_widthChanged_signal {
return QWindow_widthChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_widthChanged_signal {
pub fn connect<T: QWindow_widthChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_widthChanged_signal_connect {
fn connect(self, sigthis: QWindow_widthChanged_signal);
}
#[derive(Default)] // for QWindow_windowStateChanged
pub struct QWindow_windowStateChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn windowStateChanged(&self) -> QWindow_windowStateChanged_signal {
return QWindow_windowStateChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_windowStateChanged_signal {
pub fn connect<T: QWindow_windowStateChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_windowStateChanged_signal_connect {
fn connect(self, sigthis: QWindow_windowStateChanged_signal);
}
#[derive(Default)] // for QWindow_windowTitleChanged
pub struct QWindow_windowTitleChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn windowTitleChanged(&self) -> QWindow_windowTitleChanged_signal {
return QWindow_windowTitleChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_windowTitleChanged_signal {
pub fn connect<T: QWindow_windowTitleChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_windowTitleChanged_signal_connect {
fn connect(self, sigthis: QWindow_windowTitleChanged_signal);
}
#[derive(Default)] // for QWindow_visibilityChanged
pub struct QWindow_visibilityChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn visibilityChanged(&self) -> QWindow_visibilityChanged_signal {
return QWindow_visibilityChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_visibilityChanged_signal {
pub fn connect<T: QWindow_visibilityChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_visibilityChanged_signal_connect {
fn connect(self, sigthis: QWindow_visibilityChanged_signal);
}
#[derive(Default)] // for QWindow_minimumHeightChanged
pub struct QWindow_minimumHeightChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn minimumHeightChanged(&self) -> QWindow_minimumHeightChanged_signal {
return QWindow_minimumHeightChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_minimumHeightChanged_signal {
pub fn connect<T: QWindow_minimumHeightChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_minimumHeightChanged_signal_connect {
fn connect(self, sigthis: QWindow_minimumHeightChanged_signal);
}
#[derive(Default)] // for QWindow_xChanged
pub struct QWindow_xChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn xChanged(&self) -> QWindow_xChanged_signal {
return QWindow_xChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_xChanged_signal {
pub fn connect<T: QWindow_xChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_xChanged_signal_connect {
fn connect(self, sigthis: QWindow_xChanged_signal);
}
#[derive(Default)] // for QWindow_focusObjectChanged
pub struct QWindow_focusObjectChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn focusObjectChanged(&self) -> QWindow_focusObjectChanged_signal {
return QWindow_focusObjectChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_focusObjectChanged_signal {
pub fn connect<T: QWindow_focusObjectChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_focusObjectChanged_signal_connect {
fn connect(self, sigthis: QWindow_focusObjectChanged_signal);
}
#[derive(Default)] // for QWindow_maximumWidthChanged
pub struct QWindow_maximumWidthChanged_signal{poi:u64}
impl /* struct */ QWindow {
pub fn maximumWidthChanged(&self) -> QWindow_maximumWidthChanged_signal {
return QWindow_maximumWidthChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QWindow_maximumWidthChanged_signal {
pub fn connect<T: QWindow_maximumWidthChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QWindow_maximumWidthChanged_signal_connect {
fn connect(self, sigthis: QWindow_maximumWidthChanged_signal);
}
// xChanged(int)
extern fn QWindow_xChanged_signal_connect_cb_0(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_xChanged_signal_connect_cb_box_0(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_xChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_xChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_xChanged_signal_connect_cb_0 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow8xChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_xChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_xChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_xChanged_signal_connect_cb_box_0 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow8xChangedEi(arg0, arg1, arg2)};
}
}
// widthChanged(int)
extern fn QWindow_widthChanged_signal_connect_cb_1(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_widthChanged_signal_connect_cb_box_1(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_widthChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_widthChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_widthChanged_signal_connect_cb_1 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow12widthChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_widthChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_widthChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_widthChanged_signal_connect_cb_box_1 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow12widthChangedEi(arg0, arg1, arg2)};
}
}
// opacityChanged(qreal)
extern fn QWindow_opacityChanged_signal_connect_cb_2(rsfptr:fn(f64), arg0: c_double) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as f64;
rsfptr(rsarg0);
}
extern fn QWindow_opacityChanged_signal_connect_cb_box_2(rsfptr_raw:*mut Box<Fn(f64)>, arg0: c_double) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as f64;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_opacityChanged_signal_connect for fn(f64) {
fn connect(self, sigthis: QWindow_opacityChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_opacityChanged_signal_connect_cb_2 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow14opacityChangedEd(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_opacityChanged_signal_connect for Box<Fn(f64)> {
fn connect(self, sigthis: QWindow_opacityChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_opacityChanged_signal_connect_cb_box_2 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow14opacityChangedEd(arg0, arg1, arg2)};
}
}
// yChanged(int)
extern fn QWindow_yChanged_signal_connect_cb_3(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_yChanged_signal_connect_cb_box_3(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_yChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_yChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_yChanged_signal_connect_cb_3 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow8yChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_yChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_yChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_yChanged_signal_connect_cb_box_3 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow8yChangedEi(arg0, arg1, arg2)};
}
}
// minimumHeightChanged(int)
extern fn QWindow_minimumHeightChanged_signal_connect_cb_4(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_minimumHeightChanged_signal_connect_cb_box_4(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_minimumHeightChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_minimumHeightChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_minimumHeightChanged_signal_connect_cb_4 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow20minimumHeightChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_minimumHeightChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_minimumHeightChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_minimumHeightChanged_signal_connect_cb_box_4 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow20minimumHeightChangedEi(arg0, arg1, arg2)};
}
}
// heightChanged(int)
extern fn QWindow_heightChanged_signal_connect_cb_5(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_heightChanged_signal_connect_cb_box_5(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_heightChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_heightChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_heightChanged_signal_connect_cb_5 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13heightChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_heightChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_heightChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_heightChanged_signal_connect_cb_box_5 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13heightChangedEi(arg0, arg1, arg2)};
}
}
// maximumWidthChanged(int)
extern fn QWindow_maximumWidthChanged_signal_connect_cb_6(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_maximumWidthChanged_signal_connect_cb_box_6(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_maximumWidthChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_maximumWidthChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_maximumWidthChanged_signal_connect_cb_6 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow19maximumWidthChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_maximumWidthChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_maximumWidthChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_maximumWidthChanged_signal_connect_cb_box_6 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow19maximumWidthChangedEi(arg0, arg1, arg2)};
}
}
// screenChanged(class QScreen *)
extern fn QWindow_screenChanged_signal_connect_cb_7(rsfptr:fn(QScreen), arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsarg0 = QScreen::inheritFrom(arg0 as u64);
rsfptr(rsarg0);
}
extern fn QWindow_screenChanged_signal_connect_cb_box_7(rsfptr_raw:*mut Box<Fn(QScreen)>, arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = QScreen::inheritFrom(arg0 as u64);
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_screenChanged_signal_connect for fn(QScreen) {
fn connect(self, sigthis: QWindow_screenChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_screenChanged_signal_connect_cb_7 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13screenChangedEP7QScreen(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_screenChanged_signal_connect for Box<Fn(QScreen)> {
fn connect(self, sigthis: QWindow_screenChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_screenChanged_signal_connect_cb_box_7 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13screenChangedEP7QScreen(arg0, arg1, arg2)};
}
}
// minimumWidthChanged(int)
extern fn QWindow_minimumWidthChanged_signal_connect_cb_8(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_minimumWidthChanged_signal_connect_cb_box_8(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_minimumWidthChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_minimumWidthChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_minimumWidthChanged_signal_connect_cb_8 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow19minimumWidthChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_minimumWidthChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_minimumWidthChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_minimumWidthChanged_signal_connect_cb_box_8 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow19minimumWidthChangedEi(arg0, arg1, arg2)};
}
}
// windowTitleChanged(const class QString &)
extern fn QWindow_windowTitleChanged_signal_connect_cb_9(rsfptr:fn(QString), arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsarg0 = QString::inheritFrom(arg0 as u64);
rsfptr(rsarg0);
}
extern fn QWindow_windowTitleChanged_signal_connect_cb_box_9(rsfptr_raw:*mut Box<Fn(QString)>, arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = QString::inheritFrom(arg0 as u64);
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_windowTitleChanged_signal_connect for fn(QString) {
fn connect(self, sigthis: QWindow_windowTitleChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_windowTitleChanged_signal_connect_cb_9 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow18windowTitleChangedERK7QString(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_windowTitleChanged_signal_connect for Box<Fn(QString)> {
fn connect(self, sigthis: QWindow_windowTitleChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_windowTitleChanged_signal_connect_cb_box_9 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow18windowTitleChangedERK7QString(arg0, arg1, arg2)};
}
}
// focusObjectChanged(class QObject *)
extern fn QWindow_focusObjectChanged_signal_connect_cb_10(rsfptr:fn(QObject), arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsarg0 = QObject::inheritFrom(arg0 as u64);
rsfptr(rsarg0);
}
extern fn QWindow_focusObjectChanged_signal_connect_cb_box_10(rsfptr_raw:*mut Box<Fn(QObject)>, arg0: *mut c_void) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = QObject::inheritFrom(arg0 as u64);
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_focusObjectChanged_signal_connect for fn(QObject) {
fn connect(self, sigthis: QWindow_focusObjectChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_focusObjectChanged_signal_connect_cb_10 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow18focusObjectChangedEP7QObject(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_focusObjectChanged_signal_connect for Box<Fn(QObject)> {
fn connect(self, sigthis: QWindow_focusObjectChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_focusObjectChanged_signal_connect_cb_box_10 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow18focusObjectChangedEP7QObject(arg0, arg1, arg2)};
}
}
// visibleChanged(_Bool)
extern fn QWindow_visibleChanged_signal_connect_cb_11(rsfptr:fn(i8), arg0: c_char) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i8;
rsfptr(rsarg0);
}
extern fn QWindow_visibleChanged_signal_connect_cb_box_11(rsfptr_raw:*mut Box<Fn(i8)>, arg0: c_char) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i8;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_visibleChanged_signal_connect for fn(i8) {
fn connect(self, sigthis: QWindow_visibleChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_visibleChanged_signal_connect_cb_11 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow14visibleChangedEb(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_visibleChanged_signal_connect for Box<Fn(i8)> {
fn connect(self, sigthis: QWindow_visibleChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_visibleChanged_signal_connect_cb_box_11 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow14visibleChangedEb(arg0, arg1, arg2)};
}
}
// maximumHeightChanged(int)
extern fn QWindow_maximumHeightChanged_signal_connect_cb_12(rsfptr:fn(i32), arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsarg0 = arg0 as i32;
rsfptr(rsarg0);
}
extern fn QWindow_maximumHeightChanged_signal_connect_cb_box_12(rsfptr_raw:*mut Box<Fn(i32)>, arg0: c_int) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
let rsarg0 = arg0 as i32;
// rsfptr(rsarg0);
unsafe{(*rsfptr_raw)(rsarg0)};
}
impl /* trait */ QWindow_maximumHeightChanged_signal_connect for fn(i32) {
fn connect(self, sigthis: QWindow_maximumHeightChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_maximumHeightChanged_signal_connect_cb_12 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow20maximumHeightChangedEi(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_maximumHeightChanged_signal_connect for Box<Fn(i32)> {
fn connect(self, sigthis: QWindow_maximumHeightChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_maximumHeightChanged_signal_connect_cb_box_12 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow20maximumHeightChangedEi(arg0, arg1, arg2)};
}
}
// activeChanged()
extern fn QWindow_activeChanged_signal_connect_cb_13(rsfptr:fn(), ) {
println!("{}:{}", file!(), line!());
rsfptr();
}
extern fn QWindow_activeChanged_signal_connect_cb_box_13(rsfptr_raw:*mut Box<Fn()>, ) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
// rsfptr();
unsafe{(*rsfptr_raw)()};
}
impl /* trait */ QWindow_activeChanged_signal_connect for fn() {
fn connect(self, sigthis: QWindow_activeChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_activeChanged_signal_connect_cb_13 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13activeChangedEv(arg0, arg1, arg2)};
}
}
impl /* trait */ QWindow_activeChanged_signal_connect for Box<Fn()> {
fn connect(self, sigthis: QWindow_activeChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QWindow_activeChanged_signal_connect_cb_box_13 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QWindow_SlotProxy_connect__ZN7QWindow13activeChangedEv(arg0, arg1, arg2)};
}
}
// <= body block end
|
use challenges::random_bytes;
use cipher::{ctr::AES_128_CTR, Cipher};
fn main() {
println!("🔓 Challenge 26");
let key = Key::new();
bitflipping_attack(&key);
}
fn bitflipping_attack(key: &Key) {
let input = random_bytes(2 + 16);
let mut ct = key.encryption_oracle(&input);
let xor_diff = xor::xor(&input[2..], &b";admin=true;rand"[..]).unwrap();
let third_ct_block = xor::xor(&ct[32..48], &xor_diff).unwrap();
ct.splice(32..48, third_ct_block.iter().cloned());
assert!(key.decryption_oracle(&ct));
println!("😏 Successfully fool the system to be an admin");
}
struct Key(Vec<u8>);
impl Key {
pub fn new() -> Key {
Key(random_bytes(16))
}
pub fn encryption_oracle(&self, input: &[u8]) -> Vec<u8> {
let mut cleaned_input: Vec<u8> = vec![];
for byte in input.iter() {
match byte {
b';' => cleaned_input.extend_from_slice(b"%3b"),
b'=' => cleaned_input.extend_from_slice(b"%3d"),
_ => cleaned_input.push(*byte),
};
}
let mut actual_pt: Vec<u8> = vec![];
actual_pt.extend_from_slice(&b"comment1=cooking\x20MCs;userdata="[..]);
actual_pt.extend_from_slice(&cleaned_input);
actual_pt.extend_from_slice(&b";comment2=\x20like\x20a\x20pound\x20of\x20bacon"[..]);
let ctr_cipher = AES_128_CTR::new_with_nonce(0);
ctr_cipher.encrypt(&self.0, &actual_pt)
}
pub fn decryption_oracle(&self, ct: &[u8]) -> bool {
let ctr_cipher = AES_128_CTR::new_with_nonce(0);
let pt = ctr_cipher.decrypt(&self.0, &ct);
pt.windows(11).any(|x| x == b";admin=true")
}
}
|
use bevy::{prelude::*,};
use game_entities::*;
//not sure the usefulness of a core but will see later. Might come in use when I think of all systems working together.
pub mod stages {
pub const INIT: &'static str = "init";
pub const POST_INIT: &'static str = "post_init";
pub const PRE_UPDATE: &'static str = "pre_update";
pub const UPDATE: &'static str = "update";
pub const POST_UPDATE: &'static str = "post_update";
}
pub struct CorePlugin;
impl Plugin for CorePlugin {
fn build( &self, app: &mut AppBuilder) {
app.add_resource( GameTimer( Timer::from_seconds(0.1, false) ))
.add_startup_system_to_stage(stages::INIT, spawn_player.system());
}
}
fn core_setup(
commands: &mut Commands,
materials: Res<Materials>,
mut color_materials: ResMut<Assets<ColorMaterial>>
) {
commands
.insert_resource(Materials {
player_material: color_materials.add(Color::rgb(0.7, 0.7, 0.7).into()),
});
}
fn spawn_player(commands: &mut Commands, materials: Res<Materials>) {
commands.spawn(SpriteBundle {
material: materials.player_material.clone(),
..Default::default()
}).with(PlayerEntity::default());
}
struct GameTimer(Timer);
//system for change in time every loop
fn timer_ticker_system(
mut timer: ResMut<GameTimer>,
time: Res<Time>,
) {
timer.0.tick(time.delta_seconds());
}
struct Materials {
player_material: Handle<ColorMaterial>,
}
#[cfg(test)]
mod tests {
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
}
|
pub use VkShaderStageFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkShaderStageFlags {
VK_SHADER_STAGE_VERTEX_BIT = 0x0000_0001,
VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT = 0x0000_0002,
VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT = 0x0000_0004,
VK_SHADER_STAGE_GEOMETRY_BIT = 0x0000_0008,
VK_SHADER_STAGE_FRAGMENT_BIT = 0x0000_0010,
VK_SHADER_STAGE_COMPUTE_BIT = 0x0000_0020,
VK_SHADER_STAGE_ALL_GRAPHICS = 0x1F,
VK_SHADER_STAGE_ALL = 0x7FFF_FFFF,
VK_SHADER_STAGE_RAYGEN_BIT_NV = 0x0000_0100,
VK_SHADER_STAGE_ANY_HIT_BIT_NV = 0x0000_0200,
VK_SHADER_STAGE_CLOSEST_HIT_BIT_NV = 0x0000_0400,
VK_SHADER_STAGE_MISS_BIT_NV = 0x0000_0800,
VK_SHADER_STAGE_INTERSECTION_BIT_NV = 0x0000_1000,
VK_SHADER_STAGE_CALLABLE_BIT_NV = 0x0000_2000,
VK_SHADER_STAGE_TASK_BIT_NV = 0x0000_0040,
VK_SHADER_STAGE_MESH_BIT_NV = 0x0000_0080,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash)]
pub struct VkShaderStageFlagBits(u32);
SetupVkFlags!(VkShaderStageFlags, VkShaderStageFlagBits);
|
use hashbrown::HashSet;
fn parse_element(el: &str) -> i32 {
el.parse().unwrap()
}
pub fn part1(input: &[&str]) -> i32 {
input.iter().map(|el| parse_element(el)).sum()
}
pub fn part2_functional(input: &[&str]) -> i32 {
let mut seen = HashSet::new();
seen.insert(0);
let err: Result<_, i32> = input.iter().cycle().try_fold(0, |acc, &x| {
let new = acc + parse_element(x);
if seen.contains(&new) {
return Err(new);
} else {
seen.insert(new);
return Ok(new);
}
});
return err.err().unwrap();
}
pub fn part2_imperative(input: &[&str]) -> i32 {
let mut current = 0;
let mut seen = HashSet::new();
seen.insert(current);
let repeated = input.iter().cycle();
for element in repeated {
current = current + parse_element(element);
if seen.contains(¤t) {
return current;
}
seen.insert(current);
}
unreachable!()
}
#[cfg(test)]
mod tests {
use super::{part1, part2_functional, part2_imperative};
#[test]
fn test_part1() {
assert_eq!(part1(&["+1", "+1", "+1"]), 3);
assert_eq!(part1(&["+1", "+1", "-2"]), 0);
assert_eq!(part1(&["-1", "-2", "-3"]), -6);
}
#[test]
fn test_part2_functional() {
assert_eq!(part2_functional(&["+1", "-1"]), 0);
assert_eq!(part2_functional(&["+3", "+3", "+4", "-2", "-4"]), 10);
assert_eq!(part2_functional(&["-6", "+3", "+8", "+5", "-6"]), 5);
assert_eq!(part2_functional(&["+7", "+7", "-2", "-7", "-4"]), 14);
}
#[test]
fn test_part2_imperative() {
assert_eq!(part2_imperative(&["+1", "-1"]), 0);
assert_eq!(part2_imperative(&["+3", "+3", "+4", "-2", "-4"]), 10);
assert_eq!(part2_imperative(&["-6", "+3", "+8", "+5", "-6"]), 5);
assert_eq!(part2_imperative(&["+7", "+7", "-2", "-7", "-4"]), 14);
}
}
|
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct Image {
pub id: i32,
pub file_name: String
}
|
use pest::error::Error;
use pest::Parser;
use pest::iterators::Pair;
use std::str::FromStr;
#[derive(Debug, Clone)]
/// A representation of a simple mathematical expresion. It is produce by the Expresion grammatical
/// rule witch can be find at the parser documentation [`parser`](fn.parser.html).
pub enum Expresion {
///Semantic: input {} -> Value; Return the value that as been bind to that variable. See [`Statement::Let`](enum.Statement.html#variant.Let)
Variable(VariableID),
///Semantic: input {} -> Value; Return it value.
Integer(u64),
/// Semantic
/// ---
/// - Addition: input {Left, Right} -> Value; perform a wrapping addition.
/// - Subtraction: input {Left, Right} -> Value; perform a wrapping subtraction.
/// - Multiplication: input {Left, Right} -> Value; perform a wrapping multiplication.
/// - Division: input {Left, Right} -> Value; perform a unsigned integer division. divide Left by Right. Trap if Right = 0.
Operation(OperationType, Box<(Expresion, Expresion)>),
}
#[derive(Debug, Clone)]
pub enum Statement {
/// Semantic: Input {Expr}; Bind the value of Expr to the variable.
/// If more than one variable is declare with the same identifier (see grammar rule
/// [Statement](fn.parser.html)), the variable witch is declare latter foreshadow the former.
/// Any expresion witch use reference.
LetStatement(VariableID, Expresion),
}
#[derive(Debug, Copy, Clone)]
pub enum OperationType {
Addition,
Subtraction,
Multiplication,
Division,
}
#[derive(Parser)]
#[grammar = "grammar.pest"]
struct LangParser {}
#[derive(Debug, Clone)]
pub struct Ast {
variable_list: VariableStore,
statement_list: Vec<Statement>,
expresion: Expresion,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq, Hash)]
/// A opaque reference to a variable.
pub struct VariableID(usize);
#[derive(Debug, Clone)]
pub struct VariableStore(Vec<String>);
impl VariableStore {
fn new() -> Self {
VariableStore(Vec::new())
}
fn declare_variable(&mut self, identifier: String) -> VariableID {
self.0.push(identifier);
VariableID(self.0.len() - 1)
}
fn get_variable_id(&mut self, identifier: &str) -> VariableID {
match self
.0
.iter()
.enumerate()
.find(|(_, ident)| identifier == ident.as_str())
{
Some((id, _)) => VariableID(id),
None => {
self.0.push(identifier.to_string());
VariableID(self.0.len() - 1)
}
}
}
pub fn get_variable_identifier(&self, variable_id: VariableID) -> String {
self.0[variable_id.0].clone()
}
}
impl Ast {
fn new(
expresion: Expresion,
statement_list: Vec<Statement>,
variable_list: VariableStore,
) -> Self {
Self {
expresion,
statement_list,
variable_list,
}
}
pub fn get_statement_list(self) -> Vec<Statement> {
self.statement_list
}
pub fn get_expresion(self) -> Expresion {
self.expresion
}
}
/// Parse the given string slice with the following grammar producing a [`Ast`](struct.Ast.html).
/// This function utilize the grammar define in `grammar.pest`
pub fn parser(input: &str) -> Result<Ast, Error<Rule>> {
try {
let pair = LangParser::parse(Rule::Ast, input)?.next().unwrap();
parse_ast(pair)
}
}
fn parse_ast(input: Pair<Rule>) -> Ast {
assert_eq!(input.as_rule(), Rule::Ast);
let mut iter = input.into_inner();
let mut variable_list = VariableStore::new();
let statement_list: Vec<Statement> = iter
.clone()
.take_while(|pair| pair.as_rule() == Rule::Statement)
.map(|pair| parse_statement(pair, &mut variable_list))
.collect();
let expression: Pair<Rule> = iter.find(|pair| pair.as_rule() == Rule::Expresion).expect("Internal parser error");
assert_eq!(iter.next().unwrap().as_rule(), Rule::EOI);
let expresion = parse_expresion(expression, &mut variable_list);
Ast::new(expresion, statement_list, variable_list)
}
fn parse_statement(input: Pair<Rule>, variable_list: &mut VariableStore) -> Statement {
assert_eq!(input.as_rule(), Rule::Statement);
let mut pairs = input.into_inner();
let identifier = pairs.next().unwrap().as_str().to_string();
let expresion = parse_expresion(pairs.next().unwrap(), variable_list);
pairs.next().unwrap_none();
let id = variable_list.declare_variable(identifier);
Statement::LetStatement(id, expresion)
}
fn parse_expresion(input: Pair<Rule>, variable_list: &mut VariableStore) -> Expresion {
assert_eq!(input.as_rule(), Rule::Expresion);
let pair = input.into_inner().next().unwrap();
match pair.as_rule() {
Rule::Operation => parse_operation(pair, variable_list),
Rule::Term => parse_term(pair, variable_list),
_ => unreachable!(),
}
}
fn parse_operation(input: Pair<Rule>, variable_list: &mut VariableStore) -> Expresion {
assert_eq!(input.as_rule(), Rule::Operation);
let mut pairs = input.into_inner();
let left_term = parse_term(pairs.next().unwrap(), variable_list);
let operator = parse_operator(pairs.next().unwrap());
let right_term = parse_expresion(pairs.next().unwrap(), variable_list);
pairs.next().unwrap_none();
Expresion::Operation(operator, Box::new((left_term, right_term)))
}
fn parse_operator(input: Pair<Rule>) -> OperationType {
assert_eq!(input.as_rule(), Rule::Operator);
match input.into_inner().next().unwrap().as_rule() {
Rule::Addition => OperationType::Addition,
Rule::Subtraction => OperationType::Subtraction,
Rule::Multiplication => OperationType::Multiplication,
Rule::Division => OperationType::Division,
_ => unreachable!(),
}
}
fn parse_term(input: Pair<Rule>, variable_list: &mut VariableStore) -> Expresion {
assert_eq!(input.as_rule(), Rule::Term);
let pair = input.into_inner().next().unwrap();
match pair.as_rule() {
Rule::Lateral => Expresion::Integer(u64::from_str(pair.as_str()).unwrap()),
Rule::Identifier => Expresion::Variable(variable_list.get_variable_id(pair.as_str())),
Rule::NestedExpresion => parse_expresion(pair.into_inner().next().unwrap(), variable_list),
_ => unreachable!(),
}
}
mod test {
use super::{parser, Expresion, OperationType, Statement};
#[test]
fn statement_without_followup_expresion() {
parser(
"let x = 2 * 5\n\
let y = x / 2",
)
.unwrap_err();
}
#[test]
fn statement_without_newline() {
parser("let x = 8 8*2").unwrap_err();
}
#[test]
fn malformed_statement() {
parser(
"let x 5 * 2\n\
x * 10",
)
.unwrap_err();
}
#[test]
fn valid_operation() {
let ast = parser("2 * 8").unwrap();
if let Expresion::Operation(OperationType::Multiplication, terms) = ast.get_expresion() {
if let (Expresion::Integer(2), Expresion::Integer(8)) = *terms {
return;
}
}
panic!()
}
#[test]
fn expresion_with_undeclared_variable() {
let ast = parser("x + 10").unwrap();
if let Expresion::Operation(OperationType::Addition, terms) = ast.get_expresion() {
if let (Expresion::Variable(_), Expresion::Integer(10)) = *terms {
return;
}
}
panic!()
}
#[test]
fn valid_statement_follow_by_valid_expresion() {
let ast = parser(
"let xyz = 89\n\
xyz / 5",
)
.unwrap();
if let Statement::LetStatement(id, Expresion::Integer(89)) =
ast.clone().get_statement_list().first().unwrap()
{
if let Expresion::Operation(OperationType::Division, terms) = ast.expresion {
if let (Expresion::Variable(num), Expresion::Integer(5)) = *terms {
assert_eq!(*id, num);
return;
}
}
}
panic!()
}
#[test]
fn nested_expresion() {
let ast = parser("48 * (21 + 94)").unwrap();
if let Expresion::Operation(OperationType::Multiplication, terms) = ast.get_expresion() {
if let (Expresion::Integer(48), Expresion::Operation(OperationType::Addition, terms)) =
*terms
{
if let (Expresion::Integer(21), Expresion::Integer(94)) = *terms {
return;
}
}
}
panic!()
}
#[test]
fn variable_foreshadowing() {
let ast = parser(
"let x = 42 \n\
let x = 32\n\
x",
)
.unwrap();
let mut iter = ast.clone().get_statement_list().into_iter();
if let Some(Statement::LetStatement(true_id, _)) = iter.nth(1) {
if let Expresion::Variable(id) = ast.get_expresion() {
assert_eq!(true_id, id);
return;
}
}
panic!()
}
}
|
// Declare the EOSIO externs to read action data and print to the console.
extern "C" {
pub fn read_action_data(msg: *mut CVoid, len: u32) -> u32;
pub fn prints_l(cstr: *const u8, len: u32);
pub fn printn(name: u64);
}
#[repr(u8)]
pub enum CVoid {
// Two dummy variants so the #[repr] attribute can be used.
Variant1,
Variant2,
}
// EOSIO smart contracts are expected to have an `apply` function.
#[no_mangle]
pub extern "C" fn apply(_receiver: u64, _code: u64, _action: u64) {
// First print "Hi, " to the console.
{
let msg = "Hi, ";
let ptr = msg.as_ptr();
let len = msg.len() as u32;
unsafe { prints_l(ptr, len) };
}
// Read the action data, which is one EOSIO name (a u64, or 8 bytes).
let name = {
let mut bytes = [0u8; 8];
let ptr: *mut CVoid = &mut bytes[..] as *mut _ as *mut CVoid;
unsafe { read_action_data(ptr, 8) };
u64::from_le_bytes(bytes)
};
// Finally, print the name to the console.
unsafe { printn(name) };
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AccessKeyDisplayDismissedEventArgs(pub ::windows::core::IInspectable);
impl AccessKeyDisplayDismissedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<AccessKeyDisplayDismissedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for AccessKeyDisplayDismissedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.AccessKeyDisplayDismissedEventArgs;{8a610dc6-d72d-4ca8-9f66-556f35b513da})");
}
unsafe impl ::windows::core::Interface for AccessKeyDisplayDismissedEventArgs {
type Vtable = IAccessKeyDisplayDismissedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8a610dc6_d72d_4ca8_9f66_556f35b513da);
}
impl ::windows::core::RuntimeName for AccessKeyDisplayDismissedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.AccessKeyDisplayDismissedEventArgs";
}
impl ::core::convert::From<AccessKeyDisplayDismissedEventArgs> for ::windows::core::IUnknown {
fn from(value: AccessKeyDisplayDismissedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&AccessKeyDisplayDismissedEventArgs> for ::windows::core::IUnknown {
fn from(value: &AccessKeyDisplayDismissedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AccessKeyDisplayDismissedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a AccessKeyDisplayDismissedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<AccessKeyDisplayDismissedEventArgs> for ::windows::core::IInspectable {
fn from(value: AccessKeyDisplayDismissedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&AccessKeyDisplayDismissedEventArgs> for ::windows::core::IInspectable {
fn from(value: &AccessKeyDisplayDismissedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for AccessKeyDisplayDismissedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a AccessKeyDisplayDismissedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for AccessKeyDisplayDismissedEventArgs {}
unsafe impl ::core::marker::Sync for AccessKeyDisplayDismissedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AccessKeyDisplayRequestedEventArgs(pub ::windows::core::IInspectable);
impl AccessKeyDisplayRequestedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<AccessKeyDisplayRequestedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn PressedKeys(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for AccessKeyDisplayRequestedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.AccessKeyDisplayRequestedEventArgs;{0c079e55-13fe-4d03-a61d-e12f06567286})");
}
unsafe impl ::windows::core::Interface for AccessKeyDisplayRequestedEventArgs {
type Vtable = IAccessKeyDisplayRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0c079e55_13fe_4d03_a61d_e12f06567286);
}
impl ::windows::core::RuntimeName for AccessKeyDisplayRequestedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.AccessKeyDisplayRequestedEventArgs";
}
impl ::core::convert::From<AccessKeyDisplayRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: AccessKeyDisplayRequestedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&AccessKeyDisplayRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: &AccessKeyDisplayRequestedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AccessKeyDisplayRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a AccessKeyDisplayRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<AccessKeyDisplayRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: AccessKeyDisplayRequestedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&AccessKeyDisplayRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: &AccessKeyDisplayRequestedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for AccessKeyDisplayRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a AccessKeyDisplayRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for AccessKeyDisplayRequestedEventArgs {}
unsafe impl ::core::marker::Sync for AccessKeyDisplayRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AccessKeyInvokedEventArgs(pub ::windows::core::IInspectable);
impl AccessKeyInvokedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<AccessKeyInvokedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for AccessKeyInvokedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.AccessKeyInvokedEventArgs;{cfe9cd97-c718-4091-b7dd-adf1c072b1e1})");
}
unsafe impl ::windows::core::Interface for AccessKeyInvokedEventArgs {
type Vtable = IAccessKeyInvokedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xcfe9cd97_c718_4091_b7dd_adf1c072b1e1);
}
impl ::windows::core::RuntimeName for AccessKeyInvokedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.AccessKeyInvokedEventArgs";
}
impl ::core::convert::From<AccessKeyInvokedEventArgs> for ::windows::core::IUnknown {
fn from(value: AccessKeyInvokedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&AccessKeyInvokedEventArgs> for ::windows::core::IUnknown {
fn from(value: &AccessKeyInvokedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AccessKeyInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a AccessKeyInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<AccessKeyInvokedEventArgs> for ::windows::core::IInspectable {
fn from(value: AccessKeyInvokedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&AccessKeyInvokedEventArgs> for ::windows::core::IInspectable {
fn from(value: &AccessKeyInvokedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for AccessKeyInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a AccessKeyInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for AccessKeyInvokedEventArgs {}
unsafe impl ::core::marker::Sync for AccessKeyInvokedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct AccessKeyManager(pub ::windows::core::IInspectable);
impl AccessKeyManager {
pub fn IsDisplayModeEnabled() -> ::windows::core::Result<bool> {
Self::IAccessKeyManagerStatics(|this| unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn IsDisplayModeEnabledChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::TypedEventHandler<::windows::core::IInspectable, ::windows::core::IInspectable>>>(handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
Self::IAccessKeyManagerStatics(|this| unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveIsDisplayModeEnabledChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IAccessKeyManagerStatics(|this| unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
pub fn ExitDisplayMode() -> ::windows::core::Result<()> {
Self::IAccessKeyManagerStatics(|this| unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this)).ok() })
}
pub fn AreKeyTipsEnabled() -> ::windows::core::Result<bool> {
Self::IAccessKeyManagerStatics2(|this| unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
})
}
pub fn SetAreKeyTipsEnabled(value: bool) -> ::windows::core::Result<()> {
Self::IAccessKeyManagerStatics2(|this| unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() })
}
pub fn IAccessKeyManagerStatics<R, F: FnOnce(&IAccessKeyManagerStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<AccessKeyManager, IAccessKeyManagerStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IAccessKeyManagerStatics2<R, F: FnOnce(&IAccessKeyManagerStatics2) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<AccessKeyManager, IAccessKeyManagerStatics2> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for AccessKeyManager {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.AccessKeyManager;{ecc973b0-2ee9-4b1c-98d7-6e0e816d334b})");
}
unsafe impl ::windows::core::Interface for AccessKeyManager {
type Vtable = IAccessKeyManager_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xecc973b0_2ee9_4b1c_98d7_6e0e816d334b);
}
impl ::windows::core::RuntimeName for AccessKeyManager {
const NAME: &'static str = "Windows.UI.Xaml.Input.AccessKeyManager";
}
impl ::core::convert::From<AccessKeyManager> for ::windows::core::IUnknown {
fn from(value: AccessKeyManager) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&AccessKeyManager> for ::windows::core::IUnknown {
fn from(value: &AccessKeyManager) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for AccessKeyManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a AccessKeyManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<AccessKeyManager> for ::windows::core::IInspectable {
fn from(value: AccessKeyManager) -> Self {
value.0
}
}
impl ::core::convert::From<&AccessKeyManager> for ::windows::core::IInspectable {
fn from(value: &AccessKeyManager) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for AccessKeyManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a AccessKeyManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for AccessKeyManager {}
unsafe impl ::core::marker::Sync for AccessKeyManager {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CanExecuteRequestedEventArgs(pub ::windows::core::IInspectable);
impl CanExecuteRequestedEventArgs {
pub fn Parameter(&self) -> ::windows::core::Result<::windows::core::IInspectable> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
}
}
pub fn CanExecute(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetCanExecute(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for CanExecuteRequestedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.CanExecuteRequestedEventArgs;{c8e75256-1950-505d-993b-75907ef96830})");
}
unsafe impl ::windows::core::Interface for CanExecuteRequestedEventArgs {
type Vtable = ICanExecuteRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc8e75256_1950_505d_993b_75907ef96830);
}
impl ::windows::core::RuntimeName for CanExecuteRequestedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.CanExecuteRequestedEventArgs";
}
impl ::core::convert::From<CanExecuteRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: CanExecuteRequestedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&CanExecuteRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: &CanExecuteRequestedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for CanExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a CanExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<CanExecuteRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: CanExecuteRequestedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&CanExecuteRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: &CanExecuteRequestedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for CanExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a CanExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for CanExecuteRequestedEventArgs {}
unsafe impl ::core::marker::Sync for CanExecuteRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CharacterReceivedRoutedEventArgs(pub ::windows::core::IInspectable);
impl CharacterReceivedRoutedEventArgs {
pub fn Character(&self) -> ::windows::core::Result<u16> {
let this = self;
unsafe {
let mut result__: u16 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u16>(result__)
}
}
#[cfg(feature = "UI_Core")]
pub fn KeyStatus(&self) -> ::windows::core::Result<super::super::Core::CorePhysicalKeyStatus> {
let this = self;
unsafe {
let mut result__: super::super::Core::CorePhysicalKeyStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Core::CorePhysicalKeyStatus>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for CharacterReceivedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.CharacterReceivedRoutedEventArgs;{7849fd82-48e4-444d-9419-93ab8892c107})");
}
unsafe impl ::windows::core::Interface for CharacterReceivedRoutedEventArgs {
type Vtable = ICharacterReceivedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7849fd82_48e4_444d_9419_93ab8892c107);
}
impl ::windows::core::RuntimeName for CharacterReceivedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.CharacterReceivedRoutedEventArgs";
}
impl ::core::convert::From<CharacterReceivedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: CharacterReceivedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&CharacterReceivedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &CharacterReceivedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<CharacterReceivedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: CharacterReceivedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&CharacterReceivedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &CharacterReceivedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<CharacterReceivedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: CharacterReceivedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&CharacterReceivedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &CharacterReceivedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &CharacterReceivedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for CharacterReceivedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for CharacterReceivedRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ContextRequestedEventArgs(pub ::windows::core::IInspectable);
impl ContextRequestedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ContextRequestedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn TryGetPosition<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0, point: &mut super::super::super::Foundation::Point) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), point, &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for ContextRequestedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ContextRequestedEventArgs;{42618e0a-1cb6-46fb-8374-0aec68aa5e51})");
}
unsafe impl ::windows::core::Interface for ContextRequestedEventArgs {
type Vtable = IContextRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x42618e0a_1cb6_46fb_8374_0aec68aa5e51);
}
impl ::windows::core::RuntimeName for ContextRequestedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ContextRequestedEventArgs";
}
impl ::core::convert::From<ContextRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: ContextRequestedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ContextRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ContextRequestedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ContextRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: ContextRequestedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ContextRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ContextRequestedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ContextRequestedEventArgs> for super::RoutedEventArgs {
fn from(value: ContextRequestedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ContextRequestedEventArgs> for super::RoutedEventArgs {
fn from(value: &ContextRequestedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ContextRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ContextRequestedEventArgs {}
unsafe impl ::core::marker::Sync for ContextRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct DoubleTappedEventHandler(::windows::core::IUnknown);
impl DoubleTappedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<DoubleTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = DoubleTappedEventHandler_box::<F> {
vtable: &DoubleTappedEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, DoubleTappedRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for DoubleTappedEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({3124d025-04a7-4d45-825e-8204a624dbf4})");
}
unsafe impl ::windows::core::Interface for DoubleTappedEventHandler {
type Vtable = DoubleTappedEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3124d025_04a7_4d45_825e_8204a624dbf4);
}
#[repr(C)]
#[doc(hidden)]
pub struct DoubleTappedEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct DoubleTappedEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<DoubleTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const DoubleTappedEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<DoubleTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> DoubleTappedEventHandler_box<F> {
const VTABLE: DoubleTappedEventHandler_abi = DoubleTappedEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<DoubleTappedEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <DoubleTappedRoutedEventArgs as ::windows::core::Abi>::Abi as *const <DoubleTappedRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct DoubleTappedRoutedEventArgs(pub ::windows::core::IInspectable);
impl DoubleTappedRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<DoubleTappedRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn GetPosition<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for DoubleTappedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs;{af404424-26df-44f4-8714-9359249b62d3})");
}
unsafe impl ::windows::core::Interface for DoubleTappedRoutedEventArgs {
type Vtable = IDoubleTappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xaf404424_26df_44f4_8714_9359249b62d3);
}
impl ::windows::core::RuntimeName for DoubleTappedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.DoubleTappedRoutedEventArgs";
}
impl ::core::convert::From<DoubleTappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: DoubleTappedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&DoubleTappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &DoubleTappedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<DoubleTappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: DoubleTappedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&DoubleTappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &DoubleTappedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<DoubleTappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: DoubleTappedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&DoubleTappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &DoubleTappedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &DoubleTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for DoubleTappedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for DoubleTappedRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ExecuteRequestedEventArgs(pub ::windows::core::IInspectable);
impl ExecuteRequestedEventArgs {
pub fn Parameter(&self) -> ::windows::core::Result<::windows::core::IInspectable> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for ExecuteRequestedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ExecuteRequestedEventArgs;{e07fa734-a0b6-5755-9e87-24f54cca9372})");
}
unsafe impl ::windows::core::Interface for ExecuteRequestedEventArgs {
type Vtable = IExecuteRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe07fa734_a0b6_5755_9e87_24f54cca9372);
}
impl ::windows::core::RuntimeName for ExecuteRequestedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ExecuteRequestedEventArgs";
}
impl ::core::convert::From<ExecuteRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: ExecuteRequestedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ExecuteRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ExecuteRequestedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ExecuteRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: ExecuteRequestedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ExecuteRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ExecuteRequestedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ExecuteRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for ExecuteRequestedEventArgs {}
unsafe impl ::core::marker::Sync for ExecuteRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct FindNextElementOptions(pub ::windows::core::IInspectable);
impl FindNextElementOptions {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FindNextElementOptions, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn SearchRoot(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn SetSearchRoot<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn ExclusionRect(&self) -> ::windows::core::Result<super::super::super::Foundation::Rect> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Rect = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Rect>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetExclusionRect<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::Rect>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn HintRect(&self) -> ::windows::core::Result<super::super::super::Foundation::Rect> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Rect = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Rect>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetHintRect<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::Rect>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn XYFocusNavigationStrategyOverride(&self) -> ::windows::core::Result<XYFocusNavigationStrategyOverride> {
let this = self;
unsafe {
let mut result__: XYFocusNavigationStrategyOverride = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<XYFocusNavigationStrategyOverride>(result__)
}
}
pub fn SetXYFocusNavigationStrategyOverride(&self, value: XYFocusNavigationStrategyOverride) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for FindNextElementOptions {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.FindNextElementOptions;{d88ae22b-46c2-41fc-897e-b5961977b89d})");
}
unsafe impl ::windows::core::Interface for FindNextElementOptions {
type Vtable = IFindNextElementOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd88ae22b_46c2_41fc_897e_b5961977b89d);
}
impl ::windows::core::RuntimeName for FindNextElementOptions {
const NAME: &'static str = "Windows.UI.Xaml.Input.FindNextElementOptions";
}
impl ::core::convert::From<FindNextElementOptions> for ::windows::core::IUnknown {
fn from(value: FindNextElementOptions) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&FindNextElementOptions> for ::windows::core::IUnknown {
fn from(value: &FindNextElementOptions) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for FindNextElementOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a FindNextElementOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<FindNextElementOptions> for ::windows::core::IInspectable {
fn from(value: FindNextElementOptions) -> Self {
value.0
}
}
impl ::core::convert::From<&FindNextElementOptions> for ::windows::core::IInspectable {
fn from(value: &FindNextElementOptions) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for FindNextElementOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a FindNextElementOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for FindNextElementOptions {}
unsafe impl ::core::marker::Sync for FindNextElementOptions {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct FocusInputDeviceKind(pub i32);
impl FocusInputDeviceKind {
pub const None: FocusInputDeviceKind = FocusInputDeviceKind(0i32);
pub const Mouse: FocusInputDeviceKind = FocusInputDeviceKind(1i32);
pub const Touch: FocusInputDeviceKind = FocusInputDeviceKind(2i32);
pub const Pen: FocusInputDeviceKind = FocusInputDeviceKind(3i32);
pub const Keyboard: FocusInputDeviceKind = FocusInputDeviceKind(4i32);
pub const GameController: FocusInputDeviceKind = FocusInputDeviceKind(5i32);
}
impl ::core::convert::From<i32> for FocusInputDeviceKind {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for FocusInputDeviceKind {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for FocusInputDeviceKind {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.FocusInputDeviceKind;i4)");
}
impl ::windows::core::DefaultType for FocusInputDeviceKind {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct FocusManager(pub ::windows::core::IInspectable);
impl FocusManager {
pub fn GetFocusedElement() -> ::windows::core::Result<::windows::core::IInspectable> {
Self::IFocusManagerStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
})
}
pub fn TryMoveFocus(focusnavigationdirection: FocusNavigationDirection) -> ::windows::core::Result<bool> {
Self::IFocusManagerStatics2(|this| unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), focusnavigationdirection, &mut result__).from_abi::<bool>(result__)
})
}
pub fn FindNextFocusableElement(focusnavigationdirection: FocusNavigationDirection) -> ::windows::core::Result<super::UIElement> {
Self::IFocusManagerStatics3(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), focusnavigationdirection, &mut result__).from_abi::<super::UIElement>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn FindNextFocusableElementWithHint<'a, Param1: ::windows::core::IntoParam<'a, super::super::super::Foundation::Rect>>(focusnavigationdirection: FocusNavigationDirection, hintrect: Param1) -> ::windows::core::Result<super::UIElement> {
Self::IFocusManagerStatics3(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), focusnavigationdirection, hintrect.into_param().abi(), &mut result__).from_abi::<super::UIElement>(result__)
})
}
pub fn TryMoveFocusWithOptions<'a, Param1: ::windows::core::IntoParam<'a, FindNextElementOptions>>(focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: Param1) -> ::windows::core::Result<bool> {
Self::IFocusManagerStatics4(|this| unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), focusnavigationdirection, focusnavigationoptions.into_param().abi(), &mut result__).from_abi::<bool>(result__)
})
}
pub fn FindNextElement(focusnavigationdirection: FocusNavigationDirection) -> ::windows::core::Result<super::DependencyObject> {
Self::IFocusManagerStatics4(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), focusnavigationdirection, &mut result__).from_abi::<super::DependencyObject>(result__)
})
}
pub fn FindFirstFocusableElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(searchscope: Param0) -> ::windows::core::Result<super::DependencyObject> {
Self::IFocusManagerStatics4(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), searchscope.into_param().abi(), &mut result__).from_abi::<super::DependencyObject>(result__)
})
}
pub fn FindLastFocusableElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(searchscope: Param0) -> ::windows::core::Result<super::DependencyObject> {
Self::IFocusManagerStatics4(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), searchscope.into_param().abi(), &mut result__).from_abi::<super::DependencyObject>(result__)
})
}
pub fn FindNextElementWithOptions<'a, Param1: ::windows::core::IntoParam<'a, FindNextElementOptions>>(focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: Param1) -> ::windows::core::Result<super::DependencyObject> {
Self::IFocusManagerStatics4(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), focusnavigationdirection, focusnavigationoptions.into_param().abi(), &mut result__).from_abi::<super::DependencyObject>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn TryFocusAsync<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(element: Param0, value: super::FocusState) -> ::windows::core::Result<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>> {
Self::IFocusManagerStatics5(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), element.into_param().abi(), value, &mut result__).from_abi::<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn TryMoveFocusAsync(focusnavigationdirection: FocusNavigationDirection) -> ::windows::core::Result<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>> {
Self::IFocusManagerStatics5(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), focusnavigationdirection, &mut result__).from_abi::<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn TryMoveFocusWithOptionsAsync<'a, Param1: ::windows::core::IntoParam<'a, FindNextElementOptions>>(focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: Param1) -> ::windows::core::Result<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>> {
Self::IFocusManagerStatics5(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), focusnavigationdirection, focusnavigationoptions.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::IAsyncOperation<FocusMovementResult>>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn GotFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<FocusManagerGotFocusEventArgs>>>(handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
Self::IFocusManagerStatics6(|this| unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveGotFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IFocusManagerStatics6(|this| unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
#[cfg(feature = "Foundation")]
pub fn LostFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<FocusManagerLostFocusEventArgs>>>(handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
Self::IFocusManagerStatics6(|this| unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveLostFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IFocusManagerStatics6(|this| unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
#[cfg(feature = "Foundation")]
pub fn GettingFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<GettingFocusEventArgs>>>(handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
Self::IFocusManagerStatics6(|this| unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveGettingFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IFocusManagerStatics6(|this| unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
#[cfg(feature = "Foundation")]
pub fn LosingFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<LosingFocusEventArgs>>>(handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
Self::IFocusManagerStatics6(|this| unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveLosingFocus<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IFocusManagerStatics6(|this| unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
pub fn GetFocusedElement2<'a, Param0: ::windows::core::IntoParam<'a, super::XamlRoot>>(xamlroot: Param0) -> ::windows::core::Result<::windows::core::IInspectable> {
Self::IFocusManagerStatics7(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), xamlroot.into_param().abi(), &mut result__).from_abi::<::windows::core::IInspectable>(result__)
})
}
pub fn IFocusManagerStatics<R, F: FnOnce(&IFocusManagerStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics2<R, F: FnOnce(&IFocusManagerStatics2) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics2> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics3<R, F: FnOnce(&IFocusManagerStatics3) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics3> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics4<R, F: FnOnce(&IFocusManagerStatics4) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics4> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics5<R, F: FnOnce(&IFocusManagerStatics5) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics5> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics6<R, F: FnOnce(&IFocusManagerStatics6) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics6> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IFocusManagerStatics7<R, F: FnOnce(&IFocusManagerStatics7) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<FocusManager, IFocusManagerStatics7> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for FocusManager {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.FocusManager;{c843f50b-3b83-4da1-9d6f-557c1169f341})");
}
unsafe impl ::windows::core::Interface for FocusManager {
type Vtable = IFocusManager_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc843f50b_3b83_4da1_9d6f_557c1169f341);
}
impl ::windows::core::RuntimeName for FocusManager {
const NAME: &'static str = "Windows.UI.Xaml.Input.FocusManager";
}
impl ::core::convert::From<FocusManager> for ::windows::core::IUnknown {
fn from(value: FocusManager) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&FocusManager> for ::windows::core::IUnknown {
fn from(value: &FocusManager) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for FocusManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a FocusManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<FocusManager> for ::windows::core::IInspectable {
fn from(value: FocusManager) -> Self {
value.0
}
}
impl ::core::convert::From<&FocusManager> for ::windows::core::IInspectable {
fn from(value: &FocusManager) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for FocusManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a FocusManager {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for FocusManager {}
unsafe impl ::core::marker::Sync for FocusManager {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct FocusManagerGotFocusEventArgs(pub ::windows::core::IInspectable);
impl FocusManagerGotFocusEventArgs {
pub fn NewFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn CorrelationId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = self;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for FocusManagerGotFocusEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.FocusManagerGotFocusEventArgs;{97aa5d83-535b-507a-868e-62b706f06b61})");
}
unsafe impl ::windows::core::Interface for FocusManagerGotFocusEventArgs {
type Vtable = IFocusManagerGotFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x97aa5d83_535b_507a_868e_62b706f06b61);
}
impl ::windows::core::RuntimeName for FocusManagerGotFocusEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.FocusManagerGotFocusEventArgs";
}
impl ::core::convert::From<FocusManagerGotFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: FocusManagerGotFocusEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&FocusManagerGotFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: &FocusManagerGotFocusEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for FocusManagerGotFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a FocusManagerGotFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<FocusManagerGotFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: FocusManagerGotFocusEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&FocusManagerGotFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: &FocusManagerGotFocusEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for FocusManagerGotFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a FocusManagerGotFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for FocusManagerGotFocusEventArgs {}
unsafe impl ::core::marker::Sync for FocusManagerGotFocusEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct FocusManagerLostFocusEventArgs(pub ::windows::core::IInspectable);
impl FocusManagerLostFocusEventArgs {
pub fn OldFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn CorrelationId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = self;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for FocusManagerLostFocusEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.FocusManagerLostFocusEventArgs;{3e157e7a-9578-5cd3-aaa8-051b3d391978})");
}
unsafe impl ::windows::core::Interface for FocusManagerLostFocusEventArgs {
type Vtable = IFocusManagerLostFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3e157e7a_9578_5cd3_aaa8_051b3d391978);
}
impl ::windows::core::RuntimeName for FocusManagerLostFocusEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.FocusManagerLostFocusEventArgs";
}
impl ::core::convert::From<FocusManagerLostFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: FocusManagerLostFocusEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&FocusManagerLostFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: &FocusManagerLostFocusEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for FocusManagerLostFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a FocusManagerLostFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<FocusManagerLostFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: FocusManagerLostFocusEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&FocusManagerLostFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: &FocusManagerLostFocusEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for FocusManagerLostFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a FocusManagerLostFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for FocusManagerLostFocusEventArgs {}
unsafe impl ::core::marker::Sync for FocusManagerLostFocusEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct FocusMovementResult(pub ::windows::core::IInspectable);
impl FocusMovementResult {
pub fn Succeeded(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for FocusMovementResult {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.FocusMovementResult;{06dfead3-c2ae-44bb-bfab-9c73de8407a4})");
}
unsafe impl ::windows::core::Interface for FocusMovementResult {
type Vtable = IFocusMovementResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x06dfead3_c2ae_44bb_bfab_9c73de8407a4);
}
impl ::windows::core::RuntimeName for FocusMovementResult {
const NAME: &'static str = "Windows.UI.Xaml.Input.FocusMovementResult";
}
impl ::core::convert::From<FocusMovementResult> for ::windows::core::IUnknown {
fn from(value: FocusMovementResult) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&FocusMovementResult> for ::windows::core::IUnknown {
fn from(value: &FocusMovementResult) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for FocusMovementResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a FocusMovementResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<FocusMovementResult> for ::windows::core::IInspectable {
fn from(value: FocusMovementResult) -> Self {
value.0
}
}
impl ::core::convert::From<&FocusMovementResult> for ::windows::core::IInspectable {
fn from(value: &FocusMovementResult) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for FocusMovementResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a FocusMovementResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for FocusMovementResult {}
unsafe impl ::core::marker::Sync for FocusMovementResult {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct FocusNavigationDirection(pub i32);
impl FocusNavigationDirection {
pub const Next: FocusNavigationDirection = FocusNavigationDirection(0i32);
pub const Previous: FocusNavigationDirection = FocusNavigationDirection(1i32);
pub const Up: FocusNavigationDirection = FocusNavigationDirection(2i32);
pub const Down: FocusNavigationDirection = FocusNavigationDirection(3i32);
pub const Left: FocusNavigationDirection = FocusNavigationDirection(4i32);
pub const Right: FocusNavigationDirection = FocusNavigationDirection(5i32);
pub const None: FocusNavigationDirection = FocusNavigationDirection(6i32);
}
impl ::core::convert::From<i32> for FocusNavigationDirection {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for FocusNavigationDirection {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for FocusNavigationDirection {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.FocusNavigationDirection;i4)");
}
impl ::windows::core::DefaultType for FocusNavigationDirection {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct GettingFocusEventArgs(pub ::windows::core::IInspectable);
impl GettingFocusEventArgs {
pub fn OldFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn NewFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn SetNewFocusedElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn FocusState(&self) -> ::windows::core::Result<super::FocusState> {
let this = self;
unsafe {
let mut result__: super::FocusState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::FocusState>(result__)
}
}
pub fn Direction(&self) -> ::windows::core::Result<FocusNavigationDirection> {
let this = self;
unsafe {
let mut result__: FocusNavigationDirection = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusNavigationDirection>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn InputDevice(&self) -> ::windows::core::Result<FocusInputDeviceKind> {
let this = self;
unsafe {
let mut result__: FocusInputDeviceKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusInputDeviceKind>(result__)
}
}
pub fn Cancel(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetCancel(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn TryCancel(&self) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<IGettingFocusEventArgs2>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn TrySetNewFocusedElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, element: Param0) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<IGettingFocusEventArgs2>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), element.into_param().abi(), &mut result__).from_abi::<bool>(result__)
}
}
pub fn CorrelationId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = &::windows::core::Interface::cast::<IGettingFocusEventArgs3>(self)?;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for GettingFocusEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.GettingFocusEventArgs;{fa05b9ce-c67c-4be8-8fd4-c44d67877e0d})");
}
unsafe impl ::windows::core::Interface for GettingFocusEventArgs {
type Vtable = IGettingFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfa05b9ce_c67c_4be8_8fd4_c44d67877e0d);
}
impl ::windows::core::RuntimeName for GettingFocusEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.GettingFocusEventArgs";
}
impl ::core::convert::From<GettingFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: GettingFocusEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&GettingFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: &GettingFocusEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<GettingFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: GettingFocusEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&GettingFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: &GettingFocusEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<GettingFocusEventArgs> for super::RoutedEventArgs {
fn from(value: GettingFocusEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&GettingFocusEventArgs> for super::RoutedEventArgs {
fn from(value: &GettingFocusEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &GettingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for GettingFocusEventArgs {}
unsafe impl ::core::marker::Sync for GettingFocusEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct HoldingEventHandler(::windows::core::IUnknown);
impl HoldingEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<HoldingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = HoldingEventHandler_box::<F> {
vtable: &HoldingEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, HoldingRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for HoldingEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({ecae8ccd-8e5e-4fbe-9846-30a6370afcdf})");
}
unsafe impl ::windows::core::Interface for HoldingEventHandler {
type Vtable = HoldingEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xecae8ccd_8e5e_4fbe_9846_30a6370afcdf);
}
#[repr(C)]
#[doc(hidden)]
pub struct HoldingEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct HoldingEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<HoldingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const HoldingEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<HoldingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> HoldingEventHandler_box<F> {
const VTABLE: HoldingEventHandler_abi = HoldingEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<HoldingEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <HoldingRoutedEventArgs as ::windows::core::Abi>::Abi as *const <HoldingRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct HoldingRoutedEventArgs(pub ::windows::core::IInspectable);
impl HoldingRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<HoldingRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
#[cfg(feature = "UI_Input")]
pub fn HoldingState(&self) -> ::windows::core::Result<super::super::Input::HoldingState> {
let this = self;
unsafe {
let mut result__: super::super::Input::HoldingState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::HoldingState>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn GetPosition<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for HoldingRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.HoldingRoutedEventArgs;{c246ff23-d80d-44de-8db9-0d815e269ac0})");
}
unsafe impl ::windows::core::Interface for HoldingRoutedEventArgs {
type Vtable = IHoldingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc246ff23_d80d_44de_8db9_0d815e269ac0);
}
impl ::windows::core::RuntimeName for HoldingRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.HoldingRoutedEventArgs";
}
impl ::core::convert::From<HoldingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: HoldingRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&HoldingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &HoldingRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<HoldingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: HoldingRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&HoldingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &HoldingRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<HoldingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: HoldingRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&HoldingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &HoldingRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &HoldingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for HoldingRoutedEventArgs {}
unsafe impl ::core::marker::Sync for HoldingRoutedEventArgs {}
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyDisplayDismissedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyDisplayDismissedEventArgs {
type Vtable = IAccessKeyDisplayDismissedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8a610dc6_d72d_4ca8_9f66_556f35b513da);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyDisplayDismissedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyDisplayRequestedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyDisplayRequestedEventArgs {
type Vtable = IAccessKeyDisplayRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0c079e55_13fe_4d03_a61d_e12f06567286);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyDisplayRequestedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyInvokedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyInvokedEventArgs {
type Vtable = IAccessKeyInvokedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xcfe9cd97_c718_4091_b7dd_adf1c072b1e1);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyInvokedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyManager(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyManager {
type Vtable = IAccessKeyManager_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xecc973b0_2ee9_4b1c_98d7_6e0e816d334b);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyManager_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyManagerStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyManagerStatics {
type Vtable = IAccessKeyManagerStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ca0efe6_d9c8_4ebc_b4c7_30d1838a81f1);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyManagerStatics_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IAccessKeyManagerStatics2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IAccessKeyManagerStatics2 {
type Vtable = IAccessKeyManagerStatics2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x962bb594_2ab3_47c5_954b_7092f355f797);
}
#[repr(C)]
#[doc(hidden)]
pub struct IAccessKeyManagerStatics2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ICanExecuteRequestedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICanExecuteRequestedEventArgs {
type Vtable = ICanExecuteRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc8e75256_1950_505d_993b_75907ef96830);
}
#[repr(C)]
#[doc(hidden)]
pub struct ICanExecuteRequestedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ICharacterReceivedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICharacterReceivedRoutedEventArgs {
type Vtable = ICharacterReceivedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7849fd82_48e4_444d_9419_93ab8892c107);
}
#[repr(C)]
#[doc(hidden)]
pub struct ICharacterReceivedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u16) -> ::windows::core::HRESULT,
#[cfg(feature = "UI_Core")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Core::CorePhysicalKeyStatus) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Core"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ICommand(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICommand {
type Vtable = ICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe5af3542_ca67_4081_995b_709dd13792df);
}
impl ICommand {
#[cfg(feature = "Foundation")]
pub fn CanExecuteChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<::windows::core::IInspectable>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveCanExecuteChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn CanExecute<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, parameter: Param0) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), parameter.into_param().abi(), &mut result__).from_abi::<bool>(result__)
}
}
pub fn Execute<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, parameter: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), parameter.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ICommand {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{e5af3542-ca67-4081-995b-709dd13792df}");
}
impl ::core::convert::From<ICommand> for ::windows::core::IUnknown {
fn from(value: ICommand) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ICommand> for ::windows::core::IUnknown {
fn from(value: &ICommand) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ICommand> for ::windows::core::IInspectable {
fn from(value: ICommand) -> Self {
value.0
}
}
impl ::core::convert::From<&ICommand> for ::windows::core::IInspectable {
fn from(value: &ICommand) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
#[repr(C)]
#[doc(hidden)]
pub struct ICommand_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, parameter: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, parameter: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IContextRequestedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IContextRequestedEventArgs {
type Vtable = IContextRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x42618e0a_1cb6_46fb_8374_0aec68aa5e51);
}
#[repr(C)]
#[doc(hidden)]
pub struct IContextRequestedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, point: *mut super::super::super::Foundation::Point, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IDoubleTappedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IDoubleTappedRoutedEventArgs {
type Vtable = IDoubleTappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xaf404424_26df_44f4_8714_9359249b62d3);
}
#[repr(C)]
#[doc(hidden)]
pub struct IDoubleTappedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IExecuteRequestedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IExecuteRequestedEventArgs {
type Vtable = IExecuteRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe07fa734_a0b6_5755_9e87_24f54cca9372);
}
#[repr(C)]
#[doc(hidden)]
pub struct IExecuteRequestedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFindNextElementOptions(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFindNextElementOptions {
type Vtable = IFindNextElementOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd88ae22b_46c2_41fc_897e_b5961977b89d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFindNextElementOptions_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Rect) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::super::Foundation::Rect) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Rect) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::super::Foundation::Rect) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut XYFocusNavigationStrategyOverride) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: XYFocusNavigationStrategyOverride) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManager(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManager {
type Vtable = IFocusManager_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc843f50b_3b83_4da1_9d6f_557c1169f341);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManager_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerGotFocusEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerGotFocusEventArgs {
type Vtable = IFocusManagerGotFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x97aa5d83_535b_507a_868e_62b706f06b61);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerGotFocusEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerLostFocusEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerLostFocusEventArgs {
type Vtable = IFocusManagerLostFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3e157e7a_9578_5cd3_aaa8_051b3d391978);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerLostFocusEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics {
type Vtable = IFocusManagerStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1eccd326_8182_4482_826a_0918e9ed9af7);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics2 {
type Vtable = IFocusManagerStatics2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa920d761_dd87_4f31_beda_ef417fe7c04a);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics3 {
type Vtable = IFocusManagerStatics3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x60805ebf_b149_417d_83f1_baeb560e2a47);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics3_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, hintrect: super::super::super::Foundation::Rect, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics4(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics4 {
type Vtable = IFocusManagerStatics4_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x29276e9c_1c6c_414a_ba1c_96efd5962bcd);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics4_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, searchscope: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, searchscope: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics5(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics5 {
type Vtable = IFocusManagerStatics5_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x280edc61_207a_4d7b_b98f_ce165e1b2015);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics5_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, element: ::windows::core::RawPtr, value: super::FocusState, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, focusnavigationdirection: FocusNavigationDirection, focusnavigationoptions: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics6(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics6 {
type Vtable = IFocusManagerStatics6_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3546a1b6_20bf_5007_929d_e6d32e16afe4);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics6_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusManagerStatics7(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusManagerStatics7 {
type Vtable = IFocusManagerStatics7_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x95d6fa97_f0fc_5c32_b29d_07c04ec966b0);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusManagerStatics7_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, xamlroot: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IFocusMovementResult(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IFocusMovementResult {
type Vtable = IFocusMovementResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x06dfead3_c2ae_44bb_bfab_9c73de8407a4);
}
#[repr(C)]
#[doc(hidden)]
pub struct IFocusMovementResult_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IGettingFocusEventArgs {
type Vtable = IGettingFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfa05b9ce_c67c_4be8_8fd4_c44d67877e0d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::FocusState) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusNavigationDirection) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusInputDeviceKind) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IGettingFocusEventArgs2 {
type Vtable = IGettingFocusEventArgs2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x88754d7b_b4b9_4959_8bce_89bf212ed4eb);
}
#[repr(C)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, element: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IGettingFocusEventArgs3 {
type Vtable = IGettingFocusEventArgs3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4e024891_db3f_5e78_b75a_62bfc3510735);
}
#[repr(C)]
#[doc(hidden)]
pub struct IGettingFocusEventArgs3_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IHoldingRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IHoldingRoutedEventArgs {
type Vtable = IHoldingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc246ff23_d80d_44de_8db9_0d815e269ac0);
}
#[repr(C)]
#[doc(hidden)]
pub struct IHoldingRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
#[cfg(feature = "UI_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::HoldingState) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInertiaExpansionBehavior(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInertiaExpansionBehavior {
type Vtable = IInertiaExpansionBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x751d87e5_8d42_44c5_965e_3cd30cc9d6f7);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInertiaExpansionBehavior_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInertiaRotationBehavior(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInertiaRotationBehavior {
type Vtable = IInertiaRotationBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x424cfb2e_bbfd_4625_ae78_20c65bf1efaf);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInertiaRotationBehavior_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInertiaTranslationBehavior(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInertiaTranslationBehavior {
type Vtable = IInertiaTranslationBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x45d3a512_3b32_4882_a4c2_ecfa2d4b6df0);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInertiaTranslationBehavior_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInputScope(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInputScope {
type Vtable = IInputScope_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5c0f85f3_f9d8_4220_b666_045d074d9bfa);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInputScope_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInputScopeName(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInputScopeName {
type Vtable = IInputScopeName_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfd3e6997_08fb_4cba_a021_792d7589fd5a);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInputScopeName_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut InputScopeNameValue) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: InputScopeNameValue) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IInputScopeNameFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IInputScopeNameFactory {
type Vtable = IInputScopeNameFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4a40bb52_4bd7_4e54_8617_1cda8a1eda7f);
}
#[repr(C)]
#[doc(hidden)]
pub struct IInputScopeNameFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, namevalue: InputScopeNameValue, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyRoutedEventArgs {
type Vtable = IKeyRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd4cd3dfe_4079_42e9_a39a_3095d3f049c6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKey) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
#[cfg(feature = "UI_Core")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Core::CorePhysicalKeyStatus) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Core"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyRoutedEventArgs2 {
type Vtable = IKeyRoutedEventArgs2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1b02d57a_9634_4f14_91b2_133e42fdb3cd);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKey) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyRoutedEventArgs3 {
type Vtable = IKeyRoutedEventArgs3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2779f5b4_ca41_411b_a8ef_f4fc78e78057);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyRoutedEventArgs3_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyboardAccelerator(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyboardAccelerator {
type Vtable = IKeyboardAccelerator_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x92e6181e_19ae_465a_9b3c_a71ee9ea7420);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyboardAccelerator_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKey) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::super::System::VirtualKey) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKeyModifiers) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::super::System::VirtualKeyModifiers) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyboardAcceleratorFactory {
type Vtable = IKeyboardAcceleratorFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x44d88a99_4bfd_4a47_a893_515f388623f6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, baseinterface: ::windows::core::RawPtr, innerinterface: *mut ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorInvokedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyboardAcceleratorInvokedEventArgs {
type Vtable = IKeyboardAcceleratorInvokedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc00b03f2_04e7_4415_b17d_d76b9490de2b);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorInvokedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorInvokedEventArgs2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyboardAcceleratorInvokedEventArgs2 {
type Vtable = IKeyboardAcceleratorInvokedEventArgs2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xbefca4b8_5907_48ee_8e21_9c969078fa11);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorInvokedEventArgs2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IKeyboardAcceleratorStatics {
type Vtable = IKeyboardAcceleratorStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3bd43d51_9bb3_456d_bf15_804adfb86261);
}
#[repr(C)]
#[doc(hidden)]
pub struct IKeyboardAcceleratorStatics_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILosingFocusEventArgs {
type Vtable = ILosingFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf9f683c7_d789_472b_aa93_6d4105e6dabe);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::FocusState) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusNavigationDirection) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusInputDeviceKind) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILosingFocusEventArgs2 {
type Vtable = ILosingFocusEventArgs2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0493fad9_c27f_469f_8e62_52b3a4f7cd54);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, element: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILosingFocusEventArgs3 {
type Vtable = ILosingFocusEventArgs3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc98900bd_0b79_566e_ad1f_436fa513ae22);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILosingFocusEventArgs3_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationCompletedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationCompletedRoutedEventArgs {
type Vtable = IManipulationCompletedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb5ad9b23_2f41_498e_8319_015ee8a75346);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationCompletedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationVelocities) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationDeltaRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationDeltaRoutedEventArgs {
type Vtable = IManipulationDeltaRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x400d5794_4c6f_491d_82d6_3517109399c6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationDeltaRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationVelocities) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationInertiaStartingRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationInertiaStartingRoutedEventArgs {
type Vtable = IManipulationInertiaStartingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x246a91a9_ca43_4c0b_acef_81e8b8147520);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationInertiaStartingRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationVelocities) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationPivot(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationPivot {
type Vtable = IManipulationPivot_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2e3838a5_e6c2_4998_82ac_18748b141666);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationPivot_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut f64) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: f64) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationPivotFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationPivotFactory {
type Vtable = IManipulationPivotFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6d05b039_3702_4396_ad9b_a825efa63a3b);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationPivotFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, center: super::super::super::Foundation::Point, radius: f64, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationStartedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationStartedRoutedEventArgs {
type Vtable = IManipulationStartedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5db1aa05_9f80_48b6_ae6c_4f119de8ff13);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationStartedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
#[cfg(all(feature = "Foundation", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Input::ManipulationDelta) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "UI_Input")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationStartedRoutedEventArgsFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationStartedRoutedEventArgsFactory {
type Vtable = IManipulationStartedRoutedEventArgsFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x84c1daa7_7272_4463_b6c3_a40b9ba151fc);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationStartedRoutedEventArgsFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, baseinterface: ::windows::core::RawPtr, innerinterface: *mut ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IManipulationStartingRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IManipulationStartingRoutedEventArgs {
type Vtable = IManipulationStartingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x18d636b7_53a4_4c15_a498_f3a9ca212a42);
}
#[repr(C)]
#[doc(hidden)]
pub struct IManipulationStartingRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ManipulationModes) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ManipulationModes) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct INoFocusCandidateFoundEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for INoFocusCandidateFoundEventArgs {
type Vtable = INoFocusCandidateFoundEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xec3601a7_1007_48f9_b6b3_ed0bea53937d);
}
#[repr(C)]
#[doc(hidden)]
pub struct INoFocusCandidateFoundEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusNavigationDirection) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut FocusInputDeviceKind) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPointer(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPointer {
type Vtable = IPointer_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5ee8f39f_747d_4171_90e6_cd37a9dffb11);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPointer_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPointerRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPointerRoutedEventArgs {
type Vtable = IPointerRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xda628f0a_9752_49e2_bde2_49eccab9194d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPointerRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKeyModifiers) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "UI_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Input"))] usize,
#[cfg(all(feature = "Foundation_Collections", feature = "UI_Input"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation_Collections", feature = "UI_Input")))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPointerRoutedEventArgs2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPointerRoutedEventArgs2 {
type Vtable = IPointerRoutedEventArgs2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0821f294_1de6_4711_ba7c_8d4b8b0911d0);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPointerRoutedEventArgs2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IProcessKeyboardAcceleratorEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IProcessKeyboardAcceleratorEventArgs {
type Vtable = IProcessKeyboardAcceleratorEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfb79c216_972b_440c_9b83_2b4198dcf09d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IProcessKeyboardAcceleratorEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKey) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::System::VirtualKeyModifiers) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IRightTappedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IRightTappedRoutedEventArgs {
type Vtable = IRightTappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6834869d_7bd5_4033_b237_172f79abe393);
}
#[repr(C)]
#[doc(hidden)]
pub struct IRightTappedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IStandardUICommand(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IStandardUICommand {
type Vtable = IStandardUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd2bf7f43_0504_52d0_8aa6_0cb0f756eb27);
}
#[repr(C)]
#[doc(hidden)]
pub struct IStandardUICommand_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut StandardUICommandKind) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IStandardUICommand2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IStandardUICommand2 {
type Vtable = IStandardUICommand2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe3666069_f9e4_51eb_885b_7a620a0782ea);
}
#[repr(C)]
#[doc(hidden)]
pub struct IStandardUICommand2_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: StandardUICommandKind) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IStandardUICommandFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IStandardUICommandFactory {
type Vtable = IStandardUICommandFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8f1a7590_dce1_56e4_ab63_f5ce3ce4ebf6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IStandardUICommandFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, baseinterface: ::windows::core::RawPtr, innerinterface: *mut ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, kind: StandardUICommandKind, baseinterface: ::windows::core::RawPtr, innerinterface: *mut ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IStandardUICommandStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IStandardUICommandStatics {
type Vtable = IStandardUICommandStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7ea87ed9_2978_5533_9b2e_6759ce88569f);
}
#[repr(C)]
#[doc(hidden)]
pub struct IStandardUICommandStatics_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ITappedRoutedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ITappedRoutedEventArgs {
type Vtable = ITappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa099e6be_e624_459a_bb1d_e05c73e2cc66);
}
#[repr(C)]
#[doc(hidden)]
pub struct ITappedRoutedEventArgs_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Devices_Input")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::super::Devices::Input::PointerDeviceType) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Devices_Input"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, relativeto: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::Point) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IXamlUICommand(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IXamlUICommand {
type Vtable = IXamlUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8494f8d4_ead1_5f01_ad2e_a8cad4f9dc0e);
}
#[repr(C)]
#[doc(hidden)]
pub struct IXamlUICommand_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
#[cfg(feature = "UI_Xaml_Controls")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Xaml_Controls"))] usize,
#[cfg(feature = "UI_Xaml_Controls")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI_Xaml_Controls"))] usize,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, token: super::super::super::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IXamlUICommandFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IXamlUICommandFactory {
type Vtable = IXamlUICommandFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1eec08c3_e061_5e10_9f2a_2baa840885c2);
}
#[repr(C)]
#[doc(hidden)]
pub struct IXamlUICommandFactory_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, baseinterface: ::windows::core::RawPtr, innerinterface: *mut ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IXamlUICommandStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IXamlUICommandStatics {
type Vtable = IXamlUICommandStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x66bc457c_1a0c_58ed_876e_71533f966db6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IXamlUICommandStatics_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, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct InertiaExpansionBehavior(pub ::windows::core::IInspectable);
impl InertiaExpansionBehavior {
pub fn DesiredDeceleration(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredDeceleration(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn DesiredExpansion(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredExpansion(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for InertiaExpansionBehavior {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.InertiaExpansionBehavior;{751d87e5-8d42-44c5-965e-3cd30cc9d6f7})");
}
unsafe impl ::windows::core::Interface for InertiaExpansionBehavior {
type Vtable = IInertiaExpansionBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x751d87e5_8d42_44c5_965e_3cd30cc9d6f7);
}
impl ::windows::core::RuntimeName for InertiaExpansionBehavior {
const NAME: &'static str = "Windows.UI.Xaml.Input.InertiaExpansionBehavior";
}
impl ::core::convert::From<InertiaExpansionBehavior> for ::windows::core::IUnknown {
fn from(value: InertiaExpansionBehavior) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&InertiaExpansionBehavior> for ::windows::core::IUnknown {
fn from(value: &InertiaExpansionBehavior) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for InertiaExpansionBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a InertiaExpansionBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<InertiaExpansionBehavior> for ::windows::core::IInspectable {
fn from(value: InertiaExpansionBehavior) -> Self {
value.0
}
}
impl ::core::convert::From<&InertiaExpansionBehavior> for ::windows::core::IInspectable {
fn from(value: &InertiaExpansionBehavior) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for InertiaExpansionBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a InertiaExpansionBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for InertiaExpansionBehavior {}
unsafe impl ::core::marker::Sync for InertiaExpansionBehavior {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct InertiaRotationBehavior(pub ::windows::core::IInspectable);
impl InertiaRotationBehavior {
pub fn DesiredDeceleration(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredDeceleration(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn DesiredRotation(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredRotation(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for InertiaRotationBehavior {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.InertiaRotationBehavior;{424cfb2e-bbfd-4625-ae78-20c65bf1efaf})");
}
unsafe impl ::windows::core::Interface for InertiaRotationBehavior {
type Vtable = IInertiaRotationBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x424cfb2e_bbfd_4625_ae78_20c65bf1efaf);
}
impl ::windows::core::RuntimeName for InertiaRotationBehavior {
const NAME: &'static str = "Windows.UI.Xaml.Input.InertiaRotationBehavior";
}
impl ::core::convert::From<InertiaRotationBehavior> for ::windows::core::IUnknown {
fn from(value: InertiaRotationBehavior) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&InertiaRotationBehavior> for ::windows::core::IUnknown {
fn from(value: &InertiaRotationBehavior) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for InertiaRotationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a InertiaRotationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<InertiaRotationBehavior> for ::windows::core::IInspectable {
fn from(value: InertiaRotationBehavior) -> Self {
value.0
}
}
impl ::core::convert::From<&InertiaRotationBehavior> for ::windows::core::IInspectable {
fn from(value: &InertiaRotationBehavior) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for InertiaRotationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a InertiaRotationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for InertiaRotationBehavior {}
unsafe impl ::core::marker::Sync for InertiaRotationBehavior {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct InertiaTranslationBehavior(pub ::windows::core::IInspectable);
impl InertiaTranslationBehavior {
pub fn DesiredDeceleration(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredDeceleration(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn DesiredDisplacement(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetDesiredDisplacement(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for InertiaTranslationBehavior {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.InertiaTranslationBehavior;{45d3a512-3b32-4882-a4c2-ecfa2d4b6df0})");
}
unsafe impl ::windows::core::Interface for InertiaTranslationBehavior {
type Vtable = IInertiaTranslationBehavior_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x45d3a512_3b32_4882_a4c2_ecfa2d4b6df0);
}
impl ::windows::core::RuntimeName for InertiaTranslationBehavior {
const NAME: &'static str = "Windows.UI.Xaml.Input.InertiaTranslationBehavior";
}
impl ::core::convert::From<InertiaTranslationBehavior> for ::windows::core::IUnknown {
fn from(value: InertiaTranslationBehavior) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&InertiaTranslationBehavior> for ::windows::core::IUnknown {
fn from(value: &InertiaTranslationBehavior) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for InertiaTranslationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a InertiaTranslationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<InertiaTranslationBehavior> for ::windows::core::IInspectable {
fn from(value: InertiaTranslationBehavior) -> Self {
value.0
}
}
impl ::core::convert::From<&InertiaTranslationBehavior> for ::windows::core::IInspectable {
fn from(value: &InertiaTranslationBehavior) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for InertiaTranslationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a InertiaTranslationBehavior {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for InertiaTranslationBehavior {}
unsafe impl ::core::marker::Sync for InertiaTranslationBehavior {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct InputScope(pub ::windows::core::IInspectable);
impl InputScope {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<InputScope, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Foundation_Collections")]
pub fn Names(&self) -> ::windows::core::Result<super::super::super::Foundation::Collections::IVector<InputScopeName>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Collections::IVector<InputScopeName>>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for InputScope {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.InputScope;{5c0f85f3-f9d8-4220-b666-045d074d9bfa})");
}
unsafe impl ::windows::core::Interface for InputScope {
type Vtable = IInputScope_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5c0f85f3_f9d8_4220_b666_045d074d9bfa);
}
impl ::windows::core::RuntimeName for InputScope {
const NAME: &'static str = "Windows.UI.Xaml.Input.InputScope";
}
impl ::core::convert::From<InputScope> for ::windows::core::IUnknown {
fn from(value: InputScope) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&InputScope> for ::windows::core::IUnknown {
fn from(value: &InputScope) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for InputScope {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a InputScope {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<InputScope> for ::windows::core::IInspectable {
fn from(value: InputScope) -> Self {
value.0
}
}
impl ::core::convert::From<&InputScope> for ::windows::core::IInspectable {
fn from(value: &InputScope) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for InputScope {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a InputScope {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<InputScope> for super::DependencyObject {
fn from(value: InputScope) -> Self {
::core::convert::Into::<super::DependencyObject>::into(&value)
}
}
impl ::core::convert::From<&InputScope> for super::DependencyObject {
fn from(value: &InputScope) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for InputScope {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for &InputScope {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for InputScope {}
unsafe impl ::core::marker::Sync for InputScope {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct InputScopeName(pub ::windows::core::IInspectable);
impl InputScopeName {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<InputScopeName, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn NameValue(&self) -> ::windows::core::Result<InputScopeNameValue> {
let this = self;
unsafe {
let mut result__: InputScopeNameValue = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<InputScopeNameValue>(result__)
}
}
pub fn SetNameValue(&self, value: InputScopeNameValue) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn CreateInstance(namevalue: InputScopeNameValue) -> ::windows::core::Result<InputScopeName> {
Self::IInputScopeNameFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), namevalue, &mut result__).from_abi::<InputScopeName>(result__)
})
}
pub fn IInputScopeNameFactory<R, F: FnOnce(&IInputScopeNameFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<InputScopeName, IInputScopeNameFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for InputScopeName {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.InputScopeName;{fd3e6997-08fb-4cba-a021-792d7589fd5a})");
}
unsafe impl ::windows::core::Interface for InputScopeName {
type Vtable = IInputScopeName_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfd3e6997_08fb_4cba_a021_792d7589fd5a);
}
impl ::windows::core::RuntimeName for InputScopeName {
const NAME: &'static str = "Windows.UI.Xaml.Input.InputScopeName";
}
impl ::core::convert::From<InputScopeName> for ::windows::core::IUnknown {
fn from(value: InputScopeName) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&InputScopeName> for ::windows::core::IUnknown {
fn from(value: &InputScopeName) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<InputScopeName> for ::windows::core::IInspectable {
fn from(value: InputScopeName) -> Self {
value.0
}
}
impl ::core::convert::From<&InputScopeName> for ::windows::core::IInspectable {
fn from(value: &InputScopeName) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<InputScopeName> for super::DependencyObject {
fn from(value: InputScopeName) -> Self {
::core::convert::Into::<super::DependencyObject>::into(&value)
}
}
impl ::core::convert::From<&InputScopeName> for super::DependencyObject {
fn from(value: &InputScopeName) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for &InputScopeName {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for InputScopeName {}
unsafe impl ::core::marker::Sync for InputScopeName {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct InputScopeNameValue(pub i32);
impl InputScopeNameValue {
pub const Default: InputScopeNameValue = InputScopeNameValue(0i32);
pub const Url: InputScopeNameValue = InputScopeNameValue(1i32);
pub const EmailSmtpAddress: InputScopeNameValue = InputScopeNameValue(5i32);
pub const PersonalFullName: InputScopeNameValue = InputScopeNameValue(7i32);
pub const CurrencyAmountAndSymbol: InputScopeNameValue = InputScopeNameValue(20i32);
pub const CurrencyAmount: InputScopeNameValue = InputScopeNameValue(21i32);
pub const DateMonthNumber: InputScopeNameValue = InputScopeNameValue(23i32);
pub const DateDayNumber: InputScopeNameValue = InputScopeNameValue(24i32);
pub const DateYear: InputScopeNameValue = InputScopeNameValue(25i32);
pub const Digits: InputScopeNameValue = InputScopeNameValue(28i32);
pub const Number: InputScopeNameValue = InputScopeNameValue(29i32);
pub const Password: InputScopeNameValue = InputScopeNameValue(31i32);
pub const TelephoneNumber: InputScopeNameValue = InputScopeNameValue(32i32);
pub const TelephoneCountryCode: InputScopeNameValue = InputScopeNameValue(33i32);
pub const TelephoneAreaCode: InputScopeNameValue = InputScopeNameValue(34i32);
pub const TelephoneLocalNumber: InputScopeNameValue = InputScopeNameValue(35i32);
pub const TimeHour: InputScopeNameValue = InputScopeNameValue(37i32);
pub const TimeMinutesOrSeconds: InputScopeNameValue = InputScopeNameValue(38i32);
pub const NumberFullWidth: InputScopeNameValue = InputScopeNameValue(39i32);
pub const AlphanumericHalfWidth: InputScopeNameValue = InputScopeNameValue(40i32);
pub const AlphanumericFullWidth: InputScopeNameValue = InputScopeNameValue(41i32);
pub const Hiragana: InputScopeNameValue = InputScopeNameValue(44i32);
pub const KatakanaHalfWidth: InputScopeNameValue = InputScopeNameValue(45i32);
pub const KatakanaFullWidth: InputScopeNameValue = InputScopeNameValue(46i32);
pub const Hanja: InputScopeNameValue = InputScopeNameValue(47i32);
pub const HangulHalfWidth: InputScopeNameValue = InputScopeNameValue(48i32);
pub const HangulFullWidth: InputScopeNameValue = InputScopeNameValue(49i32);
pub const Search: InputScopeNameValue = InputScopeNameValue(50i32);
pub const Formula: InputScopeNameValue = InputScopeNameValue(51i32);
pub const SearchIncremental: InputScopeNameValue = InputScopeNameValue(52i32);
pub const ChineseHalfWidth: InputScopeNameValue = InputScopeNameValue(53i32);
pub const ChineseFullWidth: InputScopeNameValue = InputScopeNameValue(54i32);
pub const NativeScript: InputScopeNameValue = InputScopeNameValue(55i32);
pub const Text: InputScopeNameValue = InputScopeNameValue(57i32);
pub const Chat: InputScopeNameValue = InputScopeNameValue(58i32);
pub const NameOrPhoneNumber: InputScopeNameValue = InputScopeNameValue(59i32);
pub const EmailNameOrAddress: InputScopeNameValue = InputScopeNameValue(60i32);
pub const Private: InputScopeNameValue = InputScopeNameValue(61i32);
pub const Maps: InputScopeNameValue = InputScopeNameValue(62i32);
pub const NumericPassword: InputScopeNameValue = InputScopeNameValue(63i32);
pub const NumericPin: InputScopeNameValue = InputScopeNameValue(64i32);
pub const AlphanumericPin: InputScopeNameValue = InputScopeNameValue(65i32);
pub const FormulaNumber: InputScopeNameValue = InputScopeNameValue(67i32);
pub const ChatWithoutEmoji: InputScopeNameValue = InputScopeNameValue(68i32);
}
impl ::core::convert::From<i32> for InputScopeNameValue {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for InputScopeNameValue {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for InputScopeNameValue {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.InputScopeNameValue;i4)");
}
impl ::windows::core::DefaultType for InputScopeNameValue {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct KeyEventHandler(::windows::core::IUnknown);
impl KeyEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<KeyRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = KeyEventHandler_box::<F> {
vtable: &KeyEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, KeyRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for KeyEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({7c63d2e5-7a0e-4e12-b96a-7715aa6ff1c8})");
}
unsafe impl ::windows::core::Interface for KeyEventHandler {
type Vtable = KeyEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7c63d2e5_7a0e_4e12_b96a_7715aa6ff1c8);
}
#[repr(C)]
#[doc(hidden)]
pub struct KeyEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct KeyEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<KeyRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const KeyEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<KeyRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> KeyEventHandler_box<F> {
const VTABLE: KeyEventHandler_abi = KeyEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<KeyEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <KeyRoutedEventArgs as ::windows::core::Abi>::Abi as *const <KeyRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct KeyRoutedEventArgs(pub ::windows::core::IInspectable);
impl KeyRoutedEventArgs {
#[cfg(feature = "System")]
pub fn Key(&self) -> ::windows::core::Result<super::super::super::System::VirtualKey> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKey = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKey>(result__)
}
}
#[cfg(feature = "UI_Core")]
pub fn KeyStatus(&self) -> ::windows::core::Result<super::super::Core::CorePhysicalKeyStatus> {
let this = self;
unsafe {
let mut result__: super::super::Core::CorePhysicalKeyStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Core::CorePhysicalKeyStatus>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "System")]
pub fn OriginalKey(&self) -> ::windows::core::Result<super::super::super::System::VirtualKey> {
let this = &::windows::core::Interface::cast::<IKeyRoutedEventArgs2>(self)?;
unsafe {
let mut result__: super::super::super::System::VirtualKey = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKey>(result__)
}
}
pub fn DeviceId(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = &::windows::core::Interface::cast::<IKeyRoutedEventArgs3>(self)?;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for KeyRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.KeyRoutedEventArgs;{d4cd3dfe-4079-42e9-a39a-3095d3f049c6})");
}
unsafe impl ::windows::core::Interface for KeyRoutedEventArgs {
type Vtable = IKeyRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd4cd3dfe_4079_42e9_a39a_3095d3f049c6);
}
impl ::windows::core::RuntimeName for KeyRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.KeyRoutedEventArgs";
}
impl ::core::convert::From<KeyRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: KeyRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&KeyRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &KeyRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<KeyRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: KeyRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&KeyRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &KeyRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<KeyRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: KeyRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&KeyRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &KeyRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &KeyRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for KeyRoutedEventArgs {}
unsafe impl ::core::marker::Sync for KeyRoutedEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct KeyTipPlacementMode(pub i32);
impl KeyTipPlacementMode {
pub const Auto: KeyTipPlacementMode = KeyTipPlacementMode(0i32);
pub const Bottom: KeyTipPlacementMode = KeyTipPlacementMode(1i32);
pub const Top: KeyTipPlacementMode = KeyTipPlacementMode(2i32);
pub const Left: KeyTipPlacementMode = KeyTipPlacementMode(3i32);
pub const Right: KeyTipPlacementMode = KeyTipPlacementMode(4i32);
pub const Center: KeyTipPlacementMode = KeyTipPlacementMode(5i32);
pub const Hidden: KeyTipPlacementMode = KeyTipPlacementMode(6i32);
}
impl ::core::convert::From<i32> for KeyTipPlacementMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for KeyTipPlacementMode {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for KeyTipPlacementMode {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.KeyTipPlacementMode;i4)");
}
impl ::windows::core::DefaultType for KeyTipPlacementMode {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct KeyboardAccelerator(pub ::windows::core::IInspectable);
impl KeyboardAccelerator {
#[cfg(feature = "System")]
pub fn Key(&self) -> ::windows::core::Result<super::super::super::System::VirtualKey> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKey = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKey>(result__)
}
}
#[cfg(feature = "System")]
pub fn SetKey(&self, value: super::super::super::System::VirtualKey) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "System")]
pub fn Modifiers(&self) -> ::windows::core::Result<super::super::super::System::VirtualKeyModifiers> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKeyModifiers = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKeyModifiers>(result__)
}
}
#[cfg(feature = "System")]
pub fn SetModifiers(&self, value: super::super::super::System::VirtualKeyModifiers) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsEnabled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsEnabled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn ScopeOwner(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn SetScopeOwner<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn Invoked<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::TypedEventHandler<KeyboardAccelerator, KeyboardAcceleratorInvokedEventArgs>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveInvoked<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn KeyProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IKeyboardAcceleratorStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn ModifiersProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IKeyboardAcceleratorStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn IsEnabledProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IKeyboardAcceleratorStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn ScopeOwnerProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IKeyboardAcceleratorStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn new() -> ::windows::core::Result<KeyboardAccelerator> {
Self::IKeyboardAcceleratorFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, &mut result__).from_abi::<KeyboardAccelerator>(result__)
})
}
pub fn IKeyboardAcceleratorStatics<R, F: FnOnce(&IKeyboardAcceleratorStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<KeyboardAccelerator, IKeyboardAcceleratorStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IKeyboardAcceleratorFactory<R, F: FnOnce(&IKeyboardAcceleratorFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<KeyboardAccelerator, IKeyboardAcceleratorFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for KeyboardAccelerator {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.KeyboardAccelerator;{92e6181e-19ae-465a-9b3c-a71ee9ea7420})");
}
unsafe impl ::windows::core::Interface for KeyboardAccelerator {
type Vtable = IKeyboardAccelerator_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x92e6181e_19ae_465a_9b3c_a71ee9ea7420);
}
impl ::windows::core::RuntimeName for KeyboardAccelerator {
const NAME: &'static str = "Windows.UI.Xaml.Input.KeyboardAccelerator";
}
impl ::core::convert::From<KeyboardAccelerator> for ::windows::core::IUnknown {
fn from(value: KeyboardAccelerator) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&KeyboardAccelerator> for ::windows::core::IUnknown {
fn from(value: &KeyboardAccelerator) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<KeyboardAccelerator> for ::windows::core::IInspectable {
fn from(value: KeyboardAccelerator) -> Self {
value.0
}
}
impl ::core::convert::From<&KeyboardAccelerator> for ::windows::core::IInspectable {
fn from(value: &KeyboardAccelerator) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<KeyboardAccelerator> for super::DependencyObject {
fn from(value: KeyboardAccelerator) -> Self {
::core::convert::Into::<super::DependencyObject>::into(&value)
}
}
impl ::core::convert::From<&KeyboardAccelerator> for super::DependencyObject {
fn from(value: &KeyboardAccelerator) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for &KeyboardAccelerator {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for KeyboardAccelerator {}
unsafe impl ::core::marker::Sync for KeyboardAccelerator {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct KeyboardAcceleratorInvokedEventArgs(pub ::windows::core::IInspectable);
impl KeyboardAcceleratorInvokedEventArgs {
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Element(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn KeyboardAccelerator(&self) -> ::windows::core::Result<KeyboardAccelerator> {
let this = &::windows::core::Interface::cast::<IKeyboardAcceleratorInvokedEventArgs2>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<KeyboardAccelerator>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for KeyboardAcceleratorInvokedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.KeyboardAcceleratorInvokedEventArgs;{c00b03f2-04e7-4415-b17d-d76b9490de2b})");
}
unsafe impl ::windows::core::Interface for KeyboardAcceleratorInvokedEventArgs {
type Vtable = IKeyboardAcceleratorInvokedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc00b03f2_04e7_4415_b17d_d76b9490de2b);
}
impl ::windows::core::RuntimeName for KeyboardAcceleratorInvokedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.KeyboardAcceleratorInvokedEventArgs";
}
impl ::core::convert::From<KeyboardAcceleratorInvokedEventArgs> for ::windows::core::IUnknown {
fn from(value: KeyboardAcceleratorInvokedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&KeyboardAcceleratorInvokedEventArgs> for ::windows::core::IUnknown {
fn from(value: &KeyboardAcceleratorInvokedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for KeyboardAcceleratorInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a KeyboardAcceleratorInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<KeyboardAcceleratorInvokedEventArgs> for ::windows::core::IInspectable {
fn from(value: KeyboardAcceleratorInvokedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&KeyboardAcceleratorInvokedEventArgs> for ::windows::core::IInspectable {
fn from(value: &KeyboardAcceleratorInvokedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for KeyboardAcceleratorInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a KeyboardAcceleratorInvokedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for KeyboardAcceleratorInvokedEventArgs {}
unsafe impl ::core::marker::Sync for KeyboardAcceleratorInvokedEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct KeyboardAcceleratorPlacementMode(pub i32);
impl KeyboardAcceleratorPlacementMode {
pub const Auto: KeyboardAcceleratorPlacementMode = KeyboardAcceleratorPlacementMode(0i32);
pub const Hidden: KeyboardAcceleratorPlacementMode = KeyboardAcceleratorPlacementMode(1i32);
}
impl ::core::convert::From<i32> for KeyboardAcceleratorPlacementMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for KeyboardAcceleratorPlacementMode {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for KeyboardAcceleratorPlacementMode {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.KeyboardAcceleratorPlacementMode;i4)");
}
impl ::windows::core::DefaultType for KeyboardAcceleratorPlacementMode {
type DefaultType = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct KeyboardNavigationMode(pub i32);
impl KeyboardNavigationMode {
pub const Local: KeyboardNavigationMode = KeyboardNavigationMode(0i32);
pub const Cycle: KeyboardNavigationMode = KeyboardNavigationMode(1i32);
pub const Once: KeyboardNavigationMode = KeyboardNavigationMode(2i32);
}
impl ::core::convert::From<i32> for KeyboardNavigationMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for KeyboardNavigationMode {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for KeyboardNavigationMode {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.KeyboardNavigationMode;i4)");
}
impl ::windows::core::DefaultType for KeyboardNavigationMode {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct LosingFocusEventArgs(pub ::windows::core::IInspectable);
impl LosingFocusEventArgs {
pub fn OldFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn NewFocusedElement(&self) -> ::windows::core::Result<super::DependencyObject> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyObject>(result__)
}
}
pub fn SetNewFocusedElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn FocusState(&self) -> ::windows::core::Result<super::FocusState> {
let this = self;
unsafe {
let mut result__: super::FocusState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::FocusState>(result__)
}
}
pub fn Direction(&self) -> ::windows::core::Result<FocusNavigationDirection> {
let this = self;
unsafe {
let mut result__: FocusNavigationDirection = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusNavigationDirection>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn InputDevice(&self) -> ::windows::core::Result<FocusInputDeviceKind> {
let this = self;
unsafe {
let mut result__: FocusInputDeviceKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusInputDeviceKind>(result__)
}
}
pub fn Cancel(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetCancel(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn TryCancel(&self) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<ILosingFocusEventArgs2>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn TrySetNewFocusedElement<'a, Param0: ::windows::core::IntoParam<'a, super::DependencyObject>>(&self, element: Param0) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<ILosingFocusEventArgs2>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), element.into_param().abi(), &mut result__).from_abi::<bool>(result__)
}
}
pub fn CorrelationId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = &::windows::core::Interface::cast::<ILosingFocusEventArgs3>(self)?;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for LosingFocusEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.LosingFocusEventArgs;{f9f683c7-d789-472b-aa93-6d4105e6dabe})");
}
unsafe impl ::windows::core::Interface for LosingFocusEventArgs {
type Vtable = ILosingFocusEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf9f683c7_d789_472b_aa93_6d4105e6dabe);
}
impl ::windows::core::RuntimeName for LosingFocusEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.LosingFocusEventArgs";
}
impl ::core::convert::From<LosingFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: LosingFocusEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&LosingFocusEventArgs> for ::windows::core::IUnknown {
fn from(value: &LosingFocusEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<LosingFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: LosingFocusEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&LosingFocusEventArgs> for ::windows::core::IInspectable {
fn from(value: &LosingFocusEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<LosingFocusEventArgs> for super::RoutedEventArgs {
fn from(value: LosingFocusEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&LosingFocusEventArgs> for super::RoutedEventArgs {
fn from(value: &LosingFocusEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &LosingFocusEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for LosingFocusEventArgs {}
unsafe impl ::core::marker::Sync for LosingFocusEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationCompletedEventHandler(::windows::core::IUnknown);
impl ManipulationCompletedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationCompletedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = ManipulationCompletedEventHandler_box::<F> {
vtable: &ManipulationCompletedEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ManipulationCompletedRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationCompletedEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({38ef4b0f-14f8-42df-9a1e-a4bcc4af77f4})");
}
unsafe impl ::windows::core::Interface for ManipulationCompletedEventHandler {
type Vtable = ManipulationCompletedEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x38ef4b0f_14f8_42df_9a1e_a4bcc4af77f4);
}
#[repr(C)]
#[doc(hidden)]
pub struct ManipulationCompletedEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct ManipulationCompletedEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationCompletedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const ManipulationCompletedEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationCompletedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> ManipulationCompletedEventHandler_box<F> {
const VTABLE: ManipulationCompletedEventHandler_abi = ManipulationCompletedEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<ManipulationCompletedEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <ManipulationCompletedRoutedEventArgs as ::windows::core::Abi>::Abi as *const <ManipulationCompletedRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationCompletedRoutedEventArgs(pub ::windows::core::IInspectable);
impl ManipulationCompletedRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationCompletedRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Container(&self) -> ::windows::core::Result<super::UIElement> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::UIElement>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn Position(&self) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
pub fn IsInertial(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Cumulative(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Velocities(&self) -> ::windows::core::Result<super::super::Input::ManipulationVelocities> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationVelocities = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationVelocities>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationCompletedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationCompletedRoutedEventArgs;{b5ad9b23-2f41-498e-8319-015ee8a75346})");
}
unsafe impl ::windows::core::Interface for ManipulationCompletedRoutedEventArgs {
type Vtable = IManipulationCompletedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb5ad9b23_2f41_498e_8319_015ee8a75346);
}
impl ::windows::core::RuntimeName for ManipulationCompletedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationCompletedRoutedEventArgs";
}
impl ::core::convert::From<ManipulationCompletedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: ManipulationCompletedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationCompletedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ManipulationCompletedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationCompletedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: ManipulationCompletedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationCompletedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ManipulationCompletedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ManipulationCompletedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: ManipulationCompletedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ManipulationCompletedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &ManipulationCompletedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ManipulationCompletedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ManipulationCompletedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for ManipulationCompletedRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationDeltaEventHandler(::windows::core::IUnknown);
impl ManipulationDeltaEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationDeltaRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = ManipulationDeltaEventHandler_box::<F> {
vtable: &ManipulationDeltaEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ManipulationDeltaRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationDeltaEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({aa1160cb-dfb9-4c56-abdc-711b63c8eb94})");
}
unsafe impl ::windows::core::Interface for ManipulationDeltaEventHandler {
type Vtable = ManipulationDeltaEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xaa1160cb_dfb9_4c56_abdc_711b63c8eb94);
}
#[repr(C)]
#[doc(hidden)]
pub struct ManipulationDeltaEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct ManipulationDeltaEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationDeltaRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const ManipulationDeltaEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationDeltaRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> ManipulationDeltaEventHandler_box<F> {
const VTABLE: ManipulationDeltaEventHandler_abi = ManipulationDeltaEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<ManipulationDeltaEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <ManipulationDeltaRoutedEventArgs as ::windows::core::Abi>::Abi as *const <ManipulationDeltaRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationDeltaRoutedEventArgs(pub ::windows::core::IInspectable);
impl ManipulationDeltaRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationDeltaRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Container(&self) -> ::windows::core::Result<super::UIElement> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::UIElement>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn Position(&self) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
pub fn IsInertial(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Delta(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Cumulative(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Velocities(&self) -> ::windows::core::Result<super::super::Input::ManipulationVelocities> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationVelocities = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationVelocities>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
pub fn Complete(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this)).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationDeltaRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs;{400d5794-4c6f-491d-82d6-3517109399c6})");
}
unsafe impl ::windows::core::Interface for ManipulationDeltaRoutedEventArgs {
type Vtable = IManipulationDeltaRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x400d5794_4c6f_491d_82d6_3517109399c6);
}
impl ::windows::core::RuntimeName for ManipulationDeltaRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationDeltaRoutedEventArgs";
}
impl ::core::convert::From<ManipulationDeltaRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: ManipulationDeltaRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationDeltaRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ManipulationDeltaRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationDeltaRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: ManipulationDeltaRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationDeltaRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ManipulationDeltaRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ManipulationDeltaRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: ManipulationDeltaRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ManipulationDeltaRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &ManipulationDeltaRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ManipulationDeltaRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ManipulationDeltaRoutedEventArgs {}
unsafe impl ::core::marker::Sync for ManipulationDeltaRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationInertiaStartingEventHandler(::windows::core::IUnknown);
impl ManipulationInertiaStartingEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationInertiaStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = ManipulationInertiaStartingEventHandler_box::<F> {
vtable: &ManipulationInertiaStartingEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ManipulationInertiaStartingRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationInertiaStartingEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({d39d6322-7c9c-481b-827b-c8b2d9bb6fc7})");
}
unsafe impl ::windows::core::Interface for ManipulationInertiaStartingEventHandler {
type Vtable = ManipulationInertiaStartingEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd39d6322_7c9c_481b_827b_c8b2d9bb6fc7);
}
#[repr(C)]
#[doc(hidden)]
pub struct ManipulationInertiaStartingEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct ManipulationInertiaStartingEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationInertiaStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const ManipulationInertiaStartingEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationInertiaStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> ManipulationInertiaStartingEventHandler_box<F> {
const VTABLE: ManipulationInertiaStartingEventHandler_abi = ManipulationInertiaStartingEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<ManipulationInertiaStartingEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <ManipulationInertiaStartingRoutedEventArgs as ::windows::core::Abi>::Abi as *const <ManipulationInertiaStartingRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationInertiaStartingRoutedEventArgs(pub ::windows::core::IInspectable);
impl ManipulationInertiaStartingRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationInertiaStartingRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Container(&self) -> ::windows::core::Result<super::UIElement> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::UIElement>(result__)
}
}
pub fn ExpansionBehavior(&self) -> ::windows::core::Result<InertiaExpansionBehavior> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<InertiaExpansionBehavior>(result__)
}
}
pub fn SetExpansionBehavior<'a, Param0: ::windows::core::IntoParam<'a, InertiaExpansionBehavior>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn RotationBehavior(&self) -> ::windows::core::Result<InertiaRotationBehavior> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<InertiaRotationBehavior>(result__)
}
}
pub fn SetRotationBehavior<'a, Param0: ::windows::core::IntoParam<'a, InertiaRotationBehavior>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn TranslationBehavior(&self) -> ::windows::core::Result<InertiaTranslationBehavior> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<InertiaTranslationBehavior>(result__)
}
}
pub fn SetTranslationBehavior<'a, Param0: ::windows::core::IntoParam<'a, InertiaTranslationBehavior>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Delta(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Cumulative(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Velocities(&self) -> ::windows::core::Result<super::super::Input::ManipulationVelocities> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationVelocities = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationVelocities>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationInertiaStartingRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationInertiaStartingRoutedEventArgs;{246a91a9-ca43-4c0b-acef-81e8b8147520})");
}
unsafe impl ::windows::core::Interface for ManipulationInertiaStartingRoutedEventArgs {
type Vtable = IManipulationInertiaStartingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x246a91a9_ca43_4c0b_acef_81e8b8147520);
}
impl ::windows::core::RuntimeName for ManipulationInertiaStartingRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationInertiaStartingRoutedEventArgs";
}
impl ::core::convert::From<ManipulationInertiaStartingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: ManipulationInertiaStartingRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationInertiaStartingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ManipulationInertiaStartingRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationInertiaStartingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: ManipulationInertiaStartingRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationInertiaStartingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ManipulationInertiaStartingRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ManipulationInertiaStartingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: ManipulationInertiaStartingRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ManipulationInertiaStartingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &ManipulationInertiaStartingRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ManipulationInertiaStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ManipulationInertiaStartingRoutedEventArgs {}
unsafe impl ::core::marker::Sync for ManipulationInertiaStartingRoutedEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct ManipulationModes(pub u32);
impl ManipulationModes {
pub const None: ManipulationModes = ManipulationModes(0u32);
pub const TranslateX: ManipulationModes = ManipulationModes(1u32);
pub const TranslateY: ManipulationModes = ManipulationModes(2u32);
pub const TranslateRailsX: ManipulationModes = ManipulationModes(4u32);
pub const TranslateRailsY: ManipulationModes = ManipulationModes(8u32);
pub const Rotate: ManipulationModes = ManipulationModes(16u32);
pub const Scale: ManipulationModes = ManipulationModes(32u32);
pub const TranslateInertia: ManipulationModes = ManipulationModes(64u32);
pub const RotateInertia: ManipulationModes = ManipulationModes(128u32);
pub const ScaleInertia: ManipulationModes = ManipulationModes(256u32);
pub const All: ManipulationModes = ManipulationModes(65535u32);
pub const System: ManipulationModes = ManipulationModes(65536u32);
}
impl ::core::convert::From<u32> for ManipulationModes {
fn from(value: u32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for ManipulationModes {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for ManipulationModes {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.ManipulationModes;u4)");
}
impl ::windows::core::DefaultType for ManipulationModes {
type DefaultType = Self;
}
impl ::core::ops::BitOr for ManipulationModes {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ::core::ops::BitAnd for ManipulationModes {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl ::core::ops::BitOrAssign for ManipulationModes {
fn bitor_assign(&mut self, rhs: Self) {
self.0.bitor_assign(rhs.0)
}
}
impl ::core::ops::BitAndAssign for ManipulationModes {
fn bitand_assign(&mut self, rhs: Self) {
self.0.bitand_assign(rhs.0)
}
}
impl ::core::ops::Not for ManipulationModes {
type Output = Self;
fn not(self) -> Self {
Self(self.0.not())
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationPivot(pub ::windows::core::IInspectable);
impl ManipulationPivot {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationPivot, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Foundation")]
pub fn Center(&self) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetCenter<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::Point>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Radius(&self) -> ::windows::core::Result<f64> {
let this = self;
unsafe {
let mut result__: f64 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<f64>(result__)
}
}
pub fn SetRadius(&self, value: f64) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn CreateInstanceWithCenterAndRadius<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::Point>>(center: Param0, radius: f64) -> ::windows::core::Result<ManipulationPivot> {
Self::IManipulationPivotFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), center.into_param().abi(), radius, &mut result__).from_abi::<ManipulationPivot>(result__)
})
}
pub fn IManipulationPivotFactory<R, F: FnOnce(&IManipulationPivotFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationPivot, IManipulationPivotFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationPivot {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationPivot;{2e3838a5-e6c2-4998-82ac-18748b141666})");
}
unsafe impl ::windows::core::Interface for ManipulationPivot {
type Vtable = IManipulationPivot_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2e3838a5_e6c2_4998_82ac_18748b141666);
}
impl ::windows::core::RuntimeName for ManipulationPivot {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationPivot";
}
impl ::core::convert::From<ManipulationPivot> for ::windows::core::IUnknown {
fn from(value: ManipulationPivot) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationPivot> for ::windows::core::IUnknown {
fn from(value: &ManipulationPivot) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationPivot {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationPivot {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationPivot> for ::windows::core::IInspectable {
fn from(value: ManipulationPivot) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationPivot> for ::windows::core::IInspectable {
fn from(value: &ManipulationPivot) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationPivot {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationPivot {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for ManipulationPivot {}
unsafe impl ::core::marker::Sync for ManipulationPivot {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationStartedEventHandler(::windows::core::IUnknown);
impl ManipulationStartedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = ManipulationStartedEventHandler_box::<F> {
vtable: &ManipulationStartedEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ManipulationStartedRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationStartedEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({f88345f8-e0a3-4be2-b90c-dc20e6d8beb0})");
}
unsafe impl ::windows::core::Interface for ManipulationStartedEventHandler {
type Vtable = ManipulationStartedEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf88345f8_e0a3_4be2_b90c_dc20e6d8beb0);
}
#[repr(C)]
#[doc(hidden)]
pub struct ManipulationStartedEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct ManipulationStartedEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const ManipulationStartedEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> ManipulationStartedEventHandler_box<F> {
const VTABLE: ManipulationStartedEventHandler_abi = ManipulationStartedEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<ManipulationStartedEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <ManipulationStartedRoutedEventArgs as ::windows::core::Abi>::Abi as *const <ManipulationStartedRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationStartedRoutedEventArgs(pub ::windows::core::IInspectable);
impl ManipulationStartedRoutedEventArgs {
pub fn Container(&self) -> ::windows::core::Result<super::UIElement> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::UIElement>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn Position(&self) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "UI_Input"))]
pub fn Cumulative(&self) -> ::windows::core::Result<super::super::Input::ManipulationDelta> {
let this = self;
unsafe {
let mut result__: super::super::Input::ManipulationDelta = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Input::ManipulationDelta>(result__)
}
}
pub fn Complete(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this)).ok() }
}
pub fn new() -> ::windows::core::Result<ManipulationStartedRoutedEventArgs> {
Self::IManipulationStartedRoutedEventArgsFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, &mut result__).from_abi::<ManipulationStartedRoutedEventArgs>(result__)
})
}
pub fn IManipulationStartedRoutedEventArgsFactory<R, F: FnOnce(&IManipulationStartedRoutedEventArgsFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationStartedRoutedEventArgs, IManipulationStartedRoutedEventArgsFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationStartedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationStartedRoutedEventArgs;{5db1aa05-9f80-48b6-ae6c-4f119de8ff13})");
}
unsafe impl ::windows::core::Interface for ManipulationStartedRoutedEventArgs {
type Vtable = IManipulationStartedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5db1aa05_9f80_48b6_ae6c_4f119de8ff13);
}
impl ::windows::core::RuntimeName for ManipulationStartedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationStartedRoutedEventArgs";
}
impl ::core::convert::From<ManipulationStartedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: ManipulationStartedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationStartedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ManipulationStartedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationStartedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: ManipulationStartedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationStartedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ManipulationStartedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ManipulationStartedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: ManipulationStartedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ManipulationStartedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &ManipulationStartedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ManipulationStartedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ManipulationStartedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for ManipulationStartedRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationStartingEventHandler(::windows::core::IUnknown);
impl ManipulationStartingEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = ManipulationStartingEventHandler_box::<F> {
vtable: &ManipulationStartingEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ManipulationStartingRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationStartingEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({10d0b04e-bfe4-42cb-823c-3fecd8770ef8})");
}
unsafe impl ::windows::core::Interface for ManipulationStartingEventHandler {
type Vtable = ManipulationStartingEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x10d0b04e_bfe4_42cb_823c_3fecd8770ef8);
}
#[repr(C)]
#[doc(hidden)]
pub struct ManipulationStartingEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct ManipulationStartingEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const ManipulationStartingEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<ManipulationStartingRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> ManipulationStartingEventHandler_box<F> {
const VTABLE: ManipulationStartingEventHandler_abi = ManipulationStartingEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<ManipulationStartingEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <ManipulationStartingRoutedEventArgs as ::windows::core::Abi>::Abi as *const <ManipulationStartingRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ManipulationStartingRoutedEventArgs(pub ::windows::core::IInspectable);
impl ManipulationStartingRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<ManipulationStartingRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Mode(&self) -> ::windows::core::Result<ManipulationModes> {
let this = self;
unsafe {
let mut result__: ManipulationModes = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<ManipulationModes>(result__)
}
}
pub fn SetMode(&self, value: ManipulationModes) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Container(&self) -> ::windows::core::Result<super::UIElement> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::UIElement>(result__)
}
}
pub fn SetContainer<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Pivot(&self) -> ::windows::core::Result<ManipulationPivot> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<ManipulationPivot>(result__)
}
}
pub fn SetPivot<'a, Param0: ::windows::core::IntoParam<'a, ManipulationPivot>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ManipulationStartingRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ManipulationStartingRoutedEventArgs;{18d636b7-53a4-4c15-a498-f3a9ca212a42})");
}
unsafe impl ::windows::core::Interface for ManipulationStartingRoutedEventArgs {
type Vtable = IManipulationStartingRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x18d636b7_53a4_4c15_a498_f3a9ca212a42);
}
impl ::windows::core::RuntimeName for ManipulationStartingRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ManipulationStartingRoutedEventArgs";
}
impl ::core::convert::From<ManipulationStartingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: ManipulationStartingRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ManipulationStartingRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &ManipulationStartingRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ManipulationStartingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: ManipulationStartingRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ManipulationStartingRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &ManipulationStartingRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<ManipulationStartingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: ManipulationStartingRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&ManipulationStartingRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &ManipulationStartingRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &ManipulationStartingRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for ManipulationStartingRoutedEventArgs {}
unsafe impl ::core::marker::Sync for ManipulationStartingRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct NoFocusCandidateFoundEventArgs(pub ::windows::core::IInspectable);
impl NoFocusCandidateFoundEventArgs {
pub fn Direction(&self) -> ::windows::core::Result<FocusNavigationDirection> {
let this = self;
unsafe {
let mut result__: FocusNavigationDirection = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusNavigationDirection>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn InputDevice(&self) -> ::windows::core::Result<FocusInputDeviceKind> {
let this = self;
unsafe {
let mut result__: FocusInputDeviceKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<FocusInputDeviceKind>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for NoFocusCandidateFoundEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.NoFocusCandidateFoundEventArgs;{ec3601a7-1007-48f9-b6b3-ed0bea53937d})");
}
unsafe impl ::windows::core::Interface for NoFocusCandidateFoundEventArgs {
type Vtable = INoFocusCandidateFoundEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xec3601a7_1007_48f9_b6b3_ed0bea53937d);
}
impl ::windows::core::RuntimeName for NoFocusCandidateFoundEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.NoFocusCandidateFoundEventArgs";
}
impl ::core::convert::From<NoFocusCandidateFoundEventArgs> for ::windows::core::IUnknown {
fn from(value: NoFocusCandidateFoundEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&NoFocusCandidateFoundEventArgs> for ::windows::core::IUnknown {
fn from(value: &NoFocusCandidateFoundEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<NoFocusCandidateFoundEventArgs> for ::windows::core::IInspectable {
fn from(value: NoFocusCandidateFoundEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&NoFocusCandidateFoundEventArgs> for ::windows::core::IInspectable {
fn from(value: &NoFocusCandidateFoundEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<NoFocusCandidateFoundEventArgs> for super::RoutedEventArgs {
fn from(value: NoFocusCandidateFoundEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&NoFocusCandidateFoundEventArgs> for super::RoutedEventArgs {
fn from(value: &NoFocusCandidateFoundEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &NoFocusCandidateFoundEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for NoFocusCandidateFoundEventArgs {}
unsafe impl ::core::marker::Sync for NoFocusCandidateFoundEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct Pointer(pub ::windows::core::IInspectable);
impl Pointer {
pub fn PointerId(&self) -> ::windows::core::Result<u32> {
let this = self;
unsafe {
let mut result__: u32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__)
}
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
pub fn IsInContact(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn IsInRange(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for Pointer {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.Pointer;{5ee8f39f-747d-4171-90e6-cd37a9dffb11})");
}
unsafe impl ::windows::core::Interface for Pointer {
type Vtable = IPointer_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5ee8f39f_747d_4171_90e6_cd37a9dffb11);
}
impl ::windows::core::RuntimeName for Pointer {
const NAME: &'static str = "Windows.UI.Xaml.Input.Pointer";
}
impl ::core::convert::From<Pointer> for ::windows::core::IUnknown {
fn from(value: Pointer) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&Pointer> for ::windows::core::IUnknown {
fn from(value: &Pointer) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for Pointer {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a Pointer {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<Pointer> for ::windows::core::IInspectable {
fn from(value: Pointer) -> Self {
value.0
}
}
impl ::core::convert::From<&Pointer> for ::windows::core::IInspectable {
fn from(value: &Pointer) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for Pointer {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a Pointer {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for Pointer {}
unsafe impl ::core::marker::Sync for Pointer {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PointerEventHandler(::windows::core::IUnknown);
impl PointerEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<PointerRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = PointerEventHandler_box::<F> {
vtable: &PointerEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, PointerRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for PointerEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({e4385929-c004-4bcf-8970-359486e39f88})");
}
unsafe impl ::windows::core::Interface for PointerEventHandler {
type Vtable = PointerEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe4385929_c004_4bcf_8970_359486e39f88);
}
#[repr(C)]
#[doc(hidden)]
pub struct PointerEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct PointerEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<PointerRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const PointerEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<PointerRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> PointerEventHandler_box<F> {
const VTABLE: PointerEventHandler_abi = PointerEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<PointerEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <PointerRoutedEventArgs as ::windows::core::Abi>::Abi as *const <PointerRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PointerRoutedEventArgs(pub ::windows::core::IInspectable);
impl PointerRoutedEventArgs {
pub fn Pointer(&self) -> ::windows::core::Result<Pointer> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<Pointer>(result__)
}
}
#[cfg(feature = "System")]
pub fn KeyModifiers(&self) -> ::windows::core::Result<super::super::super::System::VirtualKeyModifiers> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKeyModifiers = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKeyModifiers>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "UI_Input")]
pub fn GetCurrentPoint<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::Input::PointerPoint> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::Input::PointerPoint>(result__)
}
}
#[cfg(all(feature = "Foundation_Collections", feature = "UI_Input"))]
pub fn GetIntermediatePoints<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::super::Foundation::Collections::IVector<super::super::Input::PointerPoint>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::Collections::IVector<super::super::Input::PointerPoint>>(result__)
}
}
pub fn IsGenerated(&self) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<IPointerRoutedEventArgs2>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PointerRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.PointerRoutedEventArgs;{da628f0a-9752-49e2-bde2-49eccab9194d})");
}
unsafe impl ::windows::core::Interface for PointerRoutedEventArgs {
type Vtable = IPointerRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xda628f0a_9752_49e2_bde2_49eccab9194d);
}
impl ::windows::core::RuntimeName for PointerRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.PointerRoutedEventArgs";
}
impl ::core::convert::From<PointerRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: PointerRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PointerRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &PointerRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PointerRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: PointerRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&PointerRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &PointerRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<PointerRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: PointerRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&PointerRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &PointerRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &PointerRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for PointerRoutedEventArgs {}
unsafe impl ::core::marker::Sync for PointerRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct ProcessKeyboardAcceleratorEventArgs(pub ::windows::core::IInspectable);
impl ProcessKeyboardAcceleratorEventArgs {
#[cfg(feature = "System")]
pub fn Key(&self) -> ::windows::core::Result<super::super::super::System::VirtualKey> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKey = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKey>(result__)
}
}
#[cfg(feature = "System")]
pub fn Modifiers(&self) -> ::windows::core::Result<super::super::super::System::VirtualKeyModifiers> {
let this = self;
unsafe {
let mut result__: super::super::super::System::VirtualKeyModifiers = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::System::VirtualKeyModifiers>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for ProcessKeyboardAcceleratorEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.ProcessKeyboardAcceleratorEventArgs;{fb79c216-972b-440c-9b83-2b4198dcf09d})");
}
unsafe impl ::windows::core::Interface for ProcessKeyboardAcceleratorEventArgs {
type Vtable = IProcessKeyboardAcceleratorEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfb79c216_972b_440c_9b83_2b4198dcf09d);
}
impl ::windows::core::RuntimeName for ProcessKeyboardAcceleratorEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.ProcessKeyboardAcceleratorEventArgs";
}
impl ::core::convert::From<ProcessKeyboardAcceleratorEventArgs> for ::windows::core::IUnknown {
fn from(value: ProcessKeyboardAcceleratorEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&ProcessKeyboardAcceleratorEventArgs> for ::windows::core::IUnknown {
fn from(value: &ProcessKeyboardAcceleratorEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for ProcessKeyboardAcceleratorEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a ProcessKeyboardAcceleratorEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<ProcessKeyboardAcceleratorEventArgs> for ::windows::core::IInspectable {
fn from(value: ProcessKeyboardAcceleratorEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&ProcessKeyboardAcceleratorEventArgs> for ::windows::core::IInspectable {
fn from(value: &ProcessKeyboardAcceleratorEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for ProcessKeyboardAcceleratorEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a ProcessKeyboardAcceleratorEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for ProcessKeyboardAcceleratorEventArgs {}
unsafe impl ::core::marker::Sync for ProcessKeyboardAcceleratorEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct RightTappedEventHandler(::windows::core::IUnknown);
impl RightTappedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<RightTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = RightTappedEventHandler_box::<F> {
vtable: &RightTappedEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, RightTappedRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for RightTappedEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({2532a062-f447-4950-9c46-f1e34a2c2238})");
}
unsafe impl ::windows::core::Interface for RightTappedEventHandler {
type Vtable = RightTappedEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2532a062_f447_4950_9c46_f1e34a2c2238);
}
#[repr(C)]
#[doc(hidden)]
pub struct RightTappedEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct RightTappedEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<RightTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const RightTappedEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<RightTappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> RightTappedEventHandler_box<F> {
const VTABLE: RightTappedEventHandler_abi = RightTappedEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<RightTappedEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <RightTappedRoutedEventArgs as ::windows::core::Abi>::Abi as *const <RightTappedRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct RightTappedRoutedEventArgs(pub ::windows::core::IInspectable);
impl RightTappedRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<RightTappedRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn GetPosition<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for RightTappedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.RightTappedRoutedEventArgs;{6834869d-7bd5-4033-b237-172f79abe393})");
}
unsafe impl ::windows::core::Interface for RightTappedRoutedEventArgs {
type Vtable = IRightTappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6834869d_7bd5_4033_b237_172f79abe393);
}
impl ::windows::core::RuntimeName for RightTappedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.RightTappedRoutedEventArgs";
}
impl ::core::convert::From<RightTappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: RightTappedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&RightTappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &RightTappedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<RightTappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: RightTappedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&RightTappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &RightTappedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<RightTappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: RightTappedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&RightTappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &RightTappedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &RightTappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for RightTappedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for RightTappedRoutedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct StandardUICommand(pub ::windows::core::IInspectable);
impl StandardUICommand {
pub fn Kind(&self) -> ::windows::core::Result<StandardUICommandKind> {
let this = self;
unsafe {
let mut result__: StandardUICommandKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<StandardUICommandKind>(result__)
}
}
pub fn KindProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IStandardUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn new() -> ::windows::core::Result<StandardUICommand> {
Self::IStandardUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, &mut result__).from_abi::<StandardUICommand>(result__)
})
}
pub fn CreateInstanceWithKind(kind: StandardUICommandKind) -> ::windows::core::Result<StandardUICommand> {
Self::IStandardUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), kind, ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, &mut result__).from_abi::<StandardUICommand>(result__)
})
}
pub fn SetKind(&self, value: StandardUICommandKind) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IStandardUICommand2>(self)?;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IStandardUICommandStatics<R, F: FnOnce(&IStandardUICommandStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<StandardUICommand, IStandardUICommandStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IStandardUICommandFactory<R, F: FnOnce(&IStandardUICommandFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<StandardUICommand, IStandardUICommandFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for StandardUICommand {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.StandardUICommand;{d2bf7f43-0504-52d0-8aa6-0cb0f756eb27})");
}
unsafe impl ::windows::core::Interface for StandardUICommand {
type Vtable = IStandardUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd2bf7f43_0504_52d0_8aa6_0cb0f756eb27);
}
impl ::windows::core::RuntimeName for StandardUICommand {
const NAME: &'static str = "Windows.UI.Xaml.Input.StandardUICommand";
}
impl ::core::convert::From<StandardUICommand> for ::windows::core::IUnknown {
fn from(value: StandardUICommand) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&StandardUICommand> for ::windows::core::IUnknown {
fn from(value: &StandardUICommand) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<StandardUICommand> for ::windows::core::IInspectable {
fn from(value: StandardUICommand) -> Self {
value.0
}
}
impl ::core::convert::From<&StandardUICommand> for ::windows::core::IInspectable {
fn from(value: &StandardUICommand) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::TryFrom<StandardUICommand> for ICommand {
type Error = ::windows::core::Error;
fn try_from(value: StandardUICommand) -> ::windows::core::Result<Self> {
::core::convert::TryFrom::try_from(&value)
}
}
impl ::core::convert::TryFrom<&StandardUICommand> for ICommand {
type Error = ::windows::core::Error;
fn try_from(value: &StandardUICommand) -> ::windows::core::Result<Self> {
::windows::core::Interface::cast(value)
}
}
impl<'a> ::windows::core::IntoParam<'a, ICommand> for StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ICommand> {
::windows::core::IntoParam::into_param(&self)
}
}
impl<'a> ::windows::core::IntoParam<'a, ICommand> for &StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ICommand> {
::core::convert::TryInto::<ICommand>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None)
}
}
impl ::core::convert::From<StandardUICommand> for XamlUICommand {
fn from(value: StandardUICommand) -> Self {
::core::convert::Into::<XamlUICommand>::into(&value)
}
}
impl ::core::convert::From<&StandardUICommand> for XamlUICommand {
fn from(value: &StandardUICommand) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, XamlUICommand> for StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, XamlUICommand> {
::windows::core::Param::Owned(::core::convert::Into::<XamlUICommand>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, XamlUICommand> for &StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, XamlUICommand> {
::windows::core::Param::Owned(::core::convert::Into::<XamlUICommand>::into(::core::clone::Clone::clone(self)))
}
}
impl ::core::convert::From<StandardUICommand> for super::DependencyObject {
fn from(value: StandardUICommand) -> Self {
::core::convert::Into::<super::DependencyObject>::into(&value)
}
}
impl ::core::convert::From<&StandardUICommand> for super::DependencyObject {
fn from(value: &StandardUICommand) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for &StandardUICommand {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for StandardUICommand {}
unsafe impl ::core::marker::Sync for StandardUICommand {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct StandardUICommandKind(pub i32);
impl StandardUICommandKind {
pub const None: StandardUICommandKind = StandardUICommandKind(0i32);
pub const Cut: StandardUICommandKind = StandardUICommandKind(1i32);
pub const Copy: StandardUICommandKind = StandardUICommandKind(2i32);
pub const Paste: StandardUICommandKind = StandardUICommandKind(3i32);
pub const SelectAll: StandardUICommandKind = StandardUICommandKind(4i32);
pub const Delete: StandardUICommandKind = StandardUICommandKind(5i32);
pub const Share: StandardUICommandKind = StandardUICommandKind(6i32);
pub const Save: StandardUICommandKind = StandardUICommandKind(7i32);
pub const Open: StandardUICommandKind = StandardUICommandKind(8i32);
pub const Close: StandardUICommandKind = StandardUICommandKind(9i32);
pub const Pause: StandardUICommandKind = StandardUICommandKind(10i32);
pub const Play: StandardUICommandKind = StandardUICommandKind(11i32);
pub const Stop: StandardUICommandKind = StandardUICommandKind(12i32);
pub const Forward: StandardUICommandKind = StandardUICommandKind(13i32);
pub const Backward: StandardUICommandKind = StandardUICommandKind(14i32);
pub const Undo: StandardUICommandKind = StandardUICommandKind(15i32);
pub const Redo: StandardUICommandKind = StandardUICommandKind(16i32);
}
impl ::core::convert::From<i32> for StandardUICommandKind {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for StandardUICommandKind {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for StandardUICommandKind {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.StandardUICommandKind;i4)");
}
impl ::windows::core::DefaultType for StandardUICommandKind {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct TappedEventHandler(::windows::core::IUnknown);
impl TappedEventHandler {
pub fn new<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<TappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static>(invoke: F) -> Self {
let com = TappedEventHandler_box::<F> {
vtable: &TappedEventHandler_box::<F>::VTABLE,
count: ::windows::core::RefCount::new(1),
invoke,
};
unsafe { core::mem::transmute(::windows::core::alloc::boxed::Box::new(com)) }
}
pub fn Invoke<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, TappedRoutedEventArgs>>(&self, sender: Param0, e: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).3)(::core::mem::transmute_copy(this), sender.into_param().abi(), e.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for TappedEventHandler {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"delegate({68d940cc-9ff0-49ce-b141-3f07ec477b97})");
}
unsafe impl ::windows::core::Interface for TappedEventHandler {
type Vtable = TappedEventHandler_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x68d940cc_9ff0_49ce_b141_3f07ec477b97);
}
#[repr(C)]
#[doc(hidden)]
pub struct TappedEventHandler_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, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(C)]
struct TappedEventHandler_box<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<TappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> {
vtable: *const TappedEventHandler_abi,
invoke: F,
count: ::windows::core::RefCount,
}
impl<F: FnMut(&::core::option::Option<::windows::core::IInspectable>, &::core::option::Option<TappedRoutedEventArgs>) -> ::windows::core::Result<()> + 'static> TappedEventHandler_box<F> {
const VTABLE: TappedEventHandler_abi = TappedEventHandler_abi(Self::QueryInterface, Self::AddRef, Self::Release, Self::Invoke);
unsafe extern "system" fn QueryInterface(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
*interface = if iid == &<TappedEventHandler as ::windows::core::Interface>::IID || iid == &<::windows::core::IUnknown as ::windows::core::Interface>::IID || iid == &<::windows::core::IAgileObject as ::windows::core::Interface>::IID {
&mut (*this).vtable as *mut _ as _
} else {
::core::ptr::null_mut()
};
if (*interface).is_null() {
::windows::core::HRESULT(0x8000_4002)
} else {
(*this).count.add_ref();
::windows::core::HRESULT(0)
}
}
unsafe extern "system" fn AddRef(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
(*this).count.add_ref()
}
unsafe extern "system" fn Release(this: ::windows::core::RawPtr) -> u32 {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
let remaining = (*this).count.release();
if remaining == 0 {
::windows::core::alloc::boxed::Box::from_raw(this);
}
remaining
}
unsafe extern "system" fn Invoke(this: ::windows::core::RawPtr, sender: ::windows::core::RawPtr, e: ::windows::core::RawPtr) -> ::windows::core::HRESULT {
let this = this as *mut ::windows::core::RawPtr as *mut Self;
((*this).invoke)(
&*(&sender as *const <::windows::core::IInspectable as ::windows::core::Abi>::Abi as *const <::windows::core::IInspectable as ::windows::core::DefaultType>::DefaultType),
&*(&e as *const <TappedRoutedEventArgs as ::windows::core::Abi>::Abi as *const <TappedRoutedEventArgs as ::windows::core::DefaultType>::DefaultType),
)
.into()
}
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct TappedRoutedEventArgs(pub ::windows::core::IInspectable);
impl TappedRoutedEventArgs {
pub fn new() -> ::windows::core::Result<Self> {
Self::IActivationFactory(|f| f.activate_instance::<Self>())
}
fn IActivationFactory<R, F: FnOnce(&::windows::core::IActivationFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<TappedRoutedEventArgs, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
#[cfg(feature = "Devices_Input")]
pub fn PointerDeviceType(&self) -> ::windows::core::Result<super::super::super::Devices::Input::PointerDeviceType> {
let this = self;
unsafe {
let mut result__: super::super::super::Devices::Input::PointerDeviceType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Devices::Input::PointerDeviceType>(result__)
}
}
pub fn Handled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetHandled(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn GetPosition<'a, Param0: ::windows::core::IntoParam<'a, super::UIElement>>(&self, relativeto: Param0) -> ::windows::core::Result<super::super::super::Foundation::Point> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::Point = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), relativeto.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::Point>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for TappedRoutedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.TappedRoutedEventArgs;{a099e6be-e624-459a-bb1d-e05c73e2cc66})");
}
unsafe impl ::windows::core::Interface for TappedRoutedEventArgs {
type Vtable = ITappedRoutedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa099e6be_e624_459a_bb1d_e05c73e2cc66);
}
impl ::windows::core::RuntimeName for TappedRoutedEventArgs {
const NAME: &'static str = "Windows.UI.Xaml.Input.TappedRoutedEventArgs";
}
impl ::core::convert::From<TappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: TappedRoutedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&TappedRoutedEventArgs> for ::windows::core::IUnknown {
fn from(value: &TappedRoutedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<TappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: TappedRoutedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&TappedRoutedEventArgs> for ::windows::core::IInspectable {
fn from(value: &TappedRoutedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::From<TappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: TappedRoutedEventArgs) -> Self {
::core::convert::Into::<super::RoutedEventArgs>::into(&value)
}
}
impl ::core::convert::From<&TappedRoutedEventArgs> for super::RoutedEventArgs {
fn from(value: &TappedRoutedEventArgs) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::RoutedEventArgs> for &TappedRoutedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, super::RoutedEventArgs> {
::windows::core::Param::Owned(::core::convert::Into::<super::RoutedEventArgs>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for TappedRoutedEventArgs {}
unsafe impl ::core::marker::Sync for TappedRoutedEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct XYFocusKeyboardNavigationMode(pub i32);
impl XYFocusKeyboardNavigationMode {
pub const Auto: XYFocusKeyboardNavigationMode = XYFocusKeyboardNavigationMode(0i32);
pub const Enabled: XYFocusKeyboardNavigationMode = XYFocusKeyboardNavigationMode(1i32);
pub const Disabled: XYFocusKeyboardNavigationMode = XYFocusKeyboardNavigationMode(2i32);
}
impl ::core::convert::From<i32> for XYFocusKeyboardNavigationMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for XYFocusKeyboardNavigationMode {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for XYFocusKeyboardNavigationMode {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.XYFocusKeyboardNavigationMode;i4)");
}
impl ::windows::core::DefaultType for XYFocusKeyboardNavigationMode {
type DefaultType = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct XYFocusNavigationStrategy(pub i32);
impl XYFocusNavigationStrategy {
pub const Auto: XYFocusNavigationStrategy = XYFocusNavigationStrategy(0i32);
pub const Projection: XYFocusNavigationStrategy = XYFocusNavigationStrategy(1i32);
pub const NavigationDirectionDistance: XYFocusNavigationStrategy = XYFocusNavigationStrategy(2i32);
pub const RectilinearDistance: XYFocusNavigationStrategy = XYFocusNavigationStrategy(3i32);
}
impl ::core::convert::From<i32> for XYFocusNavigationStrategy {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for XYFocusNavigationStrategy {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for XYFocusNavigationStrategy {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.XYFocusNavigationStrategy;i4)");
}
impl ::windows::core::DefaultType for XYFocusNavigationStrategy {
type DefaultType = Self;
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct XYFocusNavigationStrategyOverride(pub i32);
impl XYFocusNavigationStrategyOverride {
pub const None: XYFocusNavigationStrategyOverride = XYFocusNavigationStrategyOverride(0i32);
pub const Auto: XYFocusNavigationStrategyOverride = XYFocusNavigationStrategyOverride(1i32);
pub const Projection: XYFocusNavigationStrategyOverride = XYFocusNavigationStrategyOverride(2i32);
pub const NavigationDirectionDistance: XYFocusNavigationStrategyOverride = XYFocusNavigationStrategyOverride(3i32);
pub const RectilinearDistance: XYFocusNavigationStrategyOverride = XYFocusNavigationStrategyOverride(4i32);
}
impl ::core::convert::From<i32> for XYFocusNavigationStrategyOverride {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for XYFocusNavigationStrategyOverride {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for XYFocusNavigationStrategyOverride {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.UI.Xaml.Input.XYFocusNavigationStrategyOverride;i4)");
}
impl ::windows::core::DefaultType for XYFocusNavigationStrategyOverride {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct XamlUICommand(pub ::windows::core::IInspectable);
impl XamlUICommand {
#[cfg(feature = "Foundation")]
pub fn CanExecuteChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventHandler<::windows::core::IInspectable>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
let this = &::windows::core::Interface::cast::<ICommand>(self)?;
unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveCanExecuteChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<ICommand>(self)?;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn CanExecute<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, parameter: Param0) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<ICommand>(self)?;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), parameter.into_param().abi(), &mut result__).from_abi::<bool>(result__)
}
}
pub fn Execute<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, parameter: Param0) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<ICommand>(self)?;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), parameter.into_param().abi()).ok() }
}
pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "UI_Xaml_Controls")]
pub fn IconSource(&self) -> ::windows::core::Result<super::Controls::IconSource> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::Controls::IconSource>(result__)
}
}
#[cfg(feature = "UI_Xaml_Controls")]
pub fn SetIconSource<'a, Param0: ::windows::core::IntoParam<'a, super::Controls::IconSource>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation_Collections")]
pub fn KeyboardAccelerators(&self) -> ::windows::core::Result<super::super::super::Foundation::Collections::IVector<KeyboardAccelerator>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::super::Foundation::Collections::IVector<KeyboardAccelerator>>(result__)
}
}
pub fn AccessKey(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetAccessKey<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Description(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetDescription<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Command(&self) -> ::windows::core::Result<ICommand> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<ICommand>(result__)
}
}
pub fn SetCommand<'a, Param0: ::windows::core::IntoParam<'a, ICommand>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn ExecuteRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::TypedEventHandler<XamlUICommand, ExecuteRequestedEventArgs>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveExecuteRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn CanExecuteRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::TypedEventHandler<XamlUICommand, CanExecuteRequestedEventArgs>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::super::Foundation::EventRegistrationToken> {
let this = self;
unsafe {
let mut result__: super::super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).19)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveCanExecuteRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn NotifyCanExecuteChanged(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this)).ok() }
}
pub fn LabelProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn IconSourceProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn KeyboardAcceleratorsProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn AccessKeyProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn DescriptionProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn CommandProperty() -> ::windows::core::Result<super::DependencyProperty> {
Self::IXamlUICommandStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::DependencyProperty>(result__)
})
}
pub fn new() -> ::windows::core::Result<XamlUICommand> {
Self::IXamlUICommandFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), ::core::ptr::null_mut(), &mut ::core::option::Option::<::windows::core::IInspectable>::None as *mut _ as _, &mut result__).from_abi::<XamlUICommand>(result__)
})
}
pub fn IXamlUICommandStatics<R, F: FnOnce(&IXamlUICommandStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<XamlUICommand, IXamlUICommandStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IXamlUICommandFactory<R, F: FnOnce(&IXamlUICommandFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<XamlUICommand, IXamlUICommandFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for XamlUICommand {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.UI.Xaml.Input.XamlUICommand;{8494f8d4-ead1-5f01-ad2e-a8cad4f9dc0e})");
}
unsafe impl ::windows::core::Interface for XamlUICommand {
type Vtable = IXamlUICommand_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8494f8d4_ead1_5f01_ad2e_a8cad4f9dc0e);
}
impl ::windows::core::RuntimeName for XamlUICommand {
const NAME: &'static str = "Windows.UI.Xaml.Input.XamlUICommand";
}
impl ::core::convert::From<XamlUICommand> for ::windows::core::IUnknown {
fn from(value: XamlUICommand) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&XamlUICommand> for ::windows::core::IUnknown {
fn from(value: &XamlUICommand) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Owned(self.0 .0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for &'a XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<XamlUICommand> for ::windows::core::IInspectable {
fn from(value: XamlUICommand) -> Self {
value.0
}
}
impl ::core::convert::From<&XamlUICommand> for ::windows::core::IInspectable {
fn from(value: &XamlUICommand) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Owned(self.0)
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for &'a XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
impl ::core::convert::TryFrom<XamlUICommand> for ICommand {
type Error = ::windows::core::Error;
fn try_from(value: XamlUICommand) -> ::windows::core::Result<Self> {
::core::convert::TryFrom::try_from(&value)
}
}
impl ::core::convert::TryFrom<&XamlUICommand> for ICommand {
type Error = ::windows::core::Error;
fn try_from(value: &XamlUICommand) -> ::windows::core::Result<Self> {
::windows::core::Interface::cast(value)
}
}
impl<'a> ::windows::core::IntoParam<'a, ICommand> for XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ICommand> {
::windows::core::IntoParam::into_param(&self)
}
}
impl<'a> ::windows::core::IntoParam<'a, ICommand> for &XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, ICommand> {
::core::convert::TryInto::<ICommand>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None)
}
}
impl ::core::convert::From<XamlUICommand> for super::DependencyObject {
fn from(value: XamlUICommand) -> Self {
::core::convert::Into::<super::DependencyObject>::into(&value)
}
}
impl ::core::convert::From<&XamlUICommand> for super::DependencyObject {
fn from(value: &XamlUICommand) -> Self {
::windows::core::Interface::cast(value).unwrap()
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(self))
}
}
impl<'a> ::windows::core::IntoParam<'a, super::DependencyObject> for &XamlUICommand {
fn into_param(self) -> ::windows::core::Param<'a, super::DependencyObject> {
::windows::core::Param::Owned(::core::convert::Into::<super::DependencyObject>::into(::core::clone::Clone::clone(self)))
}
}
unsafe impl ::core::marker::Send for XamlUICommand {}
unsafe impl ::core::marker::Sync for XamlUICommand {}
|
use std::default::Default;
use std::sync::atomic::{AtomicPtr, AtomicIsize, Ordering};
use std::{fmt, ptr};
use super::item::Item;
// TODO: try to relax the ordering, on a per call basis.
const DEFAULT_ORDERING: Ordering = Ordering::SeqCst;
/// The size of a single [`Segment`]. 32 is chosen somewhat arbitrarily.
///
/// [`Segment`]: struct.Segment.html
//
// TODO: benchmark smaller and bigger sizes.
pub const SEGMENT_SIZE: usize = 32;
/// The id of a [`Segment`]. 0 is an invalid id.
///
/// [`Segment`]: struct.Segment.html
type SegmentId = isize;
/// The position of a [`Item`] in the data array in [`Segment`]. A position can
/// be mapped to a `SegmentId` and an index for `Segment` data.
///
/// if `Pos` is invalid it means that `Segment` is empty. Positions 1 through
/// `SEGMENT_SIZE` are located in the `SegmentId` with id 1. While
/// -`SEGMENT_SIZE` through -1 are located in `SegmentId` with id -1.
///
/// [`Item`]: struct.Item.html
/// [`Segment`]: struct.Segment.html
#[derive(Debug, Copy, Clone)]
struct Pos (isize);
impl Pos {
/// Check if the position is valid.
fn is_valid(self) -> bool {
self.0 != 0
}
/// Determine the `SegmentId` based on the `Pos`ition.
///
/// # Panic
///
/// This will panic if the `Pos` is invalid.
fn get_segment_id(self) -> SegmentId {
assert!(self.is_valid(), "called Pos.get_segment_id() with invalid value");
if self.0.is_negative() {
(self.0 as f64 / SEGMENT_SIZE as f64).floor() as isize
} else {
((self.0 as f64 - 1.0) / SEGMENT_SIZE as f64).floor() as isize + 1
}
}
/// Determine the index for the `Segment` data.
///
/// # Panic
///
/// This will panic if the `Pos` is invalid.
fn get_index(self) -> usize {
assert!(self.is_valid(), "called Pos.get_index() with invalid value");
if self.0.is_negative() {
(self.0 % SEGMENT_SIZE as isize) as usize
} else {
(self.0 - 1 % SEGMENT_SIZE as isize) as usize
}
}
}
impl fmt::Display for Pos {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "Pos({})", self.0)
}
}
/// `Segment` is an array that can hold [`n`] number of items `T`. All push and
/// pop operations will be deligated to its peers, if it has any.
///
/// Expand this `Segment` can be done with the [`expand_front`] and
/// [`expand_back`] methods, which will add peers to this `Segment`.
///
/// # Note
///
/// It does **not** drop it's peers, the user is responsible for that, see
/// [`get_peers`].
///
/// # Usage
///
/// Required for using a `Segment` are two positions, one for the `head` and one
/// for the `tail`, both must be [`AtomicIsize`]. The `*_front` methods require
/// the `head` position, while the `*_back` methods require the `tail` position,
/// as the different methods mention in the argument names.
///
/// These two positions are not synced in any way with each other. **Neither
/// position may be modified outside of a `Segment` call**, or bad things might
/// happen otherwise.
///
/// For performance it's recommended that the user keeps track of the first and
/// last `Segment`, however since all methods will deligate to its peers this is
/// not necessary.
///
/// [`n`]: constant.SEGMENT_SIZE.html
/// [`get_peers`]: struct.Segment.html#method.get_peers
/// [`expand_front`]: struct.Segment.html#method.expand_front
/// [`expand_back`]: struct.Segment.html#method.expand_back
/// [`AtomicIsize`]: https://doc.rust-lang.org/nightly/core/sync/atomic/struct.AtomicIsize.html
pub struct Segment<T> {
/// The `SegmentId` of the `Segment` used in determining to which `Segment`
/// data must be written or read from.
id: SegmentId,
/// The data this segment is responible for. Due to the nature of the global
/// position (see [`try_push_front`] and [`try_push_back`]) it is very
/// possible that this will contain holes.
///
/// [`try_push_front`]: #method.try_push_front
/// [`try_push_back`]: #method.try_push_back
data: [Item<T>; SEGMENT_SIZE],
/// The pointers to the next and previous `Segment`s.
///
/// For the initial Segment these pointers wil be null, but after it set
/// once it must always point to a correct `Segment` and **must never be
/// null again**!
prev: AtomicPtr<Segment<T>>,
next: AtomicPtr<Segment<T>>,
}
impl<T> Segment<T> {
/// Create new empty `Segment`, it is already boxed because this is required
/// for the [`expand_front`] and [`expand_back`] functions.
///
/// [`expand_front`]: #method.expand_front
/// [`expand_back`]: #method.expand_back
pub fn empty() -> Box<Segment<T>> {
Box::new(Segment {
id: 0,
// Creates an array of empty `Item`.
data: Default::default(),
prev: AtomicPtr::new(ptr::null_mut()),
next: AtomicPtr::new(ptr::null_mut()),
})
}
/// Push `data` to the front of the `Segment`.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn try_push_front(&self, head_pos: &AtomicIsize, data: T) -> Result<(), T> {
// Grab a new position for ourself and try to write to it.
//
// Note we don't have exclusive access to it so we're still racing for
// it, hence the fact that `Item` has it's own access control.
let pos = Pos(head_pos.fetch_sub(1, DEFAULT_ORDERING));
trace!("Segment.try_push_front: decreased head position, writing to {}", pos);
self.try_write_position(pos, data)
.map_err(|data| {
// Failed to write, release the position.
let pos = head_pos.fetch_add(1, DEFAULT_ORDERING);
trace!("Segment.try_push_front: failed to write to position {}, increased head position", pos);
// FIXME: it could also be that a `Item` is (currently)
// in a invalid state, what then?
data
})
}
/// Push `data` to the back of the `Segment`.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn try_push_back(&self, tail_pos: &AtomicIsize, data: T) -> Result<(), T> {
// See `push_front` for documentation, this does the same thing but with
// a different position and returned error.
let pos = Pos(tail_pos.fetch_add(1, DEFAULT_ORDERING));
trace!("Segment.try_push_back: increased tail position, writing to {}", pos);
self.try_write_position(pos, data)
.map_err(|data| {
let pos = tail_pos.fetch_sub(1, DEFAULT_ORDERING);
trace!("Segment.try_push_back: failed to write to position {}, decreased tail position", pos);
data
})
}
/// Write the provided `data` to the provided position.
///
/// # Note
///
/// It possible that the position is not present on the current segment, if
/// that is the case this function will deligate the writing to the correct
/// segment, if present.
///
/// If the segment to which the position belongs doesn't exitsts this will
/// return an error.
fn try_write_position(&self, pos: Pos, data: T) -> Result<(), T> {
// Get the `SegmentId` based on the `Pos`ition in which this data must
// be written.
//
// TODO: call get_segment_id only once per write.
let segment_id = pos.get_segment_id();
if segment_id == self.id {
// If its this segment we can get the index and write to it.
let index = pos.get_index();
trace!("Segment.try_write_position: writing to segment {}, index {}", segment_id, index);
self.data[index].try_write(data)
} else if segment_id < self.id {
// Otherwise we need to pass the write on to the `prev`ious or
// `next` segment.
trace!("Segment.try_write_position: passing to previous segment {}", self.id - 1);
try_write_position(&self.prev, pos, data)
} else {
trace!("Segment.try_write_position: passing to next segment {}", self.id + 1);
try_write_position(&self.next, pos, data)
}
}
/// Try to remove data from the front of the `Segment`.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn try_pop_front(&self, head_pos: &AtomicIsize) -> Option<T> {
// Grab a new position for ourself and try to read from it.
//
// Note we don't have exclusive access to it so we're still racing for
// it, hence the fact that `Item` has it's own access control.
let pos = Pos(head_pos.fetch_add(1, DEFAULT_ORDERING));
trace!("Segment.try_pop_front: increased head position, reading from {}", pos);
self.try_pop_position(pos)
.or_else(|| {
// Failed to read, release the position.
let pos = head_pos.fetch_sub(1, DEFAULT_ORDERING);
trace!("Segment.try_pop_front: failed to read from position {}, decreased head position", pos);
// FIXME: it could also be that a `Item` is (currently)
// in a invalid state, what then?
None
})
}
/// Try to remove data from the back of the `Segment`.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn try_pop_back(&self, tail_pos: &AtomicIsize) -> Option<T> {
// See `pop_front` for documentation, this does the same thing but with
// a different position.
let pos = Pos(tail_pos.fetch_sub(1, DEFAULT_ORDERING));
trace!("Segment.try_pop_back: decreased tail position, reading from {}", pos);
self.try_pop_position(pos)
.or_else(|| {
let pos = tail_pos.fetch_add(1, DEFAULT_ORDERING);
trace!("Segment.try_pop_back: failed to read from position {}, increased tail position", pos);
None
})
}
/// Pop the `data` in the provided position.
///
/// # Note
///
/// It possible that the position is not present on the current segment, if
/// that is the case this function will deligate the writing to the correct
/// segment, if present.
///
/// If the segment to which the position belongs doesn't exitsts this will
/// return `None`.
fn try_pop_position(&self, pos: Pos) -> Option<T> {
// Get the `SegmentId` based on the `Pos`ition in which this data must
// be written.
//
// TODO: call get_segment_id only once per read.
let segment_id = pos.get_segment_id();
if segment_id == self.id {
// If its this segment we can get the index and write to it.
let index = pos.get_index();
trace!("Segment.try_pop_position: reading from segment {}, index {}", segment_id, index);
self.data[index].try_pop()
} else if segment_id < self.id {
// Otherwise we need to pass the read on to the `prev`ious or
// `next` segment.
trace!("Segment.try_pop_position: passing to previous segment {}", self.id - 1);
try_pop_position(&self.prev, pos)
} else {
try_pop_position(&self.next, pos)
}
}
/// Try to remove data from the front of the `Segment`, but only is the
/// `predicate` returns true.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn conditional_try_pop_front<P>(&self, head_pos: &AtomicIsize, predicate: P) -> Option<T>
where P: FnOnce(&T) -> bool
{
// Grab a new position for ourself and try to read from it.
//
// Note we don't have exclusive access to it so we're still racing for
// it, hence the fact that `Item` has it's own access control.
let pos = Pos(head_pos.fetch_add(1, DEFAULT_ORDERING));
self.conditional_try_pop_position(pos, predicate)
.or_else(|| {
// Failed to read, release the position.
head_pos.fetch_sub(1, DEFAULT_ORDERING);
// FIXME: it could also be that a `Item` is (currently)
// in a invalid state, what then?
None
})
}
/// Try to remove data from the back of the `Segment`, but only is the
/// `predicate` returns true.
///
/// # Note
///
/// This function will deligate to peer `Segement`s if the position is not
/// in this `Segment`.
pub fn conditional_try_pop_back<P>(&self, tail_pos: &AtomicIsize, predicate: P) -> Option<T>
where P: FnOnce(&T) -> bool
{
// See `conditional_pop_front` for documentation, this does the same thing but with
// a different position.
let pos = Pos(tail_pos.fetch_sub(1, DEFAULT_ORDERING));
self.conditional_try_pop_position(pos, predicate)
.or_else(|| {
tail_pos.fetch_add(1, DEFAULT_ORDERING);
None
})
}
/// Pop the `data` in the provided position, if the `predicate` is met.
///
/// # Note
///
/// It possible that the position is not present on the current segment, if
/// that is the case this function will deligate the writing to the correct
/// segment, if present.
///
/// If the segment to which the position belongs doesn't exitsts this will
/// return `None`.
fn conditional_try_pop_position<P>(&self, pos: Pos, predicate: P) -> Option<T>
where P: FnOnce(&T) -> bool
{
// Get the `SegmentId` based on the `Pos`ition in which this data must
// be written.
//
// TODO: call get_segment_id only once per read.
let segment_id = pos.get_segment_id();
if segment_id == self.id {
// If its this segment we can get the index and write to it.
let index = pos.get_index();
self.data[index].conditional_try_pop(predicate)
} else if segment_id < self.id {
// Otherwise we need to pass the read on to the `prev`ious or
// `next` segment.
conditional_try_pop_position(&self.prev, pos, predicate)
} else {
conditional_try_pop_position(&self.next, pos, predicate)
}
}
/// Expand the current `Segment` with a peer `Segment` to the front. If this
/// `Segment` already has a peer at the front it will return `None`,
/// otherwise it will return a raw pointer to the new `Segment` in the
/// front.
///
/// This pointer can only be used to update the first `Segment` in the users
/// administration. If the `Segment` from the pointer is dropped this, and
/// all peer `Segment`s, become invalid and further usage will cause a
/// segfault, the only expection is [`get_peers`].
///
/// # Usage
///
/// **This function must be called with a heap reference**, e.g. by using a
/// `Box` or an [`AtomicPtr`], hence the reason why [`Segment::empty`]
/// returns a boxed `Segment`.
///
/// [`get_peers`]: #method.get_peers
/// [`AtomicPtr`]: https://doc.rust-lang.org/nightly/core/sync/atomic/struct.AtomicPtr.html
/// [`Segment::empty`]: #method.empty
pub unsafe fn expand_front(&self) -> Option<*mut Segment<T>> {
if self.prev.load(DEFAULT_ORDERING).is_null() {
let ptr = Segment::expand_front_with_segment(self, Segment::empty());
Some(ptr)
} else {
None
}
}
/// Expand the current segment with the provided segment.
///
/// # Note
///
/// When this function returns it will always have a segment in `self.prev`,
/// however it may be a different segment then the one provided.
///
/// **This function must be called on a box**.
unsafe fn expand_front_with_segment(&self, mut new_segment: Box<Segment<T>>) -> *mut Segment<T> {
// For an `AtomicPtr` we need `*mut Segment<T>`, or a mutable raw
// pointer to a `Segment`. But since we don't even use a mutable
// reference (`&mut`) for any method, we can make do with a raw pointer
// (`*const`). So we cast a raw pointer into a raw mutable pointer and
// pass that to `AtomicPtr`.
//
// With the raw mutable pointer we set the correct `next` pointer on the
// `new_segment` and set the correct id.
let self_ptr: *const Segment<T> = &*self;
new_segment.next = AtomicPtr::new(self_ptr as *mut Segment<T>);
new_segment.id = self.id - 1;
// Make sure the current `prev` ptr is null and we don't overwrite any
// segments.
let result = self.prev.compare_exchange(ptr::null_mut(), &mut *new_segment,
DEFAULT_ORDERING, Ordering::Relaxed);
if let Err(prev_ptr) = result {
// So unfortunately a new segment was already allocated and added to
// the current one.
//
// Now we have two choices:
// 1) do nothing, the current segment has a segment after all, or
// 2) add the new segment to the next segment, so we don't waste the
// allocation.
//
// We'll go with option two.
// We already made sure the pointer is valid, so this is safe to
// convert in to a `&Segment`.
// It is to call `expand_front_with_segment` with the `prev_ptr`
// because it is already on the heap.
Segment::expand_front_with_segment(&*prev_ptr, new_segment)
} else {
// All is ok and we added the segment to the current segment.
//
// Now we need to forget about `new_segment` and return a raw
// pointer to it.
Box::into_raw(new_segment)
}
}
/// See `expand_front` for docs. This does the same thing but adding a new
/// `Segment` to the back.
pub unsafe fn expand_back(&self) -> Option<*mut Segment<T>> {
if self.next.load(DEFAULT_ORDERING).is_null() {
let ptr = Segment::expand_back_with_segment(self, Segment::empty());
Some(ptr)
} else {
None
}
}
/// See `expand_front_with_segment`.
unsafe fn expand_back_with_segment(&self, mut new_segment: Box<Segment<T>>) -> *mut Segment<T> {
// See `expand_front_with_segment` for docs.
let self_ptr: *const Segment<T> = &*self;
new_segment.prev = AtomicPtr::new(self_ptr as *mut Segment<T>);
new_segment.id = self.id + 1;
let result = self.next.compare_exchange(ptr::null_mut(), &mut *new_segment,
DEFAULT_ORDERING, Ordering::Relaxed);
if let Err(next_ptr) = result {
Segment::expand_back_with_segment(&*next_ptr, new_segment)
} else {
Box::into_raw(new_segment)
}
}
/// Get the peer `Segment`s from this `Segment`. If these are not null they
/// will always point to other valid `Segment`s.
///
/// # Note
///
/// Once this method is called **all** peers of the `Segment` will become
/// invalid and any method called on them, with the expection of this one,
/// can result in a segfault.
///
/// This method may only be called when dropping it, hence the fact that it
/// moves and drops itself.
pub fn get_peers(self) -> (*mut Segment<T>, *mut Segment<T>) {
let prev = self.prev.load(Ordering::Relaxed);
let next = self.next.load(Ordering::Relaxed);
(prev, next)
}
}
/// Call `segment.write_position` if the pointer points to a valid `Segment`,
/// else returns an error.
///
/// # Note
///
/// The provided pointer must follow the contract defined in the `Segment.{next,
/// prev}` fields.
fn try_write_position<T>(ptr: &AtomicPtr<Segment<T>>, pos: Pos, data: T) -> Result<(), T> {
let segment = unsafe {
// This is safe because the `previous` and `next` pointers must always
// point to a valid segment, if not null.
ptr.load(DEFAULT_ORDERING).as_ref()
.map(|segment_ptr| &*segment_ptr)
};
if let Some(segment) = segment {
// the next or previous segment exists and we'll let it deal with the
// write.
segment.try_write_position(pos, data)
} else {
// A next or previous segment doesn't exists, so we return an error.
trace!("Segment.try_write_position: failed to write to position {}, doesn't exists", pos);
Err(data)
}
}
/// Call `segment.pop_position` if the pointer points to a valid `Segment`, else
/// returns `None`.
///
/// # Note
///
/// The provided pointer must follow the contract defined in the `Segment.{next,
/// prev}` fields.
fn try_pop_position<T>(ptr: &AtomicPtr<Segment<T>>, pos: Pos) -> Option<T> {
let segment = unsafe {
// This is safe because the `previous` and `next` pointers must always
// point to a valid segment, if not null.
ptr.load(DEFAULT_ORDERING).as_ref()
.map(|segment_ptr| &*segment_ptr)
};
if let Some(segment) = segment {
// the next or previous segment exists and we'll let it deal with the
// write.
segment.try_pop_position(pos)
} else {
// A next or previous segment doesn't exists.
trace!("Segment.try_pop_position: failed to read from position {}, doesn't exists", pos);
None
}
}
/// Call `segment.conditional_pop_position` if the pointer points to a valid
/// `Segment`, else returns `None`.
///
/// # Note
///
/// The provided pointer must follow the contract defined in the `Segment.{next,
/// prev}` fields.
fn conditional_try_pop_position<P, T>(ptr: &AtomicPtr<Segment<T>>, pos: Pos, predicate: P) -> Option<T>
where P: FnOnce(&T) -> bool
{
let segment = unsafe {
// This is safe because the `previous` and `next` pointers must always
// point to a valid segment, if not null.
ptr.load(DEFAULT_ORDERING).as_ref()
.map(|segment_ptr| &*segment_ptr)
};
if let Some(segment) = segment {
// the next or previous segment exists and we'll let it deal with the
// write.
segment.conditional_try_pop_position(pos, predicate)
} else {
// A next or previous segment doesn't exists.
trace!("Segment.conditional_try_pop_position: failed to read from position {}, doesn't exists", pos);
None
}
}
impl<T> fmt::Debug for Segment<T> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.pad("Segment{{ ... }}")
}
}
#[cfg(test)]
mod tests {
use std::mem;
use super::*;
fn assert_send<T: Send>() {}
fn assert_sync<T: Sync>() {}
fn assert_debug<T: fmt::Debug>() {}
fn assert_size<T>(want: usize) {
assert_eq!(mem::size_of::<T>(), want);
}
#[test]
fn segment_assertions() {
assert_send::<Segment<u64>>();
assert_sync::<Segment<u64>>();
assert_debug::<Segment<u64>>();
// 8 bytes for the id, `SEGMENT_SIZE` * `Item`, 2x pointers.
#[cfg(target_pointer_width = "64")]
let want = 8 + (SEGMENT_SIZE * (8 + 8 + 8)) + 8 + 8;
#[cfg(target_pointer_width = "32")]
let want = 8 + (SEGMENT_SIZE * (8 + 8 + 8)) + 4 + 4;
assert_size::<Segment<u64>>(want);
}
#[test]
fn pos() {
let tests = vec![
// Pos, is valid, `SegmentId`, index.
(Pos(0), false, 0, 0),
(Pos(1), true, 1, 0),
(Pos(2), true, 1, 1),
(Pos(3), true, 1, 2),
(Pos(10), true, 1, 9),
(Pos(15), true, 1, 14),
(Pos(20), true, 1, 19),
(Pos(25), true, 1, 24),
(Pos(31), true, 1, 30),
(Pos(32), true, 1, 31),
(Pos(33), true, 2, 0),
(Pos(64), true, 2, 31),
(Pos(65), true, 3, 0),
(Pos(-1), true, -1, 0),
(Pos(-2), true, -1, 1),
(Pos(-5), true, -1, 4),
(Pos(-10), true, -1, 9),
(Pos(-20), true, -1, 19),
(Pos(-32), true, -1, 31),
(Pos(-33), true, -2, 0),
(Pos(-64), true, -2, 31),
(Pos(-65), true, -3, 0),
];
for test in tests {
let pos = test.0;
assert_eq!(pos.is_valid(), test.1, "{}.is_valid()", pos);
if pos.is_valid() {
debug!("calling with {:?}", pos);
assert_eq!(pos.get_segment_id(), test.2, "{}.get_segment_id()", pos);
//assert_eq!(pos.get_index(), test.3, "{}.get_index()", pos);
}
}
}
}
|
fn main() {
let d = Data { value: 4 };
println!("{}", d.times());
println!("{}", d.plus(3));
println!("{}", d.plus2());
}
struct Data {
value: i32
}
impl Data {
fn times(&self) -> i32 {
self.value * 2
}
fn plus(&self, v: i32) -> i32 {
self.value + v
}
}
impl Data {
fn plus2(&self) -> i32 {
self.plus(2)
}
}
|
use proc_macro2::{Ident, Span, TokenStream};
use quote::quote;
use serde::Deserialize;
use serde_tokenstream::from_tokenstream;
use std::fmt::Formatter;
use std::sync::atomic::{AtomicBool, Ordering};
use syn::Error;
use syn::{spanned::Spanned, FnArg, ItemFn, Pat, PatIdent, PatType, ReturnType, Signature, Type};
#[derive(Default, Deserialize)]
struct ExportAttributes {
pub name: Option<String>,
pub guard: Option<String>,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
enum MethodType {
Init,
PreUpgrade,
PostUpgrade,
Update,
Query,
Heartbeat,
InspectMessage,
}
impl MethodType {
pub fn is_lifecycle(&self) -> bool {
matches!(
self,
MethodType::Init
| MethodType::PreUpgrade
| MethodType::PostUpgrade
| MethodType::Heartbeat
| MethodType::InspectMessage
)
}
}
impl std::fmt::Display for MethodType {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
match self {
MethodType::Init => f.write_str("canister_init"),
MethodType::PreUpgrade => f.write_str("canister_pre_upgrade"),
MethodType::PostUpgrade => f.write_str("canister_post_upgrade"),
MethodType::Query => f.write_str("canister_query"),
MethodType::Update => f.write_str("canister_update"),
MethodType::Heartbeat => f.write_str("canister_heartbeat"),
MethodType::InspectMessage => f.write_str("canister_inspect_message"),
}
}
}
fn get_args(method: MethodType, signature: &Signature) -> Result<Vec<(Ident, Box<Type>)>, Error> {
// We only need the tuple of arguments, not their types. Magic of type inference.
let mut args = vec![];
for ref arg in &signature.inputs {
let (ident, ty) = match arg {
FnArg::Receiver(r) => {
return Err(Error::new(
r.span(),
format!(
"#[{}] cannot be above functions with `self` as a parameter",
method
),
));
}
FnArg::Typed(PatType { pat, ty, .. }) => {
if let Pat::Ident(PatIdent { ident, .. }) = pat.as_ref() {
(ident.clone(), ty.clone())
} else {
(
syn::Ident::new(&format!("arg_{}", crate::id()), pat.span()),
ty.clone(),
)
}
}
};
args.push((ident, ty));
}
Ok(args)
}
fn dfn_macro(
method: MethodType,
attr: TokenStream,
item: TokenStream,
) -> Result<TokenStream, Error> {
let attrs = from_tokenstream::<ExportAttributes>(&attr)?;
let fun: ItemFn = syn::parse2::<syn::ItemFn>(item.clone()).map_err(|e| {
Error::new(
item.span(),
format!("#[{0}] must be above a function, \n{1}", method, e),
)
})?;
let signature = &fun.sig;
let generics = &signature.generics;
if !generics.params.is_empty() {
return Err(Error::new(
generics.span(),
format!(
"#[{}] must be above a function with no generic parameters",
method
),
));
}
let is_async = signature.asyncness.is_some();
let return_length = match &signature.output {
ReturnType::Default => 0,
ReturnType::Type(_, ty) => match ty.as_ref() {
Type::Tuple(tuple) => tuple.elems.len(),
_ => 1,
},
};
if method.is_lifecycle() && return_length > 0 {
return Err(Error::new(
Span::call_site(),
format!("#[{}] function cannot have a return value.", method),
));
}
let (arg_tuple, _): (Vec<Ident>, Vec<Box<Type>>) =
get_args(method, signature)?.iter().cloned().unzip();
let name = &signature.ident;
let outer_function_ident = Ident::new(
&format!("{}_{}_", name.to_string(), crate::id()),
Span::call_site(),
);
let export_name = if method.is_lifecycle() {
format!("{}", method)
} else {
format!(
"{0} {1}",
method,
attrs.name.unwrap_or_else(|| name.to_string())
)
};
let function_call = if is_async {
quote! { #name ( #(#arg_tuple),* ) .await }
} else {
quote! { #name ( #(#arg_tuple),* ) }
};
let arg_count = arg_tuple.len();
let return_encode = if method.is_lifecycle() {
quote! {}
} else {
match return_length {
0 => quote! { ic_cdk::api::call::reply(()) },
1 => quote! { ic_cdk::api::call::reply((result,)) },
_ => quote! { ic_cdk::api::call::reply(result) },
}
};
// On initialization we can actually not receive any input and it's okay, only if
// we don't have any arguments either.
// If the data we receive is not empty, then try to unwrap it as if it's DID.
let arg_decode = if method.is_lifecycle() && arg_count == 0 {
quote! {}
} else {
quote! { let ( #( #arg_tuple, )* ) = ic_cdk::api::call::arg_data(); }
};
let guard = if let Some(guard_name) = attrs.guard {
let guard_ident = syn::Ident::new(&guard_name, Span::call_site());
quote! {
let r: Result<(), String> = #guard_ident ();
if let Err(e) = r {
ic_cdk::api::call::reject(&e);
return;
}
}
} else {
quote! {}
};
Ok(quote! {
#[export_name = #export_name]
fn #outer_function_ident() {
ic_cdk::setup();
#guard
ic_cdk::block_on(async {
#arg_decode
let result = #function_call;
#return_encode
});
}
#item
})
}
pub(crate) fn ic_query(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
dfn_macro(
MethodType::Query,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
pub(crate) fn ic_update(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
dfn_macro(
MethodType::Update,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
#[derive(Default, Deserialize)]
struct InitAttributes {}
static IS_INIT: AtomicBool = AtomicBool::new(false);
pub(crate) fn ic_init(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
if IS_INIT.swap(true, Ordering::SeqCst) {
return Err(Error::new(
Span::call_site(),
"Init function already declared.",
));
}
dfn_macro(
MethodType::Init,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
static HAS_PRE_UPGRADE: AtomicBool = AtomicBool::new(false);
pub(crate) fn ic_pre_upgrade(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
if HAS_PRE_UPGRADE.swap(true, Ordering::SeqCst) {
return Err(Error::new(
Span::call_site(),
"Pre-upgrade function already declared.",
));
}
dfn_macro(
MethodType::PreUpgrade,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
static HAS_POST_UPGRADE: AtomicBool = AtomicBool::new(false);
pub(crate) fn ic_post_upgrade(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
if HAS_POST_UPGRADE.swap(true, Ordering::SeqCst) {
return Err(Error::new(
Span::call_site(),
"Post-upgrade function already declared.",
));
}
dfn_macro(
MethodType::PostUpgrade,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
static HAS_HEARTBEAT: AtomicBool = AtomicBool::new(false);
pub(crate) fn ic_heartbeat(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
if HAS_HEARTBEAT.swap(true, Ordering::SeqCst) {
return Err(Error::new(
Span::call_site(),
"Heartbeat function already declared.",
));
}
dfn_macro(
MethodType::Heartbeat,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
static HAS_INSPECT_MESSAGE: AtomicBool = AtomicBool::new(false);
pub(crate) fn ic_inspect_message(
attr: proc_macro::TokenStream,
item: proc_macro::TokenStream,
) -> Result<proc_macro::TokenStream, Error> {
if HAS_INSPECT_MESSAGE.swap(true, Ordering::SeqCst) {
return Err(Error::new(
Span::call_site(),
"Inspect-message function already declared.",
));
}
dfn_macro(
MethodType::InspectMessage,
TokenStream::from(attr),
TokenStream::from(item),
)
.map(proc_macro::TokenStream::from)
}
|
use super::{utils::sort_by_cost_weight_ratio, Item, Problem, Solution, SolverTrait};
#[derive(Debug, Clone)]
pub struct GreedySolver();
impl SolverTrait for GreedySolver {
fn construction(&self, problem: &Problem) -> Solution {
let (items, mappings) = sort_by_cost_weight_ratio(&problem.items, problem.max_weight);
let (items, cost) =
construction_greedy_inner(&items, &mappings, problem.size, problem.max_weight);
Solution {
id: problem.id,
size: problem.size,
items: Some(items),
cost,
}
}
}
pub fn construction_greedy_inner(
items: &[Item],
mappings: &[usize],
size: usize,
max_weight: u32,
) -> (Vec<bool>, u32) {
let (items, _, cost) = items.iter().enumerate().fold(
(vec![false; size], max_weight, 0),
|(mut items, rem_weight, cost), (i, item)| {
if rem_weight >= item.weight {
items[mappings[i]] = true;
(items, rem_weight - item.weight, cost + item.cost)
} else {
(items, rem_weight, cost)
}
},
);
(items, cost)
}
|
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtNetwork/qsslcertificate.h
// dst-file: /src/network/qsslcertificate.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main block end
// use block begin =>
use std::ops::Deref;
use super::super::core::qbytearray::QByteArray; // 771
use super::qsslkey::QSslKey; // 773
use super::super::core::qdatetime::QDateTime; // 771
use super::super::core::qiodevice::QIODevice; // 771
use super::super::core::qstring::QString; // 771
// <= use block end
// ext block begin =>
// #[link(name = "Qt5Core")]
// #[link(name = "Qt5Gui")]
// #[link(name = "Qt5Widgets")]
// #[link(name = "QtInline")]
extern {
fn QSslCertificate_Class_Size() -> c_int;
// proto: QByteArray QSslCertificate::toPem();
fn _ZNK15QSslCertificate5toPemEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QSslCertificate::swap(QSslCertificate & other);
fn _ZN15QSslCertificate4swapERS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: void QSslCertificate::~QSslCertificate();
fn _ZN15QSslCertificateD2Ev(qthis: u64 /* *mut c_void*/);
// proto: QSslKey QSslCertificate::publicKey();
fn _ZNK15QSslCertificate9publicKeyEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QList<QByteArray> QSslCertificate::issuerInfoAttributes();
fn _ZNK15QSslCertificate20issuerInfoAttributesEv(qthis: u64 /* *mut c_void*/);
// proto: QStringList QSslCertificate::issuerInfo(const QByteArray & attribute);
fn _ZNK15QSslCertificate10issuerInfoERK10QByteArray(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: bool QSslCertificate::isNull();
fn _ZNK15QSslCertificate6isNullEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: QByteArray QSslCertificate::toDer();
fn _ZNK15QSslCertificate5toDerEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: void QSslCertificate::clear();
fn _ZN15QSslCertificate5clearEv(qthis: u64 /* *mut c_void*/);
// proto: QDateTime QSslCertificate::expiryDate();
fn _ZNK15QSslCertificate10expiryDateEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QByteArray QSslCertificate::version();
fn _ZNK15QSslCertificate7versionEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QString QSslCertificate::toText();
fn _ZNK15QSslCertificate6toTextEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: QStringList QSslCertificate::subjectInfo(const QByteArray & attribute);
fn _ZNK15QSslCertificate11subjectInfoERK10QByteArray(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: QList<QSslCertificateExtension> QSslCertificate::extensions();
fn _ZNK15QSslCertificate10extensionsEv(qthis: u64 /* *mut c_void*/);
// proto: QByteArray QSslCertificate::serialNumber();
fn _ZNK15QSslCertificate12serialNumberEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: bool QSslCertificate::isSelfSigned();
fn _ZNK15QSslCertificate12isSelfSignedEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: void QSslCertificate::QSslCertificate(const QSslCertificate & other);
fn _ZN15QSslCertificateC2ERKS_(qthis: u64 /* *mut c_void*/, arg0: *mut c_void);
// proto: bool QSslCertificate::isBlacklisted();
fn _ZNK15QSslCertificate13isBlacklistedEv(qthis: u64 /* *mut c_void*/) -> c_char;
// proto: QList<QByteArray> QSslCertificate::subjectInfoAttributes();
fn _ZNK15QSslCertificate21subjectInfoAttributesEv(qthis: u64 /* *mut c_void*/);
// proto: QDateTime QSslCertificate::effectiveDate();
fn _ZNK15QSslCertificate13effectiveDateEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
} // <= ext block end
// body block begin =>
// class sizeof(QSslCertificate)=1
#[derive(Default)]
pub struct QSslCertificate {
// qbase: None,
pub qclsinst: u64 /* *mut c_void*/,
}
impl /*struct*/ QSslCertificate {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QSslCertificate {
return QSslCertificate{qclsinst: qthis, ..Default::default()};
}
}
// proto: QByteArray QSslCertificate::toPem();
impl /*struct*/ QSslCertificate {
pub fn toPem<RetType, T: QSslCertificate_toPem<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.toPem(self);
// return 1;
}
}
pub trait QSslCertificate_toPem<RetType> {
fn toPem(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QByteArray QSslCertificate::toPem();
impl<'a> /*trait*/ QSslCertificate_toPem<QByteArray> for () {
fn toPem(self , rsthis: & QSslCertificate) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate5toPemEv()};
let mut ret = unsafe {_ZNK15QSslCertificate5toPemEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QSslCertificate::swap(QSslCertificate & other);
impl /*struct*/ QSslCertificate {
pub fn swap<RetType, T: QSslCertificate_swap<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.swap(self);
// return 1;
}
}
pub trait QSslCertificate_swap<RetType> {
fn swap(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: void QSslCertificate::swap(QSslCertificate & other);
impl<'a> /*trait*/ QSslCertificate_swap<()> for (&'a QSslCertificate) {
fn swap(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN15QSslCertificate4swapERS_()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {_ZN15QSslCertificate4swapERS_(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: void QSslCertificate::~QSslCertificate();
impl /*struct*/ QSslCertificate {
pub fn free<RetType, T: QSslCertificate_free<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.free(self);
// return 1;
}
}
pub trait QSslCertificate_free<RetType> {
fn free(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: void QSslCertificate::~QSslCertificate();
impl<'a> /*trait*/ QSslCertificate_free<()> for () {
fn free(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN15QSslCertificateD2Ev()};
unsafe {_ZN15QSslCertificateD2Ev(rsthis.qclsinst)};
// return 1;
}
}
// proto: QSslKey QSslCertificate::publicKey();
impl /*struct*/ QSslCertificate {
pub fn publicKey<RetType, T: QSslCertificate_publicKey<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.publicKey(self);
// return 1;
}
}
pub trait QSslCertificate_publicKey<RetType> {
fn publicKey(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QSslKey QSslCertificate::publicKey();
impl<'a> /*trait*/ QSslCertificate_publicKey<QSslKey> for () {
fn publicKey(self , rsthis: & QSslCertificate) -> QSslKey {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate9publicKeyEv()};
let mut ret = unsafe {_ZNK15QSslCertificate9publicKeyEv(rsthis.qclsinst)};
let mut ret1 = QSslKey::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QList<QByteArray> QSslCertificate::issuerInfoAttributes();
impl /*struct*/ QSslCertificate {
pub fn issuerInfoAttributes<RetType, T: QSslCertificate_issuerInfoAttributes<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.issuerInfoAttributes(self);
// return 1;
}
}
pub trait QSslCertificate_issuerInfoAttributes<RetType> {
fn issuerInfoAttributes(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QList<QByteArray> QSslCertificate::issuerInfoAttributes();
impl<'a> /*trait*/ QSslCertificate_issuerInfoAttributes<()> for () {
fn issuerInfoAttributes(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate20issuerInfoAttributesEv()};
unsafe {_ZNK15QSslCertificate20issuerInfoAttributesEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QStringList QSslCertificate::issuerInfo(const QByteArray & attribute);
impl /*struct*/ QSslCertificate {
pub fn issuerInfo<RetType, T: QSslCertificate_issuerInfo<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.issuerInfo(self);
// return 1;
}
}
pub trait QSslCertificate_issuerInfo<RetType> {
fn issuerInfo(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QStringList QSslCertificate::issuerInfo(const QByteArray & attribute);
impl<'a> /*trait*/ QSslCertificate_issuerInfo<()> for (&'a QByteArray) {
fn issuerInfo(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate10issuerInfoERK10QByteArray()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {_ZNK15QSslCertificate10issuerInfoERK10QByteArray(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: bool QSslCertificate::isNull();
impl /*struct*/ QSslCertificate {
pub fn isNull<RetType, T: QSslCertificate_isNull<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isNull(self);
// return 1;
}
}
pub trait QSslCertificate_isNull<RetType> {
fn isNull(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: bool QSslCertificate::isNull();
impl<'a> /*trait*/ QSslCertificate_isNull<i8> for () {
fn isNull(self , rsthis: & QSslCertificate) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate6isNullEv()};
let mut ret = unsafe {_ZNK15QSslCertificate6isNullEv(rsthis.qclsinst)};
return ret as i8;
// return 1;
}
}
// proto: QByteArray QSslCertificate::toDer();
impl /*struct*/ QSslCertificate {
pub fn toDer<RetType, T: QSslCertificate_toDer<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.toDer(self);
// return 1;
}
}
pub trait QSslCertificate_toDer<RetType> {
fn toDer(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QByteArray QSslCertificate::toDer();
impl<'a> /*trait*/ QSslCertificate_toDer<QByteArray> for () {
fn toDer(self , rsthis: & QSslCertificate) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate5toDerEv()};
let mut ret = unsafe {_ZNK15QSslCertificate5toDerEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: void QSslCertificate::clear();
impl /*struct*/ QSslCertificate {
pub fn clear<RetType, T: QSslCertificate_clear<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.clear(self);
// return 1;
}
}
pub trait QSslCertificate_clear<RetType> {
fn clear(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: void QSslCertificate::clear();
impl<'a> /*trait*/ QSslCertificate_clear<()> for () {
fn clear(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN15QSslCertificate5clearEv()};
unsafe {_ZN15QSslCertificate5clearEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QDateTime QSslCertificate::expiryDate();
impl /*struct*/ QSslCertificate {
pub fn expiryDate<RetType, T: QSslCertificate_expiryDate<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.expiryDate(self);
// return 1;
}
}
pub trait QSslCertificate_expiryDate<RetType> {
fn expiryDate(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QDateTime QSslCertificate::expiryDate();
impl<'a> /*trait*/ QSslCertificate_expiryDate<QDateTime> for () {
fn expiryDate(self , rsthis: & QSslCertificate) -> QDateTime {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate10expiryDateEv()};
let mut ret = unsafe {_ZNK15QSslCertificate10expiryDateEv(rsthis.qclsinst)};
let mut ret1 = QDateTime::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QByteArray QSslCertificate::version();
impl /*struct*/ QSslCertificate {
pub fn version<RetType, T: QSslCertificate_version<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.version(self);
// return 1;
}
}
pub trait QSslCertificate_version<RetType> {
fn version(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QByteArray QSslCertificate::version();
impl<'a> /*trait*/ QSslCertificate_version<QByteArray> for () {
fn version(self , rsthis: & QSslCertificate) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate7versionEv()};
let mut ret = unsafe {_ZNK15QSslCertificate7versionEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QString QSslCertificate::toText();
impl /*struct*/ QSslCertificate {
pub fn toText<RetType, T: QSslCertificate_toText<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.toText(self);
// return 1;
}
}
pub trait QSslCertificate_toText<RetType> {
fn toText(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QString QSslCertificate::toText();
impl<'a> /*trait*/ QSslCertificate_toText<QString> for () {
fn toText(self , rsthis: & QSslCertificate) -> QString {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate6toTextEv()};
let mut ret = unsafe {_ZNK15QSslCertificate6toTextEv(rsthis.qclsinst)};
let mut ret1 = QString::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: QStringList QSslCertificate::subjectInfo(const QByteArray & attribute);
impl /*struct*/ QSslCertificate {
pub fn subjectInfo<RetType, T: QSslCertificate_subjectInfo<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.subjectInfo(self);
// return 1;
}
}
pub trait QSslCertificate_subjectInfo<RetType> {
fn subjectInfo(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QStringList QSslCertificate::subjectInfo(const QByteArray & attribute);
impl<'a> /*trait*/ QSslCertificate_subjectInfo<()> for (&'a QByteArray) {
fn subjectInfo(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate11subjectInfoERK10QByteArray()};
let arg0 = self.qclsinst as *mut c_void;
unsafe {_ZNK15QSslCertificate11subjectInfoERK10QByteArray(rsthis.qclsinst, arg0)};
// return 1;
}
}
// proto: QList<QSslCertificateExtension> QSslCertificate::extensions();
impl /*struct*/ QSslCertificate {
pub fn extensions<RetType, T: QSslCertificate_extensions<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.extensions(self);
// return 1;
}
}
pub trait QSslCertificate_extensions<RetType> {
fn extensions(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QList<QSslCertificateExtension> QSslCertificate::extensions();
impl<'a> /*trait*/ QSslCertificate_extensions<()> for () {
fn extensions(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate10extensionsEv()};
unsafe {_ZNK15QSslCertificate10extensionsEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QByteArray QSslCertificate::serialNumber();
impl /*struct*/ QSslCertificate {
pub fn serialNumber<RetType, T: QSslCertificate_serialNumber<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.serialNumber(self);
// return 1;
}
}
pub trait QSslCertificate_serialNumber<RetType> {
fn serialNumber(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QByteArray QSslCertificate::serialNumber();
impl<'a> /*trait*/ QSslCertificate_serialNumber<QByteArray> for () {
fn serialNumber(self , rsthis: & QSslCertificate) -> QByteArray {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate12serialNumberEv()};
let mut ret = unsafe {_ZNK15QSslCertificate12serialNumberEv(rsthis.qclsinst)};
let mut ret1 = QByteArray::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: bool QSslCertificate::isSelfSigned();
impl /*struct*/ QSslCertificate {
pub fn isSelfSigned<RetType, T: QSslCertificate_isSelfSigned<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isSelfSigned(self);
// return 1;
}
}
pub trait QSslCertificate_isSelfSigned<RetType> {
fn isSelfSigned(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: bool QSslCertificate::isSelfSigned();
impl<'a> /*trait*/ QSslCertificate_isSelfSigned<i8> for () {
fn isSelfSigned(self , rsthis: & QSslCertificate) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate12isSelfSignedEv()};
let mut ret = unsafe {_ZNK15QSslCertificate12isSelfSignedEv(rsthis.qclsinst)};
return ret as i8;
// return 1;
}
}
// proto: void QSslCertificate::QSslCertificate(const QSslCertificate & other);
impl /*struct*/ QSslCertificate {
pub fn new<T: QSslCertificate_new>(value: T) -> QSslCertificate {
let rsthis = value.new();
return rsthis;
// return 1;
}
}
pub trait QSslCertificate_new {
fn new(self) -> QSslCertificate;
}
// proto: void QSslCertificate::QSslCertificate(const QSslCertificate & other);
impl<'a> /*trait*/ QSslCertificate_new for (&'a QSslCertificate) {
fn new(self) -> QSslCertificate {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZN15QSslCertificateC2ERKS_()};
let ctysz: c_int = unsafe{QSslCertificate_Class_Size()};
let qthis_ph: u64 = unsafe{calloc(1, ctysz as usize)} as u64;
let arg0 = self.qclsinst as *mut c_void;
unsafe {_ZN15QSslCertificateC2ERKS_(qthis_ph, arg0)};
let qthis: u64 = qthis_ph;
let rsthis = QSslCertificate{qclsinst: qthis, ..Default::default()};
return rsthis;
// return 1;
}
}
// proto: bool QSslCertificate::isBlacklisted();
impl /*struct*/ QSslCertificate {
pub fn isBlacklisted<RetType, T: QSslCertificate_isBlacklisted<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.isBlacklisted(self);
// return 1;
}
}
pub trait QSslCertificate_isBlacklisted<RetType> {
fn isBlacklisted(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: bool QSslCertificate::isBlacklisted();
impl<'a> /*trait*/ QSslCertificate_isBlacklisted<i8> for () {
fn isBlacklisted(self , rsthis: & QSslCertificate) -> i8 {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate13isBlacklistedEv()};
let mut ret = unsafe {_ZNK15QSslCertificate13isBlacklistedEv(rsthis.qclsinst)};
return ret as i8;
// return 1;
}
}
// proto: QList<QByteArray> QSslCertificate::subjectInfoAttributes();
impl /*struct*/ QSslCertificate {
pub fn subjectInfoAttributes<RetType, T: QSslCertificate_subjectInfoAttributes<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.subjectInfoAttributes(self);
// return 1;
}
}
pub trait QSslCertificate_subjectInfoAttributes<RetType> {
fn subjectInfoAttributes(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QList<QByteArray> QSslCertificate::subjectInfoAttributes();
impl<'a> /*trait*/ QSslCertificate_subjectInfoAttributes<()> for () {
fn subjectInfoAttributes(self , rsthis: & QSslCertificate) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate21subjectInfoAttributesEv()};
unsafe {_ZNK15QSslCertificate21subjectInfoAttributesEv(rsthis.qclsinst)};
// return 1;
}
}
// proto: QDateTime QSslCertificate::effectiveDate();
impl /*struct*/ QSslCertificate {
pub fn effectiveDate<RetType, T: QSslCertificate_effectiveDate<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.effectiveDate(self);
// return 1;
}
}
pub trait QSslCertificate_effectiveDate<RetType> {
fn effectiveDate(self , rsthis: & QSslCertificate) -> RetType;
}
// proto: QDateTime QSslCertificate::effectiveDate();
impl<'a> /*trait*/ QSslCertificate_effectiveDate<QDateTime> for () {
fn effectiveDate(self , rsthis: & QSslCertificate) -> QDateTime {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK15QSslCertificate13effectiveDateEv()};
let mut ret = unsafe {_ZNK15QSslCertificate13effectiveDateEv(rsthis.qclsinst)};
let mut ret1 = QDateTime::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// <= body block end
|
use super::Topic;
use super::FirstUpper;
pub struct Elementary;
struct StructWithState {
a: u32,
b: String
}
impl StructWithState {
fn my_method(&self, my_string: &str) -> i32 {
println!("a was {}, parameter was {}", self.a, my_string);
43
}
}
impl Topic for Elementary {
fn run_example(&self, n: u8) {
println!("Topic: Elementary, example {}", n);
match n {
1 => { println!("Hello, world!"); },
2 => { example_2(); },
_ => { println!("Example not known or not implemented!"); }
};
}
fn describe(&self) -> String { "elementary".to_string() }
}
fn example_2() {
let mut my_struct = StructWithState { a: 42, b: "lala".to_string() };
my_struct.a = 89;
my_struct.my_method("haha");
println!("Todo");
// TODO
}
|
// auto generated, do not modify.
// created: Wed Jan 20 00:44:03 2016
// src-file: /QtQuick/qsgtextureprovider.h
// dst-file: /src/quick/qsgtextureprovider.rs
//
// header block begin =>
#![feature(libc)]
#![feature(core)]
#![feature(collections)]
extern crate libc;
use self::libc::*;
// <= header block end
// main block begin =>
// <= main block end
// use block begin =>
use super::super::core::qobject::QObject; // 771
use std::ops::Deref;
use super::qsgtexture::QSGTexture; // 773
// <= use block end
// ext block begin =>
// #[link(name = "Qt5Core")]
// #[link(name = "Qt5Gui")]
// #[link(name = "Qt5Widgets")]
// #[link(name = "QtInline")]
extern {
fn QSGTextureProvider_Class_Size() -> c_int;
// proto: QSGTexture * QSGTextureProvider::texture();
fn _ZNK18QSGTextureProvider7textureEv(qthis: u64 /* *mut c_void*/) -> *mut c_void;
// proto: const QMetaObject * QSGTextureProvider::metaObject();
fn _ZNK18QSGTextureProvider10metaObjectEv(qthis: u64 /* *mut c_void*/);
fn QSGTextureProvider_SlotProxy_connect__ZN18QSGTextureProvider14textureChangedEv(qthis: *mut c_void, ffifptr: *mut c_void, rsfptr: *mut c_void);
} // <= ext block end
// body block begin =>
// class sizeof(QSGTextureProvider)=1
#[derive(Default)]
pub struct QSGTextureProvider {
qbase: QObject,
pub qclsinst: u64 /* *mut c_void*/,
pub _textureChanged: QSGTextureProvider_textureChanged_signal,
}
impl /*struct*/ QSGTextureProvider {
pub fn inheritFrom(qthis: u64 /* *mut c_void*/) -> QSGTextureProvider {
return QSGTextureProvider{qbase: QObject::inheritFrom(qthis), qclsinst: qthis, ..Default::default()};
}
}
impl Deref for QSGTextureProvider {
type Target = QObject;
fn deref(&self) -> &QObject {
return & self.qbase;
}
}
impl AsRef<QObject> for QSGTextureProvider {
fn as_ref(& self) -> & QObject {
return & self.qbase;
}
}
// proto: QSGTexture * QSGTextureProvider::texture();
impl /*struct*/ QSGTextureProvider {
pub fn texture<RetType, T: QSGTextureProvider_texture<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.texture(self);
// return 1;
}
}
pub trait QSGTextureProvider_texture<RetType> {
fn texture(self , rsthis: & QSGTextureProvider) -> RetType;
}
// proto: QSGTexture * QSGTextureProvider::texture();
impl<'a> /*trait*/ QSGTextureProvider_texture<QSGTexture> for () {
fn texture(self , rsthis: & QSGTextureProvider) -> QSGTexture {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK18QSGTextureProvider7textureEv()};
let mut ret = unsafe {_ZNK18QSGTextureProvider7textureEv(rsthis.qclsinst)};
let mut ret1 = QSGTexture::inheritFrom(ret as u64);
return ret1;
// return 1;
}
}
// proto: const QMetaObject * QSGTextureProvider::metaObject();
impl /*struct*/ QSGTextureProvider {
pub fn metaObject<RetType, T: QSGTextureProvider_metaObject<RetType>>(& self, overload_args: T) -> RetType {
return overload_args.metaObject(self);
// return 1;
}
}
pub trait QSGTextureProvider_metaObject<RetType> {
fn metaObject(self , rsthis: & QSGTextureProvider) -> RetType;
}
// proto: const QMetaObject * QSGTextureProvider::metaObject();
impl<'a> /*trait*/ QSGTextureProvider_metaObject<()> for () {
fn metaObject(self , rsthis: & QSGTextureProvider) -> () {
// let qthis: *mut c_void = unsafe{calloc(1, 32)};
// unsafe{_ZNK18QSGTextureProvider10metaObjectEv()};
unsafe {_ZNK18QSGTextureProvider10metaObjectEv(rsthis.qclsinst)};
// return 1;
}
}
#[derive(Default)] // for QSGTextureProvider_textureChanged
pub struct QSGTextureProvider_textureChanged_signal{poi:u64}
impl /* struct */ QSGTextureProvider {
pub fn textureChanged(&self) -> QSGTextureProvider_textureChanged_signal {
return QSGTextureProvider_textureChanged_signal{poi:self.qclsinst};
}
}
impl /* struct */ QSGTextureProvider_textureChanged_signal {
pub fn connect<T: QSGTextureProvider_textureChanged_signal_connect>(self, overload_args: T) {
overload_args.connect(self);
}
}
pub trait QSGTextureProvider_textureChanged_signal_connect {
fn connect(self, sigthis: QSGTextureProvider_textureChanged_signal);
}
// textureChanged()
extern fn QSGTextureProvider_textureChanged_signal_connect_cb_0(rsfptr:fn(), ) {
println!("{}:{}", file!(), line!());
rsfptr();
}
extern fn QSGTextureProvider_textureChanged_signal_connect_cb_box_0(rsfptr_raw:*mut Box<Fn()>, ) {
println!("{}:{}", file!(), line!());
let rsfptr = unsafe{Box::from_raw(rsfptr_raw)};
// rsfptr();
unsafe{(*rsfptr_raw)()};
}
impl /* trait */ QSGTextureProvider_textureChanged_signal_connect for fn() {
fn connect(self, sigthis: QSGTextureProvider_textureChanged_signal) {
// do smth...
// self as u64; // error for Fn, Ok for fn
self as *mut c_void as u64;
self as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QSGTextureProvider_textureChanged_signal_connect_cb_0 as *mut c_void;
let arg2 = self as *mut c_void;
unsafe {QSGTextureProvider_SlotProxy_connect__ZN18QSGTextureProvider14textureChangedEv(arg0, arg1, arg2)};
}
}
impl /* trait */ QSGTextureProvider_textureChanged_signal_connect for Box<Fn()> {
fn connect(self, sigthis: QSGTextureProvider_textureChanged_signal) {
// do smth...
// Box::into_raw(self) as u64;
// Box::into_raw(self) as *mut c_void;
let arg0 = sigthis.poi as *mut c_void;
let arg1 = QSGTextureProvider_textureChanged_signal_connect_cb_box_0 as *mut c_void;
let arg2 = Box::into_raw(Box::new(self)) as *mut c_void;
unsafe {QSGTextureProvider_SlotProxy_connect__ZN18QSGTextureProvider14textureChangedEv(arg0, arg1, arg2)};
}
}
// <= body block end
|
#![feature(conservative_impl_trait)]
use std::collections::HashMap;
use std::collections::hash_map::Entry::{Occupied, Vacant};
use std::hash::Hash;
/// An Unordered `MultiSet`.
#[derive(Debug, Clone, PartialEq)]
pub struct Bag<T: Eq + Hash>(HashMap<T, usize>);
impl<T: Eq + Hash> Default for Bag<T> {
fn default() -> Self {
Bag(HashMap::new())
}
}
#[macro_export]
macro_rules! bagof {
() => { $crate::Bag::new() };
( $( $item: expr ),* ) => {
{
let mut bag = $crate::Bag::new();
$( bag.put($item); )*
bag
}
};
}
impl<T: Eq + Hash> Bag<T> {
/// Creates a new empty `Bag`.
pub fn new() -> Self {
Bag(HashMap::new())
}
/// Counts all the elements, including each duplicate.
///
/// # Examples
///
/// ```
/// #[macro_use(bagof)]
/// extern crate bag;
/// fn main() {
/// let bag = bagof!(1, 1, 2);
/// assert_eq!(3, bag.len());
/// let bag = bagof!(1, 1, 2, 2);
/// assert_eq!(4, bag.len());
/// }
/// ```
pub fn len(&self) -> usize {
self.0.values().sum()
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Insert an element.
///
/// # Examples
///
/// ```
/// #[macro_use(bagof)]
/// extern crate bag;
/// fn main() {
/// let mut bag = bagof!();
/// assert_eq!(0, bag.occurrence(&1));
/// bag.put(1);
/// assert_eq!(1, bag.occurrence(&1));
/// }
/// ```
pub fn put(&mut self, elem: T) {
match self.0.entry(elem) {
Vacant(view) => {
view.insert(1);
}
Occupied(mut view) => {
*view.get_mut() += 1;
}
}
}
/// Counts the occurrences of `value`.
///
/// # Examples
///
/// ```
/// #[macro_use(bagof)]
/// extern crate bag;
/// fn main() {
/// let bag = bagof!(0,0,1,0,1);
/// assert_eq!(3, bag.occurrence(&0));
/// assert_eq!(2, bag.occurrence(&1));
/// assert_eq!(0, bag.occurrence(&2));
/// }
/// ```
pub fn occurrence(&self, elem: &T) -> usize {
self.0.get(elem).map_or(0, |&x| x)
}
pub fn frequency<'a>(&'a self) -> impl Iterator<Item = (&T, &usize)> + 'a {
self.0.iter()
}
pub fn distinct<'a>(&'a self) -> impl Iterator<Item = &T> + 'a {
self.0.keys()
}
}
#[cfg(test)]
mod tests {
macro_rules! check_bagof {
( $( $item:expr),* ) => {
{
let bag = bagof!( $( $item ),* );
for (&e, &c) in bag.frequency() {
assert!(bag.occurrence(&e) > 0);
assert!(bag.occurrence(&e) == c);
}
}
}
}
#[test]
fn bagof_chars() {
check_bagof!(1, 2, 1, 2, 3, 3, 0, 3, 4);
check_bagof!('a', 'b', 'r', 'a', 'c', 'a', 'd', 'a', 'b', 'r', 'a');
check_bagof!("I", "am", "18", "years", "old", ".");
}
}
|
use std::env;
use std::fs;
use std::time;
use bg_core::dice::Dice;
use bg_core::game::Match;
use bg_core::movegen::{generate_o_moves, generate_x_moves};
use bg_core::position::Position;
use bg_core::rollout;
use bg_parser::parse_match;
use rand::Rng;
fn load_match(filename: &str) -> Match {
let contents = fs::read_to_string(filename).expect("Something went wrong reading the file.");
parse_match(&contents).unwrap()
}
fn main() {
let args: Vec<String> = env::args().collect();
let mtch = load_match(&args[1]);
let g1 = &mtch.games[0];
let mut p = Position::initial();
println!("{}", p);
for turn in &g1.turns {
let o_move = &turn.0;
let x_move = &turn.1;
for om in o_move {
p = p.apply_o_move(om);
println!("o -> {}", om);
println!("{}", p);
}
for xm in x_move {
p = p.apply_x_move(xm);
println!("x -> {}", xm);
println!("{}", p);
}
}
if 2 < 3 {
return;
}
let start = time::Instant::now();
let p = Position::initial();
let stats = rollout::rollout_o(&p);
let finish = time::Instant::now();
let duration: time::Duration = finish.duration_since(start);
let micros = duration.as_micros();
println!("Total time: {}", micros as f64 / 1e6);
println!("Micros per game: {}", micros / u128::from(stats.rolls));
println!("{:?}", stats);
let mut p = Position::initial();
let mut o_turn = true;
loop {
if rand::thread_rng().gen_range(0..20) == 0 {
println!("Rollout requested...");
println!("{}", p);
let s = rollout::rollout_o(&p);
println!("{:?}", s);
}
let roll = Dice::roll();
let moves: Vec<Position> = if o_turn {
generate_o_moves(&p, &roll).into_iter().collect()
} else {
generate_x_moves(&p, &roll).into_iter().collect()
};
if !moves.is_empty() {
p = moves[rand::thread_rng().gen_range(0..moves.len())];
}
if p.o_has_won() || p.x_has_won() {
break;
}
o_turn = !o_turn;
}
println!("{}", p);
}
|
pub use crate::ugid::{Gid, Uid};
|
pub mod std;
|
pub trait InspectErr<E> {
fn my_inspect_err<F>(self, f: F) -> Self
where
F: Fn(&E);
}
impl<T, E> InspectErr<E> for Result<T, E> {
fn my_inspect_err<F>(self, f: F) -> Self
where
F: Fn(&E),
{
self.map_err(|e| {f(&e); e})
}
}
|
#[doc = "Reader of register RXESC"]
pub type R = crate::R<u32, super::RXESC>;
#[doc = "Writer for register RXESC"]
pub type W = crate::W<u32, super::RXESC>;
#[doc = "Register RXESC `reset()`'s with value 0"]
impl crate::ResetValue for super::RXESC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `F0DS`"]
pub type F0DS_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `F0DS`"]
pub struct F0DS_W<'a> {
w: &'a mut W,
}
impl<'a> F0DS_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 & !0x07) | ((value as u32) & 0x07);
self.w
}
}
#[doc = "Reader of field `F1DS`"]
pub type F1DS_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `F1DS`"]
pub struct F1DS_W<'a> {
w: &'a mut W,
}
impl<'a> F1DS_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 & !(0x07 << 4)) | (((value as u32) & 0x07) << 4);
self.w
}
}
#[doc = "Reader of field `RBDS`"]
pub type RBDS_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `RBDS`"]
pub struct RBDS_W<'a> {
w: &'a mut W,
}
impl<'a> RBDS_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 & !(0x07 << 8)) | (((value as u32) & 0x07) << 8);
self.w
}
}
impl R {
#[doc = "Bits 0:2 - Rx FIFO 1 Data Field Size:"]
#[inline(always)]
pub fn f0ds(&self) -> F0DS_R {
F0DS_R::new((self.bits & 0x07) as u8)
}
#[doc = "Bits 4:6 - Rx FIFO 0 Data Field Size:"]
#[inline(always)]
pub fn f1ds(&self) -> F1DS_R {
F1DS_R::new(((self.bits >> 4) & 0x07) as u8)
}
#[doc = "Bits 8:10 - Rx Buffer Data Field Size:"]
#[inline(always)]
pub fn rbds(&self) -> RBDS_R {
RBDS_R::new(((self.bits >> 8) & 0x07) as u8)
}
}
impl W {
#[doc = "Bits 0:2 - Rx FIFO 1 Data Field Size:"]
#[inline(always)]
pub fn f0ds(&mut self) -> F0DS_W {
F0DS_W { w: self }
}
#[doc = "Bits 4:6 - Rx FIFO 0 Data Field Size:"]
#[inline(always)]
pub fn f1ds(&mut self) -> F1DS_W {
F1DS_W { w: self }
}
#[doc = "Bits 8:10 - Rx Buffer Data Field Size:"]
#[inline(always)]
pub fn rbds(&mut self) -> RBDS_W {
RBDS_W { w: self }
}
}
|
use super::UserInput;
use async_trait::async_trait;
use cursive::traits::*;
use cursive::views::Dialog;
use std::collections::HashSet;
use std::io::{Error, ErrorKind, Result};
use std::ops::Deref;
pub struct UIBackend<'a> {
shell_trust: &'a super::ShellTrust,
}
impl<'a> UIBackend<'a> {
pub fn new(shell_trust: &'a super::ShellTrust) -> Self {
Self { shell_trust }
}
}
#[async_trait]
impl<'a> UserInput for UIBackend<'a> {
async fn prompt(&self, text: &str) -> Result<String> {
let v = std::rc::Rc::new(std::cell::Cell::new(None));
let vx = v.clone();
let mut siv = cursive::default();
let form = fui::form::FormView::new()
.field(fui::fields::Text::new(text))
.on_submit(move |s, x| {
vx.set(Some(x.to_string()));
s.quit()
});
siv.add_layer(Dialog::around(form).full_screen());
siv.run();
v.take()
.ok_or_else(|| Error::new(ErrorKind::Other, "user abort"))
}
async fn shell(&self, command: &str, shell_trust: &super::ShellTrust) -> Result<String> {
super::shell(command, shell_trust, &super::Backend::UI).await
}
async fn select(
&self,
prompt: &str,
options: &std::collections::BTreeMap<String, super::Option>,
) -> Result<String> {
let keys = options.keys().cloned().collect::<Vec<String>>();
let mut index_display = 0usize;
let display_vals = options
.values()
.map(|x| {
let mut v = String::from("(");
v.push_str(&index_display.to_string());
index_display += 1;
v.push_str(") ");
v.push_str(&x.display.to_owned());
v
})
.collect::<Vec<String>>();
let sel = std::cell::Cell::new(String::new());
{
let v = std::rc::Rc::new(std::cell::Cell::new(None));
let vx = v.clone();
let mut siv = cursive::default();
siv.add_global_callback(cursive::event::Event::CtrlChar('c'), |s| {
s.quit();
});
let mut select = cursive::views::SelectView::<String>::new()
.h_align(cursive::align::HAlign::Left)
.autojump()
.on_submit(move |s, x: &str| {
vx.set(Some(x.to_owned()));
s.quit();
});
select.add_all_str(&display_vals);
siv.add_layer(
cursive::views::Dialog::around(select.scrollable().fixed_size((20, 10)))
.title(prompt),
);
siv.run();
sel.set(v.take().unwrap());
}
let sel_value = sel.take();
let selection = &options[&keys[display_vals.iter().position(|x| *x == sel_value).unwrap()]];
match &selection.value {
super::OptionValue::Static(x) => Ok(x.to_owned()),
super::OptionValue::Shell(cmd) => self.shell(cmd, &self.shell_trust).await,
}
}
async fn check(
&self,
_: &str,
separator: &str,
options: &std::collections::BTreeMap<String, super::Option>,
) -> Result<String> {
let mut opts = Vec::new();
{
let ok_pressed = std::sync::Arc::new(std::cell::Cell::new(false));
let ok_pressed_siv = ok_pressed.clone();
let items =
std::sync::Arc::new(std::sync::RwLock::new(HashSet::<std::string::String>::new()));
let items_view = items.clone();
let items_view2 = items.clone();
let keys = options.keys().cloned().collect::<Vec<String>>();
let mut index_display = 0usize;
let display_vals = options
.values()
.map(|x| {
let mut v = String::from("(");
v.push_str(&index_display.to_string());
index_display += 1;
v.push_str(") ");
v.push_str(&x.display.to_owned());
v
})
.collect::<Vec<String>>();
let mut siv = cursive::default();
siv.add_global_callback(cursive::event::Event::CtrlChar('c'), |s| {
s.quit();
});
let view = fui::views::Multiselect::new(ArrOptions::new(&display_vals))
.on_select(move |_, v| {
items_view.try_write().unwrap().insert(v.deref().to_owned());
})
.on_deselect(move |_, v| {
items_view2.try_write().unwrap().remove(v.deref());
});
let dlg = cursive::views::Dialog::around(view).button("Ok", move |s| {
ok_pressed_siv.set(true);
s.quit();
});
siv.add_layer(dlg);
siv.run();
if !ok_pressed.take() {
return Err(Error::new(ErrorKind::Other, "user abort"));
}
for x in items.try_read().unwrap().iter() {
let pos = display_vals.iter().position(|v| x == v).unwrap();
let selection = &options[&keys[pos]];
opts.push(&selection.value);
}
}
let mut data = Vec::new();
for opt in opts {
data.push(match opt {
super::OptionValue::Static(x) => x.to_owned(),
super::OptionValue::Shell(cmd) => {
self.shell(&cmd, &self.shell_trust).await.unwrap()
}
});
}
Ok(data.join(separator))
}
}
struct ArrOptions {
opts: Vec<String>,
}
impl ArrOptions {
pub fn new(opts: &[String]) -> Self {
Self {
opts: Vec::from(opts),
}
}
}
impl fui::feeders::Feeder for ArrOptions {
fn query(&self, _: &str, position: usize, items_count: usize) -> Vec<String> {
self.opts
.iter()
.skip(position)
.take(items_count)
.map(|x| x.to_owned())
.collect()
}
}
|
#[cfg(feature = "bytemuck")]
pub mod bytemuck;
#[cfg(feature = "mint")]
pub mod mint;
|
//!
//! Import data and WAL from a PostgreSQL data directory and WAL segments into
//! zenith Timeline.
//!
use log::*;
use postgres_ffi::nonrelfile_utils::clogpage_precedes;
use postgres_ffi::nonrelfile_utils::slru_may_delete_clogsegment;
use std::cmp::min;
use std::fs;
use std::fs::File;
use std::io::Read;
use std::path::Path;
use anyhow::Result;
use bytes::{Buf, Bytes};
use crate::relish::*;
use crate::repository::*;
use crate::waldecoder::*;
use postgres_ffi::nonrelfile_utils::mx_offset_to_member_segment;
use postgres_ffi::relfile_utils::*;
use postgres_ffi::xlog_utils::*;
use postgres_ffi::Oid;
use postgres_ffi::{pg_constants, CheckPoint, ControlFileData};
use zenith_utils::lsn::Lsn;
const MAX_MBR_BLKNO: u32 =
pg_constants::MAX_MULTIXACT_ID / pg_constants::MULTIXACT_MEMBERS_PER_PAGE as u32;
static ZERO_PAGE: Bytes = Bytes::from_static(&[0u8; 8192]);
///
/// Import all relation data pages from local disk into the repository.
///
pub fn import_timeline_from_postgres_datadir(
path: &Path,
timeline: &dyn Timeline,
lsn: Lsn,
) -> Result<()> {
// Scan 'global'
for direntry in fs::read_dir(path.join("global"))? {
let direntry = direntry?;
match direntry.file_name().to_str() {
None => continue,
Some("pg_control") => {
import_control_file(timeline, lsn, &direntry.path())?;
}
Some("pg_filenode.map") => import_nonrel_file(
timeline,
lsn,
RelishTag::FileNodeMap {
spcnode: pg_constants::GLOBALTABLESPACE_OID,
dbnode: 0,
},
&direntry.path(),
)?,
// Load any relation files into the page server
_ => import_relfile(
&direntry.path(),
timeline,
lsn,
pg_constants::GLOBALTABLESPACE_OID,
0,
)?,
}
}
// Scan 'base'. It contains database dirs, the database OID is the filename.
// E.g. 'base/12345', where 12345 is the database OID.
for direntry in fs::read_dir(path.join("base"))? {
let direntry = direntry?;
//skip all temporary files
if direntry.file_name().to_str().unwrap() == "pgsql_tmp" {
continue;
}
let dboid = direntry.file_name().to_str().unwrap().parse::<u32>()?;
for direntry in fs::read_dir(direntry.path())? {
let direntry = direntry?;
match direntry.file_name().to_str() {
None => continue,
Some("PG_VERSION") => continue,
Some("pg_filenode.map") => import_nonrel_file(
timeline,
lsn,
RelishTag::FileNodeMap {
spcnode: pg_constants::DEFAULTTABLESPACE_OID,
dbnode: dboid,
},
&direntry.path(),
)?,
// Load any relation files into the page server
_ => import_relfile(
&direntry.path(),
timeline,
lsn,
pg_constants::DEFAULTTABLESPACE_OID,
dboid,
)?,
}
}
}
for entry in fs::read_dir(path.join("pg_xact"))? {
let entry = entry?;
import_slru_file(timeline, lsn, SlruKind::Clog, &entry.path())?;
}
for entry in fs::read_dir(path.join("pg_multixact").join("members"))? {
let entry = entry?;
import_slru_file(timeline, lsn, SlruKind::MultiXactMembers, &entry.path())?;
}
for entry in fs::read_dir(path.join("pg_multixact").join("offsets"))? {
let entry = entry?;
import_slru_file(timeline, lsn, SlruKind::MultiXactOffsets, &entry.path())?;
}
for entry in fs::read_dir(path.join("pg_twophase"))? {
let entry = entry?;
let xid = u32::from_str_radix(entry.path().to_str().unwrap(), 16)?;
import_nonrel_file(timeline, lsn, RelishTag::TwoPhase { xid }, &entry.path())?;
}
// TODO: Scan pg_tblspc
timeline.advance_last_record_lsn(lsn);
Ok(())
}
// subroutine of import_timeline_from_postgres_datadir(), to load one relation file.
fn import_relfile(
path: &Path,
timeline: &dyn Timeline,
lsn: Lsn,
spcoid: Oid,
dboid: Oid,
) -> Result<()> {
// Does it look like a relation file?
let p = parse_relfilename(path.file_name().unwrap().to_str().unwrap());
if let Err(e) = p {
warn!("unrecognized file in postgres datadir: {:?} ({})", path, e);
return Err(e.into());
}
let (relnode, forknum, segno) = p.unwrap();
let mut file = File::open(path)?;
let mut buf: [u8; 8192] = [0u8; 8192];
let mut blknum: u32 = segno * (1024 * 1024 * 1024 / pg_constants::BLCKSZ as u32);
loop {
let r = file.read_exact(&mut buf);
match r {
Ok(_) => {
let rel = RelTag {
spcnode: spcoid,
dbnode: dboid,
relnode,
forknum,
};
let tag = RelishTag::Relation(rel);
timeline.put_page_image(tag, blknum, lsn, Bytes::copy_from_slice(&buf))?;
}
// TODO: UnexpectedEof is expected
Err(e) => match e.kind() {
std::io::ErrorKind::UnexpectedEof => {
// reached EOF. That's expected.
// FIXME: maybe check that we read the full length of the file?
break;
}
_ => {
error!("error reading file: {:?} ({})", path, e);
break;
}
},
};
blknum += 1;
}
Ok(())
}
///
/// Import a "non-blocky" file into the repository
///
/// This is used for small files like the control file, twophase files etc. that
/// are just slurped into the repository as one blob.
///
fn import_nonrel_file(
timeline: &dyn Timeline,
lsn: Lsn,
tag: RelishTag,
path: &Path,
) -> Result<()> {
let mut file = File::open(path)?;
let mut buffer = Vec::new();
// read the whole file
file.read_to_end(&mut buffer)?;
info!("importing non-rel file {}", path.display());
timeline.put_page_image(tag, 0, lsn, Bytes::copy_from_slice(&buffer[..]))?;
Ok(())
}
///
/// Import pg_control file into the repository.
///
/// The control file is imported as is, but we also extract the checkpoint record
/// from it and store it separated.
fn import_control_file(timeline: &dyn Timeline, lsn: Lsn, path: &Path) -> Result<()> {
let mut file = File::open(path)?;
let mut buffer = Vec::new();
// read the whole file
file.read_to_end(&mut buffer)?;
info!("importing control file {}", path.display());
// Import it as ControlFile
timeline.put_page_image(
RelishTag::ControlFile,
0,
lsn,
Bytes::copy_from_slice(&buffer[..]),
)?;
// Extract the checkpoint record and import it separately.
let pg_control = ControlFileData::decode(&buffer)?;
let checkpoint_bytes = pg_control.checkPointCopy.encode();
timeline.put_page_image(RelishTag::Checkpoint, 0, lsn, checkpoint_bytes)?;
Ok(())
}
///
/// Import an SLRU segment file
///
fn import_slru_file(timeline: &dyn Timeline, lsn: Lsn, slru: SlruKind, path: &Path) -> Result<()> {
// Does it look like an SLRU file?
let mut file = File::open(path)?;
let mut buf: [u8; 8192] = [0u8; 8192];
let segno = u32::from_str_radix(path.file_name().unwrap().to_str().unwrap(), 16)?;
info!("importing slru file {}", path.display());
let mut rpageno = 0;
loop {
let r = file.read_exact(&mut buf);
match r {
Ok(_) => {
timeline.put_page_image(
RelishTag::Slru { slru, segno },
rpageno,
lsn,
Bytes::copy_from_slice(&buf),
)?;
}
// TODO: UnexpectedEof is expected
Err(e) => match e.kind() {
std::io::ErrorKind::UnexpectedEof => {
// reached EOF. That's expected.
// FIXME: maybe check that we read the full length of the file?
break;
}
_ => {
error!("error reading file: {:?} ({})", path, e);
break;
}
},
};
rpageno += 1;
// TODO: Check that the file isn't unexpectedly large, not larger than SLRU_PAGES_PER_SEGMENT pages
}
Ok(())
}
///
/// Helper function to parse a WAL record and call the Timeline's PUT functions for all the
/// relations/pages that the record affects.
///
pub fn save_decoded_record(
checkpoint: &mut CheckPoint,
timeline: &dyn Timeline,
decoded: &DecodedWALRecord,
recdata: Bytes,
lsn: Lsn,
) -> Result<()> {
checkpoint.update_next_xid(decoded.xl_xid);
// Iterate through all the blocks that the record modifies, and
// "put" a separate copy of the record for each block.
for blk in decoded.blocks.iter() {
let tag = RelishTag::Relation(RelTag {
spcnode: blk.rnode_spcnode,
dbnode: blk.rnode_dbnode,
relnode: blk.rnode_relnode,
forknum: blk.forknum as u8,
});
let rec = WALRecord {
lsn,
will_init: blk.will_init || blk.apply_image,
rec: recdata.clone(),
main_data_offset: decoded.main_data_offset as u32,
};
timeline.put_wal_record(tag, blk.blkno, rec)?;
}
let mut buf = decoded.record.clone();
buf.advance(decoded.main_data_offset);
// Handle a few special record types
if decoded.xl_rmid == pg_constants::RM_SMGR_ID
&& (decoded.xl_info & pg_constants::XLR_RMGR_INFO_MASK) == pg_constants::XLOG_SMGR_TRUNCATE
{
let truncate = XlSmgrTruncate::decode(&mut buf);
save_xlog_smgr_truncate(timeline, lsn, &truncate)?;
} else if decoded.xl_rmid == pg_constants::RM_DBASE_ID {
if (decoded.xl_info & pg_constants::XLR_RMGR_INFO_MASK) == pg_constants::XLOG_DBASE_CREATE {
let createdb = XlCreateDatabase::decode(&mut buf);
save_xlog_dbase_create(timeline, lsn, &createdb)?;
} else if (decoded.xl_info & pg_constants::XLR_RMGR_INFO_MASK)
== pg_constants::XLOG_DBASE_DROP
{
let dropdb = XlDropDatabase::decode(&mut buf);
// To drop the database, we need to drop all the relations in it. Like in
// save_xlog_dbase_create(), use the previous record's LSN in the list_rels() call
let req_lsn = min(timeline.get_last_record_lsn(), lsn);
for tablespace_id in dropdb.tablespace_ids {
let rels = timeline.list_rels(tablespace_id, dropdb.db_id, req_lsn)?;
for rel in rels {
timeline.drop_relish(rel, lsn)?;
}
trace!(
"Drop FileNodeMap {}, {} at lsn {}",
tablespace_id,
dropdb.db_id,
lsn
);
timeline.drop_relish(
RelishTag::FileNodeMap {
spcnode: tablespace_id,
dbnode: dropdb.db_id,
},
lsn,
)?;
}
}
} else if decoded.xl_rmid == pg_constants::RM_TBLSPC_ID {
trace!("XLOG_TBLSPC_CREATE/DROP is not handled yet");
} else if decoded.xl_rmid == pg_constants::RM_CLOG_ID {
let info = decoded.xl_info & !pg_constants::XLR_INFO_MASK;
if info == pg_constants::CLOG_ZEROPAGE {
let pageno = buf.get_u32_le();
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_page_image(
RelishTag::Slru {
slru: SlruKind::Clog,
segno,
},
rpageno,
lsn,
ZERO_PAGE.clone(),
)?;
} else {
assert!(info == pg_constants::CLOG_TRUNCATE);
let xlrec = XlClogTruncate::decode(&mut buf);
save_clog_truncate_record(checkpoint, timeline, lsn, &xlrec)?;
}
} else if decoded.xl_rmid == pg_constants::RM_XACT_ID {
let info = decoded.xl_info & pg_constants::XLOG_XACT_OPMASK;
if info == pg_constants::XLOG_XACT_COMMIT || info == pg_constants::XLOG_XACT_ABORT {
let parsed_xact = XlXactParsedRecord::decode(&mut buf, decoded.xl_xid, decoded.xl_info);
save_xact_record(timeline, lsn, &parsed_xact, decoded)?;
} else if info == pg_constants::XLOG_XACT_COMMIT_PREPARED
|| info == pg_constants::XLOG_XACT_ABORT_PREPARED
{
let parsed_xact = XlXactParsedRecord::decode(&mut buf, decoded.xl_xid, decoded.xl_info);
save_xact_record(timeline, lsn, &parsed_xact, decoded)?;
// Remove twophase file. see RemoveTwoPhaseFile() in postgres code
trace!(
"Drop twophaseFile for xid {} parsed_xact.xid {} here at {}",
decoded.xl_xid,
parsed_xact.xid,
lsn
);
timeline.drop_relish(
RelishTag::TwoPhase {
xid: parsed_xact.xid,
},
lsn,
)?;
} else if info == pg_constants::XLOG_XACT_PREPARE {
let mut buf = decoded.record.clone();
buf.advance(decoded.main_data_offset);
timeline.put_page_image(
RelishTag::TwoPhase {
xid: decoded.xl_xid,
},
0,
lsn,
Bytes::copy_from_slice(&buf[..]),
)?;
}
} else if decoded.xl_rmid == pg_constants::RM_MULTIXACT_ID {
let info = decoded.xl_info & pg_constants::XLR_RMGR_INFO_MASK;
if info == pg_constants::XLOG_MULTIXACT_ZERO_OFF_PAGE {
let pageno = buf.get_u32_le();
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_page_image(
RelishTag::Slru {
slru: SlruKind::MultiXactOffsets,
segno,
},
rpageno,
lsn,
ZERO_PAGE.clone(),
)?;
} else if info == pg_constants::XLOG_MULTIXACT_ZERO_MEM_PAGE {
let pageno = buf.get_u32_le();
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_page_image(
RelishTag::Slru {
slru: SlruKind::MultiXactMembers,
segno,
},
rpageno,
lsn,
ZERO_PAGE.clone(),
)?;
} else if info == pg_constants::XLOG_MULTIXACT_CREATE_ID {
let xlrec = XlMultiXactCreate::decode(&mut buf);
save_multixact_create_record(checkpoint, timeline, lsn, &xlrec, decoded)?;
} else if info == pg_constants::XLOG_MULTIXACT_TRUNCATE_ID {
let xlrec = XlMultiXactTruncate::decode(&mut buf);
save_multixact_truncate_record(checkpoint, timeline, lsn, &xlrec)?;
}
} else if decoded.xl_rmid == pg_constants::RM_RELMAP_ID {
let xlrec = XlRelmapUpdate::decode(&mut buf);
save_relmap_page(timeline, lsn, &xlrec, decoded)?;
} else if decoded.xl_rmid == pg_constants::RM_XLOG_ID {
let info = decoded.xl_info & pg_constants::XLR_RMGR_INFO_MASK;
if info == pg_constants::XLOG_NEXTOID {
let next_oid = buf.get_u32_le();
checkpoint.nextOid = next_oid;
} else if info == pg_constants::XLOG_CHECKPOINT_ONLINE
|| info == pg_constants::XLOG_CHECKPOINT_SHUTDOWN
{
let mut checkpoint_bytes = [0u8; SIZEOF_CHECKPOINT];
let mut buf = decoded.record.clone();
buf.advance(decoded.main_data_offset);
buf.copy_to_slice(&mut checkpoint_bytes);
let xlog_checkpoint = CheckPoint::decode(&checkpoint_bytes).unwrap();
trace!(
"xlog_checkpoint.oldestXid={}, checkpoint.oldestXid={}",
xlog_checkpoint.oldestXid,
checkpoint.oldestXid
);
if (checkpoint.oldestXid.wrapping_sub(xlog_checkpoint.oldestXid) as i32) < 0 {
checkpoint.oldestXid = xlog_checkpoint.oldestXid;
}
}
}
Ok(())
}
/// Subroutine of save_decoded_record(), to handle an XLOG_DBASE_CREATE record.
fn save_xlog_dbase_create(timeline: &dyn Timeline, lsn: Lsn, rec: &XlCreateDatabase) -> Result<()> {
let db_id = rec.db_id;
let tablespace_id = rec.tablespace_id;
let src_db_id = rec.src_db_id;
let src_tablespace_id = rec.src_tablespace_id;
// Creating a database is implemented by copying the template (aka. source) database.
// To copy all the relations, we need to ask for the state as of the same LSN, but we
// cannot pass 'lsn' to the Timeline.get_* functions, or they will block waiting for
// the last valid LSN to advance up to it. So we use the previous record's LSN in the
// get calls instead.
let req_lsn = min(timeline.get_last_record_lsn(), lsn);
let rels = timeline.list_rels(src_tablespace_id, src_db_id, req_lsn)?;
trace!("save_create_database: {} rels", rels.len());
let mut num_rels_copied = 0;
let mut num_blocks_copied = 0;
for rel in rels {
if let RelishTag::Relation(src_rel) = rel {
assert_eq!(src_rel.spcnode, src_tablespace_id);
assert_eq!(src_rel.dbnode, src_db_id);
let nblocks = timeline.get_relish_size(rel, req_lsn)?.unwrap_or(0);
let dst_rel = RelTag {
spcnode: tablespace_id,
dbnode: db_id,
relnode: src_rel.relnode,
forknum: src_rel.forknum,
};
// Copy content
for blknum in 0..nblocks {
let content = timeline.get_page_at_lsn(rel, blknum, req_lsn)?;
debug!("copying block {} from {} to {}", blknum, src_rel, dst_rel);
timeline.put_page_image(RelishTag::Relation(dst_rel), blknum, lsn, content)?;
num_blocks_copied += 1;
}
if nblocks == 0 {
// make sure we have some trace of the relation, even if it's empty
timeline.put_truncation(RelishTag::Relation(dst_rel), lsn, 0)?;
}
num_rels_copied += 1;
}
}
// Copy relfilemap
// TODO This implementation is very inefficient -
// it scans all non-rels only to find FileNodeMaps
for tag in timeline.list_nonrels(req_lsn)? {
if let RelishTag::FileNodeMap { spcnode, dbnode } = tag {
if spcnode == src_tablespace_id && dbnode == src_db_id {
let img = timeline.get_page_at_lsn(tag, 0, req_lsn)?;
let new_tag = RelishTag::FileNodeMap {
spcnode: tablespace_id,
dbnode: db_id,
};
timeline.put_page_image(new_tag, 0, lsn, img)?;
break;
}
}
}
info!(
"Created database {}/{}, copied {} blocks in {} rels at {}",
tablespace_id, db_id, num_blocks_copied, num_rels_copied, lsn
);
Ok(())
}
/// Subroutine of save_decoded_record(), to handle an XLOG_SMGR_TRUNCATE record.
///
/// This is the same logic as in PostgreSQL's smgr_redo() function.
fn save_xlog_smgr_truncate(timeline: &dyn Timeline, lsn: Lsn, rec: &XlSmgrTruncate) -> Result<()> {
let spcnode = rec.rnode.spcnode;
let dbnode = rec.rnode.dbnode;
let relnode = rec.rnode.relnode;
if (rec.flags & pg_constants::SMGR_TRUNCATE_HEAP) != 0 {
let rel = RelTag {
spcnode,
dbnode,
relnode,
forknum: pg_constants::MAIN_FORKNUM,
};
timeline.put_truncation(RelishTag::Relation(rel), lsn, rec.blkno)?;
}
if (rec.flags & pg_constants::SMGR_TRUNCATE_FSM) != 0 {
let rel = RelTag {
spcnode,
dbnode,
relnode,
forknum: pg_constants::FSM_FORKNUM,
};
// FIXME: 'blkno' stored in the WAL record is the new size of the
// heap. The formula for calculating the new size of the FSM is
// pretty complicated (see FreeSpaceMapPrepareTruncateRel() in
// PostgreSQL), and we should also clear bits in the tail FSM block,
// and update the upper level FSM pages. None of that has been
// implemented. What we do instead, is always just truncate the FSM
// to zero blocks. That's bad for performance, but safe. (The FSM
// isn't needed for correctness, so we could also leave garbage in
// it. Seems more tidy to zap it away.)
if rec.blkno != 0 {
info!("Partial truncation of FSM is not supported");
}
let num_fsm_blocks = 0;
timeline.put_truncation(RelishTag::Relation(rel), lsn, num_fsm_blocks)?;
}
if (rec.flags & pg_constants::SMGR_TRUNCATE_VM) != 0 {
let rel = RelTag {
spcnode,
dbnode,
relnode,
forknum: pg_constants::VISIBILITYMAP_FORKNUM,
};
// FIXME: Like with the FSM above, the logic to truncate the VM
// correctly has not been implemented. Just zap it away completely,
// always. Unlike the FSM, the VM must never have bits incorrectly
// set. From a correctness point of view, it's always OK to clear
// bits or remove it altogether, though.
if rec.blkno != 0 {
info!("Partial truncation of VM is not supported");
}
let num_vm_blocks = 0;
timeline.put_truncation(RelishTag::Relation(rel), lsn, num_vm_blocks)?;
}
Ok(())
}
/// Subroutine of save_decoded_record(), to handle an XLOG_XACT_* records.
///
fn save_xact_record(
timeline: &dyn Timeline,
lsn: Lsn,
parsed: &XlXactParsedRecord,
decoded: &DecodedWALRecord,
) -> Result<()> {
// Record update of CLOG page
let mut pageno = parsed.xid / pg_constants::CLOG_XACTS_PER_PAGE;
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
let rec = WALRecord {
lsn,
will_init: false,
rec: decoded.record.clone(),
main_data_offset: decoded.main_data_offset as u32,
};
timeline.put_wal_record(
RelishTag::Slru {
slru: SlruKind::Clog,
segno,
},
rpageno,
rec.clone(),
)?;
for subxact in &parsed.subxacts {
let subxact_pageno = subxact / pg_constants::CLOG_XACTS_PER_PAGE;
if subxact_pageno != pageno {
pageno = subxact_pageno;
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_wal_record(
RelishTag::Slru {
slru: SlruKind::Clog,
segno,
},
rpageno,
rec.clone(),
)?;
}
}
for xnode in &parsed.xnodes {
for forknum in pg_constants::MAIN_FORKNUM..=pg_constants::VISIBILITYMAP_FORKNUM {
let rel = RelTag {
forknum,
spcnode: xnode.spcnode,
dbnode: xnode.dbnode,
relnode: xnode.relnode,
};
timeline.drop_relish(RelishTag::Relation(rel), lsn)?;
}
}
Ok(())
}
fn save_clog_truncate_record(
checkpoint: &mut CheckPoint,
timeline: &dyn Timeline,
lsn: Lsn,
xlrec: &XlClogTruncate,
) -> Result<()> {
info!(
"RM_CLOG_ID truncate pageno {} oldestXid {} oldestXidDB {} lsn {}",
xlrec.pageno, xlrec.oldest_xid, xlrec.oldest_xid_db, lsn
);
// Here we treat oldestXid and oldestXidDB
// differently from postgres redo routines.
// In postgres checkpoint.oldestXid lags behind xlrec.oldest_xid
// until checkpoint happens and updates the value.
// Here we can use the most recent value.
// It's just an optimization, though and can be deleted.
// TODO Figure out if there will be any issues with replica.
checkpoint.oldestXid = xlrec.oldest_xid;
checkpoint.oldestXidDB = xlrec.oldest_xid_db;
// TODO Treat AdvanceOldestClogXid() or write a comment why we don't need it
let latest_page_number = checkpoint.nextXid.value as u32 / pg_constants::CLOG_XACTS_PER_PAGE;
// Now delete all segments containing pages between xlrec.pageno
// and latest_page_number.
// First, make an important safety check:
// the current endpoint page must not be eligible for removal.
// See SimpleLruTruncate() in slru.c
if clogpage_precedes(latest_page_number, xlrec.pageno) {
info!("could not truncate directory pg_xact apparent wraparound");
return Ok(());
}
// Iterate via SLRU CLOG segments and drop segments that we're ready to truncate
// TODO This implementation is very inefficient -
// it scans all non-rels only to find Clog
//
// We cannot pass 'lsn' to the Timeline.list_nonrels(), or it
// will block waiting for the last valid LSN to advance up to
// it. So we use the previous record's LSN in the get calls
// instead.
let req_lsn = min(timeline.get_last_record_lsn(), lsn);
for obj in timeline.list_nonrels(req_lsn)? {
if let RelishTag::Slru { slru, segno } = obj {
if slru == SlruKind::Clog {
let segpage = segno * pg_constants::SLRU_PAGES_PER_SEGMENT;
if slru_may_delete_clogsegment(segpage, xlrec.pageno) {
timeline.drop_relish(RelishTag::Slru { slru, segno }, lsn)?;
trace!("Drop CLOG segment {:>04X} at lsn {}", segno, lsn);
}
}
}
}
Ok(())
}
fn save_multixact_create_record(
checkpoint: &mut CheckPoint,
timeline: &dyn Timeline,
lsn: Lsn,
xlrec: &XlMultiXactCreate,
decoded: &DecodedWALRecord,
) -> Result<()> {
let rec = WALRecord {
lsn,
will_init: false,
rec: decoded.record.clone(),
main_data_offset: decoded.main_data_offset as u32,
};
let pageno = xlrec.mid / pg_constants::MULTIXACT_OFFSETS_PER_PAGE as u32;
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_wal_record(
RelishTag::Slru {
slru: SlruKind::MultiXactOffsets,
segno,
},
rpageno,
rec.clone(),
)?;
let first_mbr_pageno = xlrec.moff / pg_constants::MULTIXACT_MEMBERS_PER_PAGE as u32;
let last_mbr_pageno =
(xlrec.moff + xlrec.nmembers - 1) / pg_constants::MULTIXACT_MEMBERS_PER_PAGE as u32;
// The members SLRU can, in contrast to the offsets one, be filled to almost
// the full range at once. So we need to handle wraparound.
let mut pageno = first_mbr_pageno;
loop {
// Update members page
let segno = pageno / pg_constants::SLRU_PAGES_PER_SEGMENT;
let rpageno = pageno % pg_constants::SLRU_PAGES_PER_SEGMENT;
timeline.put_wal_record(
RelishTag::Slru {
slru: SlruKind::MultiXactMembers,
segno,
},
rpageno,
rec.clone(),
)?;
if pageno == last_mbr_pageno {
// last block inclusive
break;
}
// handle wraparound
if pageno == MAX_MBR_BLKNO {
pageno = 0;
} else {
pageno += 1;
}
}
if xlrec.mid >= checkpoint.nextMulti {
checkpoint.nextMulti = xlrec.mid + 1;
}
if xlrec.moff + xlrec.nmembers > checkpoint.nextMultiOffset {
checkpoint.nextMultiOffset = xlrec.moff + xlrec.nmembers;
}
let max_mbr_xid = xlrec.members.iter().fold(0u32, |acc, mbr| {
if mbr.xid.wrapping_sub(acc) as i32 > 0 {
mbr.xid
} else {
acc
}
});
checkpoint.update_next_xid(max_mbr_xid);
Ok(())
}
fn save_multixact_truncate_record(
checkpoint: &mut CheckPoint,
timeline: &dyn Timeline,
lsn: Lsn,
xlrec: &XlMultiXactTruncate,
) -> Result<()> {
checkpoint.oldestMulti = xlrec.end_trunc_off;
checkpoint.oldestMultiDB = xlrec.oldest_multi_db;
// PerformMembersTruncation
let maxsegment: i32 = mx_offset_to_member_segment(pg_constants::MAX_MULTIXACT_OFFSET);
let startsegment: i32 = mx_offset_to_member_segment(xlrec.start_trunc_memb);
let endsegment: i32 = mx_offset_to_member_segment(xlrec.end_trunc_memb);
let mut segment: i32 = startsegment;
// Delete all the segments except the last one. The last segment can still
// contain, possibly partially, valid data.
while segment != endsegment {
timeline.drop_relish(
RelishTag::Slru {
slru: SlruKind::MultiXactMembers,
segno: segment as u32,
},
lsn,
)?;
/* move to next segment, handling wraparound correctly */
if segment == maxsegment {
segment = 0;
} else {
segment += 1;
}
}
// Truncate offsets
// FIXME: this did not handle wraparound correctly
Ok(())
}
fn save_relmap_page(
timeline: &dyn Timeline,
lsn: Lsn,
xlrec: &XlRelmapUpdate,
decoded: &DecodedWALRecord,
) -> Result<()> {
let tag = RelishTag::FileNodeMap {
spcnode: xlrec.tsid,
dbnode: xlrec.dbid,
};
let mut buf = decoded.record.clone();
buf.advance(decoded.main_data_offset);
// skip xl_relmap_update
buf.advance(12);
timeline.put_page_image(tag, 0, lsn, Bytes::copy_from_slice(&buf[..]))?;
Ok(())
}
|
use std::fs::File;
use std::io::prelude::*;
use std::env;
use std::io::{self,BufReader};
mod Import_File;
fn main() -> io::Result<()> {
//let path = env::current_dir()?;
//et path = String::from("12");
//let num:u8 = path.parse().unwrap();
//println!("{}", num);
let f = File::open("2460219.TXT")?;
let f = BufReader::new(f);
for line in f.lines(){
//println!("{}", line.unwrap());
Import_File::insert_data(line.unwrap());
}
Ok(())
}
|
use crate::{
core::{
math::{
vec3::Vec3,
vec2::Vec2
},
pool::{Pool, Handle},
},
resource::fbx::{
find_and_borrow_node,
find_node,
FbxContainer,
FbxComponent,
FbxNode,
FbxReference,
string_to_reference,
string_to_mapping,
error::FbxError,
},
renderer::surface::{VertexWeightSet, VertexWeight},
utils::log::Log
};
pub struct FbxGeometry {
pub vertices: Vec<Vec3>,
pub indices: Vec<i32>,
pub normals: FbxContainer<Vec3>,
pub uvs: FbxContainer<Vec2>,
pub materials: FbxContainer<i32>,
pub tangents: FbxContainer<Vec3>,
pub binormals: FbxContainer<Vec3>,
pub(in crate::resource::fbx) deformers: Vec<Handle<FbxComponent>>,
}
impl FbxGeometry {
pub(in crate::resource::fbx) fn read(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<FbxGeometry, String> {
Ok(FbxGeometry {
vertices: Self::read_vertices(geom_node_handle, nodes)?,
indices: Self::read_indices(geom_node_handle, nodes)?,
normals: Self::read_normals(geom_node_handle, nodes)?,
uvs: Self::read_uvs(geom_node_handle, nodes)?,
materials: Self::read_materials(geom_node_handle, nodes)?,
tangents: FbxContainer::default(),
binormals: FbxContainer::default(),
deformers: Vec::new(),
})
}
fn read_vertices(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<Vec<Vec3>, String> {
let vertices_node_handle = find_node(nodes, geom_node_handle, "Vertices")?;
let vertices_array_node = find_and_borrow_node(nodes, vertices_node_handle, "a")?;
let vertex_count = vertices_array_node.attrib_count() / 3;
let mut vertices = Vec::with_capacity(vertex_count);
for i in 0..vertex_count {
vertices.push(vertices_array_node.get_vec3_at(i * 3)?);
}
Ok(vertices)
}
fn read_indices(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<Vec<i32>, String> {
let indices_node_handle = find_node(nodes, geom_node_handle, "PolygonVertexIndex")?;
let indices_array_node = find_and_borrow_node(nodes, indices_node_handle, "a")?;
let index_count = indices_array_node.attrib_count();
let mut indices = Vec::with_capacity(index_count);
for i in 0..index_count {
let index = indices_array_node.get_attrib(i)?.as_i32()?;
indices.push(index);
}
Ok(indices)
}
fn read_normals(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<FbxContainer<Vec3>, String> {
if let Ok(layer_element_normal_node_handle) = find_node(nodes, geom_node_handle, "LayerElementNormal") {
let map_type_node = find_and_borrow_node(nodes, layer_element_normal_node_handle, "MappingInformationType")?;
let mapping = string_to_mapping(&map_type_node.get_attrib(0)?.as_string());
let ref_type_node = find_and_borrow_node(nodes, layer_element_normal_node_handle, "ReferenceInformationType")?;
let reference = string_to_reference(&ref_type_node.get_attrib(0)?.as_string());
let normals_node_handle = find_node(nodes, layer_element_normal_node_handle, "Normals")?;
let normals_array_node = find_and_borrow_node(nodes, normals_node_handle, "a")?;
let count = normals_array_node.attrib_count() / 3;
let mut normals = Vec::with_capacity(count);
for i in 0..count {
normals.push(normals_array_node.get_vec3_at(i * 3)?);
}
Ok(FbxContainer {
elements: normals,
mapping,
reference,
..Default::default()
})
} else {
Ok(Default::default())
}
}
fn read_uvs(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<FbxContainer<Vec2>, String> {
if let Ok(layer_element_uv_node_handle) = find_node(nodes, geom_node_handle, "LayerElementUV") {
let map_type_node = find_and_borrow_node(nodes, layer_element_uv_node_handle, "MappingInformationType")?;
let mapping = string_to_mapping(&map_type_node.get_attrib(0)?.as_string());
let ref_type_node = find_and_borrow_node(nodes, layer_element_uv_node_handle, "ReferenceInformationType")?;
let reference = string_to_reference(&ref_type_node.get_attrib(0)?.as_string());
let uvs_node_handle = find_node(nodes, layer_element_uv_node_handle, "UV")?;
let uvs_array_node = find_and_borrow_node(nodes, uvs_node_handle, "a")?;
let count = uvs_array_node.attrib_count() / 2;
let mut uvs = Vec::with_capacity(count);
for i in 0..count {
let uv = uvs_array_node.get_vec2_at(i * 2)?;
uvs.push(Vec2 { x: uv.x, y: -uv.y }); // Hack FIXME
}
let mut index = Vec::new();
if reference == FbxReference::IndexToDirect {
let uv_index_node = find_node(nodes, layer_element_uv_node_handle, "UVIndex")?;
let uv_index_array_node = find_and_borrow_node(nodes, uv_index_node, "a")?;
for i in 0..uv_index_array_node.attrib_count() {
index.push(uv_index_array_node.get_attrib(i)?.as_i32()?);
}
}
Ok(FbxContainer {
elements: uvs,
index,
mapping,
reference,
})
} else {
Ok(Default::default())
}
}
fn read_materials(geom_node_handle: Handle<FbxNode>, nodes: &Pool<FbxNode>) -> Result<FbxContainer<i32>, String> {
if let Ok(layer_element_material_node_handle) = find_node(nodes, geom_node_handle, "LayerElementMaterial") {
let map_type_node = find_and_borrow_node(nodes, layer_element_material_node_handle, "MappingInformationType")?;
let mapping = string_to_mapping(&map_type_node.get_attrib(0)?.as_string());
let ref_type_node = find_and_borrow_node(nodes, layer_element_material_node_handle, "ReferenceInformationType")?;
let reference = string_to_reference(&ref_type_node.get_attrib(0)?.as_string());
let materials_node_handle = find_node(nodes, layer_element_material_node_handle, "Materials")?;
let materials_array_node = find_and_borrow_node(nodes, materials_node_handle, "a")?;
let count = materials_array_node.attrib_count();
let mut materials = Vec::with_capacity(count);
for i in 0..count {
materials.push(materials_array_node.get_attrib(i)?.as_i32()?);
}
Ok(FbxContainer {
elements: materials,
mapping,
reference,
..Default::default()
})
} else {
Ok(Default::default())
}
}
pub(in crate::resource::fbx) fn get_skin_data(&self, components: &Pool<FbxComponent>) -> Result<Vec<VertexWeightSet>, FbxError> {
let mut out = vec![VertexWeightSet::default(); self.vertices.len()];
for deformer_handle in self.deformers.iter() {
for sub_deformer_handle in components.borrow(*deformer_handle)
.as_deformer()?.sub_deformers.iter() {
let sub_deformer = components.borrow(*sub_deformer_handle)
.as_sub_deformer()?;
for (index, weight) in sub_deformer.weights.iter() {
let bone_set = out.get_mut(*index as usize)
.ok_or(FbxError::IndexOutOfBounds)?;
if !bone_set.push(VertexWeight {
value: *weight,
effector: sub_deformer.model.into(),
}) {
// TODO: Maybe gather all weights, but then re-normalize them to 4-bones?
Log::writeln("FBX: More than 4 bones per vertex?! Excess will be discarded".to_owned());
}
}
}
}
Ok(out)
}
} |
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// 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 alloc::collections::btree_map::BTreeMap;
use alloc::sync::Arc;
use spin::Mutex;
use core::ops::Deref;
use core::u64;
use lazy_static::lazy_static;
use super::common::*;
use super::linux_def::*;
use super::linux::limits::*;
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Ord, PartialOrd, Eq, PartialEq)]
#[repr(i32)]
pub enum LimitType {
CPU = 0,
FileSize,
Data,
Stack,
Core,
Rss,
ProcessCount,
NumberOfFiles,
MemoryLocked,
AS,
Locks,
SignalsPending,
MessageQueueBytes,
Nice,
RealTimePriority,
Rttime,
}
lazy_static! {
pub static ref FROM_LINUX_RESOURCE : BTreeMap<i32, LimitType> = [
(RLIMIT_CPU, LimitType::CPU),
(RLIMIT_FSIZE, LimitType::FileSize),
(RLIMIT_DATA, LimitType::Data),
(RLIMIT_STACK, LimitType::Stack),
(RLIMIT_CORE, LimitType::Core),
(RLIMIT_RSS, LimitType::Rss),
(RLIMIT_NPROC, LimitType::ProcessCount),
(RLIMIT_NOFILE, LimitType::NumberOfFiles),
(RLIMIT_MEMLOCK, LimitType::MemoryLocked),
(RLIMIT_AS, LimitType::AS),
(RLIMIT_LOCKS, LimitType::Locks),
(RLIMIT_SIGPENDING, LimitType::SignalsPending),
(RLIMIT_MSGQUEUE, LimitType::MessageQueueBytes),
(RLIMIT_NICE, LimitType::Nice),
(RLIMIT_RTPRIO, LimitType::RealTimePriority),
(RLIMIT_RTTIME, LimitType::Rttime),
].iter().cloned().collect();
}
pub const INFINITY: u64 = u64::MAX;
pub fn FromLinux(rl: u64) -> u64 {
if rl == RLIM_INFINITY {
return INFINITY
}
return rl
}
pub fn ToLinux(l: u64) -> u64 {
if l == INFINITY {
return RLIM_INFINITY
}
return l;
}
pub fn NewLinuxLimitSet() -> LimitSet {
let ls = LimitSet::default();
for (rlt, rl) in &*INIT_RLIMITS {
let lt = FROM_LINUX_RESOURCE.get(rlt).expect("unknown rlimit type");
ls.SetUnchecked(*lt, Limit {
Cur: FromLinux(rl.Cur),
Max: FromLinux(rl.Max),
});
}
return ls
}
#[derive(Serialize, Deserialize, Clone, Copy, Debug, Eq, PartialEq)]
pub struct Limit {
pub Cur: u64,
pub Max: u64,
}
impl Default for Limit {
fn default() -> Self {
return Self {
Cur: INFINITY,
Max: INFINITY,
}
}
}
#[derive(Serialize, Deserialize, Default, Debug, Eq, PartialEq)]
pub struct LimitSetInternal {
pub data: BTreeMap<LimitType, Limit>,
}
#[derive(Clone)]
pub struct LimitSet(pub Arc<Mutex<LimitSetInternal>>);
impl Deref for LimitSet {
type Target = Arc<Mutex<LimitSetInternal>>;
fn deref(&self) -> &Arc<Mutex<LimitSetInternal>> {
&self.0
}
}
impl Default for LimitSet {
fn default() -> Self {
return Self(Arc::new(Mutex::new(LimitSetInternal {
data: BTreeMap::new()
})))
}
}
impl LimitSet {
pub fn GetCopy(&self) -> Self {
let internal = self.lock();
let mut data = BTreeMap::new();
for (k, v) in &internal.data {
data.insert(*k, *v);
}
return Self(Arc::new(Mutex::new(LimitSetInternal {
data: data
})))
}
pub fn GetInternalCopy(&self) -> LimitSetInternal {
let internal = self.lock();
let mut data = BTreeMap::new();
for (k, v) in &internal.data {
data.insert(*k, *v);
}
LimitSetInternal {
data: data
}
}
pub fn Get(&self, t: LimitType) -> Limit {
let internal = self.lock();
match internal.data.get(&t) {
None => {
Limit::default()
}
Some(v) => v.clone(),
}
}
pub fn GetCapped(&self, t: LimitType, max: u64) -> u64 {
let s = self.Get(t);
if s.Cur == INFINITY || s.Cur > max {
return max
}
return s.Cur;
}
pub fn SetUnchecked(&self, t: LimitType, v: Limit) {
let mut internal = self.lock();
internal.data.insert(t, v);
}
pub fn Set(&self, t: LimitType, v: Limit, privileged: bool) -> Result<Limit> {
let mut internal = self.lock();
match internal.data.get_mut(&t) {
Some(l) => {
info!("current is {:?}, the neww is {:?}", l, &v);
if l.Max < v.Max && !privileged {
return Err(Error::SysError(SysErr::EPERM));
}
info!("Set ....");
if l.Cur > v.Max {
return Err(Error::SysError(SysErr::EINVAL));
}
let old = *l;
*l = v;
return Ok(old)
}
None => ()
}
internal.data.insert(t, v);
return Ok(Limit::default())
}
} |
use crate::hash_cons::Consed;
use std::ops::Deref;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct Symbol(Consed<String>);
impl Deref for Symbol {
type Target = String;
fn deref(&self) -> &String {
&self.0
}
}
impl From<Consed<String>> for Symbol {
fn from(sym: Consed<String>) -> Symbol {
Symbol(sym)
}
}
|
use aoc;
use std::collections::HashMap;
use std::error::Error;
use std::fs::File;
use std::io::prelude::*;
use std::io::BufReader;
fn main() -> Result<(), Box<dyn Error>> {
let arg = aoc::get_cmdline_arg()?;
let mut plants: HashMap<String, bool> = HashMap::new();
let mut lines = BufReader::new(File::open(arg)?).lines();
let mut initial_state = lines.next().unwrap()?[15..].to_owned();
for _ in 0..4 {
initial_state.insert(0, '.');
initial_state.push('.');
}
lines.skip(1).map(|line| line.unwrap()).for_each(|line| {
let pattern = line[0..5].to_owned();
let alive = &line[9..] == "#";
plants.insert(pattern, alive);
});
let sum = sim(&initial_state, &plants, 20);
println!("part 1: {}", sum);
let sum = sim(&initial_state, &plants, 50_000_000_000);
println!("part 2: {}", sum);
Ok(())
}
fn sim(input: &str, plants: &HashMap<String, bool>, generations: u64) -> i64 {
let mut curr_state = input.to_owned();
let mut next_state = String::new();
let mut zero_index = 4;
let mut last_diff = 0;
let mut last_sum = 0;
let mut gen = 1;
let mut sum_total = 0;
let mut same_diff_count = 0;
while gen <= generations {
next_state.push_str(&curr_state[0..2]);
for k in 2..(curr_state.len() - 2) {
match plants.get(&curr_state[k - 2..k + 3]) {
Some(alive) => {
if *alive {
next_state.push('#');
} else {
next_state.push('.');
}
}
None => {
next_state.push('.');
}
}
}
next_state.push_str(&curr_state[curr_state.len() - 2..]);
let old_len = next_state.len();
if let Some(first_plant) = next_state.find("#") {
if first_plant < 4 {
for _ in 0..(4 - first_plant) {
next_state.insert(0, '.');
}
}
}
let new_len = next_state.len();
zero_index += new_len - old_len;
if let Some(last_plant) = next_state.rfind("#") {
if last_plant > next_state.len() - 5 {
for _ in 0..(last_plant - (next_state.len() - 5)) {
next_state.push('.');
}
}
}
curr_state.clear();
curr_state.push_str(&next_state);
next_state.clear();
let mut sum = 0i64;
for (i, c) in curr_state.chars().enumerate() {
if c == '#' {
sum += i as i64 - zero_index as i64;
}
}
let diff = sum - last_sum;
if diff == last_diff {
same_diff_count += 1;
if same_diff_count == 10 {
gen -= 1;
break;
}
}
sum_total += diff;
last_sum = sum;
last_diff = diff;
gen += 1;
}
if gen < generations {
sum_total += last_diff * (generations - gen) as i64;
}
sum_total
}
|
// ctrl-dが押されるまで文字列を読み続け,行ごとに反転して返す
use std::io::Read;
use std::str;
fn reserve_each_line(text: &str) -> String {
text.split_terminator("\n")
.flat_map(|line| line.chars().rev().chain(Some('\n')))
.collect()
}
fn main() {
let mut scan = std::io::stdin();
let mut buf = Vec::new();
scan.read_to_end(&mut buf).unwrap();
let s = str::from_utf8(&buf[..]).unwrap();
print!("{}", reserve_each_line(s));
}
|
//! Provides types / enums / structs for defining parser combinators
mod heredoc;
mod interpolable;
mod metadata;
mod nom_prelude;
mod segment;
mod tracked_location;
pub use crate::ast::{
Identifier, IdentifierKind, Interpolated, Literal, Node, Parameter, Program, WhenClause,
};
pub use heredoc::{HeredocIndentation, HeredocMetadata, HeredocQuoteType};
pub use interpolable::Interpolatable;
pub use metadata::Metadata;
pub(crate) use nom_prelude::*;
pub use segment::Segment;
pub use tracked_location::TrackedLocation;
/// Describes the parser's input type
pub type Input<'a> = TrackedLocation<&'a str, Metadata<'a>>;
/// Intermediate type used to build the result types for lexing combinators
pub(crate) type Parsed<'a, T> = nom::IResult<Input<'a>, T>;
// Describes a parsed program
pub(crate) type ProgramResult<'a> = Parsed<'a, Program>;
// Describes a parsed AST node
pub(crate) type NodeResult<'a> = Parsed<'a, Node>;
// Describes a vector of parsed nodes
pub(crate) type NodeListResult<'a> = Parsed<'a, Vec<Node>>;
/// Describes a parsed literal
pub(crate) type LiteralResult<'a> = Parsed<'a, Literal>;
/// Describes a parsed character
pub(crate) type CharResult<'a> = Parsed<'a, char>;
/// Describes an interpolated result
pub(crate) type InterpolatableResult<'a> = Parsed<'a, Interpolatable>;
/// Describes a nom-compatible parsing result type (input and output types match)
pub(crate) type LexResult<'a> = Parsed<'a, Input<'a>>;
/// Describes a segment of something that may be interpolated
pub(crate) type SegmentResult<'a> = Parsed<'a, Segment>;
/// Describes a parsed string
pub(crate) type StringResult<'a> = Parsed<'a, String>;
/// Describes a parsed identifier
pub(crate) type IdentifierResult<'a> = Parsed<'a, Identifier>;
|
//! Telamon's demo.
//!
//! To run the demo:
//! ```
//! cargo run --example=matmul --features=cuda --release
//! ```
//! To display the candidates evaluated, use `RUST_LOG=telamon::explorer::warn`.
use telamon::device::Context;
use telamon::{codegen, explorer, helper, ir, search_space};
use telamon_cuda as cuda;
// Define the problem size.
const M: u32 = 1024;
const N: u32 = 1024;
const K: u32 = 1024;
#[allow(clippy::many_single_char_names)]
fn main() {
// Step 0. Setup logging and the CUDA interface.
env_logger::init();
let executor = cuda::Executor::init();
// Step 1. Define the kernel signature and the parameters we optimize for.
let mut context = cuda::Context::new(&executor);
let (m, n, k, a, b, c);
let signature = {
let mut builder = helper::SignatureBuilder::new("matmul", &mut context);
// Declare 3 integer parameters `m`, `n` and `k`.
m = builder.max_size("m", M);
n = builder.max_size("n", N);
k = builder.max_size("k", K);
// Declare 3 matricies of floats of size `m*k`, `k*n` and `m*n`.
// `a` and `b` are read-only but not `c`.
a = builder.tensor::<f32>("a", vec![m.clone(), k.clone()], true);
b = builder.tensor::<f32>("b", vec![k, n.clone()], true);
c = builder.tensor::<f32>("c", vec![m, n], false);
// Build the signature.
builder.get()
};
// Step 2. Define the kernel body
let mut builder = helper::Builder::new(signature.into(), context.device());
// Define te tiling factors for dimensions `m`, `n` and `k`.
let m_tiling = helper::TilingPattern::new_fixed(&[32, 4]);
let n_tiling = helper::TilingPattern::new_fixed(&[32, 4]);
let k_tiling = helper::TilingPattern::new_fixed(&[32]);
// Create two loop nests to load A and B
// for i in 0..M:
// for k in 0..K:
// ld_a = load A[i][k]
// for k in 0..K:
// for j in 0..N:
// ld_b = load B[k][j]
// Creates a load instruction in a loop nest of the dimensionality of the tensor. Each
// dimension is tilied with the given tiling pattern. Thus `M_TILING.len() + K_TILING.len() +
// 2` iteration dimensions are actually created here.
let ld_a = a.load(vec![m_tiling, k_tiling.clone()], &mut builder);
let ld_b = b.load(vec![k_tiling, n_tiling], &mut builder);
// Create a loop nest n*m to intialize c.
// for i in 0..M:
// for j in 0..N:
// init = 0
let init_dim_m = builder.open_mapped_dim(&ld_a[0]);
let init_dim_n = builder.open_mapped_dim(&ld_b[1]);
let init = builder.mov(&0f32);
// Accumulate `a[i][.]*b[.][j]`.
// for i in 0..M:
// for j in 0..N:
// for k in 0..K:
// acc = init += a * b
let acc_dim_m = builder.open_mapped_dim(&init_dim_m);
let acc_dim_n = builder.open_mapped_dim(&init_dim_n);
let acc_dim_k = builder.open_mapped_dim(&ld_a[1]);
// Values are taken pointwise from the dimensions mapped to the currently open decisions.
// Here, `acc_dim_m` is mapped to `init_dim_m` so iteration `i` on `acc_dim_m` uses the
// value of `init` produced at iteration `i` of `init_dim_m`.
//
// For `ld_a` and `ld_b`, the dimensions are not mapped with `open_mapped_dim` so we manualy
// specify the mapping. Additionaly, we set the mapping scope to global, which allows values
// to be stored in memory between the two dimensions are executed.
let global_scope = ir::DimMapScope::Global(());
let op_a = ld_a.dim_map(&[&acc_dim_m, &acc_dim_k], global_scope, &mut builder);
let op_b = ld_b.dim_map(&[&acc_dim_k, &acc_dim_n], global_scope, &mut builder);
let acc = builder.mad(&op_a, &op_b, &helper::Reduce(init));
builder.close_dim(&acc_dim_k);
// Store the result in `C`.
// for i in 0..M:
// for j in 0..N:
// store C[i][j] <- acc
let acc = helper::tensor::VirtualTensor::new(acc, vec![acc_dim_m, acc_dim_n]);
acc.store(&c, &mut builder);
// Step 3. Apply manual decisions and retrieve the search space.
// Don't use caches to load `A`.
builder.action(search_space::Action::InstFlag(
ld_a.inst(),
search_space::InstFlag::NO_CACHE,
));
let space = builder.get();
// Step 4. Launch a search.
let mut config = explorer::Config::default();
config.timeout = Some(5); // The search stops after 5 minutes.
let best = explorer::find_best(&config, &context, vec![space], None).unwrap();
// Step 5. Print the generated code.
let code = codegen::Function::build(&best);
context.device().print(&code, &mut std::io::stdout());
}
|
pub struct Solution;
impl Solution {
pub fn search_insert(nums: Vec<i32>, target: i32) -> i32 {
let n = nums.len();
if n == 0 {
return 0;
}
if target <= nums[0] {
return 0;
}
if nums[n - 1] < target {
return n as i32;
}
let mut a = 0;
let mut b = n - 1;
while a + 1 < b {
let c = (a + b) / 2;
if nums[c] < target {
a = c;
} else {
b = c;
}
}
b as i32
}
}
#[test]
fn test0035() {
assert_eq!(Solution::search_insert(vec![1, 3, 5, 6], 5), 2);
assert_eq!(Solution::search_insert(vec![1, 3, 5, 6], 2), 1);
assert_eq!(Solution::search_insert(vec![1, 3, 5, 6], 7), 4);
assert_eq!(Solution::search_insert(vec![1, 3, 5, 6], 0), 0);
}
|
// 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 {
fidl::{endpoints::RequestStream, Error as FidlError},
fidl_fuchsia_bluetooth_snoop::{
PacketType, SnoopMarker, SnoopPacket, SnoopProxy, SnoopRequestStream, Timestamp,
},
fuchsia_async::{Channel, Executor},
fuchsia_inspect::{assert_inspect_tree, Inspector},
fuchsia_zircon as zx,
std::task::Poll,
};
use super::*;
fn setup() -> (
Executor,
ConcurrentSnooperPacketFutures,
PacketLogs,
SubscriptionManager,
ConcurrentClientRequestFutures,
Inspector,
) {
let inspect = Inspector::new();
(
fasync::Executor::new().unwrap(),
ConcurrentSnooperPacketFutures::new(),
PacketLogs::new(10, 10, Duration::new(10, 0), inspect.root().create_child("packet_log")),
SubscriptionManager::new(),
ConcurrentClientRequestFutures::new(),
inspect,
)
}
#[test]
fn test_id_generator() {
let mut id_gen = IdGenerator::new();
assert_eq!(id_gen.next(), ClientId(0));
assert_eq!(id_gen.next(), ClientId(1));
}
#[test]
fn test_register_new_client() {
let (_exec, _snoopers, _logs, _subscribers, mut requests, _inspect) = setup();
assert_eq!(requests.len(), 0);
let (_tx, rx) = zx::Channel::create().unwrap();
let stream = SnoopRequestStream::from_channel(Channel::from_channel(rx).unwrap());
register_new_client(stream, &mut requests, ClientId(0));
assert_eq!(requests.len(), 1);
}
fn fidl_endpoints() -> (SnoopProxy, SnoopRequestStream) {
let (proxy, server) = fidl::endpoints::create_proxy::<SnoopMarker>().unwrap();
let request_stream = server.into_stream().unwrap();
(proxy, request_stream)
}
fn unwrap_request<T, E>(request: Poll<Option<Result<T, E>>>) -> T {
if let Poll::Ready(Some(Ok(request))) = request {
return request;
}
panic!("Failed to receive request");
}
fn unwrap_response<T, E>(response: Poll<Result<T, E>>) -> T {
if let Poll::Ready(Ok(response)) = response {
return response;
}
panic!("Failed to receive response");
}
#[test]
fn test_snoop_default_command_line_args() {
let args = Args::from_args(&["bt-snoop.cmx"], &[]).expect("Args created from empty args");
assert_eq!(args.log_size_kib, 256);
assert_eq!(args.log_time_seconds, 60);
assert_eq!(args.max_device_count, 8);
assert_eq!(args.truncate_payload, None);
assert_eq!(args.verbosity, 0);
}
#[test]
fn test_snoop_command_line_args() {
let log_size_kib = 1;
let log_time_seconds = 2;
let max_device_count = 3;
let truncate_payload = 4;
let verbosity = 2;
let raw_args = &[
"--log-size-kib",
&log_size_kib.to_string(),
"--log-time-seconds",
&log_time_seconds.to_string(),
"--max-device-count",
&max_device_count.to_string(),
"--truncate-payload",
&truncate_payload.to_string(),
"-v",
"-v",
];
let args = Args::from_args(&["bt-snoop.cmx"], raw_args).expect("Args created from args");
assert_eq!(args.log_size_kib, log_size_kib);
assert_eq!(args.log_time_seconds, log_time_seconds);
assert_eq!(args.max_device_count, max_device_count);
assert_eq!(args.truncate_payload, Some(truncate_payload));
assert_eq!(args.verbosity, verbosity);
}
#[test]
fn test_packet_logs_inspect() {
// This is a test that basic inspect data is plumbed through from the inspect root.
// More comprehensive testing of possible permutations of packet log inspect data
// is found in bounded_queue.rs
let inspect = Inspector::new();
let runtime_metrics_node = inspect.root().create_child("runtime_metrics");
let mut packet_logs = PacketLogs::new(2, 256, Duration::from_secs(60), runtime_metrics_node);
assert_inspect_tree!(inspect, root: {
runtime_metrics: {
logging_active_for_devices: "",
}
});
let id_1 = String::from("001");
packet_logs.add_device(id_1.clone());
assert_inspect_tree!(inspect, root: {
runtime_metrics: {
logging_active_for_devices: "\"001\"",
device_001: {
size_in_bytes: 0u64,
number_of_items: 0u64,
},
}
});
let packet = SnoopPacket {
is_received: false,
type_: PacketType::Data,
timestamp: Timestamp { subsec_nanos: 0, seconds: 123 },
original_len: 3,
payload: vec![3, 2, 1],
};
packet_logs.log_packet(&id_1, packet);
assert_inspect_tree!(inspect, root: {
runtime_metrics: {
logging_active_for_devices: "\"001\"",
device_001: {
size_in_bytes: 75u64,
number_of_items: 1u64,
"0": vec![0u8, 0, 0, 123, 0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 8, 0, 0, 0, 0, 2, 3, 2, 1],
},
}
});
drop(packet_logs);
}
#[test]
fn test_snoop_config_inspect() {
let args = Args {
log_size_kib: 1,
log_time_seconds: 2,
max_device_count: 3,
truncate_payload: Some(4),
verbosity: 5,
};
let inspect = Inspector::new();
let snoop_config_node = inspect.root().create_child("configuration");
let config = SnoopConfig::from_args(args, snoop_config_node);
assert_inspect_tree!(inspect, root: {
configuration: {
log_size_bytes: 1024u64,
log_time: 2u64,
max_device_count: 3u64,
truncate_payload: "4 bytes",
hci_dir: HCI_DEVICE_CLASS_PATH,
}
});
drop(config);
}
#[test]
fn test_handle_client_request() {
let (mut exec, mut _snoopers, mut logs, mut subscribers, mut requests, _inspect) = setup();
// unrecognized device returns an error to the client
let (proxy, mut request_stream) = fidl_endpoints();
let mut client_fut = proxy.start(true, Some(""));
let _ = exec.run_until_stalled(&mut client_fut);
let request = unwrap_request(exec.run_until_stalled(&mut request_stream.next()));
let request = (ClientId(0), (Some(Ok(request)), request_stream));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
let response = unwrap_response(exec.run_until_stalled(&mut client_fut));
assert!(response.error.is_some());
assert_eq!(subscribers.number_of_subscribers(), 0);
// valid device returns no errors to a client subscribed to that device
let (proxy, mut request_stream) = fidl_endpoints();
logs.add_device(String::new());
let mut client_fut = proxy.start(true, Some(""));
let _ = exec.run_until_stalled(&mut client_fut);
let request = unwrap_request(exec.run_until_stalled(&mut request_stream.next()));
let request = (ClientId(1), (Some(Ok(request)), request_stream));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
let response = unwrap_response(exec.run_until_stalled(&mut client_fut));
assert!(response.error.is_none());
assert_eq!(subscribers.number_of_subscribers(), 1);
// valid device returns no errors to a client subscribed globally
let (proxy, mut request_stream) = fidl_endpoints();
let mut client_fut = proxy.start(true, None);
let _ = exec.run_until_stalled(&mut client_fut);
let request = unwrap_request(exec.run_until_stalled(&mut request_stream.next()));
let request = (ClientId(2), (Some(Ok(request)), request_stream));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
let response = unwrap_response(exec.run_until_stalled(&mut client_fut));
println!("{:?}", response.error);
assert!(response.error.is_none());
assert_eq!(subscribers.number_of_subscribers(), 2);
// second request by the same client returns an error
let (proxy, mut request_stream) = fidl_endpoints();
let mut client_fut = proxy.start(true, None);
let _ = exec.run_until_stalled(&mut client_fut);
let request = unwrap_request(exec.run_until_stalled(&mut request_stream.next()));
let request = (ClientId(2), (Some(Ok(request)), request_stream));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
let response = unwrap_response(exec.run_until_stalled(&mut client_fut));
println!("{:?}", response.error);
assert!(response.error.is_some());
assert_eq!(subscribers.number_of_subscribers(), 2);
// valid device returns no errors to a client requesting a dump
let (proxy, mut request_stream) = fidl_endpoints();
let mut client_fut = proxy.start(false, None);
let _ = exec.run_until_stalled(&mut client_fut);
let request = unwrap_request(exec.run_until_stalled(&mut request_stream.next()));
let request = (ClientId(3), (Some(Ok(request)), request_stream));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
let response = unwrap_response(exec.run_until_stalled(&mut client_fut));
println!("{:?}", response.error);
assert!(response.error.is_none());
assert_eq!(subscribers.number_of_subscribers(), 2);
}
#[test]
fn test_handle_bad_client_request() {
let (_exec, mut _snoopers, mut logs, mut subscribers, mut requests, _inspect) = setup();
let id = ClientId(0);
let err = Some(Err(FidlError::Invalid));
let (_proxy, req_stream) = fidl_endpoints();
let handle = req_stream.control_handle();
let request = (id, (err, req_stream));
subscribers.register(id, handle, None).unwrap();
assert!(subscribers.is_registered(&id));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
assert!(!subscribers.is_registered(&id));
let id = ClientId(1);
let err = Some(Err(FidlError::Invalid));
let (_proxy, req_stream) = fidl_endpoints();
let handle = req_stream.control_handle();
let request = (id, (err, req_stream));
subscribers.register(id, handle, None).unwrap();
assert!(subscribers.is_registered(&id));
handle_client_request(request, &mut requests, &mut subscribers, &mut logs).unwrap();
assert!(!subscribers.is_registered(&id));
}
|
use ansi_term::Colour;
use hackscanner_lib::*;
pub fn print_summary(min_severity: Severity, summary: &Summary) {
println!("[SUMMARY]");
println!(
"Detected {} violations with severity '{}' or higher",
summary.ratings_above(min_severity),
min_severity.description().to_lowercase()
);
let supports_color = match term::stdout() {
Some(t) => t.supports_color(),
None => false,
};
if supports_color {
print_summary_colored(summary);
} else {
print_summary_simple(summary);
}
println!()
}
pub fn print_ratings(min_severity: Severity, ratings: &[Rating<'_>]) {
for rating in ratings {
if rating.rating() >= min_severity as isize {
print_rating(rating);
}
}
}
pub fn print_rating(rating: &Rating<'_>) {
let supports_color = match term::stdout() {
Some(t) => t.supports_color(),
None => false,
};
if supports_color {
print_rating_colored(rating)
} else {
print_rating_simple(rating)
}
}
pub fn print_validation(rating: &Rating<'_>, verbose: bool) {
let supports_color = match term::stdout() {
Some(t) => t.supports_color(),
None => false,
};
if supports_color {
print_validation_colored(rating, verbose)
} else {
print_validation_simple(rating, verbose)
}
}
fn get_path_as_string(rating: &Rating<'_>) -> String {
rating.entry().path().to_string_lossy().into_owned()
}
fn print_rating_colored(rating: &Rating<'_>) {
println!(
"{} {} \t(Rules: {})",
colored_description_for_severity(rating.rating().into()),
Colour::Black.bold().paint(get_path_as_string(rating)),
join_violations(rating.violations())
);
}
fn print_rating_simple(rating: &Rating<'_>) {
println!(
"{} {} \t(Rules: {})",
description_for_severity(rating.rating().into(), true),
get_path_as_string(rating),
join_violations(rating.violations())
);
}
fn print_validation_colored(rating: &Rating<'_>, verbose: bool) {
let rating_value = rating.rating();
if rating_value <= 0 {
println!(
"{} No violations found for path {}",
Colour::Blue.paint("[OK]"),
Colour::Black.bold().paint(get_path_as_string(rating))
);
} else {
println!(
"{} {} violations found for path {} \t(Rules: {})",
colored_description_for_severity(rating_value.into()),
Severity::from(rating_value),
Colour::Black.bold().paint(get_path_as_string(rating)),
join_violations(rating.violations())
)
}
if verbose {
println!("Calculated rating: {}", rating_value)
}
}
fn print_validation_simple(rating: &Rating<'_>, verbose: bool) {
let rating_value = rating.rating();
if rating_value <= 0 {
println!(
"[OK] No violations found for path {}",
get_path_as_string(rating)
);
} else {
println!(
"{} {} violations found for path {} \t(Rules: {})",
description_for_severity(rating_value.into(), true),
Severity::from(rating_value),
get_path_as_string(rating),
join_violations(rating.violations())
)
}
if verbose {
println!("Calculated rating: {}", rating_value)
}
}
fn colored_description_for_severity(severity: Severity) -> String {
format!(
"{}",
color_for_severity(severity).paint(description_for_severity(severity, true))
)
}
fn color_for_severity(severity: Severity) -> Colour {
match severity {
Severity::CRITICAL => Colour::RGB(225, 17, 0),
Severity::MAJOR => Colour::RGB(237, 131, 0),
Severity::MINOR => Colour::RGB(245, 207, 0),
Severity::NOTICE => Colour::RGB(255, 255, 0),
_ => Colour::Blue,
}
}
fn description_for_severity(severity: Severity, brackets: bool) -> String {
if brackets {
format!(
"{:width$}",
format!("[{}]", severity.description()),
width = 10
)
} else {
format!(
"{:width$}",
format!("{}:", severity.description()),
width = 10
)
}
}
fn print_summary_colored(summary: &Summary) {
if summary.critical() > 0 {
println!(
"{}",
color_for_severity(Severity::CRITICAL).paint(format!(
"{} {}",
description_for_severity(Severity::CRITICAL, false),
summary.critical()
))
);
}
if summary.major() > 0 {
println!(
"{}",
color_for_severity(Severity::MAJOR).paint(format!(
"{} {}",
description_for_severity(Severity::MAJOR, false),
summary.major()
))
);
}
if summary.minor() > 0 {
println!(
"{}",
color_for_severity(Severity::MINOR).paint(format!(
"{} {}",
description_for_severity(Severity::MINOR, false),
summary.minor()
))
);
}
if summary.notice() > 0 {
println!(
"{}",
color_for_severity(Severity::NOTICE).paint(format!(
"{} {}",
description_for_severity(Severity::NOTICE, false),
summary.notice()
))
);
}
if summary.clean() > 0 {
println!(
"{}",
color_for_severity(Severity::NONE).paint(format!(
"{} {}",
description_for_severity(Severity::NONE, false),
summary.clean()
))
);
}
}
fn print_summary_simple(summary: &Summary) {
if summary.critical() > 0 {
println!(
"{} {}",
description_for_severity(Severity::CRITICAL, false),
summary.critical()
);
}
if summary.major() > 0 {
println!(
"{} {}",
description_for_severity(Severity::MAJOR, false),
summary.major()
);
}
if summary.minor() > 0 {
println!(
"{} {}",
description_for_severity(Severity::MINOR, false),
summary.minor()
);
}
if summary.notice() > 0 {
println!(
"{} {}",
description_for_severity(Severity::NOTICE, false),
summary.notice()
);
}
if summary.clean() > 0 {
println!(
"{} {}",
description_for_severity(Severity::NONE, false),
summary.clean()
);
}
}
|
use crate::scraper::BASE_BOE_URL;
use scraper::{Html, Selector};
use shylock_data::concepts::BoeConcept;
use std::collections::HashMap;
fn parse_html_table(
page: &str,
data_selector: &Selector,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
let mut result: HashMap<BoeConcept, String> = HashMap::new();
let doc = Html::parse_document(&page);
let data = doc
.select(data_selector)
.next()
.ok_or("error parsing table, no container of table found")?;
let tr_selector = Selector::parse("tr").expect("tr selector creation failed");
let th_selector = Selector::parse("th").expect("th selector creation failed");
let td_selector = Selector::parse("td").expect("td selector creation failed");
for tr in data.select(&tr_selector) {
let th = tr
.select(&th_selector)
.next()
.ok_or("not found th")?
.text()
.collect::<String>();
let td = tr
.select(&td_selector)
.next()
.ok_or("not found td")?
.text()
.collect::<String>();
result.insert(
th.trim().parse::<BoeConcept>()?,
td.trim().to_uppercase().to_owned(),
);
}
Ok(result)
}
pub(crate) fn parse_management_auction_page(
page: &str,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
parse_html_table(
page,
&Selector::parse(r#"div[id=idBloqueDatos2]"#)
.expect("div[id=idBloqueDatos2] selector creation failed"),
)
}
pub(crate) fn parse_asset_auction_page(
page: &str,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
let h4_selector = &Selector::parse("h4").expect("h4 selector creation failed");
let data_selector = &Selector::parse(r#"div[id=idBloqueLote1]"#)
.expect("div[id=idBloqueLote1 selector creation failed");
let mut result = parse_html_table(page, data_selector)?;
let doc = Html::parse_document(&page);
let data = doc.select(data_selector).next().ok_or("no div found")?;
let header = data
.select(&h4_selector)
.next()
.ok_or("no header h4 found")?;
result.insert(
BoeConcept::Header,
header
.text()
.collect::<String>()
.trim()
.to_uppercase()
.to_owned(),
);
Ok(result)
}
pub(crate) fn parse_lot_auction_page_links(
page: &str,
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let mut result = Vec::new();
let doc = Html::parse_document(page);
let ul_selector =
Selector::parse("ul.navlistver").expect("ul.navlistver selector creation failed");
let a_selector = Selector::parse("a").expect("a selector creation failed");
let ul = doc
.select(&ul_selector)
.next()
.ok_or("not ul element found")?;
for lot_anchor in ul.select(&a_selector) {
if let Some(href) = lot_anchor.value().attr("href") {
result.push(BASE_BOE_URL.to_owned() + href);
}
}
Ok(result)
}
pub(crate) fn parse_lot_auction_page(
page: &str,
i: usize,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
let h4_selector = &Selector::parse("h4").expect("h4 selector creation failed");
let div_str_selector = format!(r#"div[id=idBloqueLote{}]"#, i);
let data_selector = &Selector::parse(&div_str_selector).expect("div[id=idBloqueLoteX] failed");
let mut result = parse_html_table(page, data_selector)?;
let doc = Html::parse_document(&page);
let data = doc
.select(data_selector)
.next()
.ok_or("no div[id=idBloqueLoteX] field found")?;
let header = data
.select(&h4_selector)
.next()
.ok_or("no h4 field found")?;
result.insert(
BoeConcept::Header,
header
.text()
.collect::<String>()
.trim()
.to_uppercase()
.to_owned(),
);
Ok(result)
}
pub(crate) fn parse_main_auction_links(
page: &str,
) -> Result<(String, String), Box<dyn std::error::Error>> {
let doc = Html::parse_document(&page);
let links_selector =
Selector::parse("ul.navlist").expect("ul.navlist selector creation failed");
let data = doc
.select(&links_selector)
.next()
.ok_or("unable to select ul.navlist links")?;
let link_selector = Selector::parse("a").expect("a selector creation failed");
let mut iterator = data.select(&link_selector);
iterator.next();
let management_link = iterator
.next()
.ok_or("error looking for a link")?
.value()
.attr("href")
.ok_or("error looking for href attribute")?;
let asset_link = iterator
.next()
.ok_or("error looking for a link")?
.value()
.attr("href")
.ok_or("error looking for href attribute")?;
Ok((
BASE_BOE_URL.to_owned() + management_link,
BASE_BOE_URL.to_owned() + asset_link,
))
}
pub(crate) fn parse_main_auction_page(
page: &str,
) -> Result<HashMap<BoeConcept, String>, Box<dyn std::error::Error>> {
parse_html_table(
page,
&Selector::parse(r#"div[id=idBloqueDatos1]"#)
.expect("div[id=idBloqueDatos1] selector creation failed"),
)
}
pub(crate) fn parse_extra_pages(
main_page: &str,
) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let mut result = Vec::new();
let doc = Html::parse_document(main_page);
let pages_div = Selector::parse("div.paginar2").expect("div.paginar2 selector creation failed");
if let Some(div) = doc.select(&pages_div).next() {
let anchors_selector = Selector::parse("a").expect("a selector creation failed");
for page_anchor in div.select(&anchors_selector) {
if let Some(href) = page_anchor.value().attr("href") {
result.push(BASE_BOE_URL.to_owned() + href);
}
}
}
result.pop();
Ok(result)
}
pub(crate) fn parse_result_page(page: &str) -> Result<Vec<String>, Box<dyn std::error::Error>> {
let mut result = Vec::new();
let doc = Html::parse_document(page);
let auction_anchors = Selector::parse("a.resultado-busqueda-link-otro")
.expect("a.resultado-busueda-link-otro selector creation failed");
for auction_anchor in doc.select(&auction_anchors) {
if let Some(href) = auction_anchor.value().attr("href") {
result.push(BASE_BOE_URL.to_owned() + href);
}
}
Ok(result)
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn parse_lot_auction_page_links_test() {
const INPUT: &str = r#"<div id="cont-tabs">
<div id="tabsver">
<ul class="navlistver">
<li>
<a id="idTabLote1" href="./detalleSubasta.php?idSub=SUB-JA-2020-158475&ver=3&idLote=1&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&numPagBus=#cont-tabs" title="FINCA REGISTRAL Nº 29.047 DEL REGISTRO DE LA PROPIEDAD Nº1 DE LOGROÑO"><span class="pc">Lote </span>1</a>
</li>
<li>
<a id="idTabLote2" href="./detalleSubasta.php?idSub=SUB-JA-2020-158475&ver=3&idLote=2&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&numPagBus=#cont-tabs" title="FINCA REGISTRAL Nº29.023-45 DEL REGISTRO DE LA PROPIEDAD Nº1 DE LOGROÑO" class="current"><span class="pc">Lote </span>2</a>
</li>
</ul>
</div>
</div>
"#;
let pages = parse_lot_auction_page_links(INPUT).unwrap();
assert_eq!(2, pages.len());
assert_eq!(&"https://subastas.boe.es/./detalleSubasta.php?idSub=SUB-JA-2020-158475&ver=3&idLote=1&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&numPagBus=#cont-tabs",
pages.get(0).unwrap());
assert_eq!(&"https://subastas.boe.es/./detalleSubasta.php?idSub=SUB-JA-2020-158475&ver=3&idLote=2&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&numPagBus=#cont-tabs",
pages.get(1).unwrap());
}
#[test]
fn parse_lot_auction_page_test() {
const INPUT: &str = r#" <div class="bloque" id="idBloqueLote2">
<div>
<div class="tablet movil">
<h3>Lote 2</h3>
</div>
<div class="caja">FINCA REGISTRAL Nº29.023-45 DEL REGISTRO DE LA PROPIEDAD Nº1 DE LOGROÑO</div>
</div>
<div>
<h3>Datos relacionados con la subasta del lote 2</h3>
<table>
<tr>
<th>Valor Subasta</th>
<td>15.100,00 €</td>
</tr>
<tr>
<th>Importe del depósito</th>
<td>755,00 €</td>
</tr>
<tr>
<th>Puja mínima</th>
<td>Sin puja mínima</td>
</tr>
<tr>
<th>Tramos entre pujas</th>
<td>302,00 €</td>
</tr>
</table>
</div>
<div>
<h3>Datos del bien subastado</h3>
<div>
<h4>Bien 1 - Inmueble (Garaje)</h4>
<table>
<tr>
<th>Descripción</th>
<td>GARAJE SITO EN LOGROÑO</td>
</tr>
<tr>
<th>Dirección</th>
<td>AVENIDA MANUEL DE FALLA Nº51 SOTANA Nº1</td>
</tr>
<tr>
<th>Código Postal</th>
<td>26007</td>
</tr>
<tr>
<th>Localidad</th>
<td>LOGROÑO</td>
</tr>
<tr>
<th>Provincia</th>
<td>La Rioja</td>
</tr>
<tr>
<th>Situación posesoria</th>
<td>No consta</td>
</tr>
<tr>
<th>Visitable</th>
<td>No consta</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>"#;
let lot: HashMap<BoeConcept, String> = [
(BoeConcept::AuctionValue, String::from("15.100,00 €")),
(BoeConcept::DepositAmount, String::from("755,00 €")),
(BoeConcept::MinimumBid, String::from("SIN PUJA MÍNIMA")),
(BoeConcept::BidStep, String::from("302,00 €")),
(
BoeConcept::Header,
String::from("BIEN 1 - INMUEBLE (GARAJE)"),
),
(
BoeConcept::Description,
String::from("GARAJE SITO EN LOGROÑO"),
),
(
BoeConcept::Address,
String::from("AVENIDA MANUEL DE FALLA Nº51 SOTANA Nº1"),
),
(BoeConcept::PostalCode, String::from("26007")),
(BoeConcept::City, String::from("LOGROÑO")),
(BoeConcept::Province, String::from("LA RIOJA")),
(BoeConcept::OwnerStatus, String::from("NO CONSTA")),
(BoeConcept::Visitable, String::from("NO CONSTA")),
]
.iter()
.cloned()
.collect();
assert_eq!(lot, parse_lot_auction_page(INPUT, 2).unwrap());
}
#[test]
fn parse_main_auction_links_test() {
const INPUT: &str = r#"<div id="tabs">
<input type="checkbox" class="desplegable" id="dropDownFiltro" value="" name="dropDownFiltro"/>
<label class="selected" for="dropDownFiltro" data-toggle="dropdown">Información general</label>
<ul class="navlist">
<li>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=1&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=" class="current">Información general</a>
</li>
<li>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=2&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=">Autoridad gestora</a>
</li>
<li>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=3&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=">Lotes</a>
</li>
<li>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=4&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=">Relacionados</a>
</li>
<li>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=5&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=">Pujas</a>
</li>
</ul>
</div>"#;
let (link1, link2) = parse_main_auction_links(INPUT).unwrap();
assert_eq!("https://subastas.boe.es/./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=2&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=",
link1);
assert_eq!("https://subastas.boe.es/./detalleSubasta.php?idSub=SUB-JA-2020-149474&ver=3&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,&idLote=1&numPagBus=",
link2);
}
#[test]
fn parse_extra_pages_test() {
const INPUT: &str = r#"<body><div class="paginar2">
<ul>
<li>
<span class="fuera">Está usted en la página de resultados número </span>
<span class="current">1</span>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-500-500">
<span class="pagSigxxx">2</span>
</a>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-1000-500">
<span class="pagSigxxx">3</span>
</a>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-500-500">
<span class="pagSig"><abbr title="Página">Pág.</abbr> siguiente</span>
</a>
</li>
</ul>
</div>
<div class="paginar2">
<ul>
<li>
<span class="fuera">Está usted en la página de resultados número </span>
<span class="current">1</span>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-500-500">
<span class="pagSigxxx">2</span>
</a>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-1000-500">
<span class="pagSigxxx">3</span>
</a>
</li>
<li>
<a href="subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-500-500">
<span class="pagSig"><abbr title="Página">Pág.</abbr> siguiente</span>
</a>
</li>
</ul>
</div></body>"#;
let pages = parse_extra_pages(INPUT).unwrap();
assert_eq!(2, pages.len());
assert_eq!(&"https://subastas.boe.es/subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-500-500",
pages.get(0).unwrap());
assert_eq!(&"https://subastas.boe.es/subastas_ava.php?accion=Mas&id_busqueda=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,-1000-500",
pages.get(1).unwrap());
}
#[test]
fn parse_asset_auction_test() {
const INPUT: &str = r#"<div class="bloque" id="idBloqueLote1">
<div>
<div class="caja">FINCA URBANA, SITUADA EN VALLADOLID, CALLE MARIANO DE LOS COBOS NUM.90, PLANTA BAJA-1º. FINCA NUM. 17228</div>
</div>
<div>
<h3>Datos del bien subastado</h3>
<div>
<h4>Bien 1 - Inmueble (Vivienda)</h4>
<table>
<tr>
<th>Descripción</th>
<td>FINCA URBANA SITUADA EN VALLADOLID, CALLE MARIANO DE LOS COBOS NUM.90, BAJO-1º</td>
</tr>
<tr>
<th>Referencia catastral</th>
<td>
<a href="consultaDnprc.php?rc=4110202UM5141A0003HH&idSub=SUB-JA-2020-149494" target="_blank" title="Abre datos catastrales en nueva ventana" onclick="return confirm('El Portal de Subastas se va conectar a los servicios web de la Dirección General del Catastro y mostrará la información en una nueva ventana');">4110202UM5141A0003HH</a>
</td>
</tr>
<tr>
<th>Dirección</th>
<td>CALLE MARIANO DE LOS COBOS 90</td>
</tr>
<tr>
<th>Código Postal</th>
<td>47014</td>
</tr>
<tr>
<th>Localidad</th>
<td>VALLADOLID</td>
</tr>
<tr>
<th>Provincia</th>
<td>Valladolid</td>
</tr>
<tr>
<th>Vivienda habitual</th>
<td>Sí</td>
</tr>
<tr>
<th>Situación posesoria</th>
<td>No consta</td>
</tr>
<tr>
<th>Visitable</th>
<td>No consta</td>
</tr>
<tr>
<th>Inscripción registral</th>
<td>CONSTA EN EL EDICTO</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>"#;
let asset: HashMap<BoeConcept, String> = [
(
BoeConcept::Header,
String::from("BIEN 1 - INMUEBLE (VIVIENDA)"),
),
(
BoeConcept::Description,
String::from(
"FINCA URBANA SITUADA EN VALLADOLID, CALLE MARIANO DE LOS COBOS NUM.90, BAJO-1º",
),
),
(
BoeConcept::CatastroReference,
String::from("4110202UM5141A0003HH"),
),
(
BoeConcept::Address,
String::from("CALLE MARIANO DE LOS COBOS 90"),
),
(BoeConcept::PostalCode, String::from("47014")),
(BoeConcept::City, String::from("VALLADOLID")),
(
BoeConcept::Province,
String::from("VALLADOLID"),
),
(
BoeConcept::PrimaryResidence,
String::from("SÍ"),
),
(
BoeConcept::OwnerStatus,
String::from("NO CONSTA"),
),
(
BoeConcept::Visitable,
String::from("NO CONSTA"),
),
(
BoeConcept::RegisterInscription,
String::from("CONSTA EN EL EDICTO"),
),
]
.iter()
.cloned()
.collect();
assert_eq!(asset, parse_asset_auction_page(INPUT).unwrap());
}
#[test]
fn parse_management_auction_test() {
const INPUT: &str = r#"
<div id="idBloqueDatos2">
<h3>Datos de la autoridad gestora</h3>
<table>
<tr>
<th>Código</th>
<td>3003000230</td>
</tr>
<tr>
<th>Descripción</th>
<td>UNIDAD SUBASTAS JUDICIALES MURCIA<strong> (Ministerio de Justicia)</strong></td>
</tr>
<tr>
<th>Dirección</th>
<td>AV DE LA JUSTICIA S/N S/N ; 30011 MURCIA</td>
</tr>
<tr>
<th>Teléfono</th>
<td>968833360</td>
</tr>
<tr>
<th>Fax</th>
<td>-</td>
</tr>
<tr>
<th>Correo electrónico</th>
<td>subastas.murcia@justicia.es</td>
</tr>
</table>
</div>"#;
let mgm: HashMap<BoeConcept, String> = [
(BoeConcept::Code, String::from("3003000230")),
(
BoeConcept::Description,
String::from("UNIDAD SUBASTAS JUDICIALES MURCIA (MINISTERIO DE JUSTICIA)"),
),
(
BoeConcept::Address,
String::from("AV DE LA JUSTICIA S/N S/N ; 30011 MURCIA"),
),
(BoeConcept::Telephone, String::from("968833360")),
(BoeConcept::Fax, String::from("-")),
(
BoeConcept::Email,
String::from("SUBASTAS.MURCIA@JUSTICIA.ES"),
),
]
.iter()
.cloned()
.collect();
assert_eq!(mgm, parse_management_auction_page(INPUT).unwrap());
}
#[test]
fn parse_auction_test() {
const INPUT: &str = r#"
<div id="idBloqueDatos1">
<h3>Datos de la subasta</h3>
<table>
<tr>
<th>Identificador</th>
<td>
<strong>SUB-NE-2020-465937</strong>
</td>
</tr>
<tr>
<th>Tipo de subasta</th>
<td>
<strong>NOTARIAL EN VENTA EXTRAJUDICIAL</strong>
</td>
</tr>
<tr>
<th>Fecha de inicio</th>
<td>14-07-2020 18:00:00 CET (ISO: 2020-07-14T18:00:00+02:00)</td>
</tr>
<tr>
<th>Fecha de conclusión</th>
<td><strong class="destaca">03-08-2020 18:00:00 CET </strong> (ISO: 2020-08-03T18:00:00+02:00)</td>
</tr>
<tr>
<th>Cantidad reclamada</th>
<td>81.971,57 €</td>
</tr>
<tr>
<th>Lotes</th>
<td>Sin lotes</td>
</tr>
<tr>
<th>Anuncio BOE</th>
<td>BOE-B-2020-21708</td>
</tr>
<tr>
<th>Valor subasta</th>
<td>75.127,00 €</td>
</tr>
<tr>
<th>Tasación</th>
<td>75.127,00 €</td>
</tr>
<tr>
<th>Puja mínima</th>
<td>Sin puja mínima</td>
</tr>
<tr>
<th>Tramos entre pujas</th>
<td>Sin tramos</td>
</tr>
<tr>
<th>Importe del depósito</th>
<td>3.756,35 €</td>
</tr>
</table>
</div>
"#;
let auction: HashMap<BoeConcept, String> = [
(BoeConcept::Identifier, String::from("SUB-NE-2020-465937")),
(
BoeConcept::AuctionKind,
String::from("NOTARIAL EN VENTA EXTRAJUDICIAL"),
),
(
BoeConcept::StartDate,
String::from("14-07-2020 18:00:00 CET (ISO: 2020-07-14T18:00:00+02:00)"),
),
(
BoeConcept::EndDate,
String::from("03-08-2020 18:00:00 CET (ISO: 2020-08-03T18:00:00+02:00)"),
),
(BoeConcept::ClaimQuantity, String::from("81.971,57 €")),
(BoeConcept::Lots, String::from("SIN LOTES")),
(BoeConcept::Notice, String::from("BOE-B-2020-21708")),
(BoeConcept::AuctionValue, String::from("75.127,00 €")),
(BoeConcept::Appraisal, String::from("75.127,00 €")),
(BoeConcept::MinimumBid, String::from("SIN PUJA MÍNIMA")),
(BoeConcept::BidStep, String::from("SIN TRAMOS")),
(BoeConcept::DepositAmount, String::from("3.756,35 €")),
]
.iter()
.cloned()
.collect();
assert_eq!(auction, parse_main_auction_page(INPUT).unwrap());
}
#[test]
fn parse_result_page_test() {
const INPUT: &str = r#"
<div class="listadoResult">
<ul>
<li class="resultado-busqueda">
<h3>
SUBASTA SUB-JA-2020-146153</h3>
<h4>JUZGADO 1ª INST E INSTRUCC. 6 - TORRELAVEGA</h4>
<p>
Expediente: 0048/18</p>
<p>
Estado: Celebrándose - [Conclusión prevista: 19/07/2020 a las 16:24:28]
</p>
<p>URBANA, TERRENO EN EL PUEBLO DE COBRECES, AYUNTAMIENTO DE ALFOZ DE LLOREDO, BARRIO DE EL PINO, QUE TIENE UN SUPERCIE DE 134 METROS CUADRADOS. CONTINEN DENTRO DE SÍ UN EDIFICIO QUE OCUPA SOBRE EL TRERRENO 122 METROS CUADRADOS APROXIMADAMENTE. ALBERGA UNA UNICA VIVIENDA UNIFAMILIAR. LA PLANTA BAJA SOBRE LA RASANTE DEL TERRENO SE DESTINA A VIVIENDA , CON UNA SUPERFICIE CONSTRUIDA DE 122 METROS CUADRADOS, APROXIMADAMENTE, QUE SE DISTRIBUYE EN COCINA , BAÑO, DESPACHO, SALÓN, SALA Y TERRAZA; LA PLANTA PRIMERA SE DESTINA A VIVIENDA , CON UNA SUPERFICIE COPNSTRUIDA DE 135 METROS CUADRADOS, APROXIMADAMENTE Y SE RPARTE EN DISTRIBUIDOR, BAÑO, CINCO DORMITORIOS Y TERRAZA, Y LA PLANTA BAJO CUBIERTA, SE DESTINA A ESPACIO DIÁFANO , TIENE UNA SUPERFICIE CONSTRUIDA DE 65 METROS CUADRADOS , APROXIMADAMENTE.</p>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-146153&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-defecto" title="Subasta SUB-JA-2020-146153"> </a>
<ul>
<li class="puntoHTML">
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-146153&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-otro" title="Subasta SUB-JA-2020-146153">Más... (Referencia SUB-JA-2020-146153)</a>
</li>
</ul>
</li>
<li class="resultado-busqueda">
<h3>
SUBASTA SUB-JA-2020-149625</h3>
<h4>JUZGADO 1ª INST E INSTRUCC. 1 - MOTILLA PALANCAR</h4>
<p>
Expediente: 0008/17</p>
<p>
Estado: Celebrándose - [Conclusión prevista: 20/07/2020 a las 18:00:00]
</p>
<p>FINCA 9557 sita en Villanueva de la Jara, Calle Madrigal nº 3. Inscrita en el Registro de la Propiedad de Motilla del Palancar, tomo 1057, libro 74, folio 95.</p>
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149625&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-defecto" title="Subasta SUB-JA-2020-149625"> </a>
<ul>
<li class="puntoHTML">
<a href="./detalleSubasta.php?idSub=SUB-JA-2020-149625&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-otro" title="Subasta SUB-JA-2020-149625">Más... (Referencia SUB-JA-2020-149625)</a>
</li>
</ul>
</li>
<li class="resultado-busqueda">
<h3>
SUBASTA SUB-AT-2020-20R4186001070</h3>
<h4>U.R. SUBASTAS ANDALUCIA 41 - SEVILLA</h4>
<p>
Estado: Celebrándose - [Conclusión prevista: 20/07/2020 a las 18:00:00]
</p>
<p>SOLAR . CL TAJO 20. 41110 - BOLLULLOS DE LA MITACION (SEVILLA)</p>
<a href="./detalleSubasta.php?idSub=SUB-AT-2020-20R4186001070&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-defecto" title="Subasta SUB-AT-2020-20R4186001070"> </a>
<ul>
<li class="puntoHTML">
<a href="./detalleSubasta.php?idSub=SUB-AT-2020-20R4186001070&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,," class="resultado-busqueda-link-otro" title="Subasta SUB-AT-2020-20R4186001070">Más... (Referencia SUB-AT-2020-20R4186001070)</a>
</li>
</ul>
</li>
</ul>
</div>"#;
let links = vec![
BASE_BOE_URL.to_owned() + "./detalleSubasta.php?idSub=SUB-JA-2020-146153&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,",
BASE_BOE_URL.to_owned() + "./detalleSubasta.php?idSub=SUB-JA-2020-149625&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,",
BASE_BOE_URL.to_owned() + "./detalleSubasta.php?idSub=SUB-AT-2020-20R4186001070&idBus=_SGFOTnU2NVlnSUwvd2czQzBFcHdoUDFlZTZGS1pLT1lwNm5pbmNIdmNGTXpLNUpZcXNGRElabzlLSGdEckkwL1NuQmpKT3lSd3Z2QTJiM0dPTURUNXBYOEhSNzhqRG5CdExSSXFxZkZSM1phdTh2bkIwUjRXaWFwdkJ2ZzNmVmV0NWc5NjJpU2FDdHQ1amc1SHJSUmhGTGFSTkk4dlFkSWYwTXA5ckFaRUh2TWtkcjM4UmFVY3VCa1JOcklEdWFDdFZpcC81Z0I4UVVYRDdqQjhLeW9RZ2R3aHpOMzRXY1cyZWJwZWRKSXY2RkRHRndmL2JIUXFQckVHdVYzUEh6VA,,"];
assert_eq!(links, parse_result_page(INPUT).unwrap());
}
}
|
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::HB16CFG3 {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
self.register.set(f(&R { bits }, &mut W { bits }).bits);
}
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::reset_value(),
})
.bits,
);
}
#[doc = r"Reset value of the register"]
#[inline(always)]
pub const fn reset_value() -> u32 {
0
}
#[doc = r"Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
}
#[doc = "Possible values of the field `EPI_HB16CFG3_MODE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_MODER {
#[doc = "ADMUX - AD\\[15:0\\]"]
EPI_HB16CFG3_MODE_ADMUX,
#[doc = "ADNONMUX - D\\[15:0\\]"]
EPI_HB16CFG3_MODE_AD,
#[doc = r"Reserved"]
_Reserved(u8),
}
impl EPI_HB16CFG3_MODER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_ADMUX => 0,
EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_AD => 1,
EPI_HB16CFG3_MODER::_Reserved(bits) => bits,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> EPI_HB16CFG3_MODER {
match value {
0 => EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_ADMUX,
1 => EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_AD,
i => EPI_HB16CFG3_MODER::_Reserved(i),
}
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_MODE_ADMUX`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_mode_admux(&self) -> bool {
*self == EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_ADMUX
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_MODE_AD`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_mode_ad(&self) -> bool {
*self == EPI_HB16CFG3_MODER::EPI_HB16CFG3_MODE_AD
}
}
#[doc = "Values that can be written to the field `EPI_HB16CFG3_MODE`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_MODEW {
#[doc = "ADMUX - AD\\[15:0\\]"]
EPI_HB16CFG3_MODE_ADMUX,
#[doc = "ADNONMUX - D\\[15:0\\]"]
EPI_HB16CFG3_MODE_AD,
}
impl EPI_HB16CFG3_MODEW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_MODEW::EPI_HB16CFG3_MODE_ADMUX => 0,
EPI_HB16CFG3_MODEW::EPI_HB16CFG3_MODE_AD => 1,
}
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_MODEW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_MODEW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EPI_HB16CFG3_MODEW) -> &'a mut W {
unsafe { self.bits(variant._bits()) }
}
#[doc = "ADMUX - AD\\[15:0\\]"]
#[inline(always)]
pub fn epi_hb16cfg3_mode_admux(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_MODEW::EPI_HB16CFG3_MODE_ADMUX)
}
#[doc = "ADNONMUX - D\\[15:0\\]"]
#[inline(always)]
pub fn epi_hb16cfg3_mode_ad(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_MODEW::EPI_HB16CFG3_MODE_AD)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(3 << 0);
self.w.bits |= ((value as u32) & 3) << 0;
self.w
}
}
#[doc = "Possible values of the field `EPI_HB16CFG3_RDWS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_RDWSR {
#[doc = "Active RDn is 2 EPI clocks"]
EPI_HB16CFG3_RDWS_2,
#[doc = "Active RDn is 4 EPI clocks"]
EPI_HB16CFG3_RDWS_4,
#[doc = "Active RDn is 6 EPI clocks"]
EPI_HB16CFG3_RDWS_6,
#[doc = "Active RDn is 8 EPI clocks"]
EPI_HB16CFG3_RDWS_8,
}
impl EPI_HB16CFG3_RDWSR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_2 => 0,
EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_4 => 1,
EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_6 => 2,
EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_8 => 3,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> EPI_HB16CFG3_RDWSR {
match value {
0 => EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_2,
1 => EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_4,
2 => EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_6,
3 => EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_8,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_RDWS_2`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_rdws_2(&self) -> bool {
*self == EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_2
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_RDWS_4`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_rdws_4(&self) -> bool {
*self == EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_4
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_RDWS_6`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_rdws_6(&self) -> bool {
*self == EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_6
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_RDWS_8`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_rdws_8(&self) -> bool {
*self == EPI_HB16CFG3_RDWSR::EPI_HB16CFG3_RDWS_8
}
}
#[doc = "Values that can be written to the field `EPI_HB16CFG3_RDWS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_RDWSW {
#[doc = "Active RDn is 2 EPI clocks"]
EPI_HB16CFG3_RDWS_2,
#[doc = "Active RDn is 4 EPI clocks"]
EPI_HB16CFG3_RDWS_4,
#[doc = "Active RDn is 6 EPI clocks"]
EPI_HB16CFG3_RDWS_6,
#[doc = "Active RDn is 8 EPI clocks"]
EPI_HB16CFG3_RDWS_8,
}
impl EPI_HB16CFG3_RDWSW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_2 => 0,
EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_4 => 1,
EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_6 => 2,
EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_8 => 3,
}
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_RDWSW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_RDWSW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EPI_HB16CFG3_RDWSW) -> &'a mut W {
{
self.bits(variant._bits())
}
}
#[doc = "Active RDn is 2 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws_2(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_2)
}
#[doc = "Active RDn is 4 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws_4(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_4)
}
#[doc = "Active RDn is 6 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws_6(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_6)
}
#[doc = "Active RDn is 8 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws_8(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_RDWSW::EPI_HB16CFG3_RDWS_8)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(3 << 4);
self.w.bits |= ((value as u32) & 3) << 4;
self.w
}
}
#[doc = "Possible values of the field `EPI_HB16CFG3_WRWS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_WRWSR {
#[doc = "Active WRn is 2 EPI clocks"]
EPI_HB16CFG3_WRWS_2,
#[doc = "Active WRn is 4 EPI clocks"]
EPI_HB16CFG3_WRWS_4,
#[doc = "Active WRn is 6 EPI clocks"]
EPI_HB16CFG3_WRWS_6,
#[doc = "Active WRn is 8 EPI clocks"]
EPI_HB16CFG3_WRWS_8,
}
impl EPI_HB16CFG3_WRWSR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_2 => 0,
EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_4 => 1,
EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_6 => 2,
EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_8 => 3,
}
}
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _from(value: u8) -> EPI_HB16CFG3_WRWSR {
match value {
0 => EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_2,
1 => EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_4,
2 => EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_6,
3 => EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_8,
_ => unreachable!(),
}
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_WRWS_2`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_wrws_2(&self) -> bool {
*self == EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_2
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_WRWS_4`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_wrws_4(&self) -> bool {
*self == EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_4
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_WRWS_6`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_wrws_6(&self) -> bool {
*self == EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_6
}
#[doc = "Checks if the value of the field is `EPI_HB16CFG3_WRWS_8`"]
#[inline(always)]
pub fn is_epi_hb16cfg3_wrws_8(&self) -> bool {
*self == EPI_HB16CFG3_WRWSR::EPI_HB16CFG3_WRWS_8
}
}
#[doc = "Values that can be written to the field `EPI_HB16CFG3_WRWS`"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum EPI_HB16CFG3_WRWSW {
#[doc = "Active WRn is 2 EPI clocks"]
EPI_HB16CFG3_WRWS_2,
#[doc = "Active WRn is 4 EPI clocks"]
EPI_HB16CFG3_WRWS_4,
#[doc = "Active WRn is 6 EPI clocks"]
EPI_HB16CFG3_WRWS_6,
#[doc = "Active WRn is 8 EPI clocks"]
EPI_HB16CFG3_WRWS_8,
}
impl EPI_HB16CFG3_WRWSW {
#[allow(missing_docs)]
#[doc(hidden)]
#[inline(always)]
pub fn _bits(&self) -> u8 {
match *self {
EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_2 => 0,
EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_4 => 1,
EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_6 => 2,
EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_8 => 3,
}
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_WRWSW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_WRWSW<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EPI_HB16CFG3_WRWSW) -> &'a mut W {
{
self.bits(variant._bits())
}
}
#[doc = "Active WRn is 2 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws_2(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_2)
}
#[doc = "Active WRn is 4 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws_4(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_4)
}
#[doc = "Active WRn is 6 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws_6(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_6)
}
#[doc = "Active WRn is 8 EPI clocks"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws_8(self) -> &'a mut W {
self.variant(EPI_HB16CFG3_WRWSW::EPI_HB16CFG3_WRWS_8)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(3 << 6);
self.w.bits |= ((value as u32) & 3) << 6;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_BURSTR {
bits: bool,
}
impl EPI_HB16CFG3_BURSTR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_BURSTW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_BURSTW<'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 &= !(1 << 16);
self.w.bits |= ((value as u32) & 1) << 16;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_RDCRER {
bits: bool,
}
impl EPI_HB16CFG3_RDCRER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_RDCREW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_RDCREW<'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 &= !(1 << 17);
self.w.bits |= ((value as u32) & 1) << 17;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_WRCRER {
bits: bool,
}
impl EPI_HB16CFG3_WRCRER {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_WRCREW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_WRCREW<'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 &= !(1 << 18);
self.w.bits |= ((value as u32) & 1) << 18;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_ALEHIGHR {
bits: bool,
}
impl EPI_HB16CFG3_ALEHIGHR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_ALEHIGHW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_ALEHIGHW<'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 &= !(1 << 19);
self.w.bits |= ((value as u32) & 1) << 19;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_RDHIGHR {
bits: bool,
}
impl EPI_HB16CFG3_RDHIGHR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_RDHIGHW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_RDHIGHW<'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 &= !(1 << 20);
self.w.bits |= ((value as u32) & 1) << 20;
self.w
}
}
#[doc = r"Value of the field"]
pub struct EPI_HB16CFG3_WRHIGHR {
bits: bool,
}
impl EPI_HB16CFG3_WRHIGHR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bit(&self) -> bool {
self.bits
}
#[doc = r"Returns `true` if the bit is clear (0)"]
#[inline(always)]
pub fn bit_is_clear(&self) -> bool {
!self.bit()
}
#[doc = r"Returns `true` if the bit is set (1)"]
#[inline(always)]
pub fn bit_is_set(&self) -> bool {
self.bit()
}
}
#[doc = r"Proxy"]
pub struct _EPI_HB16CFG3_WRHIGHW<'a> {
w: &'a mut W,
}
impl<'a> _EPI_HB16CFG3_WRHIGHW<'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 &= !(1 << 21);
self.w.bits |= ((value as u32) & 1) << 21;
self.w
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:1 - CS2n Host Bus Sub-Mode"]
#[inline(always)]
pub fn epi_hb16cfg3_mode(&self) -> EPI_HB16CFG3_MODER {
EPI_HB16CFG3_MODER::_from(((self.bits >> 0) & 3) as u8)
}
#[doc = "Bits 4:5 - CS2n Read Wait States"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws(&self) -> EPI_HB16CFG3_RDWSR {
EPI_HB16CFG3_RDWSR::_from(((self.bits >> 4) & 3) as u8)
}
#[doc = "Bits 6:7 - CS2n Write Wait States"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws(&self) -> EPI_HB16CFG3_WRWSR {
EPI_HB16CFG3_WRWSR::_from(((self.bits >> 6) & 3) as u8)
}
#[doc = "Bit 16 - CS2n Burst Mode"]
#[inline(always)]
pub fn epi_hb16cfg3_burst(&self) -> EPI_HB16CFG3_BURSTR {
let bits = ((self.bits >> 16) & 1) != 0;
EPI_HB16CFG3_BURSTR { bits }
}
#[doc = "Bit 17 - CS2n PSRAM Configuration Register Read"]
#[inline(always)]
pub fn epi_hb16cfg3_rdcre(&self) -> EPI_HB16CFG3_RDCRER {
let bits = ((self.bits >> 17) & 1) != 0;
EPI_HB16CFG3_RDCRER { bits }
}
#[doc = "Bit 18 - CS2n PSRAM Configuration Register Write"]
#[inline(always)]
pub fn epi_hb16cfg3_wrcre(&self) -> EPI_HB16CFG3_WRCRER {
let bits = ((self.bits >> 18) & 1) != 0;
EPI_HB16CFG3_WRCRER { bits }
}
#[doc = "Bit 19 - CS2n ALE Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_alehigh(&self) -> EPI_HB16CFG3_ALEHIGHR {
let bits = ((self.bits >> 19) & 1) != 0;
EPI_HB16CFG3_ALEHIGHR { bits }
}
#[doc = "Bit 20 - CS2n READ Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_rdhigh(&self) -> EPI_HB16CFG3_RDHIGHR {
let bits = ((self.bits >> 20) & 1) != 0;
EPI_HB16CFG3_RDHIGHR { bits }
}
#[doc = "Bit 21 - CS2n WRITE Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_wrhigh(&self) -> EPI_HB16CFG3_WRHIGHR {
let bits = ((self.bits >> 21) & 1) != 0;
EPI_HB16CFG3_WRHIGHR { bits }
}
}
impl W {
#[doc = r"Writes raw bits to the register"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bits 0:1 - CS2n Host Bus Sub-Mode"]
#[inline(always)]
pub fn epi_hb16cfg3_mode(&mut self) -> _EPI_HB16CFG3_MODEW {
_EPI_HB16CFG3_MODEW { w: self }
}
#[doc = "Bits 4:5 - CS2n Read Wait States"]
#[inline(always)]
pub fn epi_hb16cfg3_rdws(&mut self) -> _EPI_HB16CFG3_RDWSW {
_EPI_HB16CFG3_RDWSW { w: self }
}
#[doc = "Bits 6:7 - CS2n Write Wait States"]
#[inline(always)]
pub fn epi_hb16cfg3_wrws(&mut self) -> _EPI_HB16CFG3_WRWSW {
_EPI_HB16CFG3_WRWSW { w: self }
}
#[doc = "Bit 16 - CS2n Burst Mode"]
#[inline(always)]
pub fn epi_hb16cfg3_burst(&mut self) -> _EPI_HB16CFG3_BURSTW {
_EPI_HB16CFG3_BURSTW { w: self }
}
#[doc = "Bit 17 - CS2n PSRAM Configuration Register Read"]
#[inline(always)]
pub fn epi_hb16cfg3_rdcre(&mut self) -> _EPI_HB16CFG3_RDCREW {
_EPI_HB16CFG3_RDCREW { w: self }
}
#[doc = "Bit 18 - CS2n PSRAM Configuration Register Write"]
#[inline(always)]
pub fn epi_hb16cfg3_wrcre(&mut self) -> _EPI_HB16CFG3_WRCREW {
_EPI_HB16CFG3_WRCREW { w: self }
}
#[doc = "Bit 19 - CS2n ALE Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_alehigh(&mut self) -> _EPI_HB16CFG3_ALEHIGHW {
_EPI_HB16CFG3_ALEHIGHW { w: self }
}
#[doc = "Bit 20 - CS2n READ Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_rdhigh(&mut self) -> _EPI_HB16CFG3_RDHIGHW {
_EPI_HB16CFG3_RDHIGHW { w: self }
}
#[doc = "Bit 21 - CS2n WRITE Strobe Polarity"]
#[inline(always)]
pub fn epi_hb16cfg3_wrhigh(&mut self) -> _EPI_HB16CFG3_WRHIGHW {
_EPI_HB16CFG3_WRHIGHW { w: self }
}
}
|
use std::convert::Infallible;
use std::net::SocketAddr;
use std::sync::Arc;
use std::time::Instant;
use log::{info, warn};
use snork::agents::*;
use snork::env::{GameRequest, IndexResponse, API_VERSION};
use clap::Parser;
use warp::Filter;
pub const PACKAGE_VERSION: &str = env!("CARGO_PKG_VERSION");
pub const AUTHOR: &str = "l4r0x";
/// Runtime server configuration.
struct State {
latency: u64,
color: String,
head: String,
tail: String,
config: Agent,
}
#[derive(Debug, Parser)]
#[clap(version, author, about = "High performant rust snake.")]
struct Opt {
/// IP and Port of the webserver.
///
/// **Note**: Use the IP Address of your device if you want to access it from
/// another device. (`127.0.0.1` or `localhost` is private to your computer)
#[clap(long, default_value = "127.0.0.1:5001", value_parser)]
host: SocketAddr,
/// Time in ms that is subtracted from the game timeouts.
#[clap(long, default_value_t = 100, value_parser)]
latency: u64,
/// Color in hex format.
#[clap(long, default_value = "#FF7043", value_parser)]
color: String,
/// Head @see https://docs.battlesnake.com/references/personalization
#[clap(long, default_value = "sand-worm", value_parser)]
head: String,
/// Tail @see https://docs.battlesnake.com/references/personalization
#[clap(long, default_value = "pixel", value_parser)]
tail: String,
/// Default configuration.
#[clap(long, default_value_t, value_parser)]
config: Agent,
}
#[tokio::main]
async fn main() {
env_logger::init();
let Opt {
host,
latency,
color,
head,
tail,
config,
} = Opt::parse();
let state = Arc::new(State {
latency,
color,
head,
tail,
config,
});
let index = warp::get()
.and(warp::path::end())
.and(with_state(state.clone()))
.map(|state: Arc<State>| {
warn!("index");
warp::reply::json(&IndexResponse::new(
API_VERSION.into(),
AUTHOR.into(),
state.color.clone().into(),
state.head.clone().into(),
state.tail.clone().into(),
PACKAGE_VERSION.into(),
))
});
let start = warp::path("start")
.and(warp::post())
.and(warp::body::json::<GameRequest>())
.map(|request: GameRequest| {
warn!("start {request}");
warp::reply()
});
let r#move = warp::path("move")
.and(warp::post())
.and(warp::body::json::<GameRequest>())
.and(with_state(state.clone()))
.and_then(step);
let end = warp::path("end")
.and(warp::post())
.and(warp::body::json::<GameRequest>())
.map(|request: GameRequest| {
warn!("end {request}");
warp::reply()
});
warp::serve(index.or(start).or(r#move).or(end))
.run(host)
.await;
}
fn with_state(
config: Arc<State>,
) -> impl Filter<Extract = (Arc<State>,), Error = std::convert::Infallible> + Clone {
warp::any().map(move || config.clone())
}
async fn step(request: GameRequest, state: Arc<State>) -> Result<impl warp::Reply, Infallible> {
warn!("move {request}");
let timer = Instant::now();
let next_move = state.config.step(&request, state.latency).await;
info!("response time {:?}ms", timer.elapsed().as_millis());
Ok(warp::reply::json(&next_move))
}
|
#[derive(Debug)]
enum Mode {
Position,
Immediate,
Relative,
}
#[derive(Debug)]
enum Type {
Parameter,
Address,
}
#[derive(Debug)]
enum Instruction {
Add(i64, i64, usize),
Multiply(i64, i64, usize),
Input(usize),
Output(i64),
JumpIfTrue(i64, i64),
JumpIfFalse(i64, i64),
LessThan(i64, i64, usize),
Equals(i64, i64, usize),
RelativeBaseOffset(i64),
Halt,
}
pub enum Output {
OutputVal(i64),
WaitingForInput,
Exit
}
pub struct IntcodeComputer {
memory: Vec<i64>,
pointer: usize,
relative_base: i64,
input_stack: Vec<i64>,
wait_for_input_addr: Option<usize>,
has_exited: bool
}
impl IntcodeComputer {
pub fn new(program: &Vec<i64>) -> IntcodeComputer {
IntcodeComputer {
memory: program.clone(),
pointer: 0,
relative_base: 0,
input_stack: vec!(),
wait_for_input_addr: None,
has_exited: false
}
}
pub fn finished(&self) -> bool {
self.has_exited
}
pub fn provide_input(&mut self, input: i64) {
self.write(self.wait_for_input_addr.expect("Tried to write input when it was not expected!"), input);
}
fn check_for_resize(&mut self, addr: usize) {
if addr >= self.memory.len() {
self.memory.resize(addr + 1, 0);
}
}
fn read(&mut self, addr: usize) -> i64 {
self.check_for_resize(addr);
self.memory[addr]
}
fn write(&mut self, addr: usize, val: i64) {
self.check_for_resize(addr);
self.memory[addr] = val;
}
fn read_next_parameter(&mut self, param_type: Type, param_mode: Mode) -> i64 {
let address = match param_mode {
Mode::Position => self.read(self.pointer) as usize,
Mode::Immediate => self.pointer,
Mode::Relative => (self.relative_base + self.read(self.pointer)) as usize,
};
let read_param = match param_type {
Type::Parameter => self.read(address),
Type::Address => address as i64,
};
self.pointer += 1;
return read_param;
}
fn split_instruction(&mut self) -> Vec<u8> {
let instr = self.memory[self.pointer];
self.pointer += 1;
if instr == 0 {
panic!("Invalid instruction value");
}
let mut val = instr;
std::iter::from_fn(move || {
if val == 0 {
None
} else {
let next_val = val % 10;
val /= 10;
Some(next_val as u8)
}
})
.collect()
}
fn next_instruction(&mut self) -> Instruction {
let instruction = self.split_instruction();
//check for halt
if instruction.len() > 1 && instruction[0] == 9 && instruction[1] == 9 {
return Instruction::Halt;
}
let opcode = instruction[0];
let mut param_stack: Vec<Mode> = if instruction.len() > 2 {
instruction[2..]
.iter()
.rev()
.map(|p| match p {
0 => Mode::Position,
1 => Mode::Immediate,
2 => Mode::Relative,
_ => panic!("Unknown parameter mode."),
})
.collect()
} else {
vec![]
};
match opcode {
1 | 2 | 7 | 8 => {
let p1 = self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
);
let p2 = self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
);
let addr = self
.read_next_parameter(Type::Address, param_stack.pop().unwrap_or(Mode::Position))
as usize;
if opcode == 1 {
Instruction::Add(p1, p2, addr)
} else if opcode == 2 {
Instruction::Multiply(p1, p2, addr)
} else if opcode == 7 {
Instruction::LessThan(p1, p2, addr)
} else {
Instruction::Equals(p1, p2, addr)
}
}
3 => Instruction::Input(
self.read_next_parameter(Type::Address, param_stack.pop().unwrap_or(Mode::Position))
as usize,
),
4 => {
Instruction::Output(self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
))
}
5 | 6 => {
let p1 = self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
);
let p2 = self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
);
if opcode == 5 {
Instruction::JumpIfTrue(p1, p2)
} else {
Instruction::JumpIfFalse(p1, p2)
}
}
9 => {
Instruction::RelativeBaseOffset(self.read_next_parameter(
Type::Parameter,
param_stack.pop().unwrap_or(Mode::Position),
))
}
_ => panic!("Unknown instruction opcode"),
}
}
fn internal_run(&mut self) -> Output {
loop {
match self.next_instruction() {
Instruction::Add(p1, p2, addr) => self.write(addr, p1 + p2),
Instruction::Multiply(p1, p2, addr) => self.write(addr, p1 * p2),
Instruction::Input(addr) => {
if let Some(next_input) = self.input_stack.pop() {
self.write(addr, next_input);
} else {
self.wait_for_input_addr = Some(addr);
return Output::WaitingForInput;
}
},
Instruction::Output(p) => return Output::OutputVal(p),
Instruction::JumpIfTrue(p1, p2) => {
self.pointer = if p1 != 0 { p2 as usize } else { self.pointer }
},
Instruction::JumpIfFalse(p1, p2) => {
self.pointer = if p1 == 0 { p2 as usize } else { self.pointer }
},
Instruction::LessThan(p1, p2, addr) => {
self.write(addr, if p1 < p2 { 1 } else { 0 })
},
Instruction::Equals(p1, p2, addr) => self.write(addr, if p1 == p2 { 1 } else { 0 }),
Instruction::RelativeBaseOffset(p1) => self.relative_base += p1,
Instruction::Halt => {
break;
}
};
}
self.has_exited = true;
Output::Exit
}
pub fn run(&mut self, input: Vec<i64>) -> Vec<i64> {
let mut all_outputs = vec![];
self.input_stack = input.into_iter().rev().collect::<Vec<i64>>();
loop {
match self.internal_run() {
Output::OutputVal(x) => all_outputs.push(x),
Output::WaitingForInput => panic!("Unexpected request for input"),
Output::Exit => break
}
}
all_outputs
}
pub fn tick(&mut self) -> Output {
self.internal_run()
}
}
pub fn parse_program(program: &'static str) -> Vec<i64> {
program
.split(',')
.map(|n| n.parse::<i64>().unwrap())
.collect::<Vec<i64>>()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn input_output() {
assert_eq!(
*IntcodeComputer::new(&parse_program("3,0,4,0,99"))
.run(vec!(1))
.last()
.unwrap(),
1
);
}
#[test]
fn equal_to() {
assert_eq!(
*IntcodeComputer::new(&parse_program("3,9,8,9,10,9,4,9,99,-1,8"))
.run(vec!(8))
.last()
.unwrap(),
1
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,9,8,9,10,9,4,9,99,-1,8"))
.run(vec!(10))
.last()
.unwrap(),
0
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1108,-1,8,3,4,3,99"))
.run(vec!(8))
.last()
.unwrap(),
1
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1108,-1,8,3,4,3,99"))
.run(vec!(10))
.last()
.unwrap(),
0
);
}
#[test]
fn less_than() {
assert_eq!(
*IntcodeComputer::new(&parse_program("3,9,7,9,10,9,4,9,99,-1,8"))
.run(vec!(7))
.last()
.unwrap(),
1
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,9,8,9,10,9,4,9,99,-1,8"))
.run(vec!(9))
.last()
.unwrap(),
0
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1107,-1,8,3,4,3,99"))
.run(vec!(7))
.last()
.unwrap(),
1
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1107,-1,8,3,4,3,99"))
.run(vec!(9))
.last()
.unwrap(),
0
);
}
#[test]
fn compare_to_zero() {
assert_eq!(
*IntcodeComputer::new(&parse_program("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"))
.run(vec!(0))
.last()
.unwrap(),
0
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,12,6,12,15,1,13,14,13,4,13,99,-1,0,1,9"))
.run(vec!(-1))
.last()
.unwrap(),
1
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"))
.run(vec!(0))
.last()
.unwrap(),
0
);
assert_eq!(
*IntcodeComputer::new(&parse_program("3,3,1105,-1,9,1101,0,0,12,4,12,99,1"))
.run(vec!(-1))
.last()
.unwrap(),
1
);
}
#[test]
fn compare_to_val() {
let program = parse_program("3,21,1008,21,8,20,1005,20,22,107,8,21,20,1006,20,31,1106,0,36,98,0,0,1002,21,125,20,4,20,1105,1,46,104,999,1105,1,46,1101,1000,1,20,4,20,1105,1,46,98,99");
assert_eq!(*IntcodeComputer::new(&program).run(vec!(0)).last().unwrap(), 999);
assert_eq!(*IntcodeComputer::new(&program).run(vec!(8)).last().unwrap(), 1000);
assert_eq!(*IntcodeComputer::new(&program).run(vec!(20)).last().unwrap(), 1001);
}
#[test]
fn quine_test() {
let prog = parse_program("109,1,204,-1,1001,100,1,100,1008,100,16,101,1006,101,0,99");
assert_eq!(IntcodeComputer::new(&prog).run(vec!()), prog);
}
#[test]
fn sixteen_digit_output() {
assert_eq!(
IntcodeComputer::new(&parse_program("1102,34915192,34915192,7,4,7,99,0"))
.run(vec![])
.last()
.unwrap()
.to_string()
.len(),
16
);
}
#[test]
fn large_number() {
let prog = parse_program("104,1125899906842624,99");
assert_eq!(
*IntcodeComputer::new(&prog).run(vec![]).last().unwrap(),
1125899906842624
);
}
}
|
#![feature(test)]
#![feature(iterator_fold_self)]
#![feature(min_const_generics)]
#![feature(is_sorted)]
extern crate hashbrown;
extern crate test;
extern crate utils;
#[allow(dead_code)]
mod day_25;
// mod day_9;
// mod day_8;
// mod day_7;
// mod day_6;
// mod day_5;
// mod day_4;
// mod day_3;
// mod day_2;
// mod day_1;
fn main() {
day_25::run();
}
|
// Copyright (c) 2017 Anatoly Ikorsky
//
// 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. All files in the project carrying such notice may not be copied,
// modified, or distributed except according to those terms.
#![cfg_attr(feature = "nightly", feature(test, const_fn))]
#[cfg(feature = "nightly")]
extern crate test;
#[macro_use]
extern crate bitflags;
pub use chrono;
#[macro_use]
extern crate lazy_static;
#[cfg(feature = "rustc_serialize")]
pub extern crate rustc_serialize;
pub use serde;
pub use serde_json;
pub use time;
pub use uuid;
/// This macro is a convenient way to pass named parameters to a statement.
///
/// ```ignore
/// let foo = 42;
/// conn.prep_exec("SELECT :foo, :foo2x", params! {
/// foo,
/// "foo2x" => foo * 2,
/// });
/// ```
#[macro_export]
macro_rules! params {
() => {};
(@to_pair $name:expr => $value:expr) => (
(std::string::String::from($name), $crate::value::Value::from($value))
);
(@to_pair $name:ident) => (
(std::string::String::from(stringify!($name)), $crate::value::Value::from($name))
);
(@expand $vec:expr;) => {};
(@expand $vec:expr; $name:expr => $value:expr, $($tail:tt)*) => {
$vec.push(params!(@to_pair $name => $value));
params!(@expand $vec; $($tail)*);
};
(@expand $vec:expr; $name:expr => $value:expr $(, $tail:tt)*) => {
$vec.push(params!(@to_pair $name => $value));
params!(@expand $vec; $($tail)*);
};
(@expand $vec:expr; $name:ident, $($tail:tt)*) => {
$vec.push(params!(@to_pair $name));
params!(@expand $vec; $($tail)*);
};
(@expand $vec:expr; $name:ident $(, $tail:tt)*) => {
$vec.push(params!(@to_pair $name));
params!(@expand $vec; $($tail)*);
};
($i:ident, $($tail:tt)*) => {
{
let mut output = std::vec::Vec::new();
params!(@expand output; $i, $($tail)*);
output
}
};
($i:expr => $($tail:tt)*) => {
{
let mut output = std::vec::Vec::new();
params!(@expand output; $i => $($tail)*);
output
}
};
($i:ident) => {
{
let mut output = std::vec::Vec::new();
params!(@expand output; $i);
output
}
}
}
/// Non panicking Slice::split_at
macro_rules! split_at_or_err {
($reader:expr, $at:expr, $msg:expr) => {
if $reader.len() >= $at {
Ok($reader.split_at($at))
} else {
Err(io::Error::new(io::ErrorKind::UnexpectedEof, $msg))
}
};
}
/// Reads MySql's length-encoded string
#[macro_export]
macro_rules! read_lenenc_str {
($reader:expr) => {
$reader.read_lenenc_int().and_then(|len| {
let (value, rest) = split_at_or_err!(
$reader,
len as usize,
"EOF while reading length-encoded string"
)?;
*$reader = rest;
Ok(value)
})
};
}
pub mod constants;
pub mod crypto;
pub mod io;
pub mod named_params;
#[macro_use]
pub mod packets;
pub mod params;
pub mod row;
pub mod scramble;
pub mod value;
#[cfg(test)]
#[test]
fn params_macro_test() {
use crate::value::Value;
let foo = 42;
let bar = "bar";
assert_eq!(vec![(String::from("foo"), Value::Int(42))], params! { foo });
assert_eq!(
vec![(String::from("foo"), Value::Int(42))],
params! { foo, }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { foo, bar }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { foo, bar, }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { "foo" => foo, "bar" => bar }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { "foo" => foo, "bar" => bar, }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { foo, "bar" => bar }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { "foo" => foo, bar }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { foo, "bar" => bar, }
);
assert_eq!(
vec![
(String::from("foo"), Value::Int(42)),
(String::from("bar"), Value::Bytes((&b"bar"[..]).into())),
],
params! { "foo" => foo, bar, }
);
}
|
use crate::dir_entry::*;
use crate::rule::Rule;
use crate::rule::RulePath;
use crate::rule::RuleTrait;
pub struct Matcher {}
impl Matcher {
/// Check if the entry's path matches the given rule
pub fn match_entry_path<C, P: RuleTrait<C>, D: DirEntryTrait>(rule: &P, entry: &D) -> bool {
let path_as_string = entry.path().to_string_lossy();
Matcher::match_path_str(rule, path_as_string.as_ref())
}
/// Check if the given path matches the given rule
///
/// # Panics
///
/// Panics if `rule` doesn't contain a path
pub fn match_path_str<C, P: RuleTrait<C>>(rule: &P, path_as_string: &str) -> bool {
match &rule.path() {
RulePath::String(s) => {
trace!(
"Match rule '{}' with path '{}' against path '{}'",
rule.name(),
s,
path_as_string
);
path_as_string.contains(s.as_str())
}
RulePath::Regex(r) => {
trace!(
"Match rule '{}' with path '{}' against path '{}'",
rule.name(),
r,
path_as_string
);
r.is_match(path_as_string)
}
}
}
/// Check if the entry's content matches the given rule
pub fn match_entry_content(rule: &Rule, content: &str) -> bool {
match rule.content() {
Some(content_pattern) => {
trace!(
"Match rule '{}' with pattern '{}'",
rule.name(),
content_pattern
);
content_pattern.is_match(content)
}
None => false,
}
}
}
|
mod day01;
mod day02;
mod day03;
mod day04;
mod day05;
fn main() {
println!("---- Listing solutions ---- ");
//day01::solve();
//day02::solve();
//day03::solve();
day04::solve();
//day05::solve();
}
|
use std::cmp::{max, min};
use std::collections::{HashMap, HashSet};
use itertools::Itertools;
use whiteread::parse_line;
fn main() {
let n: usize = parse_line().unwrap();
let mut hshs: Vec<(u64, u64)> = vec![];
for _ in 0..n {
let hs = parse_line().unwrap();
hshs.push(hs);
}
let mut maxhs = 0;
for (h, s) in hshs.iter() {
maxhs = max(h + (n as u64 - 1) * s, maxhs);
}
let mut left = 0;
let mut right = maxhs;
while left < right {
let pivot = (right + left) / 2;
if check(pivot, &hshs) {
right = pivot;
} else {
left = pivot + 1;
}
}
println!("{}", left);
}
fn check(target: u64, hshs: &[(u64, u64)]) -> bool {
let mut aa = vec![];
for &(h, s) in hshs.iter() {
if h > target {
return false;
} else {
aa.push((target - h) / s);
}
}
aa.sort();
for (a, ni) in aa.iter().zip(0..hshs.len()) {
if *a < ni as u64 {
return false;
}
}
true
}
|
use solana_program::{
msg,
program_error::ProgramError,
program_pack::{IsInitialized, Pack, Sealed},
pubkey::Pubkey,
};
use solana_gravity_contract::gravity::state::PartialStorage;
use spl_token::state::Mint;
use gravity_misc::model::{AbstractRecordHandler, RecordHandler};
use gravity_misc::validation::TokenMintConstrained;
use gravity_misc::ports::state::{
GenericRequest,
GenericPortOperation,
RequestsQueue,
RequestCountConstrained,
RequestStatus,
ForeignAddress,
PortOperationIdentifier
};
use arrayref::array_ref;
use borsh::{BorshDeserialize, BorshSerialize};
use gravity_misc::ports::error::PortError;
// pub type WrapRequest = GenericRequest<Pubkey, ForeignAddress>;
/**
* bytes32 topic0 = bytesToBytes32(impactData, 40); // [ 40: 72]
bytes memory token = impactData[84:104]; // [ 72:104][12:32]
bytes memory sender = impactData[116:136]; // [104:136][12:32]
bytes memory receiver = impactData[148:168]; // [136:168][12:32]
uint256 amount = deserializeUint(impactData, 168, 32); // [168:200]
*/
pub struct WrapRequest {
pub token_mint: [u8; 32],
pub origin_address: Pubkey,
pub destination_address: ForeignAddress,
pub destination_chain: [u8;3],
pub amount: u64,
}
macro_rules! pack {
($struct_name: ident, len: $len: expr) => {
impl Pack for $struct_name {
const LEN: usize = $len;
fn unpack_from_slice(src: &[u8]) -> Result<Self, ProgramError> {
let mut mut_src: &[u8] = src;
Self::deserialize(&mut mut_src).map_err(|err| {
msg!(
"Error: failed to deserialize RelayContract instruction: {}",
err
);
ProgramError::InvalidInstructionData
})
}
fn pack_into_slice(&self, dst: &mut [u8]) {
let data = self.try_to_vec().unwrap();
dst[..data.len()].copy_from_slice(&data);
}
}
};
}
pack!(WrapRequest,len: 1000);
#[repr(C)]
#[derive(BorshSerialize, BorshDeserialize, PartialEq, Default, Debug, Clone)]
pub struct RelayContract {
pub nebula_address: Pubkey, // distinct nebula address (not nebula data account)
pub token_address: Pubkey,
pub token_mint: Pubkey, // common token info, (result of spl-token create-token or as it so called - 'the mint')
pub initializer_pubkey: Pubkey,
pub oracles: Vec<Pubkey>,
pub swap_status: RecordHandler<[u8; 16], RequestStatus>,
pub requests: RecordHandler<[u8; 16], WrapRequest>,
pub is_state_initialized: bool,
pub requests_queue: RequestsQueue<[u8; 16]>,
}
pack!(RelayContract, len: 2000);
impl RequestCountConstrained for RelayContract {
const MAX_IDLE_REQUESTS_COUNT: usize = 100;
fn count_constrained_entities(&self) -> Vec<usize> {
vec![
self.unprocessed_burn_requests()
]
}
}
impl TokenMintConstrained<PortError> for RelayContract {
fn bound_token_mint(&self) -> (Pubkey, PortError) {
return (
self.token_mint,
PortError::InvalidTokenMint
)
}
}
impl PartialStorage for RelayContract {
const DATA_RANGE: std::ops::Range<usize> = 0..2000;
}
impl Sealed for RelayContract {}
impl IsInitialized for RelayContract {
fn is_initialized(&self) -> bool {
self.is_state_initialized
}
}
fn pack_into_slice(&self, dst: &mut [u8]) {
let data = self.try_to_vec().unwrap();
dst[..data.len()].copy_from_slice(&data);
}
}
pub type PortOperation<'a> = GenericPortOperation<'a, ForeignAddress>;
impl RelayContract {
fn unprocessed_burn_requests(&self) -> usize {
self.requests.len()
}
fn validate_requests_count(&self) -> Result<(), PortError> {
if !self.count_is_below_limit() {
return Err(PortError::TransferRequestsCountLimit);
}
Ok(())
}
pub fn unpack_byte_array(byte_data: &Vec<u8>) -> Result<PortOperation, ProgramError> {
if byte_data.len() < 57 {
return Err(PortError::ByteArrayUnpackFailed.into());
}
let mut pos = 0;
let action = byte_data[pos];
pos += 1;
let swap_id = array_ref![byte_data, pos, 16];
pos += 16;
let raw_amount = array_ref![byte_data, pos, 8];
pos += 8;
let receiver = array_ref![byte_data, pos, 32];
return Ok(PortOperation {
action,
swap_id,
amount: raw_amount,
receiver
});
}
pub fn attach_data<'a>(&mut self, byte_data: &'a Vec<u8>, input_pubkey: &'a Pubkey, input_amount: &'a mut u64, token_mint_info: &Mint) -> Result<String, ProgramError> {
let action = &[byte_data[0]];
let command_char = std::str::from_utf8(action).unwrap();
let amount = byte_data[200..232];
let receiver = byte_data[328..360];
}
pub fn create_transfer_wrap_request(&mut self, record_id: &[u8; 16], amount: u64, sender_data_account: &Pubkey, receiver: &ForeignAddress) -> Result<(), PortError> {
self.validate_requests_count()?;
if self.requests.contains_key(record_id) {
return Err(PortError::RequestIDIsAlreadyBeingProcessed.into());
}
self.requests.insert(*record_id, WrapRequest {
destination_address: *receiver,
origin_address: *sender_data_account,
amount
});
self.swap_status.insert(*record_id, RequestStatus::New);
self.requests_queue.push(*record_id);
Ok(())
}
}
|
extern crate cmake;
use std::env;
use std::path::PathBuf;
const ENV_LLVM_CORE_INCLUDE: &'static str = "DEP_FIREFLY_LLVM_CORE_INCLUDE";
const ENV_LLVM_PREFIX: &'static str = "DEP_FIREFLY_LLVM_CORE_PREFIX";
const ENV_LLVM_LINK_STATIC: &'static str = "DEP_FIREFLY_LLVM_CORE_LINK_STATIC";
const ENV_LLVM_LINK_LLVM_DYLIB: &'static str = "DEP_FIREFLY_LLVM_CORE_LINK_LLVM_DYLIB";
const ENV_LLVM_LTO: &'static str = "DEP_FIREFLY_LLVM_CORE_LTO";
const ENV_LLVM_USE_SANITIZER: &'static str = "LLVM_USE_SANITIZER";
fn main() {
let firefly_llvm_include_dir = env::var(ENV_LLVM_CORE_INCLUDE).unwrap();
let llvm_prefix = PathBuf::from(env::var(ENV_LLVM_PREFIX).unwrap());
let mlir_dir = llvm_prefix.join("lib/cmake/mlir");
let llvm_dir = llvm_prefix.join("lib/cmake/llvm");
let link_lto = env::var(ENV_LLVM_LTO).unwrap();
println!("cargo:rerun-if-changed=c_src");
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_CORE_INCLUDE);
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_PREFIX);
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_LINK_STATIC);
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_LINK_LLVM_DYLIB);
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_LTO);
println!("cargo:rerun-if-env-changed={}", ENV_LLVM_USE_SANITIZER);
// Build and link our MLIR dialects + extensions
let mut config = cmake::Config::new("c_src");
if let Ok(_) = which::which("ninja") {
config.generator("Ninja");
} else {
warn(
"Unable to locate Ninja, your CMake builds may take unncessarily long.\n\
It is highly recommended that you install Ninja.",
);
}
config
.env("LLVM_PREFIX", &llvm_prefix)
.define("LLVM_DIR", llvm_dir)
.define("MLIR_DIR", mlir_dir)
.cxxflag(&format!("-I{}", firefly_llvm_include_dir))
.configure_arg("-Wno-dev");
if link_lto == "true" {
config.cxxflag("-flto=thin");
}
if env::var_os("LLVM_NDEBUG").is_some() {
config.define("NDEBUG", "1");
}
if let Ok(sanitizer) = env::var(ENV_LLVM_USE_SANITIZER) {
config.define("LLVM_USE_SANITIZER", sanitizer);
}
let output_path = config.build();
let search_path = output_path.join("lib");
// NOTE: Not all of these are necessarily being used at the moment, so eventually
// we should clean up, but these cover the libs we're likely to want at some point
link_libs(&[
"MLIRAMX",
"MLIRAMXToLLVMIRTranslation",
"MLIRAMXTransforms",
"MLIRAffine",
"MLIRAffineAnalysis",
"MLIRAffineToStandard",
"MLIRAffineTransforms",
"MLIRAffineUtils",
"MLIRAnalysis",
"MLIRArithmetic",
"MLIRArithmeticToLLVM",
"MLIRArithmeticToSPIRV",
"MLIRArithmeticTransforms",
"MLIRArithmeticUtils",
"MLIRArmNeon",
"MLIRArmNeon2dToIntr",
"MLIRArmNeonToLLVMIRTranslation",
"MLIRArmSVE",
"MLIRArmSVEToLLVMIRTranslation",
"MLIRArmSVETransforms",
"MLIRAsync",
"MLIRAsyncToLLVM",
"MLIRAsyncTransforms",
"MLIRBufferization",
"MLIRBufferizationToMemRef",
"MLIRBufferizationTransforms",
"MLIRCAPIAsync",
"MLIRCAPIControlFlow",
"MLIRCAPIConversion",
"MLIRCAPIDebug",
//"MLIRCAPIExecutionEngine",
"MLIRCAPIFunc",
"MLIRCAPIGPU",
"MLIRCAPIIR",
"MLIRCAPIInterfaces",
"MLIRCAPILLVM",
"MLIRCAPILinalg",
"MLIRCAPIPDL",
"MLIRCAPIQuant",
"MLIRCAPIRegistration",
"MLIRCAPISCF",
"MLIRCAPIShape",
"MLIRCAPISparseTensor",
"MLIRCAPITensor",
"MLIRCAPITransforms",
"MLIRCallInterfaces",
"MLIRCastInterfaces",
"MLIRComplex",
"MLIRComplexToLLVM",
"MLIRComplexToStandard",
"MLIRControlFlow",
"MLIRControlFlowInterfaces",
"MLIRControlFlowToLLVM",
"MLIRControlFlowToSPIRV",
"MLIRCopyOpInterface",
"MLIRDLTI",
"MLIRDataLayoutInterfaces",
"MLIRDerivedAttributeOpInterface",
"MLIRDialect",
"MLIRDialectUtils",
//"MLIREmitC",
//"MLIRExecutionEngine",
"MLIRFunc",
"MLIRFuncToLLVM",
"MLIRFuncToSPIRV",
"MLIRFuncTransforms",
"MLIRGPUOps",
"MLIRGPUToGPURuntimeTransforms",
"MLIRGPUToNVVMTransforms",
"MLIRGPUToROCDLTransforms",
"MLIRGPUToSPIRV",
"MLIRGPUToVulkanTransforms",
"MLIRGPUTransforms",
"MLIRIR",
"MLIRInferTypeOpInterface",
//"MLIRJitRunner",
"MLIRLLVMCommonConversion",
"MLIRLLVMIR",
"MLIRLLVMIRTransforms",
"MLIRLLVMToLLVMIRTranslation",
"MLIRLinalg",
"MLIRLinalgAnalysis",
"MLIRLinalgToLLVM",
"MLIRLinalgToSPIRV",
"MLIRLinalgToStandard",
"MLIRLinalgTransforms",
"MLIRLinalgUtils",
"MLIRLoopLikeInterface",
//"MLIRLspServerLib",
//"MLIRLspServerSupportLib",
"MLIRMath",
"MLIRMathToLLVM",
"MLIRMathToLibm",
"MLIRMathToSPIRV",
"MLIRMathTransforms",
"MLIRMemRef",
"MLIRMemRefToLLVM",
"MLIRMemRefToSPIRV",
"MLIRMemRefTransforms",
"MLIRMemRefUtils",
//"MLIRMlirOptMain",
"MLIRModuleBufferization",
"MLIRNVVMIR",
"MLIRNVVMToLLVMIRTranslation",
"MLIROpenACC",
"MLIROpenACCToLLVM",
"MLIROpenACCToLLVMIRTranslation",
"MLIROpenACCToSCF",
"MLIROpenMP",
"MLIROpenMPToLLVM",
"MLIROpenMPToLLVMIRTranslation",
//"MLIROptLib",
"MLIRPDL",
"MLIRPDLInterp",
"MLIRPDLLAST",
"MLIRPDLLCodeGen",
"MLIRPDLLODS",
"MLIRPDLToPDLInterp",
"MLIRParser",
"MLIRPass",
"MLIRPresburger",
"MLIRQuant",
"MLIRQuantTransforms",
"MLIRQuantUtils",
"MLIRROCDLIR",
"MLIRROCDLToLLVMIRTranslation",
"MLIRReconcileUnrealizedCasts",
//"MLIRReduce",
//"MLIRReduceLib",
"MLIRRewrite",
"MLIRSCF",
"MLIRSCFToControlFlow",
"MLIRSCFToGPU",
"MLIRSCFToOpenMP",
"MLIRSCFToSPIRV",
"MLIRSCFTransforms",
"MLIRSCFUtils",
"MLIRSPIRV",
"MLIRSPIRVBinaryUtils",
"MLIRSPIRVConversion",
"MLIRSPIRVDeserialization",
"MLIRSPIRVModuleCombiner",
"MLIRSPIRVSerialization",
"MLIRSPIRVToLLVM",
"MLIRSPIRVTransforms",
"MLIRSPIRVTranslateRegistration",
"MLIRSPIRVUtils",
"MLIRShape",
"MLIRShapeOpsTransforms",
"MLIRShapeToStandard",
"MLIRSideEffectInterfaces",
"MLIRSparseTensor",
"MLIRSparseTensorPipelines",
"MLIRSparseTensorTransforms",
"MLIRSparseTensorUtils",
"MLIRSupport",
"MLIRSupportIndentedOstream",
"MLIRTableGen",
"MLIRTargetCpp",
"MLIRTargetLLVMIRExport",
"MLIRTargetLLVMIRImport",
"MLIRTensor",
"MLIRTensorInferTypeOpInterfaceImpl",
"MLIRTensorTilingInterfaceImpl",
"MLIRTensorToSPIRV",
"MLIRTensorTransforms",
"MLIRTensorUtils",
"MLIRTilingInterface",
"MLIRToLLVMIRTranslationRegistration",
"MLIRTosa",
"MLIRTosaToArith",
"MLIRTosaToLinalg",
"MLIRTosaToSCF",
"MLIRTosaToTensor",
"MLIRTosaTransforms",
"MLIRTransformUtils",
"MLIRTransforms",
"MLIRTranslateLib",
"MLIRVector",
"MLIRVectorInterfaces",
"MLIRVectorToGPU",
"MLIRVectorToLLVM",
"MLIRVectorToROCDL",
"MLIRVectorToSCF",
"MLIRVectorToSPIRV",
"MLIRVectorTransforms",
"MLIRVectorUtils",
"MLIRViewLikeInterface",
"MLIRX86Vector",
"MLIRX86VectorToLLVMIRTranslation",
"MLIRX86VectorTransforms",
]);
println!("cargo:rustc-link-search=native={}", search_path.display());
println!("cargo:rustc-link-lib=static=MLIRFireflyExtensions");
println!("cargo:rustc-link-lib=static=CIR");
println!("cargo:rustc-link-lib=static=CIRCAPI");
}
fn link_libs(libs: &[&str]) {
match env::var_os(ENV_LLVM_LINK_STATIC) {
Some(val) if val == "true" => link_libs_static(libs),
_ => link_libs_dylib(libs),
}
}
#[inline]
fn link_libs_static(libs: &[&str]) {
for lib in libs {
link_lib_static(lib);
}
}
#[inline]
fn link_libs_dylib(libs: &[&str]) {
let llvm_link_llvm_dylib = env::var(ENV_LLVM_LINK_LLVM_DYLIB).unwrap_or("false".to_owned());
if llvm_link_llvm_dylib == "true" {
link_lib_dylib("MLIR");
link_lib_dylib("MLIR-C");
} else {
for lib in libs {
link_lib_dylib(lib);
}
}
}
#[inline]
fn link_lib_static(lib: &str) {
//println!("cargo:rustc-link-lib=static:+whole-archive={}", lib);
println!("cargo:rustc-link-lib=static={}", lib);
}
#[inline]
fn link_lib_dylib(lib: &str) {
println!("cargo:rustc-link-lib=dylib={}", lib);
}
fn warn(s: &str) {
println!("cargo:warning={}", s);
}
|
#[doc = "Reader of register IM"]
pub type R = crate::R<u32, super::IM>;
#[doc = "Writer for register IM"]
pub type W = crate::W<u32, super::IM>;
#[doc = "Register IM `reset()`'s with value 0"]
impl crate::ResetValue for super::IM {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `CTSMIM`"]
pub type CTSMIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CTSMIM`"]
pub struct CTSMIM_W<'a> {
w: &'a mut W,
}
impl<'a> CTSMIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 1)) | (((value as u32) & 0x01) << 1);
self.w
}
}
#[doc = "Reader of field `RXIM`"]
pub type RXIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RXIM`"]
pub struct RXIM_W<'a> {
w: &'a mut W,
}
impl<'a> RXIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 4)) | (((value as u32) & 0x01) << 4);
self.w
}
}
#[doc = "Reader of field `TXIM`"]
pub type TXIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `TXIM`"]
pub struct TXIM_W<'a> {
w: &'a mut W,
}
impl<'a> TXIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
self.w
}
}
#[doc = "Reader of field `RTIM`"]
pub type RTIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RTIM`"]
pub struct RTIM_W<'a> {
w: &'a mut W,
}
impl<'a> RTIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
self.w
}
}
#[doc = "Reader of field `FEIM`"]
pub type FEIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `FEIM`"]
pub struct FEIM_W<'a> {
w: &'a mut W,
}
impl<'a> FEIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
self.w
}
}
#[doc = "Reader of field `PEIM`"]
pub type PEIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `PEIM`"]
pub struct PEIM_W<'a> {
w: &'a mut W,
}
impl<'a> PEIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
self.w
}
}
#[doc = "Reader of field `BEIM`"]
pub type BEIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `BEIM`"]
pub struct BEIM_W<'a> {
w: &'a mut W,
}
impl<'a> BEIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
self.w
}
}
#[doc = "Reader of field `OEIM`"]
pub type OEIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `OEIM`"]
pub struct OEIM_W<'a> {
w: &'a mut W,
}
impl<'a> OEIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 10)) | (((value as u32) & 0x01) << 10);
self.w
}
}
#[doc = "Reader of field `_9BITIM`"]
pub type _9BITIM_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `_9BITIM`"]
pub struct _9BITIM_W<'a> {
w: &'a mut W,
}
impl<'a> _9BITIM_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
self.w
}
}
impl R {
#[doc = "Bit 1 - UART Clear to Send Modem Interrupt Mask"]
#[inline(always)]
pub fn ctsmim(&self) -> CTSMIM_R {
CTSMIM_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 4 - UART Receive Interrupt Mask"]
#[inline(always)]
pub fn rxim(&self) -> RXIM_R {
RXIM_R::new(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 5 - UART Transmit Interrupt Mask"]
#[inline(always)]
pub fn txim(&self) -> TXIM_R {
TXIM_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - UART Receive Time-Out Interrupt Mask"]
#[inline(always)]
pub fn rtim(&self) -> RTIM_R {
RTIM_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - UART Framing Error Interrupt Mask"]
#[inline(always)]
pub fn feim(&self) -> FEIM_R {
FEIM_R::new(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bit 8 - UART Parity Error Interrupt Mask"]
#[inline(always)]
pub fn peim(&self) -> PEIM_R {
PEIM_R::new(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 9 - UART Break Error Interrupt Mask"]
#[inline(always)]
pub fn beim(&self) -> BEIM_R {
BEIM_R::new(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 10 - UART Overrun Error Interrupt Mask"]
#[inline(always)]
pub fn oeim(&self) -> OEIM_R {
OEIM_R::new(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 12 - 9-Bit Mode Interrupt Mask"]
#[inline(always)]
pub fn _9bitim(&self) -> _9BITIM_R {
_9BITIM_R::new(((self.bits >> 12) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 1 - UART Clear to Send Modem Interrupt Mask"]
#[inline(always)]
pub fn ctsmim(&mut self) -> CTSMIM_W {
CTSMIM_W { w: self }
}
#[doc = "Bit 4 - UART Receive Interrupt Mask"]
#[inline(always)]
pub fn rxim(&mut self) -> RXIM_W {
RXIM_W { w: self }
}
#[doc = "Bit 5 - UART Transmit Interrupt Mask"]
#[inline(always)]
pub fn txim(&mut self) -> TXIM_W {
TXIM_W { w: self }
}
#[doc = "Bit 6 - UART Receive Time-Out Interrupt Mask"]
#[inline(always)]
pub fn rtim(&mut self) -> RTIM_W {
RTIM_W { w: self }
}
#[doc = "Bit 7 - UART Framing Error Interrupt Mask"]
#[inline(always)]
pub fn feim(&mut self) -> FEIM_W {
FEIM_W { w: self }
}
#[doc = "Bit 8 - UART Parity Error Interrupt Mask"]
#[inline(always)]
pub fn peim(&mut self) -> PEIM_W {
PEIM_W { w: self }
}
#[doc = "Bit 9 - UART Break Error Interrupt Mask"]
#[inline(always)]
pub fn beim(&mut self) -> BEIM_W {
BEIM_W { w: self }
}
#[doc = "Bit 10 - UART Overrun Error Interrupt Mask"]
#[inline(always)]
pub fn oeim(&mut self) -> OEIM_W {
OEIM_W { w: self }
}
#[doc = "Bit 12 - 9-Bit Mode Interrupt Mask"]
#[inline(always)]
pub fn _9bitim(&mut self) -> _9BITIM_W {
_9BITIM_W { w: self }
}
}
|
//! Installing signal handlers allows us to handle traps and out-of-bounds memory
//! accesses that occur when runniing webassembly.
//!
//! This code is inspired by: https://github.com/pepyakin/wasmtime/commit/625a2b6c0815b21996e111da51b9664feb174622
use crate::call::recovery;
use nix::libc::{c_void, siginfo_t};
use nix::sys::signal::{
sigaction, SaFlags, SigAction, SigHandler, SigSet, SIGBUS, SIGFPE, SIGILL, SIGSEGV,
};
pub unsafe fn install_sighandler() {
let sa = SigAction::new(
SigHandler::SigAction(signal_trap_handler),
SaFlags::SA_ONSTACK,
SigSet::empty(),
);
sigaction(SIGFPE, &sa).unwrap();
sigaction(SIGILL, &sa).unwrap();
sigaction(SIGSEGV, &sa).unwrap();
sigaction(SIGBUS, &sa).unwrap();
}
extern "C" fn signal_trap_handler(
signum: ::nix::libc::c_int,
siginfo: *mut siginfo_t,
ucontext: *mut c_void,
) {
unsafe {
recovery::do_unwind(signum, siginfo, ucontext);
}
}
|
use async_trait::async_trait;
use data_types::{sequence_number_set::SequenceNumberSet, TableId};
use generated_types::influxdata::iox::wal::v1::sequenced_wal_op::Op;
use std::{collections::HashMap, sync::Arc, time::Duration};
use tokio::sync::watch::Receiver;
use wal::{SequencedWalOp, WriteResult};
use crate::{
cancellation_safe::CancellationSafe,
dml_payload::{encode::encode_write_op, IngestOp},
dml_sink::{DmlError, DmlSink},
};
use super::{
reference_tracker::WalReferenceHandle,
traits::{UnbufferedWriteNotifier, WalAppender},
};
/// [`DELEGATE_APPLY_TIMEOUT`] defines how long the inner [`DmlSink`] is given
/// to complete the write [`DmlSink::apply()`] call.
///
/// If this limit weren't enforced, a write that does not make progress would
/// consume resources forever. Instead, a reasonable duration of time is given
/// to attempt the write before an error is returned to the caller.
///
/// In practice, this limit SHOULD only ever be reached as a symptom of a larger
/// problem (catalog unavailable, etc) preventing a write from making progress.
const DELEGATE_APPLY_TIMEOUT: Duration = Duration::from_secs(15);
/// A [`DmlSink`] decorator that ensures any [`IngestOp`] is committed to
/// the write-ahead log before passing the operation to the inner [`DmlSink`].
#[derive(Debug)]
pub(crate) struct WalSink<T, W = wal::Wal, N = WalReferenceHandle> {
/// The inner chain of [`DmlSink`] that a [`IngestOp`] is passed to once
/// committed to the write-ahead log.
inner: T,
/// The write-ahead log implementation.
wal: W,
/// A notifier handle to report the sequence numbers of writes that enter
/// the write-ahead log but fail to buffer.
notifier_handle: N,
}
impl<T, W, N> WalSink<T, W, N> {
/// Initialise a new [`WalSink`] that appends [`IngestOp`] to `W` and
/// on success, passes the op through to `T`, using `N` to keep `W` informed
/// of writes that fail to buffer.
pub(crate) fn new(inner: T, wal: W, notifier_handle: N) -> Self {
Self {
inner,
wal,
notifier_handle,
}
}
}
#[async_trait]
impl<T, W, N> DmlSink for WalSink<T, W, N>
where
T: DmlSink + Clone + 'static,
W: WalAppender + 'static,
N: UnbufferedWriteNotifier + 'static,
{
type Error = DmlError;
async fn apply(&self, op: IngestOp) -> Result<(), Self::Error> {
// Append the operation to the WAL
let mut write_result = self.wal.append(&op);
let set = op.sequence_number_set();
// Pass it to the inner handler while we wait for the write to be made
// durable.
//
// Ensure that this future is always driven to completion now that the
// WAL entry is being committed, otherwise they'll diverge. At the same
// time, do not allow the spawned task to live forever, consuming
// resources without making progress - instead shed load after a
// reasonable duration of time (DELEGATE_APPLY_TIMEOUT) has passed,
// before returning a write error (if the caller is still listening).
//
// If this buffer apply fails, the entry remains in the WAL and will be
// attempted again during WAL replay after a crash. If this can never
// succeed, this can cause a crash loop (unlikely) - see:
//
// https://github.com/influxdata/influxdb_iox/issues/7111
//
let inner = self.inner.clone();
let inner_result = CancellationSafe::new(async move {
let res = tokio::time::timeout(DELEGATE_APPLY_TIMEOUT, inner.apply(op))
.await
.map_err(|_| DmlError::ApplyTimeout)?;
res.map_err(Into::into)
})
.await;
if inner_result.is_err() {
self.notifier_handle.notify_failed_write_buffer(set).await;
}
inner_result?;
// Wait for the write to be durable before returning to the user
write_result
.changed()
.await
.expect("unable to get WAL write result");
let res = write_result.borrow();
match res.as_ref().expect("WAL should always return result") {
WriteResult::Ok(_) => Ok(()),
WriteResult::Err(ref e) => Err(DmlError::Wal(e.to_string())),
}
}
}
impl WalAppender for Arc<wal::Wal> {
fn append(&self, op: &IngestOp) -> Receiver<Option<WriteResult>> {
let namespace_id = op.namespace();
let (wal_op, partition_sequence_numbers) = match op {
IngestOp::Write(w) => {
let partition_sequence_numbers = w
.tables()
.map(|(table_id, data)| {
(*table_id, data.partitioned_data().sequence_number().get())
})
.collect::<HashMap<TableId, u64>>();
(
Op::Write(encode_write_op(namespace_id, w)),
partition_sequence_numbers,
)
}
};
self.write_op(SequencedWalOp {
table_write_sequence_numbers: partition_sequence_numbers,
op: wal_op,
})
}
}
#[async_trait]
impl UnbufferedWriteNotifier for WalReferenceHandle {
async fn notify_failed_write_buffer(&self, set: SequenceNumberSet) {
self.enqueue_unbuffered_write(set).await;
}
}
#[cfg(test)]
pub(crate) mod mock {
use parking_lot::Mutex;
use super::*;
#[derive(Debug, Default)]
pub(crate) struct MockUnbufferedWriteNotifier {
calls: Mutex<Vec<SequenceNumberSet>>,
}
impl MockUnbufferedWriteNotifier {
pub(crate) fn calls(&self) -> Vec<SequenceNumberSet> {
self.calls.lock().clone()
}
}
#[async_trait]
impl UnbufferedWriteNotifier for Arc<MockUnbufferedWriteNotifier> {
async fn notify_failed_write_buffer(&self, set: SequenceNumberSet) {
self.calls.lock().push(set);
}
}
}
#[cfg(test)]
mod tests {
use core::{future::Future, marker::Send, pin::Pin};
use std::{future, sync::Arc};
use assert_matches::assert_matches;
use data_types::{SequenceNumber, TableId};
use lazy_static::lazy_static;
use wal::Wal;
use super::*;
use crate::{
dml_sink::mock_sink::MockDmlSink,
test_util::{
make_multi_table_write_op, ARBITRARY_NAMESPACE_ID, ARBITRARY_PARTITION_KEY,
ARBITRARY_TABLE_ID, ARBITRARY_TABLE_NAME,
},
};
lazy_static! {
static ref ALTERNATIVE_TABLE_NAME: &'static str = "arán";
static ref ALTERNATIVE_TABLE_ID: TableId = TableId::new(ARBITRARY_TABLE_ID.get() + 1);
}
#[tokio::test]
async fn test_append() {
let dir = tempfile::tempdir().unwrap();
// Generate a test op containing writes for multiple tables that will
// be appended and read back
let op = make_multi_table_write_op(
&ARBITRARY_PARTITION_KEY,
ARBITRARY_NAMESPACE_ID,
[
(
ARBITRARY_TABLE_NAME.to_string().as_str(),
ARBITRARY_TABLE_ID,
SequenceNumber::new(42),
),
(
&ALTERNATIVE_TABLE_NAME,
*ALTERNATIVE_TABLE_ID,
SequenceNumber::new(43),
),
]
.into_iter(),
&format!(
r#"{},region=Madrid temp=35,climate="dry" 4242424242
{},region=Belfast temp=14,climate="wet" 4242424242"#,
&*ARBITRARY_TABLE_NAME, &*ALTERNATIVE_TABLE_NAME,
),
);
// The write portion of this test.
{
let inner = Arc::new(MockDmlSink::default().with_apply_return(vec![Ok(())]));
let wal = Wal::new(dir.path())
.await
.expect("failed to initialise WAL");
let notifier_handle = Arc::new(mock::MockUnbufferedWriteNotifier::default());
let wal_sink = WalSink::new(Arc::clone(&inner), wal, Arc::clone(¬ifier_handle));
// Apply the op through the decorator
wal_sink
.apply(IngestOp::Write(op.clone()))
.await
.expect("wal should not error");
// Assert the mock inner sink saw the call and that no unbuffered
// write notification was sent
assert_eq!(inner.get_calls().len(), 1);
assert_eq!(notifier_handle.calls().len(), 0);
}
// Read the op back
let wal = Wal::new(dir.path())
.await
.expect("failed to initialise WAL");
// Identify the segment file
let files = wal.closed_segments();
let file = assert_matches!(&*files, [f] => f, "expected 1 file");
// Open a reader
let ops: Vec<SequencedWalOp> = wal
.reader_for_segment(file.id())
.expect("failed to obtain reader for WAL segment")
.flat_map(|batch| batch.expect("failed to read WAL op batch"))
.collect();
// Extract the op payload read from the WAL
let read_op = assert_matches!(&*ops, [op] => op, "expected 1 DML operation");
assert_eq!(
read_op.table_write_sequence_numbers,
[(ARBITRARY_TABLE_ID, 42), (*ALTERNATIVE_TABLE_ID, 43)]
.into_iter()
.collect::<std::collections::HashMap<TableId, u64>>()
);
let payload =
assert_matches!(&read_op.op, Op::Write(w) => w, "expected DML write WAL entry");
// The payload should match the serialised form of the "op" originally
// wrote above.
let want = encode_write_op(ARBITRARY_NAMESPACE_ID, &op);
assert_eq!(want, *payload);
}
/// A [`DmlSink`] implementation that hangs forever and never completes.
#[derive(Debug, Default, Clone)]
struct BlockingDmlSink;
impl DmlSink for BlockingDmlSink {
type Error = DmlError;
fn apply<'life0, 'async_trait>(
&'life0 self,
_op: IngestOp,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where
'life0: 'async_trait,
Self: 'async_trait,
{
Box::pin(future::pending())
}
}
#[tokio::test]
async fn test_timeout() {
let dir = tempfile::tempdir().unwrap();
// Generate the test op
let op = make_multi_table_write_op(
&ARBITRARY_PARTITION_KEY,
ARBITRARY_NAMESPACE_ID,
[
(
ARBITRARY_TABLE_NAME.to_string().as_str(),
ARBITRARY_TABLE_ID,
SequenceNumber::new(42),
),
(
&ALTERNATIVE_TABLE_NAME,
*ALTERNATIVE_TABLE_ID,
SequenceNumber::new(43),
),
]
.into_iter(),
&format!(
r#"{},region=Madrid temp=35,climate="dry" 4242424242
{},region=Belfast temp=14,climate="wet" 4242424242"#,
&*ARBITRARY_TABLE_NAME, &*ALTERNATIVE_TABLE_NAME,
),
);
let wal = Wal::new(dir.path())
.await
.expect("failed to initialise WAL");
let notifier_handle = Arc::new(mock::MockUnbufferedWriteNotifier::default());
let wal_sink = WalSink::new(BlockingDmlSink, wal, Arc::clone(¬ifier_handle));
// Allow tokio to automatically advance time past the timeout duration,
// when all threads are blocked on await points.
//
// This allows the test to drive the timeout logic without actually
// waiting for the timeout duration in the test.
tokio::time::pause();
let start = tokio::time::Instant::now();
// Apply the op through the decorator, which should time out
let err = wal_sink
.apply(IngestOp::Write(op.clone()))
.await
.expect_err("write should time out");
assert_matches!(err, DmlError::ApplyTimeout);
// Ensure that "time" advanced at least the timeout amount of time
// before erroring.
let duration = tokio::time::Instant::now().duration_since(start);
assert!(duration > DELEGATE_APPLY_TIMEOUT);
// Assert that an unbuffered write notification was sent for the
// correct [`SequenceNumberSet`]
assert_eq!(
notifier_handle.calls(),
[SequenceNumberSet::from_iter([
SequenceNumber::new(42),
SequenceNumber::new(43)
])]
.into_iter()
.collect::<Vec<_>>()
);
}
}
|
{{replace def.keys.NewObjs $objs=objs}}
|
use crate::ir::eval::prelude::*;
impl IrEval for ir::IrScope {
type Output = IrValue;
fn eval(
&self,
interp: &mut IrInterpreter<'_>,
used: Used,
) -> Result<Self::Output, IrEvalOutcome> {
interp.budget.take(self)?;
let guard = interp.scopes.push();
for ir in &self.instructions {
let _ = ir.eval(interp, used)?;
}
let value = if let Some(last) = &self.last {
last.eval(interp, used)?
} else {
IrValue::Unit
};
interp.scopes.pop(self, guard)?;
Ok(value)
}
}
|
use std::rc::Rc;
use crate::env::Env;
use crate::expr::{compile_expr, compile_fn_expr};
use crate::helper::allocate_env;
use anyhow::{anyhow, Error};
use inkwell::{
builder::Builder,
context::Context,
module::Module,
values::{FunctionValue, PointerValue},
AddressSpace,
};
use serde_json::Value;
pub fn compile_stmt<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<Option<PointerValue<'ctx>>, Error> {
let type_ = es_node.get("type").unwrap().as_str().unwrap();
// println!("{:?}", type_);
match type_ {
"VariableDeclaration" => {
compile_var_decl(es_node, env, context, module, builder, function).map(|_| None)
}
"ExpressionStatement" => {
compile_expr_stmt(es_node, env, context, module, builder, function).map(Some)
}
"BlockStatement" => {
compile_block_stmt(es_node, env, context, module, builder, function).map(|_| None)
}
"IfStatement" => {
compile_if_stmt(es_node, env, context, module, builder, function).map(|_| None)
}
"FunctionDeclaration" => {
compile_fn_decl(es_node, env, context, module, builder).map(|_| None)
}
"ReturnStatement" => {
compile_return_stmt(es_node, env, context, module, builder, function).map(|_| None)
}
_ => Err(anyhow!("stmt compile error")),
}
}
pub fn compile_var_decl<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<(), Error> {
let declaration = &es_node.get("declarations").unwrap().as_array().unwrap()[0];
let name = declaration
.get("id")
.unwrap()
.get("name")
.unwrap()
.as_str()
.unwrap();
let init = declaration.get("init").unwrap();
let value = compile_expr(init, env.clone(), context, module, builder, function)?;
let mut frame = env.ptr.clone().unwrap();
let source_obj_type = module.get_struct_type("source_obj").unwrap();
let source_obj_ptr_type = source_obj_type.ptr_type(AddressSpace::Generic);
let source_obj_ptr_ptr_type = source_obj_ptr_type.ptr_type(AddressSpace::Generic);
let (jumps, offset) = env.lookup(name)?;
for _ in 0..jumps {
let tmp = builder
.build_bitcast(*frame, frame.get_type().ptr_type(AddressSpace::Generic), "")
.into_pointer_value();
frame = Rc::new(builder.build_load(tmp, "").into_pointer_value());
}
let frame_casted = builder
.build_bitcast(*frame, source_obj_ptr_ptr_type, "")
.into_pointer_value();
// SAFETY: Inherently unsafe
let ptr = unsafe {
builder.build_in_bounds_gep(
frame_casted,
&[context.i32_type().const_int(offset, false)],
"",
)
};
builder.build_store(ptr, value);
Ok(())
}
pub fn compile_expr_stmt<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<PointerValue<'ctx>, Error> {
compile_expr(
es_node.get("expression").unwrap(),
env,
context,
module,
builder,
function,
)
}
pub fn compile_block_stmt<'ctx>(
es_node: &Value,
parent: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<(), Error> {
let body = es_node.get("body").unwrap().as_array().unwrap();
let env = Rc::new(allocate_env(body, Some(parent), context, module, builder)?);
for s in body.iter() {
compile_stmt(s, env.clone(), context, module, builder, function).unwrap();
if s.get("type").unwrap().as_str().unwrap() == "ReturnStatement" {
break;
}
}
Ok(())
}
pub fn compile_if_stmt<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<(), Error> {
let test = es_node.get("test").unwrap();
let test_result_ptr = compile_expr(test, env.clone(), context, module, builder, function)?;
let zero = context.i32_type().const_int(0, false);
let one = context.i32_type().const_int(1, false);
let test_result_value_ptr =
unsafe { builder.build_in_bounds_gep(test_result_ptr, &[zero, one], "") };
let value = builder
.build_load(test_result_value_ptr, "")
.into_int_value();
let as_i1 = builder.build_int_truncate(value, context.bool_type(), "");
let consequent_block = context.append_basic_block(*function, "if.true");
let alternate_block = context.append_basic_block(*function, "if.false");
let end_block = context.append_basic_block(*function, "if.end");
builder.build_conditional_branch(as_i1, consequent_block, alternate_block);
builder.position_at_end(consequent_block);
compile_stmt(
es_node.get("consequent").unwrap(),
env.clone(),
context,
module,
builder,
function,
)?;
if builder
.get_insert_block()
.unwrap()
.get_terminator()
.is_none()
{
builder.build_unconditional_branch(end_block);
}
builder.position_at_end(alternate_block);
compile_stmt(
es_node.get("alternate").unwrap(),
env,
context,
module,
builder,
function,
)?;
if builder
.get_insert_block()
.unwrap()
.get_terminator()
.is_none()
{
builder.build_unconditional_branch(end_block);
}
builder.position_at_end(end_block);
Ok(())
}
pub fn compile_fn_decl<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
) -> Result<(), Error> {
let source_obj_type = module.get_struct_type("source_obj").unwrap();
let source_obj_ptr_type = source_obj_type.ptr_type(AddressSpace::Generic);
let source_obj_ptr_ptr_type = source_obj_ptr_type.ptr_type(AddressSpace::Generic);
let name = es_node
.get("id")
.unwrap()
.get("name")
.unwrap()
.as_str()
.unwrap();
let lit = compile_fn_expr(
Some(name),
es_node,
env.clone(),
false,
context,
module,
builder,
)?;
let mut frame = env.ptr.clone().unwrap();
let (jumps, offset) = env.lookup(name)?;
for _ in 0..jumps {
let tmp = builder
.build_bitcast(*frame, frame.get_type().ptr_type(AddressSpace::Generic), "")
.into_pointer_value();
frame = Rc::new(builder.build_load(tmp, "").into_pointer_value());
}
let frame_casted = builder
.build_bitcast(*frame, source_obj_ptr_ptr_type, "")
.into_pointer_value();
// SAFETY: Inherently unsafe
let ptr = unsafe {
builder.build_in_bounds_gep(
frame_casted,
&[context.i32_type().const_int(offset, false)],
"",
)
};
builder.build_store(ptr, lit);
Ok(())
}
pub fn compile_return_stmt<'ctx>(
es_node: &Value,
env: Rc<Env<'ctx>>,
context: &'ctx Context,
module: &Module<'ctx>,
builder: &Builder<'ctx>,
function: &FunctionValue<'ctx>,
) -> Result<(), Error> {
let argument = es_node.get("argument").unwrap();
let result = compile_expr(argument, env, context, module, builder, function)?;
builder.build_return(Some(&result));
Ok(())
}
|
#![crate_name = "ovr"]
#![crate_type = "lib"]
#![feature(link_args, path, core, std_misc)]
#![allow(non_upper_case_globals)]
extern crate cgmath;
extern crate libc;
use libc::{c_int, c_uint, c_void, c_float, c_double};
use std::default::Default;
use std::ptr;
use std::old_path::BytesContainer;
use cgmath::Quaternion;
use cgmath::{Vector2, Vector3};
use cgmath::{Matrix4};
#[cfg(target_os = "linux")]
#[link(name="ovr")]
#[link(name="stdc++")]
#[link(name="udev")]
#[link(name="Xinerama")]
#[link(name="Xrandr")]
#[link(name="X11")]
#[link(name="GL")]
extern {}
#[cfg(target_os = "macos")]
#[link(name="ovr")]
#[link(name="stdc++")]
#[link(name = "Cocoa", kind = "framework")]
#[link(name = "IOKit", kind = "framework")]
#[link(name = "CoreFoundation", kind = "framework")]
extern {}
pub mod ll {
use libc::{c_uint, c_int, c_float, c_char, c_void, c_double, c_short};
use std::ptr;
use std::default::Default;
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Vector2i {
pub x: c_int,
pub y: c_int
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Sizei {
pub x: c_int,
pub y: c_int
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Recti {
pub pos: Vector2i,
pub size: Sizei
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct FovPort {
pub up_tan: c_float,
pub down_tan: c_float,
pub left_tan: c_float,
pub right_tan: c_float
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Vector2f {pub x: c_float, pub y: c_float}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Vector3f {pub x: c_float, pub y: c_float, pub z: c_float}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Quaternionf {pub x: c_float, pub y: c_float, pub z: c_float, pub w: c_float}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Matrix4f {pub m11: c_float, pub m12: c_float, pub m13: c_float, pub m14: c_float,
pub m21: c_float, pub m22: c_float, pub m23: c_float, pub m24: c_float,
pub m31: c_float, pub m32: c_float, pub m33: c_float, pub m34: c_float,
pub m41: c_float, pub m42: c_float, pub m43: c_float, pub m44: c_float}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct Posef {
pub orientation: Quaternionf,
pub position: Vector3f
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct PoseState {
pub pose: Posef,
pub angular_velocity: Vector3f,
pub linear_velocity: Vector3f,
pub angular_acceleration: Vector3f,
pub linear_acceleration: Vector3f,
pub time_in_seconds: c_double
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct SensorState {
pub predicted: PoseState,
pub recorded: PoseState,
pub temperature: c_float,
pub status_flags: c_uint
}
#[derive(Clone, Debug, Copy)]
pub enum Hmd {}
#[repr(C)]
pub struct HmdDesc {
pub handle: *const Hmd,
pub hmd_type: c_int,
pub product_name: *const c_char,
pub manufacture: *const c_char,
pub hmd_capabilities: c_uint,
pub sensor_capabilities: c_uint,
pub distortion_capabilities: c_uint,
pub resolution: Sizei,
pub window_position: Vector2i,
pub default_eye_fov: [FovPort; 2],
pub max_eye_fov: [FovPort; 2],
pub eye_render_order: [c_uint; 2],
pub display_device_name: *const c_char,
pub display_id: c_int
}
impl Default for HmdDesc {
fn default() -> HmdDesc {
HmdDesc {
handle: ptr::null(),
hmd_type: 0,
product_name: ptr::null(),
manufacture: ptr::null(),
hmd_capabilities: 0,
sensor_capabilities: 0,
distortion_capabilities: 0,
resolution: Default::default(),
window_position: Default::default(),
default_eye_fov: [Default::default(); 2],
max_eye_fov: [Default::default(); 2],
eye_render_order: [0; 2],
display_device_name: ptr::null(),
display_id: 0
}
}
}
#[derive(Copy, Debug, Clone)]
#[repr(C)]
pub struct SensorDesc {
pub vendor_id: c_short,
pub product_id: c_short,
pub serial_number: [c_char; 24]
}
#[derive(Clone, Default, Debug, Copy)]
#[repr(C)]
pub struct EyeRenderDesc {
pub eye: c_uint,
pub fov: FovPort,
pub distorted_viewport: Recti,
pub pixels_per_tan_angle_at_center: Vector2f,
pub view_adjust: Vector3f
}
#[derive(Copy, Default, Debug, Clone)]
#[repr(C)]
pub struct RenderApiConfigHeader {
pub render_api_type: c_uint,
pub rt_size: Sizei,
pub multisample: c_int,
}
#[derive(Copy, Debug, Clone)]
#[repr(C)]
pub struct RenderApiConfig {
pub header: RenderApiConfigHeader,
pub display: *const c_void,
pub window: *const c_void,
pub padd: [*const c_void; 6]
}
#[derive(Copy, Debug, Clone)]
#[repr(C)]
pub struct FrameTiming {
pub delta_seconds: f32,
pub this_frame_seconds: f64,
pub timewarp_point_seconds: f64,
pub next_frame_seconds: f64,
pub scanout_midpoint_seconds: f64,
pub eye_scanout_seconds: [f64; 2]
}
#[derive(Copy, Default, Debug, Clone)]
#[repr(C)]
pub struct TextureHeader {
pub render_api_type: c_uint,
pub size: Sizei,
pub viewport: Recti
}
#[derive(Copy, Debug, Clone)]
#[repr(C)]
pub struct Texture {
pub header: TextureHeader,
pub texture_id: u32,
pub padd: [*const c_void; 7]
}
pub const Hmd_None : c_int = 0;
pub const Hmd_DK1 : c_int = 3;
pub const Hmd_DKHD : c_int = 4;
pub const Hmd_CrystalCoveProto : c_int = 5;
pub const Hmd_DK2 : c_int = 6;
pub const Hmd_Other : c_int = 7;
pub const HmdCap_Present : c_uint = 0x0001;
pub const HmdCap_Available : c_uint = 0x0002;
pub const HmdCap_LowPersistence : c_uint = 0x0080;
pub const HmdCap_LatencyTest : c_uint = 0x0100;
pub const HmdCap_DynamicPrediction : c_uint = 0x0200;
pub const HmdCap_NoVSync : c_uint = 0x1000;
pub const HmdCap_NoRestore : c_uint = 0x4000;
pub const HmdCap_Writable_Mask : c_uint = 0x1380;
pub const SensorCap_Orientation : c_uint = 0x0010;
pub const SensorCap_YawCorrection : c_uint = 0x0020;
pub const SensorCap_Position : c_uint = 0x0040;
pub const Status_OrientationTracked : c_uint = 0x0001;
pub const Status_PositionTracked : c_uint = 0x0002;
pub const Status_PositionConnected : c_uint = 0x0020;
pub const Status_HmdConnected : c_uint = 0x0080;
pub const DistortionCap_Chromatic : c_uint = 0x01;
pub const DistortionCap_TimeWarp : c_uint = 0x02;
pub const DistortionCap_Vignette : c_uint = 0x08;
pub const Eye_Left : c_uint = 0;
pub const Eye_Right : c_uint = 1;
pub const RenderAPI_None : c_uint = 0;
pub const RenderAPI_OpenGL : c_uint = 1;
pub const RenderAPI_Android_GLES : c_uint = 2;
pub const RenderAPI_D3D9 : c_uint = 3;
pub const RenderAPI_D3D10 : c_uint = 4;
pub const RenderAPI_D3D11 : c_uint = 5;
pub const RenderAPI_Count : c_uint = 6;
extern "C" {
pub fn ovr_Initialize() -> bool;
pub fn ovr_Shutdown();
pub fn ovrHmd_Detect() -> c_int;
pub fn ovrHmd_Create(index: c_int) -> *mut Hmd;
pub fn ovrHmd_Destroy(hmd: *mut Hmd);
pub fn ovrHmd_CreateDebug(hmd_type: c_int) -> *mut Hmd;
pub fn ovrHmd_GetLastError(hmd: *mut Hmd) -> *const c_char;
pub fn ovrHmd_GetEnabledCaps(hmd: *mut Hmd) -> c_uint;
pub fn ovrHmd_SetEnabledCaps(hmd: *mut Hmd, flags: c_uint);
pub fn ovrHmd_StartSensor(hmd: *mut Hmd,
supported: c_uint,
required: c_uint) -> bool;
pub fn ovrHmd_StopSensor(hmd: *mut Hmd);
pub fn ovrHmd_ResetSensor(hmd: *mut Hmd);
pub fn ovrHmd_GetSensorState(hmd: *mut Hmd,
abs_time: c_double) -> SensorState;
pub fn ovrHmd_GetSensorDesc(hmd: *mut Hmd,
sensor_desc: *mut SensorDesc) -> bool;
pub fn ovrHmd_GetDesc(hmd: *mut Hmd,
size: *mut HmdDesc);
pub fn ovrHmd_GetFovTextureSize(hmd: *mut Hmd,
eye: c_uint,
fov: FovPort,
pixels: c_float) -> Sizei;
pub fn ovrHmd_ConfigureRendering(hmd: *mut Hmd,
apiConfig: *const RenderApiConfig,
distortionCaps: c_uint,
fov_in: *const FovPort,
render_desc_out: *mut EyeRenderDesc) -> bool;
pub fn ovrHmd_BeginFrame(hmd: *mut Hmd,
frame_index: c_uint) -> FrameTiming;
pub fn ovrHmd_EndFrame(hmd: *mut Hmd);
pub fn ovrHmd_BeginEyeRender(hmd: *mut Hmd, eye: c_uint) -> Posef;
pub fn ovrHmd_EndEyeRender(hmd: *mut Hmd, eye: c_uint,
pose: Posef, texture: *const Texture);
pub fn ovrMatrix4f_Projection(fov: FovPort,
znear: c_float,
zfar: c_float,
right_handed: bool) -> Matrix4f;
pub fn ovr_WaitTillTime(abs_time: c_double) -> c_double;
pub fn ovr_GetTimeInSeconds() -> c_double;
}
}
pub fn get_time() -> f64 {
unsafe{ ll::ovr_GetTimeInSeconds() as f64 }
}
pub fn wait_till_time(time: f64) -> f64 {
unsafe{ ll::ovr_WaitTillTime(time as c_double) as f64 }
}
#[derive(Debug, Copy, Clone)]
pub enum HmdType {
None,
DK1,
DKHD,
CrystalCoveProto,
DK2,
Other
}
impl HmdType {
fn from_ll(c: c_int) -> HmdType {
match c {
ll::Hmd_None => HmdType::None,
ll::Hmd_DK1 => HmdType::DK1,
ll::Hmd_DKHD => HmdType::DKHD,
ll::Hmd_CrystalCoveProto => HmdType::CrystalCoveProto,
ll::Hmd_DK2 => HmdType::DK2,
_ => HmdType::Other
}
}
fn to_ll(&self) -> c_int {
match *self {
HmdType::None => ll::Hmd_None,
HmdType::DK1 => ll::Hmd_DK1,
HmdType::DKHD => ll::Hmd_DKHD,
HmdType::CrystalCoveProto => ll::Hmd_CrystalCoveProto,
HmdType::DK2 => ll::Hmd_DK2,
HmdType::Other => ll::Hmd_Other
}
}
}
pub struct Ovr;
impl Ovr {
pub fn init() -> Option<Ovr> {
unsafe {
if ll::ovr_Initialize() {
Some(Ovr)
} else {
None
}
}
}
// return a count of the number of Hmd devices
pub fn detect(&self) -> isize {
unsafe { ll::ovrHmd_Detect() as isize }
}
pub fn create_hmd(&self, index: isize) -> Option<Hmd> {
unsafe {
let ptr = ll::ovrHmd_Create(index as i32);
if !ptr.is_null() {
Some(Hmd { ptr: ptr })
} else {
None
}
}
}
pub fn first_hmd(&self) -> Option<Hmd> {
if self.detect() >= 1 {
self.create_hmd(0)
} else {
None
}
}
pub fn create_hmd_debug(&self, hmd_type: HmdType) -> Option<Hmd> {
unsafe {
let ptr = ll::ovrHmd_CreateDebug(hmd_type.to_ll());
if !ptr.is_null() {
Some(Hmd{ptr:ptr})
} else {
None
}
}
}
}
impl Drop for Ovr {
fn drop(&mut self) {
unsafe { ll::ovr_Shutdown(); }
}
}
pub struct Hmd {
ptr: *mut ll::Hmd
}
unsafe impl Sync for Hmd {}
unsafe impl Send for Hmd {}
impl Drop for Hmd {
fn drop(&mut self) {
unsafe {ll::ovrHmd_Destroy(self.ptr)}
}
}
impl Hmd {
pub fn get_last_error(&self) -> Result<(), String> {
unsafe {
let ptr = ll::ovrHmd_GetLastError(self.ptr);
if ptr.is_null() {
Ok(())
} else {
Err(from_buf(ptr as *const u8))
}
}
}
pub fn get_enabled_caps(&self) -> HmdCapabilities {
unsafe {
let flags = ll::ovrHmd_GetEnabledCaps(self.ptr);
HmdCapabilities{flags:flags}
}
}
pub fn set_enabled_caps(&self, cap: SensorCapabilities) {
unsafe {
let flags = cap.flags;
ll::ovrHmd_SetEnabledCaps(self.ptr, flags);
}
}
pub fn start_sensor(&self,
supported: SensorCapabilities,
required: SensorCapabilities) -> bool {
unsafe {
ll::ovrHmd_StartSensor(self.ptr, supported.flags, required.flags)
}
}
pub fn stop_sensor(&self) {
unsafe {
ll::ovrHmd_StopSensor(self.ptr)
}
}
pub fn reset_sensor(&self) {
unsafe {
ll::ovrHmd_StopSensor(self.ptr)
}
}
pub fn get_sensor_state(&self, abs_time: f64) -> SensorState {
unsafe {
SensorState::from_ll(ll::ovrHmd_GetSensorState(self.ptr, abs_time))
}
}
pub fn get_sensor_description(&self) -> Option<SensorDescription> {
unsafe {
let mut c_desc = ll::SensorDesc {
vendor_id: 0,
product_id: 0,
serial_number: [0; 24]
};
if !ll::ovrHmd_GetSensorDesc(self.ptr, &mut c_desc as *mut ll::SensorDesc) {
None
} else {
Some(SensorDescription::from_ll(c_desc))
}
}
}
pub fn get_description(&self) -> HmdDescription {
unsafe {
let mut c_desc = Default::default();
ll::ovrHmd_GetDesc(self.ptr, &mut c_desc);
HmdDescription::from_ll(c_desc)
}
}
pub fn get_fov_texture_size(&self,
eye: Eye,
fov: FovPort,
pixels_per_display_pixel: f32) -> ll::Sizei {
unsafe {
ll::ovrHmd_GetFovTextureSize(self.ptr,
eye.to_ll(),
fov.to_ll(),
pixels_per_display_pixel)
}
}
pub fn configure_rendering<RC: ToRenderConfig>(&self,
api_config: &RC,
cap: DistortionCapabilities,
eye_fov: PerEye<FovPort>) -> Option<PerEye<EyeRenderDescriptor>> {
unsafe {
let mut out: PerEye<ll::EyeRenderDesc> = PerEye::new(Default::default(),
Default::default());
let was_started = ll::ovrHmd_ConfigureRendering(
self.ptr,
&api_config.to_render_config(),
cap.flags,
eye_fov.map(|_, d| d.to_ll()).ptr(),
out.mut_ptr()
);
if was_started {
Some(out.map(|_, d| EyeRenderDescriptor::from_ll(d)))
} else {
None
}
}
}
pub fn begin_frame(&self, frame_index: usize) -> FrameTiming {
unsafe {
FrameTiming::from_ll(
ll::ovrHmd_BeginFrame(self.ptr, frame_index as c_uint)
)
}
}
pub fn end_frame(&self) {
unsafe {
ll::ovrHmd_EndFrame(self.ptr);
}
}
pub fn begin_eye_render(&self, eye: Eye) -> Pose {
unsafe {
Pose::from_ll(ll::ovrHmd_BeginEyeRender(self.ptr, eye.to_ll()))
}
}
pub fn end_eye_render<T: ToTexture>(&self,
eye: Eye,
pose: Pose,
texture: &T) {
unsafe {
ll::ovrHmd_EndEyeRender(self.ptr,
eye.to_ll(),
pose.to_ll(),
&texture.to_texture());
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct HmdCapabilities {
flags: c_uint
}
impl HmdCapabilities {
pub fn present(&self) -> bool {
self.flags & ll::HmdCap_Present == ll::HmdCap_Present
}
pub fn available(&self) -> bool {
self.flags & ll::HmdCap_Available == ll::HmdCap_Available
}
pub fn low_persistance(&self) -> bool {
self.flags & ll::HmdCap_LowPersistence
== ll::HmdCap_LowPersistence
}
pub fn set_low_persistance(&self, flag: bool) -> HmdCapabilities {
HmdCapabilities{flags:
if flag {
self.flags | ll::HmdCap_LowPersistence
} else {
self.flags & !ll::HmdCap_LowPersistence
}
}
}
pub fn latency_test(&self) -> bool {
self.flags & ll::HmdCap_LatencyTest == ll::HmdCap_LatencyTest
}
pub fn set_latency_test(&self, flag: bool) -> HmdCapabilities {
HmdCapabilities{flags:
if flag {
self.flags | ll::HmdCap_LatencyTest
} else {
self.flags & !ll::HmdCap_LatencyTest
}
}
}
pub fn dynamic_prediction(&self) -> bool {
self.flags & ll::HmdCap_DynamicPrediction
== ll::HmdCap_DynamicPrediction
}
pub fn set_dynamic_prediction(&self, flag: bool) -> HmdCapabilities {
HmdCapabilities{flags:
if flag {
self.flags | ll::HmdCap_DynamicPrediction
} else {
self.flags & !ll::HmdCap_DynamicPrediction
}
}
}
pub fn no_vsync(&self) -> bool {
self.flags & ll::HmdCap_NoVSync == ll::HmdCap_NoVSync
}
pub fn set_no_vsync(&self, flag: bool) -> HmdCapabilities {
HmdCapabilities{flags:
if flag {
self.flags | ll::HmdCap_NoVSync
} else {
self.flags & !ll::HmdCap_NoVSync
}
}
}
pub fn no_restore(&self) -> bool {
self.flags & ll::HmdCap_NoRestore == ll::HmdCap_NoRestore
}
}
#[derive(Debug, Copy, Clone)]
pub struct SensorCapabilities {
flags: c_uint
}
impl SensorCapabilities {
pub fn new() -> SensorCapabilities {
SensorCapabilities {
flags: 0
}
}
pub fn orientation(&self) -> bool {
self.flags & ll::SensorCap_Orientation ==
ll::SensorCap_Orientation
}
pub fn yaw_correction(&self) -> bool {
self.flags & ll::SensorCap_YawCorrection ==
ll::SensorCap_YawCorrection
}
pub fn position(&self) -> bool {
self.flags & ll::SensorCap_Position ==
ll::SensorCap_Position
}
pub fn set_orientation(&self, flag: bool) -> SensorCapabilities {
SensorCapabilities {flags:
if flag {
self.flags | ll::SensorCap_Orientation
} else {
self.flags & !ll::SensorCap_Orientation
}
}
}
pub fn set_yaw_correction(&self, flag: bool) -> SensorCapabilities {
SensorCapabilities {flags:
if flag {
self.flags | ll::SensorCap_YawCorrection
} else {
self.flags & !ll::SensorCap_YawCorrection
}
}
}
pub fn set_position(&self, flag: bool) -> SensorCapabilities {
SensorCapabilities {flags:
if flag {
self.flags | ll::SensorCap_Position
} else {
self.flags & !ll::SensorCap_Position
}
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct DistortionCapabilities {
flags: c_uint
}
impl DistortionCapabilities {
pub fn new() -> DistortionCapabilities {
DistortionCapabilities {
flags: 0
}
}
pub fn chromatic(&self) -> bool {
self.flags & ll::DistortionCap_Chromatic ==
ll::DistortionCap_Chromatic
}
pub fn timewarp(&self) -> bool {
self.flags & ll::DistortionCap_TimeWarp ==
ll::DistortionCap_TimeWarp
}
pub fn vignette(&self) -> bool {
self.flags & ll::DistortionCap_Vignette ==
ll::DistortionCap_Vignette
}
pub fn set_chromatic(&self, flag: bool) -> DistortionCapabilities {
DistortionCapabilities {flags:
if flag {
self.flags | ll::DistortionCap_Chromatic
} else {
self.flags & !ll::DistortionCap_Chromatic
}
}
}
pub fn set_timewarp(&self, flag: bool) -> DistortionCapabilities {
DistortionCapabilities {flags:
if flag {
self.flags | ll::DistortionCap_TimeWarp
} else {
self.flags & !ll::DistortionCap_TimeWarp
}
}
}
pub fn set_vignette(&self, flag: bool) -> DistortionCapabilities {
DistortionCapabilities {flags:
if flag {
self.flags | ll::DistortionCap_Vignette
} else {
self.flags & !ll::DistortionCap_Vignette
}
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct Status {
flags: u32
}
impl Status {
pub fn orientation_tracked(&self) -> bool {
self.flags & ll::Status_OrientationTracked ==
ll::Status_OrientationTracked
}
pub fn position_tracked(&self) -> bool {
self.flags & ll::Status_PositionTracked ==
ll::Status_PositionTracked
}
pub fn position_connected(&self) -> bool {
self.flags & ll::Status_PositionConnected ==
ll::Status_PositionConnected
}
pub fn hmd_connected(&self) -> bool {
self.flags & ll::Status_HmdConnected ==
ll::Status_HmdConnected
}
}
fn to_quat(q: ll::Quaternionf) -> Quaternion<f32> {
Quaternion::new(q.w, q.x, q.y, q.z)
}
fn to_vec3(v: ll::Vector3f) -> Vector3<f32> {
Vector3::new(v.x, v.y, v.z)
}
fn to_mat4(ll: ll::Matrix4f) -> Matrix4<f32> {
Matrix4::new(
ll.m11, ll.m21, ll.m31, ll.m41,
ll.m12, ll.m22, ll.m32, ll.m42,
ll.m13, ll.m23, ll.m33, ll.m43,
ll.m14, ll.m24, ll.m34, ll.m44
)
}
fn from_quat(q: Quaternion<f32>) -> ll::Quaternionf {
ll::Quaternionf {
x: q.v.x, y: q.v.y, z: q.v.z, w: q.s
}
}
fn from_vec3(v: Vector3<f32>) -> ll::Vector3f {
ll::Vector3f {
x: v.x, y: v.y, z: v.z
}
}
#[derive(Debug, Copy, Clone)]
pub struct Pose {
pub orientation: Quaternion<f32>,
pub position: Vector3<f32>
}
impl Pose {
fn from_ll(pose: ll::Posef) -> Pose {
Pose {
orientation: to_quat(pose.orientation),
position: to_vec3(pose.position),
}
}
fn to_ll(&self) -> ll::Posef {
ll::Posef {
orientation: from_quat(self.orientation),
position: from_vec3(self.position),
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct PoseState {
pub pose: Pose,
pub angular_velocity: Vector3<f32>,
pub linear_velocity: Vector3<f32>,
pub angular_acceleration: Vector3<f32>,
pub linear_acceleration: Vector3<f32>,
pub time_in_seconds: f64
}
impl PoseState {
fn from_ll(pose: ll::PoseState) -> PoseState {
PoseState {
pose: Pose::from_ll(pose.pose),
angular_velocity: to_vec3(pose.angular_velocity),
linear_velocity: to_vec3(pose.linear_velocity),
angular_acceleration: to_vec3(pose.angular_acceleration),
linear_acceleration: to_vec3(pose.linear_acceleration),
time_in_seconds: pose.time_in_seconds as f64
}
}
}
#[derive(Copy, Clone)]
pub struct SensorState {
pub predicted: PoseState,
pub recorded: PoseState,
pub temperature: f32,
pub status_flags: Status
}
impl SensorState {
fn from_ll(ss: ll::SensorState) -> SensorState {
SensorState {
predicted: PoseState::from_ll(ss.predicted),
recorded: PoseState::from_ll(ss.recorded),
temperature: ss.temperature as f32,
status_flags: Status{flags: ss.status_flags}
}
}
}
#[derive(Debug)]
pub struct SensorDescription {
pub vendor_id: i16,
pub product_id: i16,
pub serial_number: String,
}
impl SensorDescription {
fn from_ll(sd: ll::SensorDesc) -> SensorDescription {
SensorDescription {
vendor_id: sd.vendor_id as i16,
product_id: sd.product_id as i16,
serial_number: unsafe { from_buf((&sd.serial_number[0] as *const i8) as *const u8) }
}
}
}
#[derive(Debug, Copy, Clone)]
pub enum Eye {
Left,
Right
}
impl Eye {
fn from_ll(c: c_uint) -> Eye {
match c {
ll::Eye_Left => Eye::Left,
ll::Eye_Right => Eye::Right,
_ => panic!("Invalid eye type {}", c)
}
}
fn to_ll(&self) -> c_uint {
match *self {
Eye::Left => ll::Eye_Left,
Eye::Right => ll::Eye_Right
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct PerEye<T> {
pub left: T,
pub right: T
}
impl<T> PerEye<T> {
pub fn new(left: T, right: T) -> PerEye<T> {
PerEye {
left: left,
right: right
}
}
pub fn eye<'a>(&'a self, eye: Eye) -> &'a T {
match eye {
Eye::Left => &self.left,
Eye::Right => &self.right
}
}
pub fn map<U, F>(&self, mut f: F) -> PerEye<U> where F: FnMut(Eye, &T) -> U {
PerEye::new(
f(Eye::Left, &self.left),
f(Eye::Right, &self.right)
)
}
pub unsafe fn ptr(&self) -> *const T {
&self.left as *const T
}
pub unsafe fn mut_ptr(&mut self) -> *mut T {
&mut self.left as *mut T
}
}
#[derive(Debug, Copy, Clone)]
pub struct HmdDescriptionEye {
pub default_eye_fov: FovPort,
pub max_eye_fov: FovPort,
}
#[derive(Debug, Clone)]
pub struct HmdDescription {
pub hmd_type: HmdType,
pub product_name: String,
pub manufacture: String,
pub hmd_capabilities: HmdCapabilities,
pub sensor_capabilities: SensorCapabilities,
pub distortion_capabilities: DistortionCapabilities,
pub resolution: ll::Sizei,
pub window_position: ll::Vector2i,
pub eye_fovs: PerEye<HmdDescriptionEye>,
pub eye_render_order: [Eye; 2],
pub display_device_name: String,
pub display_id: c_int
}
fn from_buf(ptr: *const u8) -> String {
use std::ffi::{CString, c_str_to_bytes};
unsafe { CString::from_slice(c_str_to_bytes(&(ptr as *const i8)))
.container_as_str()
.unwrap()
.to_string() }
}
impl HmdDescription {
fn from_ll(sd: ll::HmdDesc) -> HmdDescription {
unsafe {
HmdDescription {
hmd_type: HmdType::from_ll(sd.hmd_type),
product_name: from_buf((sd.product_name as *const i8) as *const u8),
manufacture: from_buf((sd.manufacture as *const i8) as *const u8),
hmd_capabilities: HmdCapabilities{
flags: sd.hmd_capabilities
},
sensor_capabilities: SensorCapabilities{
flags: sd.sensor_capabilities
},
distortion_capabilities: DistortionCapabilities{
flags: sd.distortion_capabilities
},
resolution: sd.resolution,
window_position: sd.window_position,
eye_fovs: PerEye::new(
HmdDescriptionEye {
default_eye_fov: FovPort::from_ll(sd.default_eye_fov[ll::Eye_Left as usize]),
max_eye_fov: FovPort::from_ll(sd.max_eye_fov[ll::Eye_Left as usize])
},
HmdDescriptionEye {
default_eye_fov: FovPort::from_ll(sd.default_eye_fov[ll::Eye_Right as usize]),
max_eye_fov: FovPort::from_ll(sd.max_eye_fov[ll::Eye_Right as usize])
}
),
eye_render_order: [Eye::from_ll(sd.eye_render_order[0]),
Eye::from_ll(sd.eye_render_order[1])],
display_device_name: from_buf((sd.display_device_name as *const i8) as *const u8),
display_id: sd.display_id
}
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct EyeRenderDescriptor {
pub eye: Eye,
pub fov: FovPort,
pub distorted_viewport: ll::Recti,
pub pixels_per_tan_angle_at_center: Vector2<f32>,
pub view_adjust: Vector3<f32>
}
impl EyeRenderDescriptor {
fn from_ll(d: &ll::EyeRenderDesc) -> EyeRenderDescriptor {
EyeRenderDescriptor {
eye: Eye::from_ll(d.eye),
fov: FovPort::from_ll(d.fov),
distorted_viewport: d.distorted_viewport,
pixels_per_tan_angle_at_center:
Vector2::new(d.pixels_per_tan_angle_at_center.x,
d.pixels_per_tan_angle_at_center.y),
view_adjust: Vector3::new(d.view_adjust.x,
d.view_adjust.y,
d.view_adjust.z)
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct RenderGLConfig {
pub size: ll::Sizei,
pub multisample: isize,
pub display: Option<*const c_void>,
pub window: Option<*const c_void>
}
pub trait ToRenderConfig {
fn to_render_config(&self) -> ll::RenderApiConfig;
}
impl ToRenderConfig for RenderGLConfig {
fn to_render_config(&self) -> ll::RenderApiConfig {
ll::RenderApiConfig {
header: ll::RenderApiConfigHeader {
render_api_type: ll::RenderAPI_OpenGL,
rt_size: self.size,
multisample: self.multisample as c_int,
},
display: match self.display { Some(p) => p, None => ptr::null() },
window: match self.window { Some(p) => p, None => ptr::null() },
padd: [ptr::null(), ptr::null(), ptr::null(),
ptr::null(), ptr::null(), ptr::null()]
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct FrameTiming {
pub delta_seconds: f32,
pub this_frame_seconds: f64,
pub timewarp_point_seconds: f64,
pub next_frame_seconds: f64,
pub scanout_midpoint_seconds: f64,
pub eye_scanout_seconds: PerEye<f64>
}
impl FrameTiming {
fn from_ll(old: ll::FrameTiming) -> FrameTiming {
FrameTiming {
delta_seconds: old.delta_seconds,
this_frame_seconds: old.this_frame_seconds,
timewarp_point_seconds: old.timewarp_point_seconds,
next_frame_seconds: old.next_frame_seconds,
scanout_midpoint_seconds: old.scanout_midpoint_seconds,
eye_scanout_seconds: PerEye::new(old.eye_scanout_seconds[ll::Eye_Left as usize],
old.eye_scanout_seconds[ll::Eye_Right as usize])
}
}
}
pub trait ToTexture {
fn to_texture(&self) -> ll::Texture;
}
#[derive(Debug, Copy, Clone)]
pub struct Texture {
pub size: ll::Sizei,
pub viewport: ll::Recti,
pub texture: u32
}
impl Texture {
pub fn new(width: isize,
height: isize,
viewport_x: isize,
viewport_y: isize,
viewport_width: isize,
viewport_height: isize,
opengl_texture: u32) -> Texture {
Texture {
size: ll::Sizei {
x: width as i32,
y: height as i32
},
viewport: ll::Recti {
pos: ll::Vector2i {
x: viewport_x as i32,
y: viewport_y as i32
},
size: ll::Sizei {
x: viewport_width as i32,
y: viewport_height as i32
}
},
texture: opengl_texture
}
}
}
impl ToTexture for Texture {
fn to_texture(&self) -> ll::Texture {
ll::Texture {
header: ll::TextureHeader {
render_api_type: ll::RenderAPI_OpenGL,
size: self.size,
viewport: self.viewport,
},
texture_id: self.texture,
padd: [ptr::null(), ptr::null(), ptr::null(), ptr::null(),
ptr::null(), ptr::null(), ptr::null()]
}
}
}
#[derive(Debug, Copy, Clone)]
pub struct FovPort {
pub up: f32,
pub down: f32,
pub left: f32,
pub right: f32
}
impl FovPort {
fn from_ll(ll: ll::FovPort) -> FovPort {
FovPort {
up: ll.up_tan as f32,
down: ll.down_tan as f32,
left: ll.left_tan as f32,
right: ll.right_tan as f32
}
}
fn to_ll(&self) -> ll::FovPort {
ll::FovPort {
up_tan: self.up as c_float,
down_tan: self.down as c_float,
left_tan: self.left as c_float,
right_tan: self.right as c_float
}
}
pub fn projection(&self, znear: f32, zfar: f32, right_handed: bool) -> Matrix4<f32> {
unsafe {
let mat = ll::ovrMatrix4f_Projection(self.to_ll(), znear, zfar, right_handed);
to_mat4(mat)
}
}
} |
use scanner_proc_macro::insert_scanner;
use std::collections::HashMap;
fn f(x: u64, memo: &mut HashMap<u64, u64>) -> u64 {
if x <= 4 {
return x;
}
if let Some(&ans) = memo.get(&x) {
return ans;
}
let ans = f(x / 2, memo) * f((x + 1) / 2, memo) % 998244353;
memo.insert(x, ans);
return ans;
}
#[insert_scanner]
fn main() {
let x = scan!(u64);
let mut memo = HashMap::new();
let ans = f(x, &mut memo);
println!("{}", ans);
}
|
extern crate crypto;
use crypto::digest::Digest;
use crypto::md5::Md5;
fn main() {
let mut digest = Md5::new();
digest.input_str("signme");
println!("{}", digest.result_str());
}
|
/*
* hurl (https://hurl.dev)
* Copyright (C) 2020 Orange
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
use std::collections::HashMap;
use regex::Regex;
use crate::core::common::{Pos, SourceInfo};
use crate::core::common::Value;
use super::core::{Error, RunnerError};
use super::core::*;
use super::super::core::ast::*;
// equals 10 function return ()
// not equals 10
// countEquals 3 return () => ok PredicateExpectedError
// not countEquals nok
// PredicateValue => Recoverable with a not
// PredicateType
// xpath boolean(//user) equals 10
// ^^^^^^^^^^ Type does not matched with value return by query (generic message for the time-being
// xpath boolean(//user) not equals 10
// ^^^^^^^^^^^^^ Type does not matched with value return by query
// xpath cont(//user) equals 10
// ^^^^^^^^^^^^^ actual value is 9
// xpath cont(//user) greaterThan 10
// ^^^^^^^^^^^^^^ actual value is 9
// Predicate
// 2 evals
// 1) eval template
// 2) eval predicate
// equals template becomes and equals string
impl Predicate {
pub fn eval(self, variables: &HashMap<String, Value>, value: Option<Value>) -> PredicateResult {
let assert_result = self.predicate_func.clone().eval(variables, value)?;
let source_info = SourceInfo {
start: Pos { line: self.space0.source_info.start.line, column: 0 },
end: Pos { line: self.space0.source_info.start.line, column: 0 },
};
if assert_result.type_mismatch {
Err(Error {
source_info,
inner: RunnerError::AssertFailure {
actual: assert_result.actual,
expected: assert_result.expected,
type_mismatch: true,
},
assert: true,
})
} else if self.not && assert_result.success {
Err(Error {
source_info,
inner: RunnerError::AssertFailure {
actual: assert_result.actual,
expected: format!("not {}", assert_result.expected),
type_mismatch: false,
},
assert: true,
})
} else if !self.not && !assert_result.success {
Err(Error {
source_info,
inner: RunnerError::AssertFailure {
actual: assert_result.actual,
expected: assert_result.expected,
type_mismatch: false,
},
assert: true,
})
} else {
Ok(())
}
}
}
struct AssertResult {
pub success: bool,
pub type_mismatch: bool,
pub actual: String,
pub expected: String,
}
impl Value {
pub fn display(self) -> String {
match self {
Value::Bool(v) => format!("bool <{}>", v.to_string()),
Value::Integer(v) => format!("int <{}>", v.to_string()),
Value::String(v) => format!("string <{}>", v),
Value::Float(i, d) => format!("float <{}.{}>", i, d),
Value::List(values) => format!("[{}]", values.iter().map(|v| v.clone().display()).collect::<Vec<String>>().join(", ")),
Value::Nodeset(n) => format!("nodeset of size <{}>", n),
Value::Object(_) => "object".to_string(),
Value::Bytes(values) => format!("byte array of size <{}>", values.len()),
Value::Null => "null".to_string(),
}
}
}
impl PredicateFunc {
fn eval(self, variables: &HashMap<String, Value>, optional_value: Option<Value>) -> Result<AssertResult, Error> {
match optional_value {
None => {
let type_mismatch = if let PredicateFuncValue::Exist {} = self.value {
false
} else {
true
};
Ok(AssertResult {
success: false,
actual: "none".to_string(),
expected: self.expected(variables)?,
type_mismatch,
})
}
Some(value) => self.eval_something(variables, value)
}
}
fn expected(self, variables: &HashMap<String, Value>) -> Result<String, Error> {
match self.value {
PredicateFuncValue::EqualInt { value: expected, .. } => {
let expected = expected.to_string();
Ok(format!("int <{}>", expected))
}
PredicateFuncValue::EqualFloat { value: Float { int: expected_int, decimal: expected_dec, .. }, .. } => {
Ok(format!("float <{}.{}>", expected_int, expected_dec))
}
PredicateFuncValue::EqualNull { .. } => Ok("null".to_string()),
PredicateFuncValue::EqualBool { value: expected, .. } => {
let expected = expected.to_string();
Ok(format!("bool <{}>", expected))
}
PredicateFuncValue::EqualString { value: expected, .. } => {
let expected = expected.eval(variables)?;
Ok(format!("string <{}>", expected))
}
PredicateFuncValue::EqualExpression { value: expected, .. } => {
let expected = expected.eval(variables)?;
eprintln!(">> {:?}", expected);
todo!()
}
PredicateFuncValue::CountEqual { value: expected, .. } => {
let expected = expected.to_string();
Ok(format!("count equals to <{}>", expected))
}
PredicateFuncValue::StartWith { value: expected, .. } => {
let expected = expected.eval(variables)?;
Ok(format!("starts with string <{}>", expected))
}
PredicateFuncValue::Contain { value: expected, .. } => {
let expected = expected.eval(variables)?;
Ok(format!("contains string <{}>", expected))
}
PredicateFuncValue::IncludeString { value: expected, .. } => {
let expected = expected.eval(variables)?;
Ok(format!("includes string <{}>", expected))
}
PredicateFuncValue::IncludeInt { value: expected, .. } => {
Ok(format!("includes int <{}>", expected))
}
PredicateFuncValue::IncludeFloat { value: expected, .. } => {
Ok(format!("includes float <{}>", expected))
}
PredicateFuncValue::IncludeNull { .. } => Ok("includes null".to_string()),
PredicateFuncValue::IncludeBool { value: expected, .. } => {
Ok(format!("includes bool <{}>", expected))
}
PredicateFuncValue::IncludeExpression { value: _expected, .. } => {
todo!()
}
PredicateFuncValue::Match { value: expected, .. } => {
let expected = expected.eval(variables)?;
Ok(format!("matches regex <{}>", expected))
}
PredicateFuncValue::Exist {} => Ok("something".to_string())
}
}
fn eval_something(self, variables: &HashMap<String, Value>, value: Value) -> Result<AssertResult, Error> {
match self.value {
// equals int
PredicateFuncValue::EqualInt { value: expected, .. } => {
assert_values_equal(value, Value::Integer(expected))
}
// equals null
PredicateFuncValue::EqualNull { .. } => {
assert_values_equal(value, Value::Null)
}
// equals bool
PredicateFuncValue::EqualBool { value: expected, .. } => {
assert_values_equal(value, Value::Bool(expected))
}
// equals float
PredicateFuncValue::EqualFloat { value: Float { int, decimal, .. }, .. } => {
assert_values_equal(value, Value::Float(int, decimal))
}
// equals string
PredicateFuncValue::EqualString { value: expected, .. } => {
let expected = expected.eval(variables)?;
assert_values_equal(value, Value::String(expected))
}
// equals expression
PredicateFuncValue::EqualExpression { value: expected, .. } => {
let expected = expected.eval(variables)?;
assert_values_equal(value, expected)
}
// countEquals
PredicateFuncValue::CountEqual { value: expected_value, .. } => {
let actual = value.clone().display();
let expected = format!("count equals to <{}>", expected_value);
match value {
Value::List(values) => Ok(AssertResult {
success: values.len() as u64 == expected_value,
actual,
expected,
type_mismatch: false,
}),
Value::Nodeset(n) => Ok(AssertResult {
success: n as u64 == expected_value,
actual,
expected,
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual,
expected,
type_mismatch: true,
})
}
}
// starts with string
PredicateFuncValue::StartWith { value: expected, .. } => {
let expected = expected.eval(variables)?;
match value.clone() {
Value::String(actual) => Ok(AssertResult {
success: actual.as_str().starts_with(expected.as_str()),
actual: value.display(),
expected: format!("starts with string <{}>", expected),
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual: value.display(),
expected: format!("starts with string <{}>", expected),
type_mismatch: true,
})
}
}
// contains
PredicateFuncValue::Contain { value: expected, .. } => {
let expected = expected.eval(variables)?;
match value.clone() {
Value::String(actual) => Ok(AssertResult {
success: actual.as_str().contains(expected.as_str()),
actual: value.display(),
expected: format!("contains string <{}>", expected),
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual: value.display(),
expected: format!("contains string <{}>", expected),
type_mismatch: true,
})
}
}
// includes String
PredicateFuncValue::IncludeString { value: expected, .. } => {
let expected = expected.eval(variables)?;
assert_include(value,Value::String(expected))
}
// includes int
PredicateFuncValue::IncludeInt { value: expected, .. } => {
assert_include(value,Value::Integer(expected))
}
// includes float
PredicateFuncValue::IncludeFloat { value: Float { int, decimal, .. }, .. } => {
assert_include(value,Value::Float(int, decimal))
}
// includes bool
PredicateFuncValue::IncludeBool { value: expected, .. } => {
assert_include(value,Value::Bool(expected))
}
// includes null
PredicateFuncValue::IncludeNull { .. } => {
assert_include(value,Value::Null)
}
// includes expression
PredicateFuncValue::IncludeExpression { value: expected, .. } => {
let expected = expected.eval(variables)?;
assert_include(value,expected)
}
// match string
PredicateFuncValue::Match { value: expected, .. } => {
let expected = expected.eval(variables)?;
let regex = match Regex::new(expected.as_str()) {
Ok(re) => re,
Err(_) => return Err(Error { source_info: self.source_info.clone(), inner: RunnerError::InvalidRegex(), assert: false })
};
match value.clone() {
Value::String(actual) => Ok(AssertResult {
success: regex.is_match(actual.as_str()),
actual: value.display(),
expected: format!("matches regex <{}>", expected),
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual: value.display(),
expected: format!("matches regex <{}>", expected),
type_mismatch: true,
})
}
}
// exists
PredicateFuncValue::Exist {} => {
match value {
Value::Nodeset(0) => Ok(AssertResult {
success: false,
actual: value.display(),
expected: "something".to_string(),
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: true,
actual: value.display(),
expected: "something".to_string(),
type_mismatch: false,
})
}
}
}
}
}
fn assert_values_equal(actual: Value, expected: Value) -> Result<AssertResult, Error> {
match (actual.clone(), expected.clone()) {
(Value::Null {}, Value::Null {}) => Ok(AssertResult {
success: true,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::Bool(value1), Value::Bool(value2)) => Ok(AssertResult {
success: value1 == value2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::Integer(value1), Value::Integer(value2)) => Ok(AssertResult {
success: value1 == value2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::Float(int1,decimal), Value::Integer(int2)) => Ok(AssertResult {
success: int1 == int2 && decimal == 0,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::Float(i1, d1), Value::Float(i2, d2)) => Ok(AssertResult {
success: i1 == i2 && d1 == d2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::String(value1), Value::String(value2)) => Ok(AssertResult {
success: value1 == value2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::List(value1), Value::List(value2)) => Ok(AssertResult {
success: value1 == value2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
(Value::Bytes(value1), Value::Bytes(value2)) => Ok(AssertResult {
success: value1 == value2,
actual: actual.display(),
expected: expected.display(),
type_mismatch: false,
}),
_ => Ok(AssertResult {
success: false,
actual: actual.display(),
expected: expected.display(),
type_mismatch: true,
})
}
}
fn assert_include(value: Value, element: Value) -> Result<AssertResult, Error> {
let expected = format!("includes {}", element.clone().display());
match value.clone() {
Value::List(values) => {
let mut success = false;
for v in values {
let result = assert_values_equal(v, element.clone())?;
if result.success {
success = true;
break;
}
}
Ok(AssertResult {
success,
actual: value.display(),
expected,
type_mismatch: false,
})
}
_ => Ok(AssertResult {
success: false,
actual: value.display(),
expected,
type_mismatch: true,
})
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_invalid_xpath() {}
#[test]
fn test_predicate() {
// not equals 10 with value 1 OK
// not equals 10 with value 10 ValueError
// not equals 10 with value true TypeError
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(1, 1, 0, 0),
};
let predicate = Predicate {
not: true,
space0: whitespace.clone(),
predicate_func: PredicateFunc {
value: PredicateFuncValue::EqualInt { space0: whitespace, value: 10 },
source_info: SourceInfo::init(1, 11, 1, 12),
},
};
let error = predicate.clone().eval(&variables, Some(Value::Bool(true))).err().unwrap();
assert_eq!(error.inner, RunnerError::AssertFailure {
actual: "bool <true>".to_string(),
expected: "int <10>".to_string(),
type_mismatch: true,
});
assert_eq!(error.source_info, SourceInfo::init(1, 0, 1, 0));
let error = predicate.clone().eval(&variables, Some(Value::Integer(10))).err().unwrap();
assert_eq!(error.inner, RunnerError::AssertFailure {
actual: "int <10>".to_string(),
expected: "not int <10>".to_string(),
type_mismatch: false,
});
assert_eq!(error.source_info, SourceInfo::init(1, 0, 1, 0));
assert_eq!(predicate.eval(&variables, Some(Value::Integer(1))).unwrap(), ());
}
#[test]
fn test_predicate_type_mismatch() {
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualInt { space0: whitespace, value: 10 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval(&variables, Some(Value::Bool(true))).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, true);
assert_eq!(assert_result.actual.as_str(), "bool <true>");
assert_eq!(assert_result.expected.as_str(), "int <10>");
}
#[test]
fn test_predicate_value_error() {
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualInt { space0: whitespace.clone(), value: 10 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Integer(1)).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "int <1>");
assert_eq!(assert_result.expected.as_str(), "int <10>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualBool { space0: whitespace.clone(), value: true },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Bool(false)).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "bool <false>");
assert_eq!(assert_result.expected.as_str(), "bool <true>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualFloat { space0: whitespace, value: Float { int: 1, decimal: 200_000_000_000_000_000, decimal_digits: 0 } },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Float(1, 1)).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "float <1.1>");
assert_eq!(assert_result.expected.as_str(), "float <1.200000000000000000>");
}
#[test]
fn test_predicate_value_equals() {
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualInt { space0: whitespace.clone(), value: 1 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Integer(1)).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "int <1>");
assert_eq!(assert_result.expected.as_str(), "int <1>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualBool { space0: whitespace.clone(), value: false },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Bool(false)).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "bool <false>");
assert_eq!(assert_result.expected.as_str(), "bool <false>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualFloat { space0: whitespace.clone(), value: Float { int: 1, decimal: 1, decimal_digits: 1 } },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Float(1, 1)).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "float <1.1>");
assert_eq!(assert_result.expected.as_str(), "float <1.1>");
// a float can be equals to an int (but the reverse)
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualInt { space0: whitespace, value: 1 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Float(1, 0)).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "float <1.0>");
assert_eq!(assert_result.expected.as_str(), "int <1>");
}
#[test]
fn test_predicate_value_equals_string() {
let mut variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let template = Template {
quotes: true,
elements: vec![
TemplateElement::Expression(Expr {
space0: Whitespace { value: "".to_string(), source_info: SourceInfo::init(1, 11, 1, 11) },
variable: Variable { name: String::from("base_url"), source_info: SourceInfo::init(1, 11, 1, 19) },
space1: Whitespace { value: "".to_string(), source_info: SourceInfo::init(1, 19, 1, 19) },
})],
source_info: SourceInfo::init(1, 1, 1, 1),
};
let error = PredicateFunc {
value: PredicateFuncValue::EqualString { space0: whitespace.clone(), value: template.clone() },
source_info: SourceInfo::init(1, 1, 1, 21),
}.eval_something(&variables, Value::String(String::from("http://localhost:8000"))).err().unwrap();
assert_eq!(error.inner, RunnerError::TemplateVariableNotDefined { name: String::from("base_url") });
assert_eq!(error.source_info, SourceInfo::init(1, 11, 1, 19));
variables.insert(String::from("base_url"), Value::String(String::from("http://localhost:8000")));
let assert_result = PredicateFunc {
value: PredicateFuncValue::EqualString { space0: whitespace, value: template },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::String(String::from("http://localhost:8000"))).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "string <http://localhost:8000>");
assert_eq!(assert_result.expected.as_str(), "string <http://localhost:8000>");
}
#[test]
fn test_predicate_count_equals_error() {
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let assert_result = PredicateFunc {
value: PredicateFuncValue::CountEqual { space0: whitespace.clone(), value: 10 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Bool(true)).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, true);
assert_eq!(assert_result.actual.as_str(), "bool <true>");
assert_eq!(assert_result.expected.as_str(), "count equals to <10>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::CountEqual { space0: whitespace.clone(), value: 1 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::List(vec![])).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "[]");
assert_eq!(assert_result.expected.as_str(), "count equals to <1>");
let assert_result = PredicateFunc {
source_info: SourceInfo::init(0, 0, 0, 0),
value: PredicateFuncValue::CountEqual { space0: whitespace, value: 1 },
}.eval_something(&variables, Value::Nodeset(3)).unwrap();
assert_eq!(assert_result.success, false);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "nodeset of size <3>");
assert_eq!(assert_result.expected.as_str(), "count equals to <1>");
}
#[test]
fn test_predicate_count_equals() {
let variables = HashMap::new();
let whitespace = Whitespace {
value: String::from(" "),
source_info: SourceInfo::init(0, 0, 0, 0),
};
let assert_result = PredicateFunc {
value: PredicateFuncValue::CountEqual { space0: whitespace.clone(), value: 1 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::List(vec![Value::Integer(1)])).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "[int <1>]");
assert_eq!(assert_result.expected.as_str(), "count equals to <1>");
let assert_result = PredicateFunc {
value: PredicateFuncValue::CountEqual { space0: whitespace, value: 1 },
source_info: SourceInfo::init(0, 0, 0, 0),
}.eval_something(&variables, Value::Nodeset(1)).unwrap();
assert_eq!(assert_result.success, true);
assert_eq!(assert_result.type_mismatch, false);
assert_eq!(assert_result.actual.as_str(), "nodeset of size <1>");
assert_eq!(assert_result.expected.as_str(), "count equals to <1>");
}
}
|
use crate::board::*;
const MAX_DEPTH: u32 = 4;
pub struct Move {
pub start: (usize, usize),
pub end: (usize, usize),
value: i32,
}
impl PartialEq for Move {
fn eq(&self, mov: &Move) -> bool {
self.value == mov.value
}
}
impl PartialOrd for Move {
fn partial_cmp(&self, other: &Move) -> Option<std::cmp::Ordering> {
self.value.partial_cmp(&other.value)
}
}
impl Eq for Move {}
impl Ord for Move {
fn cmp(&self, other: &Move) -> std::cmp::Ordering {
self.value.cmp(&other.value)
}
}
impl Move {
pub fn new(x0: usize, y0: usize, x1: usize, y1: usize, points: i32) -> Self {
Move {
start: (x0, y0),
end: (x1, y1),
value: points,
}
}
pub fn max() -> Self {
Move {
start: (0, 0),
end: (0, 0),
value: i32::MAX,
}
}
pub fn min() -> Self {
Move {
start: (0, 0),
end: (0, 0),
value: i32::MIN,
}
}
}
pub fn points(piece: PieceType) -> i32 {
match piece {
PieceType::Pawn => 1,
PieceType::Knight => 3,
PieceType::Bishop => 3,
PieceType::Rook => 5,
PieceType::Queen => 9,
PieceType::King => 900,
}
}
pub fn maximize(board: ChessBoard, depth: u32) -> Move {
let mut best_move = Move::min();
/* super::log(&format!("{:?}",board.pieces));
super::log(&board.to_string()); */
for piece in &board.pieces {
if let ChessPiece {
position: Some((x, y)),
piece_color: PieceColor::Black,
..
} = piece
{
for (movx, movy) in board.get_possible_moves(*x, *y) {
let value: i32 = if let Some(p) = board.get(movx, movy) {
points(p.piece_type)
} else {
0
};
if depth == MAX_DEPTH {
best_move = std::cmp::max(best_move, Move::new(*x, *y, movx, movy, value))
} else {
let mut cloned = board.clone();
cloned.make_move((*x, *y), (movx, movy));
let seq = minimize(cloned, depth + 1);
best_move =
std::cmp::max(best_move, Move::new(*x, *y, movx, movy, seq.value + value))
}
}
}
}
best_move
}
pub fn minimize(board: ChessBoard, depth: u32) -> Move {
let mut best_move = Move::max();
/* super::log(&format!("{:?}",board.pieces));
super::log(&board.to_string()); */
for piece in &board.pieces {
if let ChessPiece {
position: Some((x, y)),
piece_color: PieceColor::White,
..
} = piece
{
for (movx, movy) in board.get_possible_moves(*x, *y) {
let value: i32 = if let Some(p) = board.get(movx, movy) {
-points(p.piece_type)
} else {
0
};
if depth == MAX_DEPTH {
best_move = std::cmp::min(best_move, Move::new(*x, *y, movx, movy, value))
} else {
let mut cloned = board.clone();
cloned.make_move((*x, *y), (movx, movy));
let seq = maximize(cloned, depth + 1);
best_move =
std::cmp::min(best_move, Move::new(*x, *y, movx, movy, seq.value + value))
}
}
}
}
best_move
}
|
//! Macros for creating compile-time EOSIO names and symbols.
//!
//! Creating EOSIO names:
//!
//! ```
//! use eosio_macros::n;
//! assert_eq!(n!("test"), 14_605_613_396_213_628_928);
//! assert_eq!(n!("1234"), 614_248_767_926_829_056);
//! assert_eq!(n!("123451234512"), 614_251_535_012_020_768);
//! assert_eq!(n!("eosio.token"), 6_138_663_591_592_764_928);
//! ```
//!
//! Creating EOSIO symbols:
//!
//! ```
//! use eosio_macros::s;
//! assert_eq!(s!(4, "EOS"), 1162826500);
//! ```
#![no_std]
#![allow(clippy::missing_docs_in_private_items)]
use proc_macro_hack::proc_macro_hack;
/// Macro for converting EOSIO names into `u64` representations at compile time.
///
/// # Examples
///
/// ```
/// use eosio_macros::n;
/// assert_eq!(n!("test"), 14_605_613_396_213_628_928);
/// assert_eq!(n!("1234"), 614_248_767_926_829_056);
/// assert_eq!(n!("123451234512"), 614_251_535_012_020_768);
/// assert_eq!(n!("eosio.token"), 6_138_663_591_592_764_928);
/// ```
#[proc_macro_hack]
pub use eosio_macros_internal::n;
/// Macro for converting EOSIO symbols into `u64` representations at compile time.
///
/// # Examples
///
/// ```
/// use eosio_macros::s;
/// assert_eq!(s!(4, "EOS"), 1162826500);
/// ```
#[proc_macro_hack]
pub use eosio_macros_internal::s;
pub use eosio_macros_internal::{action, table, NumBytes, Read, Table, Write};
|
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
// Regression test for #36381. The monomorphization collector was asserting that
// there are no projection types, but the `<&str as
// StreamOnce>::Position` projection contained a late-bound region,
// and we don't currently normalize in that case until the function is
// actually invoked.
pub trait StreamOnce {
type Position;
}
impl<'a> StreamOnce for &'a str {
type Position = usize;
}
pub fn parser<F>(_: F) {
}
fn follow(_: &str) -> <&str as StreamOnce>::Position {
panic!()
}
fn main() {
parser(follow);
}
|
extern crate rand;
use rand::distributions::{IndependentSample, Range};
use std::collections::HashMap;
pub struct LSystem {
alphabet: Vec<char>,
constants: Vec<char>,
start: String,
rules: HashMap<char, String>,
}
impl LSystem {
/// Some guarantees of a LSystem:
/// 1. Every char in start is in alphabet
/// 2. Given a rule X -> Y, X and Y are in alphabet
/// 3. Each char in alphabet has a rule that maps it to something else
/// -> by default a char maps to itself, but this can be overwriten with
/// the `push` method
/// See https://en.wikipedia.org/wiki/L-system for more details
pub fn new(start: String) -> LSystem {
// push chars in start to alphabet
// and make them map to themselves in a rule
let mut alphabet: Vec<char> = Vec::new();
let mut rules: HashMap<char, String> = HashMap::new();
for c in start.chars() {
if !alphabet.contains(&c) {
alphabet.push(c);
rules.insert(c, c.to_string());
}
}
LSystem {
alphabet: alphabet,
constants: Vec::new(),
start: start,
rules: rules,
}
}
pub fn to_string(&self) -> String {
self.start.clone()
}
/// Iterate to the next LSystem string, following all rules
pub fn next(&mut self) -> LSystem {
let mut next = String::from("");
for c in self.start.chars() {
next.push_str(self.get(c));
}
LSystem {
alphabet: self.alphabet.clone(),
constants: self.constants.clone(),
start: next,
rules: self.rules.clone(),
}
}
/// Randomly selects a character in the start string to apply
/// the rules to, then returns an LSystem with the new string
pub fn next_rand(&mut self) -> LSystem {
let mut next = String::from("");
let mut index = 0;
if self.start.len() > 1 {
let between = Range::new(0, self.start.len() - 1);
let mut rng = rand::thread_rng();
index = between.ind_sample(&mut rng);
}
for (i, c) in self.start.chars().enumerate() {
if i != index {
next.push_str(&c.to_string());
} else {
next.push_str(self.get(c));
}
}
LSystem {
alphabet: self.alphabet.clone(),
constants: self.constants.clone(),
start: next,
rules: self.rules.clone(),
}
}
/// Add a character to the alphabet with the default 'identity rule'
pub fn add(&mut self, c: char) {
if !self.alphabet.contains(&c) {
self.alphabet.push(c);
self.rules.insert(c, c.to_string());
}
}
/// Helper function for push
fn overwrite_rule(&mut self, key: &char, value: &String) {
*self.rules.get_mut(key).unwrap() = value.to_owned();
}
/// Add a constant to the LSystem
/// Constants always map to themselves and cannot be changed
pub fn add_constant(&mut self, c: char) {
self.add(c);
self.constants.push(c);
}
/// Add a new rule to the LSystem
/// If the values in the rule do not exist, they are added
pub fn push(&mut self, rule: HashMap<char, String>) {
for (key, value) in &rule {
// Make sure key is not a constant
if !self.constants.contains(&key) {
for c in value.chars() {
self.add(c);
}
if !self.rules.contains_key(key) {
self.add(*key);
}
self.overwrite_rule(key, value);
}
}
}
/// Returns the rule for which key maps to
pub fn get(&self, key: char) -> &String {
&self.rules[&key]
}
}
#[cfg(test)]
mod tests {
use std::collections::HashMap;
use LSystem;
#[test]
fn test_new_should_have_correct_alphabet() {
let lsys: LSystem = LSystem::new("AB".to_string());
assert!(lsys.alphabet.contains(&'A'));
}
#[test]
fn test_new_should_have_correct_start() {
let lsys: LSystem = LSystem::new("AB".to_string());
assert_eq!(lsys.start, "AB");
}
#[test]
fn test_new_should_not_have_duplicate_alphabet_chars() {
let lsys: LSystem = LSystem::new("AA".to_string());
assert_eq!(lsys.alphabet.len(), 1);
}
#[test]
fn test_new_should_add_default_rules() {
let lsys: LSystem = LSystem::new("A".to_string());
assert_eq!(*lsys.get('A'), "A");
}
#[test]
fn test_add_should_add_to_alphabet() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add('B');
assert!(lsys.alphabet.contains(&'B'));
}
#[test]
fn test_add_should_add_default_rule() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add('B');
assert_eq!(*lsys.get('B'), "B");
}
#[test]
fn test_add_constant_should_add_to_constants() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add_constant('B');
assert!(lsys.constants.contains(&'B'));
}
#[test]
fn test_add_constant_should_add_to_alphabet() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add_constant('B');
assert!(lsys.alphabet.contains(&'B'));
}
#[test]
fn test_add_constant_should_add_default_rule() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add_constant('B');
assert_eq!(*lsys.get('B'), "B");
}
#[test]
fn test_push_should_overwrite_existing_rule() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
assert_eq!(*lsys.get('A'), "B");
}
#[test]
fn test_push_should_add_to_alphabet() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
assert!(lsys.alphabet.contains(&'B'));
}
#[test]
fn test_push_should_add_default_rules_for_new_chars() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
assert_eq!(*lsys.get('B'), "B");
}
#[test]
fn test_push_should_not_overwrite_constants() {
let mut lsys: LSystem = LSystem::new("A".to_string());
lsys.add_constant('A');
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
assert_eq!(*lsys.get('A'), "A");
}
#[test]
fn test_push_should_work_with_multiple_rules() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "AB".to_string());
rule.insert('B', "A".to_string());
lsys.push(rule);
assert_eq!(*lsys.get('B'), "A");
assert_eq!(*lsys.get('A'), "AB");
}
#[test]
fn test_next_with_simple_rules_should_have_correct_start() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
let next: LSystem = lsys.next();
assert_eq!(next.start, "B");
}
#[test]
fn test_next_with_complex_rules_should_have_correct_start() {
let mut lsys: LSystem = LSystem::new("AB".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "AB".to_string());
rule.insert('B', "A".to_string());
lsys.push(rule);
let next: LSystem = lsys.next();
assert_eq!(next.start, "ABA");
}
#[test]
fn test_next_should_work_in_chains() {
let mut lsys: LSystem = LSystem::new("AB".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "AB".to_string());
rule.insert('B', "A".to_string());
lsys.push(rule);
let next: LSystem = lsys.next().next();
assert_eq!(next.start, "ABAAB");
}
#[test]
fn test_next_rand_should_apply_rule_once() {
let mut lsys: LSystem = LSystem::new("AA".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
let next: LSystem = lsys.next_rand();
assert!(next.start == "AB" || next.start == "BA");
}
#[test]
fn test_next_rand_should_work_with_single_char_start() {
let mut lsys: LSystem = LSystem::new("A".to_string());
let mut rule: HashMap<char, String> = HashMap::new();
rule.insert('A', "B".to_string());
lsys.push(rule);
let next: LSystem = lsys.next_rand();
assert_eq!(next.start, "B");
}
#[test]
fn test_to_string_should_return_start_string() {
let lsys: LSystem = LSystem::new("AB".to_string());
assert_eq!(lsys.to_string(), "AB");
}
}
|
/*
Copyright 2020 Timo Saarinen
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 super::*;
// -------------------------------------------------------------------------------------------------
/// Type 17: DGNSS Broadcast Binary Message.
#[derive(Clone, Debug, PartialEq)]
pub struct DgnssBroadcastBinaryMessage {
/// True if the data is about own vessel, false if about other.
pub own_vessel: bool,
/// AIS station type.
pub station: Station,
/// Source MMSI (30 bits)
pub mmsi: u32,
/// Latitude (17 bits)
pub latitude: Option<f64>,
/// Longitude (18 bits)
pub longitude: Option<f64>,
/// Payload (80-815 bits). Note that it appears to be tied to the now obsolete RTCM2 protocol.
pub payload: BitVec,
}
// -------------------------------------------------------------------------------------------------
/// AIS VDM/VDO type 17: DGNSS Broadcast Binary Message
pub(crate) fn handle(
bv: &BitVec,
station: Station,
own_vessel: bool,
) -> Result<ParsedMessage, ParseError> {
Ok(ParsedMessage::DgnssBroadcastBinaryMessage(
DgnssBroadcastBinaryMessage {
own_vessel: { own_vessel },
station: { station },
mmsi: { pick_u64(&bv, 8, 30) as u32 },
latitude: {
let lat_raw = pick_i64(&bv, 58, 17) as i32;
if lat_raw != 0xd548 {
Some((lat_raw as f64) / 600.0)
} else {
None
}
},
longitude: {
let lon_raw = pick_i64(&bv, 40, 18) as i32;
if lon_raw != 0x1a838 {
Some((lon_raw as f64) / 600.0)
} else {
None
}
},
payload: bv.iter().skip(80).collect(),
},
))
}
// -------------------------------------------------------------------------------------------------
#[cfg(test)]
mod test {
use super::*;
#[test]
fn test_parse_vdm_type17() {
let mut p = NmeaParser::new();
match p.parse_sentence(
"!AIVDM,2,1,5,A,A02VqLPA4I6C07h5Ed1h<OrsuBTTwS?r:C?w`?la<gno1RTRwSP9:BcurA8a,0*3A",
) {
Ok(ps) => match ps {
ParsedMessage::Incomplete => {
assert!(true);
}
_ => {
assert!(false);
}
},
Err(e) => {
assert_eq!(e.to_string(), "OK");
}
}
match p.parse_sentence("!AIVDM,2,2,5,A,:Oko02TSwu8<:Jbb,0*11") {
Ok(ps) => {
match ps {
// The expected result
ParsedMessage::DgnssBroadcastBinaryMessage(i) => {
assert_eq!(i.mmsi, 2734450);
assert::close(i.latitude.unwrap_or(0.0), 59.987, 0.001);
assert::close(i.longitude.unwrap_or(0.0), 29.130, 0.001);
assert_eq!(i.payload.len(), 376);
}
ParsedMessage::Incomplete => {
assert!(false);
}
_ => {
assert!(false);
}
}
}
Err(e) => {
assert_eq!(e.to_string(), "OK");
}
}
}
}
|
#[macro_use]
#[derive(Clone, Copy)]
pub enum Key {
Key1, Key2, Key3, Key4, Key5, Key6, Key7, Key8, Key9, Key0, A, B, C, D, E, F, G, H, I, J, K, L, M,
N, O, P, Q, R, S, T, U, V, W, X, Y, Z, Escape, F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12,
F13, F14, F15, Snapshot, Scroll, Pause, Insert, Home, Delete, End, PageDown, PageUp, Left, Up, Right,
Down, Back, Return, Space, Compose, Caret, Numlock, Numpad0, Numpad1, Numpad2, Numpad3, Numpad4, Numpad5,
Numpad6, Numpad7, Numpad8, Numpad9, AbntC1, AbntC2, Add, Apostrophe, Apps, At, Ax, Backslash, Calculator,
Capital, Colon, Comma, Convert, Decimal, Divide, Equals, Grave, Kana, Kanji, LAlt, LBracket, LControl,
LShift, LWin, Mail, MediaSelect, MediaStop, Minus, Multiply, Mute, MyComputer, NavigateForward,
NavigateBackward, NextTrack, NoConvert, NumpadComma, NumpadEnter, NumpadEquals, OEM102, Period, PlayPause,
Power, PrevTrack, RAlt, RBracket, RControl, RShift, RWin, Semicolon, Slash, Sleep, Stop, Subtract,
Sysrq, Tab, Underline, Unlabeled, VolumeDown, VolumeUp, Wake, WebBack, WebFavorites, WebForward, WebHome,
WebRefresh, WebSearch, WebStop, Yen,
}
pub enum Widget {
#[derive(Default)]
Label{
text:String,
size:f32,
xy:(f32, f32),
rgba:(f32, f32, f32, f32),
},
#[derive(Default)]
Input{
focused: bool,
text:String,
size:f32,
xy:(f32, f32),
wh:(f32, f32),
rgba:(f32, f32, f32, f32),
},
Button{
hovered: bool,
pressed: bool,
text:String,
size:f32,
xy:(f32, f32),
wh:(f32, f32),
rgba:(f32, f32, f32, f32),
},
LoadingSpinner{
active:bool,
xy:(f32, f32),
radius:f32,
angle:f32,
rgba:(f32, f32, f32, f32),
},
}
use super::Drawer;
use std::time::{SystemTime, UNIX_EPOCH};
impl Widget{
pub fn draw(&self, drawer:&mut Drawer){
match self {
Widget::Label{text, size, xy, rgba} => {
drawer.set_font_style(*size);
drawer.set_fill_style(*rgba);
let (w, h) = drawer.rendered_text_wh(text);
let (x, y) = *xy;
drawer.draw_text(text, (x-w*0.5,y-h*0.5));
}
Widget::Input{focused, text, size, xy, wh, rgba} => {
let (x, y) = (xy.0-wh.0*0.5, xy.1-wh.1*0.5);
drawer.set_font_style(*size);
drawer.set_fill_style(*rgba);
drawer.draw_rect((x, y+wh.1, wh.0, 2.));
if *focused {
drawer.draw_text(text, (x, y));
let (w, h) = drawer.rendered_text_wh(text);
drawer.draw_rect((x+w, y, 1., h));
}
else {
drawer.draw_text(text, (x, y));
}
}
Widget::Button{hovered, pressed, text, size, xy, wh, rgba} => {
let (x, y) = (xy.0-wh.0*0.5, xy.1-wh.1*0.5);
drawer.set_font_style(*size);
drawer.set_fill_style(*rgba);
let (w, h) = drawer.rendered_text_wh(text);
if *pressed {
drawer.draw_rect((x, y, wh.0, 1.));
drawer.draw_rect((x, y, 1., wh.1));
drawer.draw_rect((x, y+wh.1, wh.0, 1.));
drawer.draw_rect((x+wh.0, y, 1., wh.1));
let (x, y) = (x+(wh.0-w)*0.5, y+(wh.1-h)*0.5);
drawer.draw_text(text, (x, y));
}
else {
let (x, y) = (xy.0-wh.0*0.5-2., xy.1-wh.1*0.5-2.);
drawer.draw_rect((x, y, wh.0, 1.));
drawer.draw_rect((x, y, 1., wh.1));
drawer.draw_rect((x, y+wh.1, wh.0, 1.));
drawer.draw_rect((x+wh.0, y, 1., wh.1));
drawer.draw_rect((x+3., y+wh.1, wh.0, 3.));
drawer.draw_rect((x+wh.0, y+3., 3., wh.1));
let (x, y) = (x+(wh.0-w)*0.5, y+(wh.1-h)*0.5);
drawer.draw_text(text, (x, y));
}
}
Widget::LoadingSpinner{active, xy, radius, angle, rgba} => {
if !*active { return; }
const MAX_ANGLE:f32 = std::f32::consts::PI*1.;
let (x, y) = (xy.0, xy.1);
let (cx, cy) = (x+angle.sin()**radius, y-angle.cos()**radius);
drawer.draw_rect((cx, cy, 3., 3.));
}
_ => {}
}
}
pub fn update(&mut self){
match self {
Widget::LoadingSpinner{active, angle, ..} => {
if !*active { return; }
const MAX_ANGLE:f32 = std::f32::consts::PI*100.;
*angle += (*angle).min(MAX_ANGLE-*angle).max(0.1)*0.08;
if *angle > MAX_ANGLE { *angle -= MAX_ANGLE; }
}
_ => {
}
}
}
pub fn mouse_move(&mut self, xy:(f32,f32)){
let (mx, my) = xy;
match self {
Widget::Button{ref mut hovered, pressed, xy: (x, y), wh: (w,h), ..}=> {
if *x-(*w)*0.5<mx && mx<*x+(*w)*0.5 && *y-(*h)*0.5<my && my<*y+(*h)*0.5 {
*hovered = true;
}
else {
*hovered = false;
*pressed = false;
}
}
_ => {}
}
}
pub fn mouse_down(&mut self, xy:(f32,f32)){
let (mx, my) = xy;
match self {
Widget::Input{ref mut focused, text:_, size:_, xy: (x, y), wh: (w,h), ..}=> {
if *x-(*w)*0.5<mx && mx<*x+(*w)*0.5 && *y-(*h)*0.5<my && my<*y+(*h)*0.5 {
*focused = true;
}
else {
*focused = false;
}
}
Widget::Button{ref mut hovered, pressed, xy: (x, y), wh: (w,h), ..}=> {
if *x-(*w)*0.5<mx && mx<*x+(*w)*0.5 && *y-(*h)*0.5<my && my<*y+(*h)*0.5 {
*pressed = true;
}
}
_ => {}
}
}
pub fn mouse_up(&mut self, xy:(f32,f32)){
let (mx, my) = xy;
match self {
Widget::Button{ref mut hovered, pressed, xy: (x, y), wh: (w,h), ..}=> {
if *x-(*w)*0.5<mx && mx<*x+(*w)*0.5 && *y-(*h)*0.5<my && my<*y+(*h)*0.5 {
*pressed = false;
}
}
_ => {}
}
}
pub fn key_down(&mut self, key: Key) {
match key {
Key::Back => {
match self {
Widget::Input{ref mut focused, text, size:_, xy: (x, y), wh: (w,h), ..}=> {
if *focused {
text.pop();
}
}
_ => {}
}
}
_ => {}
}
}
pub fn key_input(&mut self, ch: char) {
match self {
Widget::Input{ref mut focused, text, size:_, xy: (x, y), wh: (w,h), ..}=> {
if *focused {
text.push(ch);
}
}
_ => {}
}
}
}
|
// 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.
mod config;
mod validators;
use {
config::{Config, ConfigContext},
failure::{format_err, Error},
fidl::endpoints::{create_proxy, Request, RequestStream, ServerEnd, ServiceMarker},
fidl_fuchsia_boot::FactoryItemsMarker,
fidl_fuchsia_factory::{
CastCredentialsFactoryStoreProviderMarker, CastCredentialsFactoryStoreProviderRequest,
CastCredentialsFactoryStoreProviderRequestStream, MiscFactoryStoreProviderMarker,
MiscFactoryStoreProviderRequest, MiscFactoryStoreProviderRequestStream,
PlayReadyFactoryStoreProviderMarker, PlayReadyFactoryStoreProviderRequest,
PlayReadyFactoryStoreProviderRequestStream, WidevineFactoryStoreProviderMarker,
WidevineFactoryStoreProviderRequest, WidevineFactoryStoreProviderRequestStream,
},
fidl_fuchsia_io::{
DirectoryMarker, DirectoryProxy, NodeMarker, MODE_TYPE_DIRECTORY, OPEN_RIGHT_READABLE,
},
fuchsia_async::{self as fasync},
fuchsia_bootfs::BootfsParser,
fuchsia_component::server::ServiceFs,
fuchsia_syslog as syslog,
fuchsia_vfs_pseudo_fs::{
directory::{self, entry::DirectoryEntry},
file::simple::read_only,
},
fuchsia_zircon as zx,
futures::{lock::Mutex, prelude::*, TryStreamExt},
std::{collections::HashMap, iter, path::PathBuf, sync::Arc},
};
const CONCURRENT_LIMIT: usize = 10_000;
const DEFAULT_BOOTFS_FACTORY_ITEM_EXTRA: u32 = 0;
enum IncomingServices {
CastCredentialsFactoryStoreProvider(CastCredentialsFactoryStoreProviderRequestStream),
MiscFactoryStoreProvider(MiscFactoryStoreProviderRequestStream),
PlayReadyFactoryStoreProvider(PlayReadyFactoryStoreProviderRequestStream),
WidevineFactoryStoreProvider(WidevineFactoryStoreProviderRequestStream),
}
// TODO(mbrunson): Use implementation from fuchsia_vfs_pseudo_fs when it becomes available:
// https://fuchsia-review.googlesource.com/c/fuchsia/+/305595
/// A "node" within a potential directory tree.
///
/// Unlike the pseudo directory types in the fuchsia-vfs library which only allow adding of direct
/// child directory entries, `DirectoryTreeBuilder::Directory` allows adding files using the full
/// file path, creating extra `DirectoryTreeBuilder` instances as necessary to allow successful
/// conversion of the entire directory tree to a `DirectoryEntry` implementation.
///
/// The `DirectoryTreeBuilder::File` type represents a pseudo file. It can only be a leaf in the
/// directory tree and store file contents unlike `DirectoryTreeBuilder::Directory`.
enum DirectoryTreeBuilder {
Directory(HashMap<String, DirectoryTreeBuilder>),
File(Vec<u8>),
}
impl DirectoryTreeBuilder {
pub fn empty_dir() -> Self {
DirectoryTreeBuilder::Directory(HashMap::new())
}
/// Adds a file to the directory tree.
///
/// An error is returned if either of the following occur:
/// * This function is called on a `DirectoryTreeBuilder::File` enum.
/// * A file already exists at the given `path`.
pub fn add_file(&mut self, path: &[&str], content: Vec<u8>) -> Result<(), Error> {
self.add_file_impl(path, content, &mut PathBuf::from(""))
}
fn add_file_impl(
&mut self,
path: &[&str],
content: Vec<u8>,
mut full_path: &mut PathBuf,
) -> Result<(), Error> {
match self {
DirectoryTreeBuilder::File(_) => Err(format_err!(
"Cannot add a file within a File: path={}, name={}, content={:X?}",
full_path.to_string_lossy(),
path[0],
content
)),
DirectoryTreeBuilder::Directory(children) => {
let name = path[0].to_string();
let nested = &path[1..];
full_path.push(&name);
if nested.is_empty() {
if children.insert(name, DirectoryTreeBuilder::File(content)).is_some() {
Err(format_err!("Duplicate entry at {}", full_path.to_string_lossy()))
} else {
Ok(())
}
} else {
match children.get_mut(&name) {
Some(entry) => entry.add_file_impl(nested, content, &mut full_path),
None => {
let mut entry = DirectoryTreeBuilder::empty_dir();
entry.add_file_impl(nested, content, &mut full_path)?;
children.insert(name, entry);
Ok(())
}
}
}
}
}
}
/// Converts this `DirectoryTreeBuilder` into a `DirectoryEntry`.
///
/// On successful creation of the `DirectoryEntry`, any payloads owned by this node or its
/// children are moved into closures called by an associated pseudo file implementation.
///
/// Errors are propogated from `Controllable::add_boxed_entry()` but are converted to
/// `zx::Status` before being wrapped in an `Error`.
pub fn build<'a>(self) -> Result<Box<dyn DirectoryEntry>, Error> {
self.build_impl(&mut PathBuf::from(""))
}
fn build_impl<'a>(self, mut full_path: &mut PathBuf) -> Result<Box<dyn DirectoryEntry>, Error> {
match self {
DirectoryTreeBuilder::File(content) => {
syslog::fx_log_info!("Adding content at {}", full_path.to_string_lossy());
Ok(Box::new(read_only(move || Ok(content.to_vec()))))
}
DirectoryTreeBuilder::Directory(children) => {
let mut dir = directory::simple::empty();
for (name, child) in children.into_iter() {
full_path.push(&name);
let entry = child.build_impl(&mut full_path)?;
full_path.pop();
dir.add_boxed_entry(&name, entry).map_err(|err| Error::from(err.0))?;
}
Ok(Box::new(dir))
}
}
}
}
fn parse_bootfs<'a>(vmo: zx::Vmo) -> HashMap<String, Vec<u8>> {
let mut items = HashMap::new();
match BootfsParser::create_from_vmo(vmo) {
Ok(parser) => parser.iter().for_each(|result| match result {
Ok(entry) => {
syslog::fx_log_info!("Found {} in factory bootfs", &entry.name);
items.insert(entry.name, entry.payload);
}
Err(err) => syslog::fx_log_err!(tag: "BootfsParser", "{}", err),
}),
Err(err) => syslog::fx_log_err!(tag: "BootfsParser", "{}", err),
};
items
}
async fn fetch_new_factory_item() -> Result<zx::Vmo, Error> {
let factory_items = fuchsia_component::client::connect_to_service::<FactoryItemsMarker>()?;
let (vmo_opt, _) = factory_items.get(DEFAULT_BOOTFS_FACTORY_ITEM_EXTRA).await?;
vmo_opt.ok_or(format_err!("Failed to get a valid VMO from service"))
}
async fn create_dir_from_context<'a>(
context: &'a ConfigContext,
items: &'a HashMap<String, Vec<u8>>,
) -> Result<Box<dyn DirectoryEntry>, Error> {
let mut dir_builder = DirectoryTreeBuilder::empty_dir();
for (path, dest) in &context.file_path_map {
let contents = match items.get(path) {
Some(contents) => contents,
None => {
syslog::fx_log_err!("Failed to find {}, skipping", &path);
continue;
}
};
let mut failed_validation = false;
let mut validated = false;
for validator_context in &context.validator_contexts {
if validator_context.paths_to_validate.contains(path) {
syslog::fx_log_info!(
"Validating {} with {} validator",
&path,
&validator_context.name
);
if let Err(err) = validator_context.validator.validate(&path, &contents) {
syslog::fx_log_err!("{}", err);
failed_validation = true;
break;
}
validated = true;
}
}
// Do not allow files that failed validation or have not been validated at all.
if !failed_validation && validated {
let path_parts: Vec<&str> = dest.split("/").collect();
dir_builder.add_file(&path_parts, contents.to_vec()).unwrap_or_else(|err| {
syslog::fx_log_err!("Failed to add file {} to directory: {}", dest, err);
});
} else if !validated {
syslog::fx_log_err!("{} was never validated, ignored", &path);
}
}
dir_builder.build()
}
fn apply_config(config: Config, items: Arc<Mutex<HashMap<String, Vec<u8>>>>) -> DirectoryProxy {
let (directory_proxy, directory_server_end) = create_proxy::<DirectoryMarker>().unwrap();
fasync::spawn(async move {
let items_mtx = items.clone();
// We only want to hold this lock to create `dir` so limit the scope of `items_ref`.
let mut dir = {
let items_ref = items_mtx.lock().await;
let context = config.into_context().expect("Failed to convert config into context");
create_dir_from_context(&context, &*items_ref).await.unwrap_or_else(|err| {
syslog::fx_log_err!(
"Failed to create directory from config: {}, {:?}",
err,
context
);
Box::new(directory::simple::empty())
})
};
dir.open(
OPEN_RIGHT_READABLE,
MODE_TYPE_DIRECTORY,
&mut iter::empty(),
ServerEnd::<NodeMarker>::new(directory_server_end.into_channel()),
);
dir.await;
});
directory_proxy
}
async fn handle_request_stream<RS, G>(
mut stream: RS,
directory_mutex: Arc<Mutex<DirectoryProxy>>,
mut get_directory_request_fn: G,
) -> Result<(), Error>
where
RS: RequestStream,
G: FnMut(
Request<RS::Service>,
) -> Option<fidl::endpoints::ServerEnd<fidl_fuchsia_io::DirectoryMarker>>,
{
while let Some(request) = stream.try_next().await? {
if let Some(directory_request) = get_directory_request_fn(request) {
if let Err(err) = directory_mutex.lock().await.clone(
OPEN_RIGHT_READABLE,
ServerEnd::<NodeMarker>::new(directory_request.into_channel()),
) {
syslog::fx_log_err!(
"Failed to clone directory connection for {}: {:?}",
RS::Service::DEBUG_NAME,
err
);
}
}
}
Ok(())
}
#[fasync::run_singlethreaded]
async fn main() -> Result<(), Error> {
syslog::init_with_tags(&["factory_store_providers"]).expect("Can't init logger");
syslog::fx_log_info!("{}", "Starting factory_store_providers");
let directory_items =
fetch_new_factory_item().await.map(|vmo| parse_bootfs(vmo)).unwrap_or_else(|err| {
syslog::fx_log_err!("Failed to get factory item, returning empty item list: {}", err);
HashMap::new()
});
let mut fs = ServiceFs::new();
fs.dir("svc")
.add_fidl_service(IncomingServices::CastCredentialsFactoryStoreProvider)
.add_fidl_service(IncomingServices::MiscFactoryStoreProvider)
.add_fidl_service(IncomingServices::PlayReadyFactoryStoreProvider)
.add_fidl_service(IncomingServices::WidevineFactoryStoreProvider);
fs.take_and_serve_directory_handle().expect("Failed to serve factory providers");
let items_mtx = Arc::new(Mutex::new(directory_items));
let cast_credentials_config = Config::load::<CastCredentialsFactoryStoreProviderMarker>()?;
let cast_directory =
Arc::new(Mutex::new(apply_config(cast_credentials_config, items_mtx.clone())));
let misc_config = Config::load::<MiscFactoryStoreProviderMarker>()?;
let misc_directory = Arc::new(Mutex::new(apply_config(misc_config, items_mtx.clone())));
let playready_config = Config::load::<PlayReadyFactoryStoreProviderMarker>()?;
let playready_directory =
Arc::new(Mutex::new(apply_config(playready_config, items_mtx.clone())));
let widevine_config = Config::load::<WidevineFactoryStoreProviderMarker>()?;
let widevine_directory = Arc::new(Mutex::new(apply_config(widevine_config, items_mtx.clone())));
fs.for_each_concurrent(CONCURRENT_LIMIT, move |incoming_service| {
let cast_directory_clone = cast_directory.clone();
let misc_directory_clone = misc_directory.clone();
let playready_directory_clone = playready_directory.clone();
let widevine_directory_clone = widevine_directory.clone();
async move {
match incoming_service {
IncomingServices::CastCredentialsFactoryStoreProvider(stream) => {
let cast_directory_clone = cast_directory_clone.clone();
handle_request_stream(
stream,
cast_directory_clone,
|req: CastCredentialsFactoryStoreProviderRequest| {
req.into_get_factory_store().map(|item| item.0)
},
)
.await
}
IncomingServices::MiscFactoryStoreProvider(stream) => {
let misc_directory_clone = misc_directory_clone.clone();
handle_request_stream(
stream,
misc_directory_clone,
|req: MiscFactoryStoreProviderRequest| {
req.into_get_factory_store().map(|item| item.0)
},
)
.await
}
IncomingServices::PlayReadyFactoryStoreProvider(stream) => {
let playready_directory_clone = playready_directory_clone.clone();
handle_request_stream(
stream,
playready_directory_clone,
|req: PlayReadyFactoryStoreProviderRequest| {
req.into_get_factory_store().map(|item| item.0)
},
)
.await
}
IncomingServices::WidevineFactoryStoreProvider(stream) => {
let widevine_directory_clone = widevine_directory_clone.clone();
handle_request_stream(
stream,
widevine_directory_clone,
|req: WidevineFactoryStoreProviderRequest| {
req.into_get_factory_store().map(|item| item.0)
},
)
.await
}
}
}
.unwrap_or_else(|err| syslog::fx_log_err!("Failed to handle incoming service: {}", err))
})
.await;
Ok(())
}
|
fn main() {
// This struct presents unique challenges to the type reader as it is both arch-specific
// and one of those definitions has nested types. This combination is tricky because
// traditional scope resolution is insufficient.
windows::core::build_legacy! {
Windows::Win32::System::Diagnostics::Debug::KNONVOLATILE_CONTEXT_POINTERS,
};
}
|
/*
* Integration tests for vsv.
*
* Author: Dave Eddy <dave@daveeddy.com>
* Date: February 19, 2022
* License: MIT
*/
use anyhow::Result;
mod common;
#[test]
fn usage() -> Result<()> {
let assert = common::vsv()?.arg("-h").assert();
assert.success().stderr("");
Ok(())
}
#[test]
fn external_success() -> Result<()> {
let mut cmd = common::vsv()?;
cmd.env("SV_PROG", "true");
let assert = cmd.args(&["external", "cmd"]).assert();
assert.success();
Ok(())
}
#[test]
fn external_failure() -> Result<()> {
let mut cmd = common::vsv()?;
cmd.env("SV_PROG", "false");
let assert = cmd.args(&["external", "cmd"]).assert();
assert.failure();
Ok(())
}
|
use std::ffi::OsStr;
use std::path::Path;
use std::str::FromStr;
use serde::{de, Deserialize, Deserializer};
use strum::{EnumString, IntoStaticStr};
/// Programming language or file format being edited in a buffer.
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, EnumString, IntoStaticStr)]
pub enum Syntax {
#[strum(serialize = "javascript")]
JavaScript,
#[strum(serialize = "rust")]
Rust,
}
impl Syntax {
/// Attempts to identify the syntax for a given file.
///
/// If the syntax is unknown or unsupported, `None` is returned.
pub fn identify(path: impl AsRef<Path>) -> Option<Self> {
let path = path.as_ref();
if let Some(ext) = path.extension().and_then(OsStr::to_str) {
match ext {
"js" => return Some(Syntax::JavaScript),
"rs" => return Some(Syntax::Rust),
_ => (),
}
}
None
}
/// Converts returns a syntax to a [LSP-compatible language identifier][language id].
///
/// [language id]: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#textDocumentItem
pub fn into_language_id(self) -> &'static str {
self.into()
}
}
/// Used for deserializing [`crate::config::Config`].
impl<'de> Deserialize<'de> for Syntax {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s = String::deserialize(deserializer)?;
FromStr::from_str(&s).map_err(de::Error::custom)
}
}
|
use byteorder::LittleEndian;
use crate::io::Buf;
use crate::mysql::protocol::Capabilities;
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_basic_err_packet.html
// https://mariadb.com/kb/en/err_packet/
#[derive(Debug)]
pub struct ErrPacket {
pub error_code: u16,
pub sql_state: Option<Box<str>>,
pub error_message: Box<str>,
}
impl ErrPacket {
pub(crate) fn read(mut buf: &[u8], capabilities: Capabilities) -> crate::Result<Self>
where
Self: Sized,
{
let header = buf.get_u8()?;
if header != 0xFF {
return Err(protocol_err!(
"expected 0xFF for ERR_PACKET; received 0x{:X}",
header
))?;
}
let error_code = buf.get_u16::<LittleEndian>()?;
let mut sql_state = None;
if capabilities.contains(Capabilities::PROTOCOL_41) {
// If the next byte is '#' then we have a SQL STATE
if buf.get(0) == Some(&0x23) {
buf.advance(1);
sql_state = Some(buf.get_str(5)?.into())
}
}
let error_message = buf.get_str(buf.len())?.into();
Ok(Self {
error_code,
sql_state,
error_message,
})
}
}
#[cfg(test)]
mod tests {
use super::{Capabilities, ErrPacket};
const ERR_PACKETS_OUT_OF_ORDER: &[u8] = b"\xff\x84\x04Got packets out of order";
const ERR_HANDSHAKE_UNKNOWN_DB: &[u8] = b"\xff\x19\x04#42000Unknown database \'unknown\'";
#[test]
fn it_decodes_packets_out_of_order() {
let p = ErrPacket::read(ERR_PACKETS_OUT_OF_ORDER, Capabilities::PROTOCOL_41).unwrap();
assert_eq!(&*p.error_message, "Got packets out of order");
assert_eq!(p.error_code, 1156);
assert_eq!(p.sql_state, None);
}
#[test]
fn it_decodes_ok_handshake() {
let p = ErrPacket::read(ERR_HANDSHAKE_UNKNOWN_DB, Capabilities::PROTOCOL_41).unwrap();
assert_eq!(p.error_code, 1049);
assert_eq!(p.sql_state.as_deref(), Some("42000"));
assert_eq!(&*p.error_message, "Unknown database \'unknown\'");
}
}
|
use std::rc::Rc;
use crate::chunk::{Constant, Chunk};
use crate::op::*;
use crate::scanner::Token;
const U8_SIZE: usize = (u8::MAX as usize) + 1;
#[derive(PartialEq)]
enum ChunkTag {
Script,
Function,
}
struct Local {
pub name: Rc<Token>,
pub depth: i32,
pub is_captured: bool,
}
impl Local {
pub fn new(name: &Rc<Token>) -> Self {
let name = Rc::clone(name);
let depth = -1;
let is_captured = false;
Local { name, depth, is_captured }
}
}
#[derive(Copy, Clone, PartialEq)]
pub enum Upvalue {
Local(u8),
Upvalue(u8),
}
pub struct ChunkBuilder {
i: usize,
tag: Vec<ChunkTag>,
code: Vec<Vec<u8>>,
constants: Vec<Vec<Constant>>,
lines: Vec<Vec<usize>>,
locals: Vec<Vec<Local>>,
scope_depth: Vec<i32>,
upvalues: Vec<Vec<Upvalue>>,
}
impl ChunkBuilder {
pub fn new() -> ChunkBuilder {
ChunkBuilder {
i: 0,
tag: vec![ChunkTag::Script],
code: vec![vec![]],
constants: vec![vec![]],
lines: vec![vec![]],
locals: vec![vec![]],
scope_depth: vec![0],
upvalues: vec![vec![]],
}
}
pub fn scope_depth(&self) -> i32 {
self.scope_depth[self.i]
}
fn code(&self) -> &Vec<u8> {
&self.code[self.i]
}
fn code_mut(&mut self) -> &mut Vec<u8> {
&mut self.code[self.i]
}
fn lines_mut(&mut self) -> &mut Vec<usize> {
&mut self.lines[self.i]
}
fn locals_at(&self, i: usize) -> &Vec<Local> {
&self.locals[i]
}
fn locals(&self) -> &Vec<Local> {
self.locals_at(self.i)
}
fn locals_mut(&mut self) -> &mut Vec<Local> {
&mut self.locals[self.i]
}
pub fn is_script(&self) -> bool {
self.tag[self.i] == ChunkTag::Script
}
pub fn push_function(&mut self) {
self.i += 1;
self.tag.push(ChunkTag::Function);
self.code.push(vec![]);
self.constants.push(vec![]);
self.lines.push(vec![]);
self.locals.push(vec![]);
self.scope_depth.push(0);
self.upvalues.push(vec![]);
}
pub fn pop(&mut self) -> (Chunk, Vec<Upvalue>) {
assert!(self.i >= 1);
self.i -= 1;
self.tag.pop();
let code = self.code.pop().unwrap();
let constants = self.constants.pop().unwrap();
let lines = self.lines.pop().unwrap();
self.locals.pop();
self.scope_depth.pop();
let upvalues = self.upvalues.pop().unwrap();
let chunk = Chunk::new(code, constants, lines);
(chunk, upvalues)
}
/// Returns the script chunk. All functions must be popped. Do not use after finish.
pub fn finish(&mut self) -> Chunk {
assert!(self.i == 0);
let code = self.code.pop().unwrap();
let constants = self.constants.pop().unwrap();
let lines = self.lines.pop().unwrap();
Chunk::new(code, constants, lines)
}
/// Adds a value to the chunk's constant table. Returns the value's index
/// in the constant table.
pub fn add_constant(&mut self, constant: Constant) -> Result<u8, String> {
if self.constants[self.i].len() < U8_SIZE {
self.constants[self.i].push(constant);
let index = self.constants[self.i].len() as u8 - 1;
Ok(index)
} else {
let message = String::from("Too many constants in one chunk.");
Err(message)
}
}
/// Adds the token's lexeme to the chunk's constant table. Returns the index
/// in the constant table.
pub fn identifier_constant(&mut self, token: &Rc<Token>) -> Result<u8, String> {
let constant_value = token.lexeme.clone();
let constant = Constant::String(constant_value);
self.add_constant(constant)
}
pub fn emit(&mut self, byte: u8, line: usize) {
self.code_mut().push(byte);
self.lines_mut().push(line);
}
pub fn emit_loop(&mut self, loop_start: usize, line: usize) -> Result<(), String> {
self.emit(OP_LOOP, line);
let offset = self.code().len() - loop_start + 2;
if offset > u16::MAX as usize {
return Err(String::from("Loop body too large."));
}
self.emit(high_byte(offset), line);
self.emit(low_byte(offset), line);
Ok(())
}
pub fn emit_constant(&mut self, constant: Constant, line: usize) -> Result<u8, String> {
let index = self.add_constant(constant)?;
self.emit(OP_CONSTANT, line);
self.emit(index, line);
Ok(index)
}
pub fn emit_jump(&mut self, instruction: u8, line: usize) -> usize {
self.emit(instruction, line);
self.emit(0xff, line);
self.emit(0xff, line);
self.code().len() - 2
}
pub fn patch_jump(&mut self, offset: usize) -> Result<(), String> {
// -2 to adjust for the bytecode for the jump offset itself.
let jump = self.code().len() - offset - 2;
if jump > u16::MAX as usize {
return Err(String::from("Too much code to jump over."));
}
self.code_mut()[offset] = high_byte(jump);
self.code_mut()[offset + 1] = low_byte(jump);
Ok(())
}
pub fn next_instruction_offset(&self) -> usize {
self.code[self.i].len()
}
pub fn begin_scope(&mut self) {
self.scope_depth[self.i] += 1;
}
pub fn end_scope(&mut self, line: usize) {
self.scope_depth[self.i] -= 1;
while self.locals().len() > 0
&& self.locals()[self.locals().len() - 1].depth > self.scope_depth()
{
if self.locals()[self.locals().len() - 1].is_captured {
self.emit(OP_CLOSE_UPVALUE, line);
} else {
self.emit(OP_POP, line);
}
self.locals_mut().pop();
}
}
pub fn mark_initialized(&mut self) {
if self.scope_depth() == 0 {
return;
}
let last_offset = self.locals().len() - 1;
self.locals_mut()[last_offset].depth = self.scope_depth();
}
pub fn define_variable(&mut self, line: usize, global: u8) {
if self.scope_depth() == 0 {
self.emit(OP_DEFINE_GLOBAL, line);
self.emit(global, line);
} else if self.scope_depth() > 0 {
self.mark_initialized();
}
}
pub fn declare_variable(&mut self, name: &Rc<Token>) -> Result<(), String> {
if self.scope_depth() > 0 {
self.add_local(name)?;
}
Ok(())
}
pub fn add_local(&mut self, name: &Rc<Token>) -> Result<(), String> {
if self.locals().len() == U8_SIZE {
return Err("Exceeded maximum number of local variables.".to_owned());
}
for local in self.locals().iter().rev() {
if local.depth == -1 && local.depth < self.scope_depth() {
break;
}
if name.lexeme == local.name.lexeme {
return Err("Variable with this name already declared in this scope.".to_owned());
}
}
let local = Local::new(name);
self.locals_mut().push(local);
Ok(())
}
fn resolve_local_at(&mut self, i: usize, name: &Rc<Token>) -> Result<Option<u8>, String> {
for (i_local, local) in self.locals_at(i).iter().enumerate().rev() {
if local.name.lexeme == name.lexeme {
if local.depth == -1 {
return Err("Cannot read local variable in its own initializer.".to_owned());
}
return Ok(Some(i_local as u8));
}
}
return Ok(None);
}
pub fn resolve_local(&mut self, name: &Rc<Token>) -> Result<Option<u8>, String> {
self.resolve_local_at(self.i, name)
}
fn add_upvalue_at(&mut self, i: usize, upvalue: Upvalue) -> Result<u8, String> {
for (i_uv, uv) in self.upvalues[i].iter().enumerate() {
if *uv == upvalue {
return Ok(i_uv as u8);
}
}
if self.upvalues[i].len() == U8_SIZE {
return Err("Too many closure variables in function.".to_owned())
}
self.upvalues[i].push(upvalue);
return Ok((self.upvalues[i].len() - 1) as u8);
}
fn resolve_upvalue_at(&mut self, i: usize, name: &Rc<Token>) -> Result<Option<u8>, String> {
if i == 0 {
return Ok(None);
}
let i_enclosing = i - 1;
if let Some(index) = self.resolve_local_at(i_enclosing, name)? {
self.locals[i_enclosing][index as usize].is_captured = true;
let arg = self.add_upvalue_at(i, Upvalue::Local(index))?;
return Ok(Some(arg));
}
if let Some(index) = self.resolve_upvalue_at(i_enclosing, name)? {
let arg = self.add_upvalue_at(i, Upvalue::Upvalue(index))?;
return Ok(Some(arg));
}
return Ok(None);
}
pub fn resolve_upvalue(&mut self, name: &Rc<Token>) -> Result<Option<u8>, String> {
self.resolve_upvalue_at(self.i, name)
}
}
/// Assuming x is at most a 16 bit value, the high byte of x.
fn high_byte(x: usize) -> u8 {
((x >> 8) & 0xff) as u8
}
/// Assuming x is at most a 16 bit value, the low byte of x.
fn low_byte(x: usize) -> u8 {
(x & 0xff) as u8
}
|
use crossterm::event::KeyModifiers;
use crossterm::event::{poll, read, Event, KeyCode, KeyEvent};
use std::collections::HashMap;
macro_rules! key_map {
($($key:expr => $val: expr), *) => {
{
let mut map = HashMap::<KeyCode, u8>::new();
$(
map.insert(KeyCode::Char($key), $val);
)*
map
}
};
}
#[derive(Debug)]
pub struct Keyboard {
keys: [bool; 0xF + 1],
pub mapping: HashMap<KeyCode, u8>,
}
impl Keyboard {
pub fn new() -> Self {
Keyboard {
keys: [false; 0xF + 1],
mapping: key_map!(
'1' => 0x1,
'2' => 0x2,
'3' => 0x3,
'4' => 0xC,
'q' => 0x4,
'w' => 0x5,
'e' => 0x6,
'r' => 0xD,
'a' => 0x7,
's' => 0x8,
'd' => 0x9,
'f' => 0xe,
'z' => 0xA,
'x' => 0,
'c' => 0xB,
'v' => 0xF
),
}
}
pub fn set_state(&mut self, index: u8, state: bool) {
self.keys[index as usize] = state;
}
pub fn is_pressed(&self, index: u8) -> bool {
self.keys[index as usize]
}
pub fn press(&mut self, key: KeyCode, state: bool) {
if self.mapping.contains_key(&key) {
let index = self.mapping[&key];
self.keys[index as usize] = state
}
}
pub fn wait_for_key(&self) -> u8 {
loop {
match read().unwrap() {
Event::Key(event) => {
if event.modifiers.contains(KeyModifiers::CONTROL)
&& event.code == KeyCode::Char('c')
{
std::process::exit(0)
} else {
let key = self.mapping.get(&event.code);
if let Some(key) = key {
return key.clone();
} else {
continue;
}
}
}
_ => continue,
}
}
}
pub fn register_key_press(&mut self) {
use std::time::Duration;
if poll(Duration::from_millis(5)).unwrap() {
match read().unwrap() {
Event::Key(event) => {
if event.modifiers.contains(KeyModifiers::CONTROL)
&& event.code == KeyCode::Char('c')
{
std::process::exit(0)
} else {
match self.mapping.get(&event.code) {
Some(key) => self.keys[*key as usize] = true,
None => self.keys = [false; 0xf + 1],
}
}
},
_ => ()
}
}
}
}
|
use common::privkey::key_pair_from_seed;
use crate::WithdrawFee;
use crate::utxo::rpc_clients::{ElectrumProtocol};
use futures::executor::block_on;
use futures::future::join_all;
use mocktopus::mocking::*;
use super::*;
fn electrum_client_for_test(servers: &[&str]) -> UtxoRpcClientEnum {
let mut client = ElectrumClientImpl::new();
for server in servers {
client.add_server(&ElectrumRpcRequest {
url: server.to_string(),
protocol: ElectrumProtocol::TCP,
disable_cert_verification: false,
}).unwrap();
}
let mut attempts = 0;
while !block_on(client.is_connected()) {
if attempts >= 10 {
panic!("Failed to connect to at least 1 of {:?} in 5 seconds.", servers);
}
thread::sleep(Duration::from_millis(500));
attempts += 1;
}
UtxoRpcClientEnum::Electrum(ElectrumClient(Arc::new(client)))
}
fn utxo_coin_for_test(rpc_client: UtxoRpcClientEnum, force_seed: Option<&str>) -> UtxoCoin {
let checksum_type = ChecksumType::DSHA256;
let default_seed = "spice describe gravity federal blast come thank unfair canal monkey style afraid";
let seed = match force_seed {
Some(s) => s.into(),
None => match std::env::var("BOB_PASSPHRASE") {
Ok(p) => if p.is_empty() {
default_seed.into()
} else {
p
},
Err(_) => default_seed.into(),
}
};
let key_pair = key_pair_from_seed(&seed).unwrap();
let my_address = Address {
prefix: 60,
hash: key_pair.public().address_hash(),
t_addr_prefix: 0,
checksum_type,
};
let coin = UtxoCoinImpl {
decimals: 8,
rpc_client,
key_pair,
is_pos: false,
notarized: false,
overwintered: true,
segwit: false,
tx_version: 4,
my_address,
asset_chain: true,
p2sh_addr_prefix: 85,
p2sh_t_addr_prefix: 0,
pub_addr_prefix: 60,
pub_t_addr_prefix: 0,
ticker: "ETOMIC".into(),
wif_prefix: 0,
tx_fee: TxFee::Fixed(1000),
version_group_id: 0x892f2085,
zcash: true,
checksum_type,
fork_id: 0,
signature_version: SignatureVersion::Base,
history_sync_state: Mutex::new(HistorySyncState::NotEnabled),
required_confirmations: 1.into(),
};
UtxoCoin(Arc::new(coin))
}
#[test]
fn test_extract_secret() {
let tx: UtxoTx = "0100000001de7aa8d29524906b2b54ee2e0281f3607f75662cbc9080df81d1047b78e21dbc00000000d7473044022079b6c50820040b1fbbe9251ced32ab334d33830f6f8d0bf0a40c7f1336b67d5b0220142ccf723ddabb34e542ed65c395abc1fbf5b6c3e730396f15d25c49b668a1a401209da937e5609680cb30bff4a7661364ca1d1851c2506fa80c443f00a3d3bf7365004c6b6304f62b0e5cb175210270e75970bb20029b3879ec76c4acd320a8d0589e003636264d01a7d566504bfbac6782012088a9142fb610d856c19fd57f2d0cffe8dff689074b3d8a882103f368228456c940ac113e53dad5c104cf209f2f102a409207269383b6ab9b03deac68ffffffff01d0dc9800000000001976a9146d9d2b554d768232320587df75c4338ecc8bf37d88ac40280e5c".into();
let secret = tx.extract_secret().unwrap();
let expected_secret = hex::decode("9da937e5609680cb30bff4a7661364ca1d1851c2506fa80c443f00a3d3bf7365").unwrap();
assert_eq!(expected_secret, secret);
}
#[test]
fn test_generate_transaction() {
let client = electrum_client_for_test(&["test1.cipig.net:10025"]);
let coin = utxo_coin_for_test(client, None);
let unspents = vec![UnspentInfo {
value: 10000000000,
outpoint: OutPoint::default(),
}];
let outputs = vec![TransactionOutput {
script_pubkey: vec![].into(),
value: 999,
}];
let generated = coin.generate_transaction(unspents, outputs, FeePolicy::SendExact, None).wait();
// must not allow to use output with value < dust
unwrap_err!(generated);
let unspents = vec![UnspentInfo {
value: 100000,
outpoint: OutPoint::default(),
}];
let outputs = vec![TransactionOutput {
script_pubkey: vec![].into(),
value: 98001,
}];
let generated = unwrap!(coin.generate_transaction(unspents, outputs, FeePolicy::SendExact, None).wait());
// the change that is less than dust must be included to miner fee
// so no extra outputs should appear in generated transaction
assert_eq!(generated.0.outputs.len(), 1);
assert_eq!(generated.1.fee_amount, 1999);
assert_eq!(generated.1.received_by_me, 0);
assert_eq!(generated.1.spent_by_me, 100000);
let unspents = vec![UnspentInfo {
value: 100000,
outpoint: OutPoint::default(),
}];
let outputs = vec![TransactionOutput {
script_pubkey: Builder::build_p2pkh(&coin.my_address.hash).to_bytes(),
value: 100000,
}];
// test that fee is properly deducted from output amount equal to input amount (max withdraw case)
let generated = unwrap!(coin.generate_transaction(unspents, outputs, FeePolicy::DeductFromOutput(0), None).wait());
assert_eq!(generated.0.outputs.len(), 1);
assert_eq!(generated.1.fee_amount, 1000);
assert_eq!(generated.1.received_by_me, 99000);
assert_eq!(generated.1.spent_by_me, 100000);
assert_eq!(generated.0.outputs[0].value, 99000);
let unspents = vec![UnspentInfo {
value: 100000,
outpoint: OutPoint::default(),
}];
let outputs = vec![TransactionOutput {
script_pubkey: vec![].into(),
value: 100000,
}];
// test that generate_transaction returns an error when input amount is not sufficient to cover output + fee
unwrap_err!(coin.generate_transaction(unspents, outputs, FeePolicy::SendExact, None).wait());
}
#[test]
fn test_addresses_from_script() {
let client = electrum_client_for_test(&["test1.cipig.net:10025"]);
let coin = utxo_coin_for_test(client, None);
// P2PKH
let script: Script = "76a91405aab5342166f8594baf17a7d9bef5d56744332788ac".into();
let expected_addr: Vec<Address> = vec!["R9o9xTocqr6CeEDGDH6mEYpwLoMz6jNjMW".into()];
let actual_addr = unwrap!(coin.addresses_from_script(&script));
assert_eq!(expected_addr, actual_addr);
// P2SH
let script: Script = "a914e71a6120653ebd526e0f9d7a29cde5969db362d487".into();
let expected_addr: Vec<Address> = vec!["bZoEPR7DjTqSDiQTeRFNDJuQPTRY2335LD".into()];
let actual_addr = unwrap!(coin.addresses_from_script(&script));
assert_eq!(expected_addr, actual_addr);
}
#[test]
fn test_kmd_interest() {
let value = 64605500822;
let lock_time = 1556623906;
let current_time = 1556623906 + 3600 + 300;
let expected = 36870;
let actual = kmd_interest(1000001, value, lock_time, current_time);
assert_eq!(expected, actual);
// UTXO amount must be at least 10 KMD to be eligible for interest
let value = 999999999;
let lock_time = 1556623906;
let current_time = 1556623906 + 3600 + 300;
let expected = 0;
let actual = kmd_interest(1000001, value, lock_time, current_time);
assert_eq!(expected, actual);
}
#[test]
fn test_sat_from_big_decimal() {
let amount = "0.000001".parse().unwrap();
let sat = sat_from_big_decimal(&amount, 18).unwrap();
let expected_sat = 1000000000000;
assert_eq!(expected_sat, sat);
let amount = "0.12345678".parse().unwrap();
let sat = sat_from_big_decimal(&amount, 8).unwrap();
let expected_sat = 12345678;
assert_eq!(expected_sat, sat);
let amount = "1.000001".parse().unwrap();
let sat = sat_from_big_decimal(&amount, 18).unwrap();
let expected_sat = 1000001000000000000;
assert_eq!(expected_sat, sat);
let amount = 1.into();
let sat = sat_from_big_decimal(&amount, 18).unwrap();
let expected_sat = 1000000000000000000;
assert_eq!(expected_sat, sat);
let amount = "0.000000000000000001".parse().unwrap();
let sat = sat_from_big_decimal(&amount, 18).unwrap();
let expected_sat = 1u64;
assert_eq!(expected_sat, sat);
let amount = 1234.into();
let sat = sat_from_big_decimal(&amount, 9).unwrap();
let expected_sat = 1234000000000;
assert_eq!(expected_sat, sat);
let amount = 1234.into();
let sat = sat_from_big_decimal(&amount, 0).unwrap();
let expected_sat = 1234;
assert_eq!(expected_sat, sat);
let amount = 1234.into();
let sat = sat_from_big_decimal(&amount, 1).unwrap();
let expected_sat = 12340;
assert_eq!(expected_sat, sat);
let amount = "1234.12345".parse().unwrap();
let sat = sat_from_big_decimal(&amount, 1).unwrap();
let expected_sat = 12341;
assert_eq!(expected_sat, sat);
}
#[test]
fn test_wait_for_payment_spend_timeout_native() {
let client = NativeClientImpl {
uri: "http://127.0.0.1:10271".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
};
static mut OUTPUT_SPEND_CALLED: bool = false;
NativeClient::find_output_spend.mock_safe(|_, _, _, _| {
unsafe { OUTPUT_SPEND_CALLED = true };
MockResult::Return(Ok(None))
});
let client = UtxoRpcClientEnum::Native(NativeClient(Arc::new(client)));
let coin = utxo_coin_for_test(client, None);
let transaction = unwrap!(hex::decode("01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000"));
let wait_until = now_ms() / 1000 - 1;
let from_block = 1000;
assert!(coin.wait_for_tx_spend(&transaction, wait_until, from_block).is_err());
assert!(unsafe { OUTPUT_SPEND_CALLED });
}
#[test]
fn test_wait_for_payment_spend_timeout_electrum() {
static mut OUTPUT_SPEND_CALLED: bool = false;
ElectrumClient::find_output_spend.mock_safe(|_, _, _, _| {
unsafe { OUTPUT_SPEND_CALLED = true };
MockResult::Return(Ok(None))
});
let client = ElectrumClientImpl::new();
let client = UtxoRpcClientEnum::Electrum(ElectrumClient(Arc::new(client)));
let coin = utxo_coin_for_test(client, None);
let transaction = unwrap!(hex::decode("01000000000102fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f00000000494830450221008b9d1dc26ba6a9cb62127b02742fa9d754cd3bebf337f7a55d114c8e5cdd30be022040529b194ba3f9281a99f2b1c0a19c0489bc22ede944ccf4ecbab4cc618ef3ed01eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac000247304402203609e17b84f6a7d30c80bfa610b5b4542f32a8a0d5447a12fb1366d7f01cc44a0220573a954c4518331561406f90300e8f3358f51928d43c212a8caed02de67eebee0121025476c2e83188368da1ff3e292e7acafcdb3566bb0ad253f62fc70f07aeee635711000000"));
let wait_until = now_ms() / 1000 - 1;
let from_block = 1000;
assert!(coin.wait_for_tx_spend(&transaction, wait_until, from_block).is_err());
assert!(unsafe { OUTPUT_SPEND_CALLED });
}
#[test]
fn test_search_for_swap_tx_spend_electrum_was_spent() {
let client = electrum_client_for_test(&["test1.cipig.net:10025", "test2.cipig.net:10025", "test3.cipig.net:10025"]);
let coin = utxo_coin_for_test(client, Some("spice describe gravity federal blast come thank unfair canal monkey style afraid"));
// raw tx bytes of https://etomic.explorer.dexstats.info/tx/c514b3163d66636ebc3574817cb5853d5ab39886183de71ffedf5c5768570a6b
let payment_tx_bytes = unwrap!(hex::decode("0400008085202f89013ac014d4926c8b435f7a5c58f38975d14f1aba597b1eef2dfdc093457678eb83010000006a47304402204ddb9b10237a1267a02426d923528213ad1e0b62d45be7d9629e2909f099d90c02205eecadecf6fd09cb8465170eb878c5d54e563f067b64e23c418da0f6519ca354012102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ffffffff02809698000000000017a914bbd726b74f27b476d5d932e903b5893fd4e8bd2187acdaaa87010000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ac2771515d000000000000000000000000000000"));
// raw tx bytes of https://etomic.explorer.dexstats.info/tx/e72be40bab15f3914e70507e863e26b8ccfaa75a9861d6fe706b39cab1272617
let spend_tx_bytes = unwrap!(hex::decode("0400008085202f89016b0a5768575cdffe1fe73d188698b35a3d85b57c817435bc6e63663d16b314c500000000d8483045022100d3cf75d26d977c0358e46c5db3753aa332ba12130b36b24b541cb90416f4606102201d805c5bdfc4d630cb78adb63239911c97a09c41125af37be219e876610f15f201209ac4a742e81a47dc26a3ddf83de84783fdb49c2322c4a3fdafc0613bf3335c40004c6b6304218f515db1752102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ac6782012088a914954f5a3f3b5de4410e5e1a82949410de95a4b6ba882102631dcf1d4b1b693aa8c2751afc68e4794b1e5996566cfc701a663f8b7bbbe640ac68ffffffff0198929800000000001976a91464ae8510aac9546d5e7704e31ce177451386455588ac3963515d000000000000000000000000000000"));
let spend_tx = TransactionEnum::UtxoTx(unwrap!(deserialize(spend_tx_bytes.as_slice())));
let found = unwrap!(unwrap!(coin.search_for_swap_tx_spend(
1565626145,
coin.key_pair.public(),
&unwrap!(Public::from_slice(&unwrap!(hex::decode("02631dcf1d4b1b693aa8c2751afc68e4794b1e5996566cfc701a663f8b7bbbe640")))),
&unwrap!(hex::decode("954f5a3f3b5de4410e5e1a82949410de95a4b6ba")),
&payment_tx_bytes,
0
)));
assert_eq!(FoundSwapTxSpend::Spent(spend_tx), found);
}
#[test]
fn test_search_for_swap_tx_spend_electrum_was_refunded() {
let client = electrum_client_for_test(&["test1.cipig.net:10025", "test2.cipig.net:10025", "test3.cipig.net:10025"]);
let coin = utxo_coin_for_test(client, Some("spice describe gravity federal blast come thank unfair canal monkey style afraid"));
// raw tx bytes of https://etomic.explorer.dexstats.info/tx/c9a47cc6e80a98355cd4e69d436eae6783cbee5991756caa6e64a0743442fa96
let payment_tx_bytes = unwrap!(hex::decode("0400008085202f8901887e809b10738b1625b7f47fd5d2201f32e8a4c6c0aaefc3b9ab6c07dc6a5925010000006a47304402203966f49ba8acc9fcc0e53e7b917ca5599ce6054a0c2d22752c57a3dc1b0fc83502206fde12c869da20a21cedd5bbc4bcd12977d25ff4b00e0999de5ac4254668e891012102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ffffffff02809698000000000017a9147e9456f37fa53cf9053e192ea4951d2c8b58647c8784631684010000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ac0fb3525d000000000000000000000000000000"));
// raw tx bytes of https://etomic.explorer.dexstats.info/tx/a5f11bdb657ee834a4c410e2001beccce0374bfa3f662bd890fd3d01b0b3d101
let spend_tx_bytes = unwrap!(hex::decode("0400008085202f890196fa423474a0646eaa6c759159eecb8367ae6e439de6d45c35980ae8c67ca4c900000000c4483045022100969c3b2c1ab630b67a6ee74316c9356e38872276a070d126da1d731503bb6e3e02204398d8c23cb59c2caddc33ce9c9716c54b11574126a3c3350a17043f3751696d01514c786304cf93525db1752102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ac6782012088a92102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3882102031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3ac68feffffff0198929800000000001976a91405aab5342166f8594baf17a7d9bef5d56744332788ac01a5525d000000000000000000000000000000"));
let spend_tx = TransactionEnum::UtxoTx(unwrap!(deserialize(spend_tx_bytes.as_slice())));
let found = unwrap!(unwrap!(coin.search_for_swap_tx_spend(
1565692879,
coin.key_pair.public(),
&unwrap!(Public::from_slice(&unwrap!(hex::decode("02031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3")))),
&unwrap!(hex::decode("02031d4256c4bc9f99ac88bf3dba21773132281f65f9bf23a59928bce08961e2f3")),
&payment_tx_bytes,
0
)));
assert_eq!(FoundSwapTxSpend::Refunded(spend_tx), found);
}
#[test]
fn test_withdraw_impl_set_fixed_fee() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: 1.into(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: false,
fee: Some(WithdrawFee::UtxoFixed { amount: "0.1".parse().unwrap() }),
};
let expected = Some(UtxoFeeDetails {
amount: "0.1".parse().unwrap()
}.into());
let tx_details = unwrap!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
assert_eq!(expected, tx_details.fee_details);
}
#[test]
fn test_withdraw_impl_sat_per_kb_fee() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: 1.into(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: false,
fee: Some(WithdrawFee::UtxoPerKbyte { amount: "0.1".parse().unwrap() }),
};
// The resulting transaction size might be 244 or 245 bytes depending on signature size
// MM2 always expects the worst case during fee calculation
// 0.1 * 245 / 1024 ~ 0.02392577
let expected = Some(UtxoFeeDetails {
amount: "0.02392577".parse().unwrap()
}.into());
let tx_details = unwrap!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
assert_eq!(expected, tx_details.fee_details);
}
#[test]
fn test_withdraw_impl_sat_per_kb_fee_amount_equal_to_max() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: "9.97939454".parse().unwrap(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: false,
fee: Some(WithdrawFee::UtxoPerKbyte { amount: "0.1".parse().unwrap() }),
};
let tx_details = unwrap!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
// The resulting transaction size might be 210 or 211 bytes depending on signature size
// MM2 always expects the worst case during fee calculation
// 0.1 * 211 / 1024 ~ 0.02060546
let expected_fee = Some(UtxoFeeDetails {
amount: "0.02060546".parse().unwrap()
}.into());
assert_eq!(expected_fee, tx_details.fee_details);
let expected_balance_change = BigDecimal::from(-10);
assert_eq!(expected_balance_change, tx_details.my_balance_change);
}
#[test]
fn test_withdraw_impl_sat_per_kb_fee_amount_equal_to_max_dust_included_to_fee() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: "9.97939454".parse().unwrap(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: false,
fee: Some(WithdrawFee::UtxoPerKbyte { amount: "0.09999999".parse().unwrap() }),
};
let tx_details = unwrap!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
// The resulting transaction size might be 210 or 211 bytes depending on signature size
// MM2 always expects the worst case during fee calculation
// 0.1 * 211 / 1024 ~ 0.02060546
let expected_fee = Some(UtxoFeeDetails {
amount: "0.02060546".parse().unwrap()
}.into());
assert_eq!(expected_fee, tx_details.fee_details);
let expected_balance_change = BigDecimal::from(-10);
assert_eq!(expected_balance_change, tx_details.my_balance_change);
}
#[test]
fn test_withdraw_impl_sat_per_kb_fee_amount_over_max() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: "9.97939455".parse().unwrap(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: false,
fee: Some(WithdrawFee::UtxoPerKbyte { amount: "0.1".parse().unwrap() }),
};
unwrap_err!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
}
#[test]
fn test_withdraw_impl_sat_per_kb_fee_max() {
NativeClient::list_unspent_ordered.mock_safe(|_,_| {
let unspents = vec![UnspentInfo { outpoint: OutPoint { hash: 1.into(), index: 0 }, value: 1000000000 }];
MockResult::Return(Box::new(futures01::future::ok(unspents)))
});
let client = NativeClient(Arc::new(NativeClientImpl {
uri: "http://127.0.0.1".to_owned(),
auth: fomat!("Basic " (base64_encode("user481805103:pass97a61c8d048bcf468c6c39a314970e557f57afd1d8a5edee917fb29bafb3a43371", URL_SAFE))),
}));
let coin = utxo_coin_for_test(UtxoRpcClientEnum::Native(client), None);
let withdraw_req = WithdrawRequest {
amount: 0.into(),
to: "RQq6fWoy8aGGMLjvRfMY5mBNVm2RQxJyLa".to_string(),
coin: "ETOMIC".to_string(),
max: true,
fee: Some(WithdrawFee::UtxoPerKbyte { amount: "0.1".parse().unwrap() }),
};
// The resulting transaction size might be 210 or 211 bytes depending on signature size
// MM2 always expects the worst case during fee calculation
// 0.1 * 211 / 1024 ~ 0.02060546
let expected = Some(UtxoFeeDetails {
amount: "0.02060546".parse().unwrap()
}.into());
let tx_details = unwrap!(block_on(withdraw_impl(coin.clone(), withdraw_req)));
assert_eq!(expected, tx_details.fee_details);
}
#[test]
fn test_utxo_lock() {
// send several transactions concurrently to check that they are not using same inputs
let client = electrum_client_for_test(&["test1.cipig.net:10025", "test2.cipig.net:10025", "test3.cipig.net:10025"]);
let coin = utxo_coin_for_test(client, None);
let output = TransactionOutput {
value: 1000000,
script_pubkey: Builder::build_p2pkh(&coin.my_address.hash).to_bytes(),
};
let mut futures = vec![];
for _ in 0..5 {
futures.push(send_outputs_from_my_address_impl(coin.clone(), vec![output.clone()]));
}
let results = block_on(join_all(futures));
for result in results {
unwrap!(result);
}
}
|
mod test_utils;
mod accept {
use super::test_utils::TestServer;
use async_h1::{client::Encoder, server::ConnectionStatus};
use async_std::io::{self, prelude::WriteExt, Cursor};
use http_types::{headers::CONNECTION, Body, Request, Response, Result};
#[async_std::test]
async fn basic() -> Result<()> {
let mut server = TestServer::new(|req| async {
let mut response = Response::new(200);
let len = req.len();
response.set_body(Body::from_reader(req, len));
Ok(response)
});
let content_length = 10;
let request_str = format!(
"POST / HTTP/1.1\r\nHost: example.com\r\nContent-Length: {}\r\n\r\n{}\r\n\r\n",
content_length,
std::str::from_utf8(&vec![b'|'; content_length]).unwrap()
);
server.write_all(request_str.as_bytes()).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.close();
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn request_close() -> Result<()> {
let mut server = TestServer::new(|_| async { Ok(Response::new(200)) });
server
.write_all(b"GET / HTTP/1.1\r\nHost: example.com\r\nConnection: Close\r\n\r\n")
.await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn response_close() -> Result<()> {
let mut server = TestServer::new(|_| async {
let mut response = Response::new(200);
response.insert_header(CONNECTION, "close");
Ok(response)
});
server
.write_all(b"GET / HTTP/1.1\r\nHost: example.com\r\n\r\n")
.await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn keep_alive_short_fixed_length_unread_body() -> Result<()> {
let mut server = TestServer::new(|_| async { Ok(Response::new(200)) });
let content_length = 10;
let request_str = format!(
"POST / HTTP/1.1\r\nHost: example.com\r\nContent-Length: {}\r\n\r\n{}\r\n\r\n",
content_length,
std::str::from_utf8(&vec![b'|'; content_length]).unwrap()
);
server.write_all(request_str.as_bytes()).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.write_all(request_str.as_bytes()).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.close();
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn keep_alive_short_chunked_unread_body() -> Result<()> {
let mut server = TestServer::new(|_| async { Ok(Response::new(200)) });
let content_length = 100;
let mut request = Request::post("http://example.com/");
request.set_body(Body::from_reader(
Cursor::new(vec![b'|'; content_length]),
None,
));
io::copy(&mut Encoder::new(request), &mut server).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server
.write_fmt(format_args!(
"GET / HTTP/1.1\r\nHost: example.com\r\nContent-Length: 0\r\n\r\n"
))
.await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.close();
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn keep_alive_long_fixed_length_unread_body() -> Result<()> {
let mut server = TestServer::new(|_| async { Ok(Response::new(200)) });
let content_length = 10000;
let request_str = format!(
"POST / HTTP/1.1\r\nHost: example.com\r\nContent-Length: {}\r\n\r\n{}\r\n\r\n",
content_length,
std::str::from_utf8(&vec![b'|'; content_length]).unwrap()
);
server.write_all(request_str.as_bytes()).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.write_all(request_str.as_bytes()).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.close();
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
#[async_std::test]
async fn keep_alive_long_chunked_unread_body() -> Result<()> {
let mut server = TestServer::new(|_| async { Ok(Response::new(200)) });
let content_length = 10000;
let mut request = Request::post("http://example.com/");
request.set_body(Body::from_reader(
Cursor::new(vec![b'|'; content_length]),
None,
));
server.write_request(request).await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server
.write_fmt(format_args!(
"GET / HTTP/1.1\r\nHost: example.com\r\nContent-Length: 0\r\n\r\n"
))
.await?;
assert_eq!(server.accept_one().await?, ConnectionStatus::KeepAlive);
server.close();
assert_eq!(server.accept_one().await?, ConnectionStatus::Close);
assert!(server.all_read());
Ok(())
}
}
|
use std::{collections::HashMap, hash::Hash, rc::Rc};
use crate::{
algorithm::{Components, ComponentsIter, Point, Sorted, TaggedComponent, TaggedComponentExt},
chromset::LexicalChromRef,
properties::{WithRegion, WithRegionCore},
records::{Bed3, Bed4},
};
//use super::{Components, ComponentsIter, Point, Sorted};
pub struct Merger<I: Iterator + Sorted>
where
I::Item: WithRegion<LexicalChromRef> + Clone,
{
peek: Option<Point<LexicalChromRef, I::Item>>,
iter: ComponentsIter<LexicalChromRef, I>,
}
impl<I: Iterator + Sorted> Iterator for Merger<I>
where
I::Item: WithRegion<LexicalChromRef> + Clone,
{
type Item = Bed3<LexicalChromRef>;
fn next(&mut self) -> Option<Self::Item> {
let mut begin = None;
let mut end;
while self.peek.as_ref().map_or(false, |peek| peek.depth > 0) {
let mut buf = self.iter.next();
std::mem::swap(&mut buf, &mut self.peek);
end = Some(buf.unwrap().value.clone());
if begin.is_none() {
begin = end.clone();
}
}
end = self.peek.take().map(|x| x.value);
self.peek = self.iter.next();
if let Some(ret) = begin {
let mut ret = Bed3::new(ret);
ret.end = end.unwrap().end();
Some(ret)
} else {
None
}
}
}
pub struct TaggedMerger<I, T> {
iter: I,
chrom: Option<LexicalChromRef>,
begins: HashMap<T, u32>,
}
impl<I, R, T> Iterator for TaggedMerger<I, T>
where
I: Iterator<Item = (T, Point<LexicalChromRef, R>)>,
R: WithRegion<LexicalChromRef> + Clone,
T: ToString + Eq + Hash,
{
type Item = Bed4<LexicalChromRef>;
fn next(&mut self) -> Option<Self::Item> {
while let Some((tag, comp)) = self.iter.next() {
let (chr, pos) = comp.position();
if Some(&chr) != self.chrom.as_ref() {
self.begins.clear();
}
self.chrom = Some(chr);
if let Some(&begin) = self.begins.get(&tag) {
if !comp.is_open {
let core = Bed3 {
chrom: self.chrom.clone().unwrap(),
begin,
end: pos,
};
let result = Bed4 {
core,
name: Rc::new(tag.to_string()),
};
self.begins.remove(&tag);
return Some(result);
}
} else {
self.begins.entry(tag).or_insert(pos);
}
}
None
}
}
pub trait MergeExt
where
Self: IntoIterator + Sized,
<Self as IntoIterator>::IntoIter: Sorted,
<Self as IntoIterator>::Item: WithRegion<LexicalChromRef> + Clone,
{
fn merge_overlaps(self) -> Merger<<Self as IntoIterator>::IntoIter> {
let mut iter = self.into_iter().components();
let peek = iter.next();
Merger { iter, peek }
}
fn tagged_merge<T: Clone + Hash + Eq, F: FnMut(&Self::Item) -> T>(
self,
f: F,
) -> TaggedMerger<
TaggedComponent<
LexicalChromRef,
ComponentsIter<LexicalChromRef, Self::IntoIter>,
Self::Item,
T,
F,
>,
T,
> {
TaggedMerger {
iter: self.into_iter().components().with_tag(f),
begins: HashMap::new(),
chrom: None,
}
}
}
impl<T: IntoIterator + Sized> MergeExt for T
where
T::IntoIter: Sorted,
T::Item: WithRegion<LexicalChromRef> + Clone,
{
}
|
mod affine_expr;
mod affine_map;
pub(crate) mod attributes;
mod block;
mod context;
mod function;
mod location;
mod module;
mod operations;
mod region;
mod symbols;
pub(crate) mod types;
mod values;
pub use self::affine_expr::*;
pub use self::affine_map::*;
pub use self::attributes::*;
pub use self::block::*;
pub use self::context::*;
pub use self::function::*;
pub use self::location::*;
pub use self::module::*;
pub use self::operations::*;
pub use self::region::*;
pub use self::symbols::{SymbolTable, Visibility};
pub use self::types::*;
pub use self::values::*;
use crate::support::StringRef;
use std::ops::Deref;
/// This error is used with `TryFrom<>` for various MLIR types
#[derive(thiserror::Error, Debug)]
#[error("invalid target type for dynamic cast")]
pub struct InvalidTypeCastError;
extern "C" {
type MlirTypeId;
type MlirBuilder;
type MlirOpBuilder;
type MlirInsertPoint;
}
/// Represents the C++ equivalent of Rust type ids.
///
/// Used for type checks/casts.
#[repr(transparent)]
#[derive(Debug, Copy, Clone)]
pub struct TypeId(*mut MlirTypeId);
impl TypeId {
pub fn is_null(&self) -> bool {
self.0.is_null()
}
}
impl Eq for TypeId {}
impl PartialEq for TypeId {
fn eq(&self, other: &Self) -> bool {
unsafe { mlir_type_id_equal(*self, *other) }
}
}
impl std::hash::Hash for TypeId {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
let value = unsafe { mlir_type_id_hash_value(*self) };
value.hash(state);
}
}
extern "C" {
#[link_name = "mlirTypeIDEqual"]
fn mlir_type_id_equal(a: TypeId, b: TypeId) -> bool;
#[link_name = "mlirTypeIDHashValue"]
fn mlir_type_id_hash_value(id: TypeId) -> usize;
}
/// This trait encompasses functionality common to all
/// derived `Builder` types in MLIR
///
/// Common functionality includes building types and attributes
pub trait Builder {
/// Get the context the builder is associated with
fn context(&self) -> Context {
unsafe { mlir_builder_get_context(self.base()) }
}
/// Obtain an identifier from the given string
///
/// NOTE: Identifiers are just StringAttrs in recent versions of MLIR
fn get_identifier<S: Into<StringRef>>(&self, name: S) -> StringAttr {
StringAttr::get(self.context(), name)
}
/// Obtain a `Location` value of unknown origin
fn get_unknown_loc(&self) -> Location {
unsafe { mlir_builder_get_unknown_loc(self.base()) }
}
/// Obtain a `Location` value from file/line/column info
fn get_file_line_col_loc<S: Into<StringRef>>(
&self,
filename: S,
line: u32,
col: u32,
) -> Location {
unsafe { mlir_builder_get_file_line_col_loc(self.base(), filename.into(), line, col) }
}
/// Fuse multiple `Location` values into a single `Location`
fn get_fused_loc(&self, locs: &[Location]) -> Location {
unsafe { mlir_builder_get_fused_loc(self.base(), locs.len(), locs.as_ptr()) }
}
/// Get a type corresponding to `f64`
fn get_f64_type(&self) -> FloatType {
unsafe { mlir_builder_get_f64_type(self.base()) }
}
/// Get a type corresponding to the opaque index type (a kind of integer)
fn get_index_type(&self) -> IndexType {
unsafe { mlir_builder_get_index_type(self.base()) }
}
/// Get a type corresponding to `i1`
fn get_i1_type(&self) -> IntegerType {
unsafe { mlir_builder_get_i1_type(self.base()) }
}
/// Get a type corresponding to `i8`
fn get_i8_type(&self) -> IntegerType {
self.get_integer_type(8)
}
/// Get a type corresponding to `i16`
fn get_i16_type(&self) -> IntegerType {
self.get_integer_type(16)
}
/// Get a type corresponding to `i32`
fn get_i32_type(&self) -> IntegerType {
unsafe { mlir_builder_get_i32_type(self.base()) }
}
/// Get a type corresponding to `i64`
fn get_i64_type(&self) -> IntegerType {
unsafe { mlir_builder_get_i64_type(self.base()) }
}
/// Get a type corresponding to a signless integer of the provided bit width
fn get_integer_type(&self, width: u32) -> IntegerType {
unsafe { mlir_builder_get_integer_type(self.base(), width) }
}
/// Get a type corresponding to a signed integer of the provided bit width
fn get_signed_integer_type(&self, width: u32) -> IntegerType {
unsafe { mlir_builder_get_signed_integer_type(self.base(), width) }
}
/// Get a type corresponding to a unsigned integer of the provided bit width
fn get_unsigned_integer_type(&self, width: u32) -> IntegerType {
unsafe { mlir_builder_get_unsigned_integer_type(self.base(), width) }
}
/// Get a type corresponding to a tuple of the given elements
fn get_tuple_type(&self, elements: &[TypeBase]) -> TupleType {
TupleType::get(self.context(), elements)
}
/// Get a type corresponding to a memref with the given element type,
/// rank, shape, and address space, with a potentially empty list of affine maps.
fn get_memref_type<T: Type>(
&self,
element_type: T,
shape: &[u64],
layout: AffineMapAttr,
addrspace: AddressSpace,
) -> MemRefType {
MemRefType::get(element_type, shape, layout, addrspace)
}
/// Get a type corresponding to a memref with the given element type, shape and address space.
///
/// This is slightly different than the one returned by `get_memref_type`, as it has no affine maps, i.e.
/// it represents a default row-major contiguous memref.
fn get_contiguous_memref_type<T: Type>(
element_type: T,
shape: &[u64],
addrspace: AddressSpace,
) -> MemRefType {
MemRefType::get_contiguous(element_type, shape, addrspace)
}
/// Get a type corresponding to a memref of dynamic rank, with the given element type and address space.
fn get_unranked_memref<T: Type>(element_type: T, addrspace: AddressSpace) -> MemRefType {
MemRefType::get_unranked(element_type, addrspace)
}
/// Get a type corresponding to a function signature with the given input and result types
fn get_function_type(&self, inputs: &[TypeBase], results: &[TypeBase]) -> FunctionType {
let inputc = inputs.len();
let inputv = inputs.as_ptr();
let resultc = results.len();
let resultv = results.as_ptr();
unsafe { mlir_builder_get_function_type(self.base(), inputc, inputv, resultc, resultv) }
}
/// Get a type respresenting the none value, something akin to `null`
fn get_none_type(&self) -> NoneType {
unsafe { mlir_builder_get_none_type(self.base()) }
}
/// Get a type representing a 1D vector of `element_ty` and `arity`
fn get_array_type<T: Type>(&self, element_ty: T, arity: usize) -> VectorType {
VectorType::get(element_ty, &[arity as u64])
}
/// Get a type representing an N-dimensional vector of `element_ty` and `arity`
fn get_vector_type<T: Type>(&self, element_ty: T, shape: &[u64]) -> VectorType {
VectorType::get(element_ty, shape)
}
/// Associate the given name to the provided attribute value as a `NamedAttribute`
fn get_named_attr<S: Into<StringRef>, A: Attribute>(
&self,
name: S,
value: A,
) -> NamedAttribute {
NamedAttribute::get(self.get_string_attr(name), value)
}
/// Get an attribute which has no value (i.e. its presence is significant)
fn get_unit_attr(&self) -> UnitAttr {
unsafe { mlir_builder_get_unit_attr(self.base()) }
}
/// Get an attribute which has a type value
fn get_type_attr<T: Type>(&self, ty: T) -> TypeAttr {
TypeAttr::get(ty)
}
/// Get an attribute which has a boolean value
fn get_bool_attr(&self, value: bool) -> BoolAttr {
unsafe { mlir_builder_get_bool_attr(self.base(), value) }
}
/// Get an attribute which is a collection of key/value pairs, or more precisely, a set of
/// `NamedAttribute`
fn get_dictionary_attr(&self, values: &[NamedAttribute]) -> DictionaryAttr {
DictionaryAttr::get(self.context(), values)
}
/// Get an attribute which has an integer value of the given type
fn get_integer_attr<I: IntegerLike>(&self, ty: I, value: i64) -> IntegerAttr {
unsafe { mlir_builder_get_integer_attr(self.base(), ty.base(), value) }
}
/// Get an attribute which has an integer value of the given type
/// NOTE: This will panic if a non-primitive integer type is provided
unsafe fn get_integer_attr_unchecked(&self, ty: TypeBase, value: i64) -> IntegerAttr {
mlir_builder_get_integer_attr(self.base(), ty, value)
}
/// Get an attribute which has an i8 integer value
fn get_i8_attr(&self, value: i8) -> IntegerAttr {
unsafe { mlir_builder_get_i8_attr(self.base(), value) }
}
/// Get an attribute which has an i16 integer value
fn get_i16_attr(&self, value: i16) -> IntegerAttr {
unsafe { mlir_builder_get_i16_attr(self.base(), value) }
}
/// Get an attribute which has an i32 integer value
fn get_i32_attr(&self, value: i32) -> IntegerAttr {
unsafe { mlir_builder_get_i32_attr(self.base(), value) }
}
/// Get an attribute which has an i64 integer value
fn get_i64_attr(&self, value: i64) -> IntegerAttr {
unsafe { mlir_builder_get_i64_attr(self.base(), value) }
}
/// Get an attribute which has an index value
fn get_index_attr(&self, value: i64) -> IntegerAttr {
unsafe { mlir_builder_get_index_attr(self.base(), value) }
}
/// Get an attribute which has an float value of the given type
fn get_float_attr(&self, ty: FloatType, value: f64) -> FloatAttr {
unsafe { mlir_builder_get_float_attr(self.base(), ty, value) }
}
/// Get an attribute which has an f64 integer value
fn get_f64_attr(&self, value: f64) -> FloatAttr {
self.get_float_attr(self.get_f64_type(), value)
}
/// Get an attribute which has a string value
fn get_string_attr<S: Into<StringRef>>(&self, value: S) -> StringAttr {
unsafe { mlir_builder_get_string_attr(self.base(), value.into()) }
}
/// Get an attribute which has an array value
fn get_array_attr(&self, values: &[AttributeBase]) -> ArrayAttr {
unsafe { mlir_builder_get_array_attr(self.base(), values.len(), values.as_ptr()) }
}
/// Get an attribute which has a FlatSymbolRef value, using the given Operation to get the
/// symbol name
fn get_flat_symbol_ref_attr_by_op<O: Operation>(&self, op: O) -> FlatSymbolRefAttr {
unsafe { mlir_builder_get_flat_symbol_ref_attr_by_operation(self.base(), op.base()) }
}
/// Get an attribute which has a FlatSymbolRef value, using the given string as the symbol name
fn get_flat_symbol_ref_attr_by_name<S: Into<StringRef>>(&self, symbol: S) -> FlatSymbolRefAttr {
unsafe { mlir_builder_get_flat_symbol_ref_attr_by_name(self.base(), symbol.into()) }
}
/// Get an attribute which has a SymbolRef value, using the given string as the root symbol
/// name, and the given nested SymbolRef/FlatSymbolRef values
fn get_symbol_ref_attr<S: Into<StringRef>>(
&self,
value: S,
nested: &[SymbolRefAttr],
) -> SymbolRefAttr {
unsafe {
mlir_builder_get_symbol_ref_attr(
self.base(),
value.into(),
nested.len(),
nested.as_ptr(),
)
}
}
/// Get an attribute which has the given AffineMap value
fn get_affine_map_attr(&self, map: AffineMap) -> AffineMapAttr {
AffineMapAttr::get(map)
}
/// Get a zero-result affine map with no dimensions or symbols
fn get_empty_affine_map(&self) -> AffineMap {
AffineMap::get_empty(self.context())
}
/// Creates a zero-result affine map with the given dimensions and symbols
fn get_zero_result_affine_map(&self, dims: usize, symbols: usize) -> AffineMap {
AffineMap::get_zero_result(self.context(), dims, symbols)
}
/// Get an affine map with results defined by the given list of affine expressions.
/// The resulting map also has the requested number of input dimensions and symbols,
/// regardless of them being used in the results.
fn get_affine_map(&self, dims: usize, symbols: usize, exprs: &[AffineExprBase]) -> AffineMap {
AffineMap::get(self.context(), dims, symbols, exprs)
}
/// Gets a single constant result affine map
fn get_constant_affine_map(&self, value: u64) -> AffineMap {
AffineMap::get_constant(self.context(), value)
}
/// Gets an affine map with `dims` identity
fn get_multi_dim_identity_affine_map(&self, dims: usize) -> AffineMap {
AffineMap::get_multi_dim_identity(self.context(), dims)
}
/// Gets an identity affine map on the most minor dimensions.
/// This function will panic if the number of dimensions is greater or equal to the number of results
fn get_minor_identity_affine_map(&self, dims: usize, results: usize) -> AffineMap {
AffineMap::get_minor_identity(self.context(), dims, results)
}
/// Gets an affine map with a permutation expression and its size.
///
/// The permutation expression is a non-empty vector of integers.
/// The elements of the permutation vector must be continuous from 0 and cannot be repeated,
/// i.e. `[1, 2, 0]` is a valid permutation, `[2, 0]` or `[1, 1, 2]` are not.
fn get_affine_map_permutation(&self, permutation: Permutation) -> AffineMap {
AffineMap::get_permutation(self.context(), permutation)
}
fn base(&self) -> BuilderBase;
}
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct BuilderBase(*mut MlirBuilder);
impl Builder for BuilderBase {
#[inline(always)]
fn base(&self) -> BuilderBase {
*self
}
}
/// This trait extends the `Builder` trait with op-building functionality
pub trait OpBuilder: Builder {
/// Saves the current insertion point to a guard, that when dropped, restores the builder
/// to the saved location
fn insertion_guard<'a>(&'a self) -> InsertionGuard<'a> {
let builder = self.base().into();
let ip = unsafe { mlir_op_builder_save_insertion_point(builder) };
InsertionGuard {
ip,
builder,
_marker: core::marker::PhantomData,
}
}
/// Sets the insertion point to just before the given operation
fn set_insertion_point<O: Operation>(&self, op: O) {
unsafe {
mlir_op_builder_set_insertion_point(self.base().into(), op.base());
}
}
/// Sets the insertion point to just after the given operation
fn set_insertion_point_after<O: Operation>(&self, op: O) {
unsafe {
mlir_op_builder_set_insertion_point_after(self.base().into(), op.base());
}
}
/// Sets the insertion point to just after the operation that introduced the given value
fn set_insertion_point_after_value<V: Value>(&self, value: V) {
unsafe {
mlir_op_builder_set_insertion_point_after_value(self.base().into(), value.base());
}
}
/// Sets the insertion point to the start of the given block
fn set_insertion_point_to_start(&self, block: Block) {
unsafe {
mlir_op_builder_set_insertion_point_to_start(self.base().into(), block);
}
}
/// Sets the insertion point to the end of the given block
fn set_insertion_point_to_end(&self, block: Block) {
unsafe {
mlir_op_builder_set_insertion_point_to_end(self.base().into(), block);
}
}
/// Returns the current block the builder is inserting into, if positioned inside a block
fn get_insertion_block(&self) -> Option<Block> {
let block = unsafe { mlir_op_builder_get_insertion_block(self.base().into()) };
if block.is_null() {
None
} else {
Some(block)
}
}
/// Creates a new block with the given arguments, appending it to the given region
fn create_block_in_region(
&self,
region: Region,
args: &[TypeBase],
locs: &[Location],
) -> Block {
assert_eq!(args.len(), locs.len());
unsafe {
mlir_op_builder_create_block(
self.base().into(),
region,
args.len(),
args.as_ptr(),
locs.as_ptr(),
)
}
}
/// Creates a new block with the given arguments, placing it before the given block
fn create_block_before(&self, before: Block, args: &[TypeBase], locs: &[Location]) -> Block {
assert_eq!(args.len(), locs.len());
unsafe {
mlir_op_builder_create_block_before(
self.base().into(),
before,
args.len(),
args.as_ptr(),
locs.as_ptr(),
)
}
}
/// Inserts the given operation
fn insert_operation<O: Operation>(&self, op: O) -> OperationBase {
unsafe { mlir_op_builder_insert_operation(self.base().into(), op.base()) }
}
/// Creates an operation of the given type using the provided state
///
/// This is a low-level operation, and should be used by dialect-specific builders
/// to construct their operations.
fn create_operation<O: Operation>(&self, state: OperationState) -> anyhow::Result<O>
where
O: Operation + TryFrom<OperationBase, Error = InvalidTypeCastError>,
{
let base = unsafe { mlir_op_builder_create_operation(self.base().into(), &state) };
if base.is_null() {
Err(InvalidOperationError.into())
} else {
O::try_from(base).map_err(|e| e.into())
}
}
/// Clones the given operation
fn clone_operation<O: Operation>(&self, op: O) -> O
where
O: Operation + TryFrom<OperationBase, Error = InvalidTypeCastError>,
{
let base = unsafe { mlir_op_builder_clone_operation(self.base().into(), op.base()) };
assert!(!base.is_null(), "clone of operation returned null");
O::try_from(base).unwrap()
}
/// Creates a new ModuleOp with the given source location and name
///
/// NOTE: Ownership is with the caller
fn create_module<S: Into<StringRef>>(&self, loc: Location, name: S) -> OwnedModule {
unsafe { mlir_op_builder_create_module(self.base().into(), loc, name.into()) }
}
/// Gets the function with the given symbol name, using the symbol table associated with
/// the operation currently being inserted into.
///
/// If the symbol is found, but not associated with a FuncOp, this function will panic
///
/// If the current operation's symbol table does not contain an entry by that name, returns None
fn get_func_by_symbol<S: Into<StringRef>>(&self, name: S) -> Option<FuncOp> {
let current_block = self.get_insertion_block()?;
let current_op = current_block.operation().unwrap();
if let Some(op) = SymbolTable::lookup_nearest_symbol_from(current_op, name) {
Some(op.try_into().unwrap())
} else {
None
}
}
/// Declares a function with the given source location, name, type, visibility and attributes,
/// unless a function by that name already exists, in which case the existing declaration is
/// returned instead.
///
/// This function will panic if the symbol name provided is associated with an operation that is
/// not a FuncOp.
fn get_or_declare_func<S: Into<StringRef>>(
&self,
loc: Location,
name: S,
ty: FunctionType,
vis: Visibility,
attrs: &[NamedAttribute],
) -> FuncOp {
let name = name.into();
if let Some(op) = self.get_func_by_symbol(name) {
op
} else {
let func = self.build_func(loc, name, ty, attrs, &[]);
func.set_visibility(vis);
func
}
}
/// Builds a FuncOp with the given source location, name, type, and attributes
fn build_func<S: Into<StringRef>>(
&self,
loc: Location,
name: S,
ty: FunctionType,
attrs: &[NamedAttribute],
arg_attrs: &[DictionaryAttr],
) -> FuncOp {
unsafe {
mlir_func_build_func_op(
self.base().into(),
loc,
name.into(),
ty,
attrs.len(),
attrs.as_ptr(),
arg_attrs.len(),
arg_attrs.as_ptr(),
)
}
}
}
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct OpBuilderBase(*mut MlirOpBuilder);
impl Builder for OpBuilderBase {
#[inline(always)]
fn base(&self) -> BuilderBase {
(*self).into()
}
}
impl OpBuilder for OpBuilderBase {}
impl Into<BuilderBase> for OpBuilderBase {
fn into(self) -> BuilderBase {
BuilderBase(unsafe { std::mem::transmute::<*mut MlirOpBuilder, *mut MlirBuilder>(self.0) })
}
}
impl From<BuilderBase> for OpBuilderBase {
fn from(builder: BuilderBase) -> Self {
Self(unsafe { std::mem::transmute::<*mut MlirBuilder, *mut MlirOpBuilder>(builder.0) })
}
}
/// This type is essentially the concrete implementation of the `Builder`
/// trait, but in C++ this type corresponds to `mlir::Builder`, which is
/// the base class for the more useful `OpBuilder` class. We model it here
/// in case in the future we need to support APIs that only take a `Builder`,
/// not `OpBuilder` in MLIR.
#[repr(transparent)]
pub struct OwnedBuilder(BuilderBase);
impl OwnedBuilder {
pub fn new(context: Context) -> Self {
unsafe { mlir_builder_new_from_context(context) }
}
pub fn from_module(module: Module) -> Self {
unsafe { mlir_builder_new_from_module(module) }
}
}
impl Builder for OwnedBuilder {
#[inline]
fn base(&self) -> BuilderBase {
self.0
}
}
impl Deref for OwnedBuilder {
type Target = BuilderBase;
fn deref(&self) -> &Self::Target {
&self.0
}
}
/// The `OpBuilder` type is the primary builder type used when constructing
/// IR during compilation. With it, one can do all the things `Builder` can do,
/// but can also construct operations, blocks, and regions.
#[repr(transparent)]
pub struct OwnedOpBuilder(OpBuilderBase);
impl OwnedOpBuilder {
#[inline]
pub fn new(context: Context) -> Self {
unsafe { mlir_op_builder_new_from_context(context) }
}
#[inline]
pub fn at_block_start(block: Block) -> Self {
unsafe { mlir_op_builder_at_block_begin(block) }
}
#[inline]
pub fn at_block_end(block: Block) -> Self {
unsafe { mlir_op_builder_at_block_end(block) }
}
#[inline]
pub fn at_block_terminator(block: Block) -> Self {
unsafe { mlir_op_builder_at_block_terminator(block) }
}
}
impl Drop for OwnedOpBuilder {
fn drop(&mut self) {
unsafe { mlir_op_builder_destroy(self.0) }
}
}
impl Builder for OwnedOpBuilder {
fn base(&self) -> BuilderBase {
self.0.into()
}
}
impl OpBuilder for OwnedOpBuilder {}
impl Deref for OwnedOpBuilder {
type Target = OpBuilderBase;
fn deref(&self) -> &Self::Target {
&self.0
}
}
extern "C" {
#[link_name = "mlirBuilderNewFromContext"]
fn mlir_builder_new_from_context(context: Context) -> OwnedBuilder;
#[link_name = "mlirBuilderNewFromModule"]
fn mlir_builder_new_from_module(module: Module) -> OwnedBuilder;
#[link_name = "mlirBuilderGetContext"]
fn mlir_builder_get_context(builder: BuilderBase) -> Context;
#[link_name = "mlirBuilderGetUnknownLoc"]
fn mlir_builder_get_unknown_loc(builder: BuilderBase) -> Location;
#[link_name = "mlirBuilderGetFileLineColLoc"]
fn mlir_builder_get_file_line_col_loc(
builder: BuilderBase,
filename: StringRef,
line: u32,
column: u32,
) -> Location;
#[link_name = "mlirBuilderGetFusedLoc"]
fn mlir_builder_get_fused_loc(
builder: BuilderBase,
num_locs: usize,
locs: *const Location,
) -> Location;
#[link_name = "mlirBuilderGetF64Type"]
fn mlir_builder_get_f64_type(builder: BuilderBase) -> FloatType;
#[link_name = "mlirBuilderGetIndexType"]
fn mlir_builder_get_index_type(builder: BuilderBase) -> IndexType;
#[link_name = "mlirBuilderGetI1Type"]
fn mlir_builder_get_i1_type(builder: BuilderBase) -> IntegerType;
#[link_name = "mlirBuilderGetI32Type"]
fn mlir_builder_get_i32_type(builder: BuilderBase) -> IntegerType;
#[link_name = "mlirBuilderGetI64Type"]
fn mlir_builder_get_i64_type(builder: BuilderBase) -> IntegerType;
#[link_name = "mlirBuilderGetIntegerType"]
fn mlir_builder_get_integer_type(builder: BuilderBase, width: u32) -> IntegerType;
#[link_name = "mlirBuilderGetSignedIntegerType"]
fn mlir_builder_get_signed_integer_type(builder: BuilderBase, width: u32) -> IntegerType;
#[link_name = "mlirBuilderGetUnsignedIntegerType"]
fn mlir_builder_get_unsigned_integer_type(builder: BuilderBase, width: u32) -> IntegerType;
#[link_name = "mlirBuilderGetFunctionType"]
fn mlir_builder_get_function_type(
builder: BuilderBase,
num_inputs: usize,
inputs: *const TypeBase,
num_results: usize,
results: *const TypeBase,
) -> FunctionType;
#[link_name = "mlirBuilderGetNoneType"]
fn mlir_builder_get_none_type(builder: BuilderBase) -> NoneType;
#[link_name = "mlirBuilderGetUnitAttr"]
fn mlir_builder_get_unit_attr(builder: BuilderBase) -> UnitAttr;
#[link_name = "mlirBuilderGetBoolAttr"]
fn mlir_builder_get_bool_attr(builder: BuilderBase, value: bool) -> BoolAttr;
#[link_name = "mlirBuilderGetIntegerAttr"]
fn mlir_builder_get_integer_attr(builder: BuilderBase, ty: TypeBase, value: i64)
-> IntegerAttr;
#[link_name = "mlirBuilderGetI8Attr"]
fn mlir_builder_get_i8_attr(builder: BuilderBase, value: i8) -> IntegerAttr;
#[link_name = "mlirBuilderGetI16Attr"]
fn mlir_builder_get_i16_attr(builder: BuilderBase, value: i16) -> IntegerAttr;
#[link_name = "mlirBuilderGetI32Attr"]
fn mlir_builder_get_i32_attr(builder: BuilderBase, value: i32) -> IntegerAttr;
#[link_name = "mlirBuilderGetI64Attr"]
fn mlir_builder_get_i64_attr(builder: BuilderBase, value: i64) -> IntegerAttr;
#[link_name = "mlirBuilderGetIndexAttr"]
fn mlir_builder_get_index_attr(builder: BuilderBase, value: i64) -> IntegerAttr;
#[link_name = "mlirBuilderGetFloatAttr"]
fn mlir_builder_get_float_attr(builder: BuilderBase, ty: FloatType, value: f64) -> FloatAttr;
#[link_name = "mlirBuilderGetStringAttr"]
fn mlir_builder_get_string_attr(builder: BuilderBase, value: StringRef) -> StringAttr;
#[link_name = "mlirBuilderGetArrayAttr"]
fn mlir_builder_get_array_attr(
builder: BuilderBase,
num_elements: usize,
elements: *const AttributeBase,
) -> ArrayAttr;
#[link_name = "mlirBuilderGetFlatSymbolRefAttrByOperation"]
fn mlir_builder_get_flat_symbol_ref_attr_by_operation(
builder: BuilderBase,
op: OperationBase,
) -> FlatSymbolRefAttr;
#[link_name = "mlirBuilderGetFlatSymbolRefAttrByName"]
fn mlir_builder_get_flat_symbol_ref_attr_by_name(
builder: BuilderBase,
symbol: StringRef,
) -> FlatSymbolRefAttr;
#[link_name = "mlirBuilderGetSymbolRefAttr"]
fn mlir_builder_get_symbol_ref_attr(
builder: BuilderBase,
value: StringRef,
num_nested: usize,
nested: *const SymbolRefAttr,
) -> SymbolRefAttr;
#[link_name = "mlirOpBuilderNewFromContext"]
fn mlir_op_builder_new_from_context(context: Context) -> OwnedOpBuilder;
#[link_name = "mlirOpBuilderCreateModule"]
fn mlir_op_builder_create_module(
builder: OpBuilderBase,
loc: Location,
name: StringRef,
) -> OwnedModule;
#[link_name = "mlirOpBuilderAtBlockBegin"]
fn mlir_op_builder_at_block_begin(block: Block) -> OwnedOpBuilder;
#[link_name = "mlirOpBuilderAtBlockEnd"]
fn mlir_op_builder_at_block_end(block: Block) -> OwnedOpBuilder;
#[link_name = "mlirOpBuilderAtBlockTerminator"]
fn mlir_op_builder_at_block_terminator(block: Block) -> OwnedOpBuilder;
#[link_name = "mlirOpBuilderDestroy"]
fn mlir_op_builder_destroy(builder: OpBuilderBase);
#[link_name = "mlirOpBuilderSetInsertionPoint"]
fn mlir_op_builder_set_insertion_point(builder: OpBuilderBase, op: OperationBase);
#[link_name = "mlirOpBuilderSetInsertionPointAfter"]
fn mlir_op_builder_set_insertion_point_after(builder: OpBuilderBase, op: OperationBase);
#[link_name = "mlirOpBuilderSetInsertionPointAfterValue"]
fn mlir_op_builder_set_insertion_point_after_value(builder: OpBuilderBase, value: ValueBase);
#[link_name = "mlirOpBuilderSetInsertionPointToStart"]
fn mlir_op_builder_set_insertion_point_to_start(builder: OpBuilderBase, block: Block);
#[link_name = "mlirOpBuilderSetInsertionPointToEnd"]
fn mlir_op_builder_set_insertion_point_to_end(builder: OpBuilderBase, block: Block);
#[link_name = "mlirOpBuilderGetInsertionBlock"]
fn mlir_op_builder_get_insertion_block(builder: OpBuilderBase) -> Block;
#[link_name = "mlirOpBuilderCreateBlock"]
fn mlir_op_builder_create_block(
builder: OpBuilderBase,
parent: Region,
num_args: usize,
args: *const TypeBase,
locs: *const Location,
) -> Block;
#[link_name = "mlirOpBuilderCreateBlockBefore"]
fn mlir_op_builder_create_block_before(
builder: OpBuilderBase,
before: Block,
num_args: usize,
args: *const TypeBase,
locs: *const Location,
) -> Block;
#[link_name = "mlirOpBuilderInsertOperation"]
fn mlir_op_builder_insert_operation(builder: OpBuilderBase, op: OperationBase)
-> OperationBase;
#[link_name = "mlirOpBuilderCreateOperation"]
fn mlir_op_builder_create_operation(
builder: OpBuilderBase,
state: *const OperationState,
) -> OperationBase;
#[link_name = "mlirOpBuilderCloneOperation"]
fn mlir_op_builder_clone_operation(builder: OpBuilderBase, op: OperationBase) -> OperationBase;
}
/// This opaque type represents the insertion point of an OpBuilder
#[repr(transparent)]
#[derive(Copy, Clone)]
pub struct InsertPoint(*mut MlirInsertPoint);
/// This type provides an RAII-style guard which saves the insertion
/// point of its parent OpBuilder on creation, and restores the saved
/// insertion point when dropped.
pub struct InsertionGuard<'a> {
ip: InsertPoint,
builder: OpBuilderBase,
_marker: core::marker::PhantomData<&'a OpBuilderBase>,
}
impl Drop for InsertionGuard<'_> {
fn drop(&mut self) {
unsafe {
mlir_op_builder_restore_insertion_point(self.builder, self.ip);
}
}
}
extern "C" {
#[link_name = "mlirOpBuilderSaveInsertionPoint"]
fn mlir_op_builder_save_insertion_point(builder: OpBuilderBase) -> InsertPoint;
#[link_name = "mlirOpBuilderRestoreInsertionPoint"]
fn mlir_op_builder_restore_insertion_point(builder: OpBuilderBase, ip: InsertPoint);
}
|
use std::collections::BTreeMap;
use std::fs::{self, File};
use std::io::Write;
use std::net::SocketAddr;
use std::net::TcpStream;
use std::os::unix::fs::PermissionsExt;
use std::path::PathBuf;
use std::process::{Command, Stdio};
use std::str::FromStr;
use std::sync::Arc;
use std::time::Duration;
use anyhow::{Context, Result};
use zenith_utils::connstring::connection_host_port;
use zenith_utils::lsn::Lsn;
use zenith_utils::postgres_backend::AuthType;
use zenith_utils::zid::ZTenantId;
use zenith_utils::zid::ZTimelineId;
use crate::local_env::LocalEnv;
use crate::postgresql_conf::PostgresConf;
use crate::storage::PageServerNode;
//
// ComputeControlPlane
//
pub struct ComputeControlPlane {
base_port: u16,
pageserver: Arc<PageServerNode>,
pub nodes: BTreeMap<(ZTenantId, String), Arc<PostgresNode>>,
env: LocalEnv,
}
impl ComputeControlPlane {
// Load current nodes with ports from data directories on disk
// Directory structure has the following layout:
// pgdatadirs
// |- tenants
// | |- <tenant_id>
// | | |- <branch name>
pub fn load(env: LocalEnv) -> Result<ComputeControlPlane> {
// TODO: since pageserver do not have config file yet we believe here that
// it is running on default port. Change that when pageserver will have config.
let pageserver = Arc::new(PageServerNode::from_env(&env));
let mut nodes = BTreeMap::default();
let pgdatadirspath = &env.pg_data_dirs_path();
for tenant_dir in fs::read_dir(&pgdatadirspath)
.with_context(|| format!("failed to list {}", pgdatadirspath.display()))?
{
let tenant_dir = tenant_dir?;
for timeline_dir in fs::read_dir(tenant_dir.path())
.with_context(|| format!("failed to list {}", tenant_dir.path().display()))?
{
let node = PostgresNode::from_dir_entry(timeline_dir?, &env, &pageserver)?;
nodes.insert((node.tenantid, node.name.clone()), Arc::new(node));
}
}
Ok(ComputeControlPlane {
base_port: 55431,
pageserver,
nodes,
env,
})
}
fn get_port(&mut self) -> u16 {
1 + self
.nodes
.iter()
.map(|(_name, node)| node.address.port())
.max()
.unwrap_or(self.base_port)
}
pub fn local(local_env: &LocalEnv, pageserver: &Arc<PageServerNode>) -> ComputeControlPlane {
ComputeControlPlane {
base_port: 65431,
pageserver: Arc::clone(pageserver),
nodes: BTreeMap::new(),
env: local_env.clone(),
}
}
pub fn new_node(
&mut self,
tenantid: ZTenantId,
branch_name: &str,
port: Option<u16>,
) -> Result<Arc<PostgresNode>> {
let timeline_id = self
.pageserver
.branch_get_by_name(&tenantid, branch_name)?
.timeline_id;
let port = port.unwrap_or_else(|| self.get_port());
let node = Arc::new(PostgresNode {
name: branch_name.to_owned(),
address: SocketAddr::new("127.0.0.1".parse().unwrap(), port),
env: self.env.clone(),
pageserver: Arc::clone(&self.pageserver),
is_test: false,
timelineid: timeline_id,
tenantid,
uses_wal_proposer: false,
});
node.create_pgdata()?;
node.setup_pg_conf(self.env.auth_type)?;
self.nodes
.insert((tenantid, node.name.clone()), Arc::clone(&node));
Ok(node)
}
}
///////////////////////////////////////////////////////////////////////////////
#[derive(Debug)]
pub struct PostgresNode {
pub address: SocketAddr,
name: String,
pub env: LocalEnv,
pageserver: Arc<PageServerNode>,
is_test: bool,
pub timelineid: ZTimelineId,
pub tenantid: ZTenantId,
uses_wal_proposer: bool,
}
impl PostgresNode {
fn from_dir_entry(
entry: std::fs::DirEntry,
env: &LocalEnv,
pageserver: &Arc<PageServerNode>,
) -> Result<PostgresNode> {
if !entry.file_type()?.is_dir() {
anyhow::bail!(
"PostgresNode::from_dir_entry failed: '{}' is not a directory",
entry.path().display()
);
}
// parse data directory name
let fname = entry.file_name();
let name = fname.to_str().unwrap().to_string();
// Read config file into memory
let cfg_path = entry.path().join("postgresql.conf");
let cfg_path_str = cfg_path.to_string_lossy();
let mut conf_file = File::open(&cfg_path)
.with_context(|| format!("failed to open config file in {}", cfg_path_str))?;
let conf = PostgresConf::read(&mut conf_file)
.with_context(|| format!("failed to read config file in {}", cfg_path_str))?;
// Read a few options from the config file
let context = format!("in config file {}", cfg_path_str);
let port: u16 = conf.parse_field("port", &context)?;
let timelineid: ZTimelineId = conf.parse_field("zenith.zenith_timeline", &context)?;
let tenantid: ZTenantId = conf.parse_field("zenith.zenith_tenant", &context)?;
let uses_wal_proposer = conf.get("wal_acceptors").is_some();
// ok now
Ok(PostgresNode {
address: SocketAddr::new("127.0.0.1".parse().unwrap(), port),
name,
env: env.clone(),
pageserver: Arc::clone(pageserver),
is_test: false,
timelineid,
tenantid,
uses_wal_proposer,
})
}
fn sync_walkeepers(&self) -> Result<Lsn> {
let pg_path = self.env.pg_bin_dir().join("postgres");
let sync_handle = Command::new(pg_path)
.arg("--sync-safekeepers")
.env_clear()
.env("LD_LIBRARY_PATH", self.env.pg_lib_dir().to_str().unwrap())
.env("DYLD_LIBRARY_PATH", self.env.pg_lib_dir().to_str().unwrap())
.env("PGDATA", self.pgdata().to_str().unwrap())
.stdout(Stdio::piped())
// Comment this to avoid capturing stderr (useful if command hangs)
.stderr(Stdio::piped())
.spawn()
.expect("postgres --sync-safekeepers failed to start");
let sync_output = sync_handle
.wait_with_output()
.expect("postgres --sync-safekeepers failed");
if !sync_output.status.success() {
anyhow::bail!(
"sync-safekeepers failed: '{}'",
String::from_utf8_lossy(&sync_output.stderr)
);
}
let lsn = Lsn::from_str(std::str::from_utf8(&sync_output.stdout)?.trim())?;
println!("Walkeepers synced on {}", lsn);
Ok(lsn)
}
/// Get basebackup from the pageserver as a tar archive and extract it
/// to the `self.pgdata()` directory.
fn do_basebackup(&self, lsn: Option<Lsn>) -> Result<()> {
println!(
"Extracting base backup to create postgres instance: path={} port={}",
self.pgdata().display(),
self.address.port()
);
let sql = if let Some(lsn) = lsn {
format!("basebackup {} {} {}", self.tenantid, self.timelineid, lsn)
} else {
format!("basebackup {} {}", self.tenantid, self.timelineid)
};
let mut client = self
.pageserver
.page_server_psql_client()
.with_context(|| "connecting to page server failed")?;
let copyreader = client
.copy_out(sql.as_str())
.with_context(|| "page server 'basebackup' command failed")?;
// Read the archive directly from the `CopyOutReader`
tar::Archive::new(copyreader)
.unpack(&self.pgdata())
.with_context(|| "extracting page backup failed")?;
Ok(())
}
fn create_pgdata(&self) -> Result<()> {
fs::create_dir_all(&self.pgdata()).with_context(|| {
format!(
"could not create data directory {}",
self.pgdata().display()
)
})?;
fs::set_permissions(self.pgdata().as_path(), fs::Permissions::from_mode(0o700))
.with_context(|| {
format!(
"could not set permissions in data directory {}",
self.pgdata().display()
)
})
}
// Connect to a page server, get base backup, and untar it to initialize a
// new data directory
fn setup_pg_conf(&self, auth_type: AuthType) -> Result<()> {
let mut conf = PostgresConf::new();
conf.append("max_wal_senders", "10");
// wal_log_hints is mandatory when running against pageserver (see gh issue#192)
// TODO: is it possible to check wal_log_hints at pageserver side via XLOG_PARAMETER_CHANGE?
conf.append("wal_log_hints", "on");
conf.append("max_replication_slots", "10");
conf.append("hot_standby", "on");
conf.append("shared_buffers", "1MB");
conf.append("fsync", "off");
conf.append("max_connections", "100");
conf.append("wal_sender_timeout", "0");
conf.append("wal_level", "replica");
conf.append("listen_addresses", &self.address.ip().to_string());
conf.append("port", &self.address.port().to_string());
// Never clean up old WAL. TODO: We should use a replication
// slot or something proper, to prevent the compute node
// from removing WAL that hasn't been streamed to the safekeeper or
// page server yet. (gh issue #349)
conf.append("wal_keep_size", "10TB");
// Configure the node to fetch pages from pageserver
let pageserver_connstr = {
let (host, port) = connection_host_port(&self.pageserver.pg_connection_config);
// Set up authentication
//
// $ZENITH_AUTH_TOKEN will be replaced with value from environment
// variable during compute pg startup. It is done this way because
// otherwise user will be able to retrieve the value using SHOW
// command or pg_settings
let password = if let AuthType::ZenithJWT = auth_type {
"$ZENITH_AUTH_TOKEN"
} else {
""
};
format!("host={} port={} password={}", host, port, password)
};
conf.append("shared_preload_libraries", "zenith");
conf.append_line("");
conf.append("zenith.page_server_connstring", &pageserver_connstr);
conf.append("zenith.zenith_tenant", &self.tenantid.to_string());
conf.append("zenith.zenith_timeline", &self.timelineid.to_string());
conf.append_line("");
// Configure the node to stream WAL directly to the pageserver
conf.append("synchronous_standby_names", "pageserver"); // TODO: add a new function arg?
conf.append("zenith.callmemaybe_connstring", &self.connstr());
let mut file = File::create(self.pgdata().join("postgresql.conf"))?;
file.write_all(conf.to_string().as_bytes())?;
Ok(())
}
fn load_basebackup(&self) -> Result<()> {
let lsn = if self.uses_wal_proposer {
// LSN 0 means that it is bootstrap and we need to download just
// latest data from the pageserver. That is a bit clumsy but whole bootstrap
// procedure evolves quite actively right now, so let's think about it again
// when things would be more stable (TODO).
let lsn = self.sync_walkeepers()?;
if lsn == Lsn(0) {
None
} else {
Some(lsn)
}
} else {
None
};
self.do_basebackup(lsn)?;
Ok(())
}
pub fn pgdata(&self) -> PathBuf {
self.env.pg_data_dir(&self.tenantid, &self.name)
}
pub fn status(&self) -> &str {
let timeout = Duration::from_millis(300);
let has_pidfile = self.pgdata().join("postmaster.pid").exists();
let can_connect = TcpStream::connect_timeout(&self.address, timeout).is_ok();
match (has_pidfile, can_connect) {
(true, true) => "running",
(false, false) => "stopped",
(true, false) => "crashed",
(false, true) => "running, no pidfile",
}
}
fn pg_ctl(&self, args: &[&str], auth_token: &Option<String>) -> Result<()> {
let pg_ctl_path = self.env.pg_bin_dir().join("pg_ctl");
let mut cmd = Command::new(pg_ctl_path);
cmd.args(
[
&[
"-D",
self.pgdata().to_str().unwrap(),
"-l",
self.pgdata().join("pg.log").to_str().unwrap(),
"-w", //wait till pg_ctl actually does what was asked
],
args,
]
.concat(),
)
.env_clear()
.env("LD_LIBRARY_PATH", self.env.pg_lib_dir().to_str().unwrap())
.env("DYLD_LIBRARY_PATH", self.env.pg_lib_dir().to_str().unwrap());
if let Some(token) = auth_token {
cmd.env("ZENITH_AUTH_TOKEN", token);
}
let pg_ctl = cmd.status().with_context(|| "pg_ctl failed")?;
if !pg_ctl.success() {
anyhow::bail!("pg_ctl failed");
}
Ok(())
}
pub fn start(&self, auth_token: &Option<String>) -> Result<()> {
// Bail if the node already running.
if self.status() == "running" {
anyhow::bail!("The node is already running");
}
// 1. We always start compute node from scratch, so
// if old dir exists, preserve 'postgresql.conf' and drop the directory
let postgresql_conf_path = self.pgdata().join("postgresql.conf");
let postgresql_conf = fs::read(&postgresql_conf_path).with_context(|| {
format!(
"failed to read config file in {}",
postgresql_conf_path.to_str().unwrap()
)
})?;
fs::remove_dir_all(&self.pgdata())?;
self.create_pgdata()?;
// 2. Bring back config files
fs::write(&postgresql_conf_path, postgresql_conf)?;
// 3. Load basebackup
self.load_basebackup()?;
// 4. Finally start the compute node postgres
println!("Starting postgres node at '{}'", self.connstr());
self.pg_ctl(&["start"], auth_token)
}
pub fn restart(&self, auth_token: &Option<String>) -> Result<()> {
self.pg_ctl(&["restart"], auth_token)
}
pub fn stop(&self, destroy: bool) -> Result<()> {
// If we are going to destroy data directory,
// use immediate shutdown mode, otherwise,
// shutdown gracefully to leave the data directory sane.
//
// Compute node always starts from scratch, so stop
// without destroy only used for testing and debugging.
//
if destroy {
self.pg_ctl(&["-m", "immediate", "stop"], &None)?;
println!(
"Destroying postgres data directory '{}'",
self.pgdata().to_str().unwrap()
);
fs::remove_dir_all(&self.pgdata())?;
} else {
self.pg_ctl(&["stop"], &None)?;
}
Ok(())
}
pub fn connstr(&self) -> String {
format!(
"host={} port={} user={} dbname={}",
self.address.ip(),
self.address.port(),
"zenith_admin",
"postgres"
)
}
// XXX: cache that in control plane
pub fn whoami(&self) -> String {
let output = Command::new("whoami")
.output()
.expect("failed to execute whoami");
if !output.status.success() {
panic!("whoami failed");
}
String::from_utf8(output.stdout).unwrap().trim().to_string()
}
}
impl Drop for PostgresNode {
// destructor to clean up state after test is done
// XXX: we may detect failed test by setting some flag in catch_unwind()
// and checking it here. But let just clean datadirs on start.
fn drop(&mut self) {
if self.is_test {
let _ = self.stop(true);
}
}
}
|
pub type StockId = String;
pub type Quantity = u32;
#[derive(Debug, Clone)]
pub enum Stock {
Nothing,
OutOfStock { id: StockId },
InStock { id: StockId, qty: Quantity },
}
pub trait CommandHandle<S, E> {
fn handle(&self, state: S) -> Option<E>;
}
pub trait EventApply<S> {
fn apply(&self, state: S) -> Option<S>;
}
#[derive(Debug, Clone)]
pub enum StockCommand {
Create(StockId),
Ship(StockId, Quantity),
Arrive(StockId, Quantity),
}
impl StockCommand {
pub fn create(id: StockId) -> Self {
Self::Create(id)
}
pub fn ship(id: StockId, qty: Quantity) -> Self {
Self::Ship(id, qty)
}
pub fn arrive(id: StockId, qty: Quantity) -> Self {
Self::Arrive(id, qty)
}
}
#[derive(Debug, Clone)]
pub enum StockEvent {
Created(StockId),
Shipped(StockId, Quantity),
Arrived(StockId, Quantity),
}
impl CommandHandle<Stock, StockEvent> for StockCommand {
fn handle(&self, state: Stock) -> Option<StockEvent> {
match self {
StockCommand::Create(id) => {
match state {
Stock::Nothing => {
Some(
StockEvent::Created(id.clone())
)
},
_ => None
}
},
StockCommand::Ship(id, qty) => {
match state {
Stock::InStock { id: sid, qty: sqty }
if sid == id.clone() && sqty >= qty.clone() => {
Some(
StockEvent::Shipped(id.clone(), qty.clone())
)
},
_ => None
}
},
StockCommand::Arrive(id, qty) => {
match state {
Stock::OutOfStock { id: sid } |
Stock::InStock { id: sid, .. } if sid == id.clone() => {
Some(
StockEvent::Arrived(id.clone(), qty.clone())
)
},
_ => None
}
},
}
}
}
impl EventApply<Stock> for StockEvent {
fn apply(&self, state: Stock) -> Option<Stock> {
match self {
StockEvent::Created(id) => {
match state {
Stock::Nothing => Some(
Stock::OutOfStock { id: id.clone() }
),
_ => None
}
},
StockEvent::Shipped(id, qty) => {
match state {
Stock::InStock { id: sid, qty: sqty }
if sid == id.clone() && sqty == qty.clone() => {
Some(
Stock::OutOfStock { id: id.clone() }
)
},
Stock::InStock { id: sid, qty: sqty }
if sid == id.clone() && sqty > qty.clone() => {
Some(
Stock::InStock { id: id.clone(), qty: sqty - qty }
)
},
_ => None
}
},
StockEvent::Arrived(id, qty) => {
match state {
Stock::OutOfStock { id: sid } if sid == id.clone() => {
Some(
Stock::InStock { id: id.clone(), qty: qty.clone() }
)
},
Stock::InStock { id: sid, qty: sqty } if sid == id.clone() => {
Some(
Stock::InStock { id: id.clone(), qty: sqty + qty }
)
},
_ => None
}
},
}
}
}
impl Stock {
pub fn action(self, cmd: &StockCommand) -> Option<(Stock, StockEvent)> {
cmd.handle(self.clone())
.and_then(|ev|
ev.apply(self).map(|s| (s, ev))
)
}
pub fn restore(self, events: Vec<&StockEvent>) -> Stock {
events.iter().fold(self, |acc, x| x.apply(acc.clone()).unwrap_or(acc))
}
}
|
// Copyright 2017 Amagicom AB.
//
// 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.
//! Low level bindings to the Apple [SystemConfiguration] framework. Generated with bindgen.
//! For a safe, higher level, API, check out the [`system-configuration`] crate.
//!
//! [SystemConfiguration]: https://developer.apple.com/documentation/systemconfiguration?language=objc
//! [`system-configuration`]: https://crates.io/crates/system-configuration
#![no_std]
#![allow(non_camel_case_types)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
pub use core_foundation_sys;
pub use libc;
/// This is a temporary solution.
pub type dispatch_queue_t = *mut libc::c_void;
pub mod dynamic_store;
pub mod dynamic_store_copy_specific;
pub mod network_configuration;
pub mod network_reachability;
pub mod preferences;
pub mod schema_definitions;
|
use std::io::Read;
fn main() {
const MOD: u32 = 20201227;
const PUB_SUB: u32 = 7;
let mut input = String::new();
std::io::stdin().read_to_string(&mut input).unwrap();
let pub_keys: Vec<u32> = input.lines().map(|line| line.parse().unwrap()).collect();
let loop_size = (1..).try_fold(1, |acc, i| {
let val = acc * PUB_SUB % MOD;
if val == pub_keys[0] {
Err(i)
} else {
Ok(val)
}
}).err().unwrap();
println!("{}", (0..loop_size).fold(1, |acc, _| acc * pub_keys[1] as u64 % MOD as u64));
}
|
pub mod natural;
pub mod object;
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
pub enum Error {
/// Number exceeded 32 bits
NaturalOverflow,
/// Non-'case' nodes may not have hidden children
NonCaseHiddenChild,
/// 'case' nodes may have at most one hidden child
CaseMultipleHiddenChildren,
/// Bitstream ended early
EndOfStream,
/// Unrecognized node
ParseError,
}
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum Node {
Iden,
Unit,
InjL(usize),
InjR(usize),
Take(usize),
Drop(usize),
Comp(usize, usize),
Case(usize, usize),
Pair(usize, usize),
Disconnect(usize, usize),
Witness(Vec<u8>),
Fail([u8; 32], [u8; 32]),
Hidden([u8; 32]),
}
/// Decode a natural number according to section 7.2.1
/// of the Simplicity whitepaper.
pub fn decode_node_no_witness<BitStream: Iterator<Item = bool>>(
mut iter: BitStream,
) -> Result<Node, Error> {
let b1 = match iter.next() {
Some(bit) => bit,
None => return Err(Error::EndOfStream),
};
let b2 = match iter.next() {
Some(bit) => bit,
None => return Err(Error::EndOfStream),
};
let b3 = match iter.next() {
Some(bit) => bit,
None => return Err(Error::EndOfStream),
};
let b4 = match iter.next() {
Some(bit) => bit,
None => return Err(Error::EndOfStream),
};
match (b1, b2, b3, b4) {
(false, true, true, false) => {
let mut h = [0; 32];
for i in 0..32 {
for b in 0..8 {
match iter.next() {
Some(true) => h[i] |= 1 << (7 - b),
Some(false) => {},
None => return Err(Error::EndOfStream),
};
}
}
Ok(Node::Hidden(h))
},
(false, true, true, true) => {
Ok(Node::Witness(vec![]))
},
_ => {
let b5 = match iter.next() {
Some(bit) => bit,
None => return Err(Error::EndOfStream),
};
match (b1, b2, b3, b4, b5) {
(false, false, false, false, false) => {
Ok(Node::Comp(
natural::decode(&mut iter)?,
natural::decode(&mut iter)?,
))
},
(false, false, false, false, true) => {
Ok(Node::Case(
natural::decode(&mut iter)?,
natural::decode(&mut iter)?,
))
},
(false, false, false, true, false) => {
Ok(Node::Pair(
natural::decode(&mut iter)?,
natural::decode(&mut iter)?,
))
},
(false, false, false, true, true) => {
Ok(Node::Disconnect(
natural::decode(&mut iter)?,
natural::decode(&mut iter)?,
))
},
(false, false, true, false, false)
=> Ok(Node::InjL(natural::decode(&mut iter)?)),
(false, false, true, false, true)
=> Ok(Node::InjR(natural::decode(&mut iter)?)),
(false, false, true, true, false)
=> Ok(Node::Take(natural::decode(&mut iter)?)),
(false, false, true, true, true)
=> Ok(Node::Drop(natural::decode(&mut iter)?)),
(false, true, false, false, false) => Ok(Node::Iden),
(false, true, false, false, true) => Ok(Node::Unit),
(false, true, false, true, false) => {
let mut h1 = [0; 32];
let mut h2 = [0; 32];
for i in 0..32 {
for b in 0..8 {
match iter.next() {
Some(true) => h1[i] |= 1 << (7 - b),
Some(false) => {},
None => return Err(Error::EndOfStream),
};
}
}
for i in 0..32 {
for b in 0..8 {
match iter.next() {
Some(true) => h2[i] |= 1 << (7 - b),
Some(false) => {},
None => return Err(Error::EndOfStream),
};
}
}
Ok(Node::Fail(h1, h2))
},
(false, true, false, true, true) => Err(Error::ParseError),
(false, true, false, false, true) => Err(Error::ParseError),
(true, _, _, _, _) => Err(Error::ParseError),
(false, true, true, _, _) => unreachable!(),
}
},
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.