text
stringlengths
8
4.13M
use serde::{Deserialize, Serialize}; #[derive(Debug, Deserialize, Serialize)] pub enum TransformationCrop { #[serde(rename = "fit")] FIT, #[serde(rename = "fill")] FILL, }
use chrono::prelude::*; use jsonwebtoken; #[derive(Debug, serde::Deserialize, serde::Serialize)] pub struct Claims { pub sub: String, pub email: String, pub exp: i64, pub iat: i64, } /// Generate JWT for passed User pub fn generate(user: &crate::models::user::User) -> String { let secret = match dotenv::var("JWT_SECRET") { Ok(s) => s, Err(_) => "".to_string(), }; let duration = match dotenv::var("JWT_LIFETIME_IN_SECONDS") { Ok(d) => d, Err(_) => "300".to_string(), }; let duration: i64 = duration.parse().unwrap(); let exp = Utc::now() + chrono::Duration::seconds(duration); let claims = Claims { sub: String::from(&user.id), email: String::from(&user.email), exp: exp.timestamp(), iat: Utc::now().timestamp(), }; jsonwebtoken::encode( &jsonwebtoken::Header::default(), &claims, &jsonwebtoken::EncodingKey::from_secret(&secret.as_bytes()), ) .unwrap_or_default() } /// Verify given token and return user if its okay pub fn verify(token: String) -> Result<crate::models::user::User, jsonwebtoken::errors::Error> { let secret = match dotenv::var("JWT_SECRET") { Ok(s) => s, Err(_) => "".to_string(), }; let token_data = jsonwebtoken::decode::<Claims>( &token, &jsonwebtoken::DecodingKey::from_secret(secret.as_bytes()), &jsonwebtoken::Validation::new(jsonwebtoken::Algorithm::HS256), )?; Ok(crate::models::user::User::from_jwt(&token_data.claims)) } #[cfg(test)] mod tests { use super::{generate, verify}; use crate::models::user::User; #[test] fn generate_and_verify_jwt_token() { let user = User { id: "123".into(), email: "test@test.com".into(), password: "".into(), }; let token = generate(&user.clone()); let verify = match verify(token) { Ok(user) => user.id, Err(e) => panic!(e), }; assert_eq!(verify, user.id); } }
//! Unit propagation. use partial_ref::{partial, PartialRef}; use crate::context::{parts::*, Context}; pub mod assignment; pub mod binary; pub mod graph; pub mod long; pub mod watch; pub use assignment::{backtrack, enqueue_assignment, full_restart, restart, Assignment, Trail}; pub use graph::{Conflict, ImplGraph, ImplNode, Reason}; pub use watch::{enable_watchlists, Watch, Watchlists}; /// Propagate enqueued assignments. /// /// Returns when all enqueued assignments are propagated, including newly propagated assignemnts, or /// if there is a conflict. /// /// On conflict the first propagation that would assign the opposite value to an already assigned /// literal is returned. pub fn propagate( mut ctx: partial!( Context, mut AssignmentP, mut ClauseAllocP, mut ImplGraphP, mut TrailP, mut WatchlistsP, BinaryClausesP, ClauseDbP, ), ) -> Result<(), Conflict> { enable_watchlists(ctx.borrow()); while let Some(lit) = ctx.part_mut(TrailP).pop_queue() { binary::propagate_binary(ctx.borrow(), lit)?; long::propagate_long(ctx.borrow(), lit)?; } Ok(()) } #[cfg(test)] mod tests { use super::*; use proptest::{prelude::*, *}; use rand::{distributions::Bernoulli, seq::SliceRandom}; use partial_ref::IntoPartialRefMut; use varisat_formula::{cnf::strategy::*, CnfFormula, Lit}; use crate::{ clause::{db, gc}, load::load_clause, state::SatState, }; /// Generate a random formula and list of implied literals. pub fn prop_formula( vars: impl Strategy<Value = usize>, extra_vars: impl Strategy<Value = usize>, extra_clauses: impl Strategy<Value = usize>, density: impl Strategy<Value = f64>, ) -> impl Strategy<Value = (Vec<Lit>, CnfFormula)> { (vars, extra_vars, extra_clauses, density).prop_flat_map( |(vars, extra_vars, extra_clauses, density)| { let polarity = collection::vec(bool::ANY, vars + extra_vars); let dist = Bernoulli::new(density).unwrap(); let lits = polarity .prop_map(|polarity| { polarity .into_iter() .enumerate() .map(|(index, polarity)| Lit::from_index(index, polarity)) .collect::<Vec<_>>() }) .prop_shuffle(); lits.prop_perturb(move |mut lits, mut rng| { let assigned_lits = &lits[..vars]; let mut clauses: Vec<Vec<Lit>> = vec![]; for (i, &lit) in assigned_lits.iter().enumerate() { // Build a clause that implies lit let mut clause = vec![lit]; for &reason_lit in assigned_lits[..i].iter() { if rng.sample(dist) { clause.push(!reason_lit); } } clause.shuffle(&mut rng); clauses.push(clause); } for _ in 0..extra_clauses { // Build a clause that is satisfied let &true_lit = assigned_lits.choose(&mut rng).unwrap(); let mut clause = vec![true_lit]; for &other_lit in lits.iter() { if other_lit != true_lit && rng.sample(dist) { clause.push(other_lit ^ rng.gen::<bool>()); } } clause.shuffle(&mut rng); clauses.push(clause); } clauses.shuffle(&mut rng); // Only return implied lits lits.drain(vars..); (lits, CnfFormula::from(clauses)) }) }, ) } proptest! { #[test] fn propagation_no_conflict( (mut lits, formula) in prop_formula( 2..30usize, 0..10usize, 0..20usize, 0.1..0.9 ), ) { let mut ctx = Context::default(); let mut ctx = ctx.into_partial_ref_mut(); for clause in formula.iter() { load_clause(ctx.borrow(), clause); } prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::Unknown); let prop_result = propagate(ctx.borrow()); prop_assert_eq!(prop_result, Ok(())); lits.sort(); let mut prop_lits = ctx.part(TrailP).trail().to_owned(); // Remap vars for lit in prop_lits.iter_mut() { *lit = lit.map_var(|solver_var| { ctx.part(VariablesP).existing_user_from_solver(solver_var) }); } prop_lits.sort(); prop_assert_eq!(prop_lits, lits); } #[test] fn propagation_conflict( (lits, formula) in prop_formula( 2..30usize, 0..10usize, 0..20usize, 0.1..0.9 ), conflict_size in any::<sample::Index>(), ) { let mut ctx = Context::default(); let mut ctx = ctx.into_partial_ref_mut(); // We add the conflict clause first to make sure that it isn't simplified during loading let conflict_size = conflict_size.index(lits.len() - 1) + 2; let conflict_clause: Vec<_> = lits[..conflict_size].iter().map(|&lit| !lit).collect(); load_clause(ctx.borrow(), &conflict_clause); for clause in formula.iter() { load_clause(ctx.borrow(), clause); } prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::Unknown); let prop_result = propagate(ctx.borrow()); prop_assert!(prop_result.is_err()); let conflict = prop_result.unwrap_err(); let conflict_lits = conflict.lits(&ctx.borrow()).to_owned(); for &lit in conflict_lits.iter() { prop_assert!(ctx.part(AssignmentP).lit_is_false(lit)); } } #[test] fn propagation_no_conflict_after_gc( tmp_formula in cnf_formula(3..30usize, 30..100, 3..30), (mut lits, formula) in prop_formula( 2..30usize, 0..10usize, 0..20usize, 0.1..0.9 ), ) { let mut ctx = Context::default(); let mut ctx = ctx.into_partial_ref_mut(); for clause in tmp_formula.iter() { // Only add long clauses here let mut lits = clause.to_owned(); lits.sort(); lits.dedup(); if lits.len() >= 3 { load_clause(ctx.borrow(), clause); } } let tmp_crefs: Vec<_> = db::clauses_iter(&ctx.borrow()).collect(); for clause in formula.iter() { load_clause(ctx.borrow(), clause); } for cref in tmp_crefs { db::delete_clause(ctx.borrow(), cref); } gc::collect_garbage(ctx.borrow()); prop_assert_eq!(ctx.part(SolverStateP).sat_state, SatState::Unknown); let prop_result = propagate(ctx.borrow()); prop_assert_eq!(prop_result, Ok(())); lits.sort(); let mut prop_lits = ctx.part(TrailP).trail().to_owned(); // Remap vars for lit in prop_lits.iter_mut() { *lit = lit.map_var(|solver_var| { ctx.part(VariablesP).existing_user_from_solver(solver_var) }); } prop_lits.sort(); prop_assert_eq!(prop_lits, lits); } } }
mod with_pid_alive; use super::*; #[test] fn without_pid_alive_returns_badarg() { run!( |arc_process| { ( Just(arc_process.clone()), strategy::process(), strategy::term::pid::local(), ) }, |(arc_process, group_leader_arc_process, pid)| { let group_leader = group_leader_arc_process.pid_term(); prop_assert_badarg!( result(&arc_process, group_leader, pid), format!("pid ({}) is not alive", pid) ); Ok(()) } ); }
// Copyright 2020-2021, The Tremor Team // // 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. //! # Elastic Search Offramp //! //! The Elastic Search Offramp uses batch writes to send data to elastic search //! //! ## Configuration //! //! See [Config](struct.Config.html) for details. //! //! ## Input Metadata Variables //! * `index` - index to write to (required) //! * `doc-type` - document type for the event (required) //! * `pipeline` - pipeline to use //! //! ## Outputs //! //! The 1st additional output is used to send divert messages that can not be //! enqueued due to overload #![cfg(not(tarpaulin_include))] use crate::sink::prelude::*; use async_channel::{bounded, Receiver, Sender}; use async_std::task::JoinHandle; use elastic::{ client::responses::bulk::{ErrorItem, OkItem}, prelude::*, }; use halfbrown::HashMap; use simd_json::json; use std::time::Instant; use std::{iter, str}; use tremor_pipeline::{EventId, EventIdGenerator}; use tremor_script::prelude::*; use tremor_script::Object; use tremor_value::literal; #[derive(Debug, Deserialize)] pub struct Config { /// list of elasticsearch cluster nodes pub nodes: Vec<String>, /// maximum number of paralel in flight batches (default: 4) #[serde(default = "concurrency")] pub concurrency: usize, } fn concurrency() -> usize { 4 } impl ConfigImpl for Config {} pub struct Elastic { sink_url: TremorUrl, client: SyncClient, queue: AsyncSink<u64>, insight_tx: Sender<sink::Reply>, is_linked: bool, response_sender: Sender<(EventPayload, Cow<'static, str>)>, response_task_handle: Option<JoinHandle<Result<()>>>, origin_uri: EventOriginUri, } impl offramp::Impl for Elastic { fn from_config(config: &Option<OpConfig>) -> Result<Box<dyn Offramp>> { if let Some(config) = config { let config: Config = Config::new(config)?; let client = SyncClientBuilder::new() .static_nodes(config.nodes.into_iter()) .build()?; let queue = AsyncSink::new(config.concurrency); let (tx, _rx) = bounded(1); // dummy value let (res_tx, _res_rx) = bounded(1); // dummy value Ok(SinkManager::new_box(Self { sink_url: TremorUrl::from_offramp_id("elastic")?, // just a dummy value, gonna be overwritten on init client, queue, insight_tx: tx, is_linked: false, response_sender: res_tx, response_task_handle: None, origin_uri: EventOriginUri::default(), })) } else { Err("Elastic offramp requires a configuration.".into()) } } } fn build_source(id: &EventId, origin_uri: Option<&EventOriginUri>) -> Value<'static> { let mut source = Object::with_capacity(2); source.insert("event_id".into(), Value::from(id.to_string())); source.insert( "origin".into(), origin_uri.map_or_else(Value::null, |uri| Value::from(uri.to_string())), ); Value::from(source) } fn build_bulk_error_data( item: &ErrorItem<String, String, String>, id: &EventId, payload: Value<'static>, origin_uri: Option<&EventOriginUri>, maybe_correlation: Option<Value<'static>>, ) -> Result<EventPayload> { let mut meta = literal!({ "elastic": { "_id": item.id().to_string(), "_index": item.index().to_string(), "_type": item.ty().to_string(), // TODO: deprecated remove with removing top level es keys "id": item.id().to_string(), "index": item.index().to_string(), "doc_type": item.ty().to_string(), } }); if let Some(correlation) = maybe_correlation { meta.try_insert("correlation", correlation); } let value = literal!({ "source": build_source(id, origin_uri), "payload": payload, "error": tremor_value::to_value(item.err())?, "success": false }); Ok((value, meta).into()) } fn build_bulk_success_data( item: &OkItem<String, String, String>, id: &EventId, payload: Value<'static>, origin_uri: Option<&EventOriginUri>, maybe_correlation: Option<Value<'static>>, ) -> EventPayload { let mut meta = literal!({ "elastic": { "_id": item.id().to_string(), "_index": item.index().to_string(), "_type": item.ty().to_string(), // TODO: deprecated remove with removing top level es keys "id": item.id().to_string(), "index": item.index().to_string(), "doc_type": item.ty().to_string(), "version": item.version().map_or_else(Value::null, Value::from) } }); if let Some(correlation) = maybe_correlation { meta.try_insert("correlation", correlation); } let value = literal!({ "source": build_source(id, origin_uri), "payload": payload, "success": true }); (value, meta).into() } /// Build event payload for elasticsearch _bulk request fn build_event_payload(event: &Event) -> Result<Vec<u8>> { // We estimate a single message is 512 byte on everage, might be off but it's // a guess let vec_size = 512 * event.len(); let mut payload = Vec::with_capacity(vec_size); for (value, meta) in event.value_meta_iter() { let elastic = meta.get("elastic"); let index = if let Some(idx) = meta.get_str("index") { warn!("[Sink::ES] $index is deprecated please use `$elastic._index` instead"); idx } else if let Some(idx) = elastic.get_str("_index") { idx } else { return Err(Error::from("'index' not set for elastic offramp!")); }; let mut index_meta = json!({ "_index": index, }); // _type is deprecated in ES 7.10, thus it is no longer required if let Some(doc_type) = meta.get_str("doc_type") { warn!("[Sink::ES] $doc_type is deprecated please use `$elastic._type` instead"); index_meta.insert("_type", doc_type)?; } else if let Some(doc_type) = elastic.get_str("_type") { index_meta.insert("_type", doc_type)?; } if let Some(id) = meta.get_str("doc_id") { warn!("[Sink::ES] $doc_id is deprecated please use `$elastic._id` instead"); index_meta.insert("_id", id)?; } else if let Some(id) = elastic.get_str("_id") { index_meta.insert("_id", id)?; } if let Some(pipeline) = meta.get_str("pipeline") { warn!("[Sink::ES] $pipeline is deprecated please use `$elastic.pipeline` instead"); index_meta.insert("pipeline", pipeline)?; } else if let Some(pipeline) = elastic.get_str("pipeline") { index_meta.insert("pipeline", pipeline)?; }; let action = if meta.get_str("action").is_some() { warn!("[Sink::ES] $action is deprecated please use `$elastic.action` instead"); meta.get_str("action") } else { elastic.get_str("action") }; let key = match action { Some("delete") => "delete", Some("create") => "create", Some("update") => "update", Some("index") | None => "index", Some(other) => { return Err(format!( "invalid ES operation, use one of `delete`, `create`, `update`, `index`: {}", other ) .into()) } }; let value_meta = json!({ key: index_meta }); value_meta.write(&mut payload)?; match key { "delete" => (), "update" => { payload.push(b'\n'); let value = json!({ "doc": value }); value.write(&mut payload)?; } "create" | "index" => { payload.push(b'\n'); value.write(&mut payload)?; } other => error!("[ES::Sink] Unsupported action: {}", other), } payload.push(b'\n'); } Ok(payload) } impl Elastic { #[allow(clippy::too_many_lines)] async fn enqueue_send_future(&mut self, event: Event) { let (tx, rx) = bounded(1); let insight_tx = self.insight_tx.clone(); let response_tx = self.response_sender.clone(); let is_linked = self.is_linked; let transactional = event.transactional; let id = event.id.clone(); let op_meta = event.op_meta.clone(); let ingest_ns = event.ingest_ns; let response_origin_uri = if is_linked { event.origin_uri.clone() } else { None }; let mut responses = Vec::with_capacity(if is_linked { 8 } else { 0 }); // build payload and request let payload = match build_event_payload(&event) { Ok(payload) => payload, Err(e) => { // send fail self.send_insight(event.to_fail()).await; // send error response about event not being able to be serialized into ES payload let error_msg = format!("Invalid ES Payload: {}", e); let mut data = Value::object_with_capacity(2); let payload = event.data.suffix().value().clone_static(); data.try_insert("success", Value::from(false)); data.try_insert("error", Value::from(error_msg)); data.try_insert("payload", payload); let source = build_source(&event.id, event.origin_uri.as_ref()); data.try_insert("source", source); // if we have more than one event (batched), correlation will be an array with `null` or an actual value // for the event at the batch position let correlation_value = event.correlation_meta(); let meta = correlation_value.map_or_else(Value::object, |correlation| { literal!({ "correlation": correlation }) }); // send error response if let Err(e) = response_tx.send(((data, meta).into(), ERR)).await { error!( "[Sink::{}] Failed to send build_event_payload error response: {}", self.sink_url, e ); } return; } }; let req = self.client.request(BulkRequest::new(payload)); let mut correlation_values = if is_linked { event.correlation_metas() } else { vec![] }; // go async task::spawn_blocking(move || { let ress = &mut responses; let start = Instant::now(); let r: Result<BulkResponse> = (move || { // send event to elastic, blockingly Ok(req.send()?.into_response::<BulkResponse>()?) })(); // The truncation we do is sensible since we're only looking at a short timeframe #[allow(clippy::cast_possible_truncation)] let time = start.elapsed().as_millis() as u64; let mut insight_meta = Value::object_with_capacity(1); let cb = match &r { Ok(bulk_response) => { insight_meta.try_insert("time", Value::from(time)); if is_linked { // send out response events for each item // success events via OUT port // error events via ERR port for ((item, value), correlation) in bulk_response .iter() .zip(event.value_iter()) .zip(correlation_values.into_iter().chain(iter::repeat(None))) { let item_res = match item { Ok(ok_item) => ( OUT, Ok(build_bulk_success_data( ok_item, &id, value.clone_static(), // uaarrghhh event.origin_uri.as_ref(), correlation, )), ), Err(err_item) => ( ERR, build_bulk_error_data( err_item, &id, value.clone_static(), // uaarrrghhh event.origin_uri.as_ref(), correlation, ), ), }; if let (port, Ok(item_body)) = item_res { ress.push((item_body, port)); } else { error!( "Error extracting bulk item response for document id {}", item.map_or_else(ErrorItem::id, OkItem::id) ); } } }; CbAction::Ack } Err(e) => { // request failed // TODO how to update error metric here? insight_meta.try_insert("error", Value::from(e.to_string())); if is_linked { // if we have more than one event (batched), correlation will be an array with `null` or an actual value // for the event at the batch position let mut meta = Value::object_with_capacity(1); match correlation_values.len() { 1 => { if let Some(cv) = correlation_values.pop().flatten() { meta.try_insert("correlation", cv); } } l if l > 1 => { meta.try_insert("correlation", Value::from(correlation_values)); } _ => {} }; // send error event via ERR port let error_data = literal!({ "source": { "event_id": id.to_string(), "origin": response_origin_uri.map(|uri| uri.to_string()), }, "success": false, "error": e.to_string() }); responses.push(((error_data, meta).into(), ERR)); }; CbAction::Fail } }; task::block_on(async move { // send response events for response in responses { if let Err(e) = response_tx.send(response).await { error!("[Sink::ES] Failed to send bulk item response: {}", e); } } // send insight - if required if transactional { let insight = Event { id, data: (Value::null(), insight_meta).into(), ingest_ns, op_meta, cb, ..Event::default() }; if let Err(e) = insight_tx.send(sink::Reply::Insight(insight)).await { error!("[Sink::ES] Failed to send insight: {}", e); } } // mark this task as done in order to free a slot if let Err(e) = tx.send(r.map(|_| time)).await { error!("[Sink::ES] Failed to send AsyncSink done message: {}", e); } }); }); // this should actually never fail, given how we call this from maybe_enqueue if let Err(e) = self.queue.enqueue(rx) { // no need to send insight or response here, this should not affect event handling // this might just mess with the concurrency limitation error!( "[Sink::{}] Error enqueuing the ready receiver for the Es request execution: {}", &self.sink_url, e ); } } async fn handle_error(&mut self, event: Event, error_msg: &'static str) { self.send_insight(event.to_fail()).await; let data = literal!({ "success": false, "error": error_msg, "payload": event.data.suffix().value().clone_static(), }); let mut meta = literal!({ "error": error_msg }); if let Some(correlation) = event.correlation_meta() { meta.try_insert("correlation", correlation); } if let Err(e) = self.response_sender.send(((data, meta).into(), ERR)).await { error!( "[Sink::{}] Failed to send error response on overflow: {}.", self.sink_url, e ); } error!("[Sink::{}] {}", &self.sink_url, error_msg); } async fn maybe_enque(&mut self, event: Event) { match self.queue.dequeue() { Err(SinkDequeueError::NotReady) if !self.queue.has_capacity() => { let error_msg = "Dropped data due to es overload"; self.handle_error(event, error_msg).await; } _ => { self.enqueue_send_future(event).await; } } } // we swallow send errors here, we only log them async fn send_insight(&mut self, insight: Event) { if let Err(e) = self.insight_tx.send(sink::Reply::Insight(insight)).await { error!("[Sink::{}] Failed to send insight: {}", &self.sink_url, e); } } } /// task responsible to receive raw response data, build response event and send it off. /// keeps ownership of `EventIdGenerator` and more async fn response_task( mut id_gen: EventIdGenerator, origin_uri: EventOriginUri, rx: Receiver<(EventPayload, Cow<'static, str>)>, insight_tx: Sender<sink::Reply>, ) -> Result<()> { loop { match rx.recv().await { Ok((data, port)) => { let response_event = Event { id: id_gen.next_id(), data, ingest_ns: nanotime(), origin_uri: Some(origin_uri.clone()), ..Event::default() }; if let Err(e) = insight_tx .send(sink::Reply::Response(port, response_event)) .await { return Err(e.into()); } } Err(e) => { error!("[Sink::elastic] Response task channel closed: {}", e); return Err(e.into()); } } } } #[async_trait::async_trait] impl Sink for Elastic { // We enforce json here! async fn on_event( &mut self, _input: &str, _codec: &mut dyn Codec, _codec_map: &HashMap<String, Box<dyn Codec>>, mut event: Event, ) -> ResultVec { if event.is_empty() { // nothing to send to ES, an empty event would result in debug!( "[Sink::{}] Received empty event. Won't send it to ES", self.sink_url ); Ok(Some(if event.transactional { vec![Reply::Insight(event.insight_ack())] } else { vec![] })) } else { // we have either one event or a batched one with > 1 event self.maybe_enque(event).await; Ok(None) // insights are sent via reply_channel directly } } #[allow(clippy::too_many_arguments)] async fn init( &mut self, sink_uid: u64, sink_url: &TremorUrl, _codec: &dyn Codec, _codec_map: &HashMap<String, Box<dyn Codec>>, _processors: Processors<'_>, is_linked: bool, reply_channel: Sender<sink::Reply>, ) -> Result<()> { // try to connect to check provided config and extract the cluster name let cluster_name = self.client.ping().send()?.cluster_name().to_string(); info!( "[Sink::{}] Connected to ES cluster {}.", &sink_url, &cluster_name ); self.sink_url = sink_url.clone(); self.insight_tx = reply_channel; self.is_linked = is_linked; if is_linked { let event_id_gen = EventIdGenerator::new(sink_uid); self.origin_uri = EventOriginUri { uid: sink_uid, // placeholder, scheme: "elastic".to_string(), host: cluster_name, port: None, path: vec![], }; // channels that events go through that end up here are bounded, so we should not grow out of memory let (tx, rx) = async_channel::unbounded(); self.response_sender = tx; self.response_task_handle = Some(task::spawn(response_task( event_id_gen, self.origin_uri.clone(), rx, self.insight_tx.clone(), ))); } Ok(()) } async fn on_signal(&mut self, _signal: Event) -> ResultVec { Ok(None) // insights are sent via reply_channel directly } fn is_active(&self) -> bool { true } fn auto_ack(&self) -> bool { false } fn default_codec(&self) -> &str { "json" } async fn terminate(&mut self) { let mut swap: Option<JoinHandle<Result<()>>> = None; std::mem::swap(&mut swap, &mut self.response_task_handle); if let Some(handle) = swap { info!("[Sink::{}] Terminating response task...", self.sink_url); handle.cancel().await; info!("[Sink::{}] Done.", self.sink_url); } } } #[cfg(test)] mod tests { use super::*; #[test] fn build_event_payload_test() -> Result<()> { let mut numbers = Value::array_with_capacity(3); for x in 1..=3 { numbers.push(Value::from(x))?; } numbers.push(Value::from("snot"))?; let data = json!({ "numbers": numbers, }); let meta = json!({ "index": "my_index", "doc_type": "my_type", "doc_id": "my_id", "pipeline": "my_pipeline" }); let event = Event { data: (data.clone(), meta).into(), ..Event::default() }; let payload = build_event_payload(&event)?; let mut expected = Vec::new(); let es_meta = json!({ "index": { "_index": "my_index", "_type": "my_type", "_id": "my_id", "pipeline": "my_pipeline" } }); es_meta.write(&mut expected)?; expected.push(b'\n'); data.write(&mut expected)?; // this clone is here so both are the same structure internally expected.push(b'\n'); assert_eq!( String::from_utf8_lossy(&expected), String::from_utf8_lossy(&payload) ); Ok(()) } #[test] fn build_event_payload_missing_index() -> Result<()> { let meta = json!({ "doc_type": "my_type", "doc_id": "my_id" }); let event = Event { data: (Value::object(), meta).into(), ..Event::default() }; let p = build_event_payload(&event); assert!(p.is_err(), "Didnt fail with missing index."); Ok(()) } }
use crate::sprintln; use embedded_hal::blocking::delay::DelayMs; use embedded_hal::blocking::spi::Write; use embedded_hal::digital::v2::*; const WIDTH: usize = 800; const HEIGHT: usize = 480; const WIDE: usize = WIDTH / 8; pub struct EPD75b<SPI, CS, DC, RST, BUSY, DELAY> { spi: SPI, cs: CS, busy: BUSY, dc: DC, rst: RST, delay: DELAY, } impl<SPI, CS, DC, RST, BUSY, DELAY> EPD75b<SPI, CS, DC, RST, BUSY, DELAY> where SPI: Write<u8>, BUSY: InputPin, DC: OutputPin, CS: OutputPin, RST: OutputPin, DELAY: DelayMs<u8>, { pub fn new(spi: SPI, cs: CS, dc: DC, rst: RST, busy: BUSY, delay: DELAY) -> Self { Self { spi, cs, busy, dc, rst, delay, } } //Hardware reset pub fn reset(&mut self) { self.rst.set_high().ok(); self.delay.delay_ms(200); self.rst.set_low().ok(); self.delay.delay_ms(2); self.rst.set_high().ok(); self.delay.delay_ms(200); } pub fn send_command(&mut self, cmd: u8) { self.dc.set_low().ok(); self.cs.set_low().ok(); self.spi.write(&[cmd]).ok(); self.cs.set_high().ok(); } fn send_data(&mut self, data: u8) { self.dc.set_high().ok(); self.cs.set_low().ok(); self.spi.write(&[data]).ok(); self.cs.set_high().ok(); } pub fn send_cmd_and_data(&mut self, cmd: u8, data: &[u8]) { self.send_command(cmd); self.dc.set_high().ok(); self.cs.set_low().ok(); self.spi.write(data).ok(); self.cs.set_high().ok(); } pub fn wait_until_idle(&mut self) { sprintln!("e-Paper busy"); while let Ok(true) = self.busy.is_low() { //忙状态输出引脚(低电平表示忙) self.delay.delay_ms(20); } self.delay.delay_ms(20); sprintln!("e-Paper busy release"); } pub fn turn_on_display(&mut self) { self.send_command(0x12); self.delay.delay_ms(100); self.wait_until_idle(); } pub fn init(&mut self) { self.reset(); self.send_command(0x06); self.send_data(0x17); self.send_data(0x17); self.send_data(0x28); self.send_data(0x17); self.send_command(0x04); self.delay.delay_ms(100); self.wait_until_idle(); self.send_command(0x00); self.send_data(0x0F); self.send_command(0x61); self.send_data(0x03); self.send_data(0x20); self.send_data(0x01); self.send_data(0xE0); self.send_command(0x15); self.send_data(0x00); self.send_command(0x50); self.send_data(0x11); self.send_data(0x07); self.send_command(0x60); self.send_data(0x22); self.send_command(0x65); self.send_data(0x00); self.send_data(0x00); self.send_data(0x00); self.send_data(0x00); } pub fn clear(&mut self) { self.send_command(0x10); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0xff); }); }); self.send_command(0x13); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0x00); }); }); self.turn_on_display(); } pub fn clear_red(&mut self) { self.send_command(0x10); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0xff); }); }); self.send_command(0x13); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0xff); }); }); self.turn_on_display(); } pub fn clear_black(&mut self) { self.send_command(0x10); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0x00); }); }); self.send_command(0x13); (0..HEIGHT).for_each(|_| { (0..WIDE).for_each(|_| { self.send_data(0x00); }); }); self.turn_on_display(); } pub fn display(&mut self, black: &[u8; WIDTH * HEIGHT / 8], red: &[u8; WIDTH * HEIGHT / 8]) { self.send_command(0x10); for j in 0..HEIGHT { for i in 0..WIDE { self.send_data(black[i + j * WIDE]); } } self.send_command(0x13); for j in 0..HEIGHT { for i in 0..WIDE { self.send_data(red[i + j * WIDE]); } } self.turn_on_display(); } pub fn sleep(&mut self) { self.send_command(0x02); self.wait_until_idle(); self.send_command(0x07); self.send_data(0xa5); } }
mod with_atom; mod with_small_integer; use proptest::strategy::{Just, Strategy}; use liblumen_alloc::atom; use liblumen_alloc::erts::term::prelude::*; use crate::erlang::system_time_1::result; use crate::test::{strategy, with_process}; #[test] fn without_atom_or_integer_errors_badarg() { run!( |arc_process| { ( Just(arc_process.clone()), strategy::term(arc_process.clone()) .prop_filter("Unit must not be an atom or integer", |unit| { !(unit.is_integer() || unit.is_atom()) }), ) }, |(arc_process, unit)| { prop_assert_badarg!(result(&arc_process, unit,), "supported units are :second, :seconds, :millisecond, :milli_seconds, :microsecond, :micro_seconds, :nanosecond, :nano_seconds, :native, :perf_counter, or hertz (positive integer)"); Ok(()) }, ); }
use std::collections::HashMap; pub struct Url { path: String, arguments: HashMap<String, String>, } impl Url { pub fn path(&self) -> &String{&self.path} pub fn arguments(&self) -> &HashMap<String, String> { &self.arguments } pub fn new() -> Self { Url{path:"/".to_string(), arguments:HashMap::new()} } pub fn parse(url_string: &str) -> Self { let mut url = Url::new(); if url_string.contains("?") { let items: Vec<&str> = url_string.split("?").collect(); url.path = items[0].to_string(); let arguments: Vec<&str> = items[1].split("&").collect(); for argument in arguments { let split_argument: Vec<&str> = argument.split("=").collect(); url.arguments.insert(split_argument[0].to_string(), split_argument[1].to_string()); } } else { url.path = url_string.to_string(); } return url; } }
extern crate libc; use api::ErrorCode; use errors::ToErrorCode; use commands::{Command, CommandExecutor}; use utils::cstring::CStringUtils; use self::libc::c_char; /// Establishes agent to agent connection. /// /// Information about sender Identity must be saved in the wallet with sovrin_create_and_store_my_did /// call before establishing of connection. /// /// Information about receiver Identity can be saved in the wallet with sovrin_store_their_did /// call before establishing of connection. If there is no corresponded wallet record for receiver Identity /// than this call will lookup Identity Ledger and cache this information in the wallet. /// /// Note that messages encryption/decryption will be performed automatically. /// /// #Params /// command_handle: Command handle to map callback to caller context. /// wallet_handle: Wallet handle (created by open_wallet). /// sender_did: Id of sender Identity stored in secured Wallet. /// receiver_did: Id of receiver Identity. /// connection_cb: Callback that will be called after establishing of connection or on error. /// message_cb: Callback that will be called on receiving of an incomming message. /// /// #Returns /// Error code /// connection_cb: /// - xcommand_handle: command handle to map callback to caller context. /// - err: Error code. /// - connection_handle: Connection handle to use for messages sending and mapping of incomming messages to this connection. /// message_cb: /// - xconnection_handle: Connection handle. Indetnifies connection. /// - err: Error code. /// - message: Received message. #[no_mangle] pub extern fn sovrin_agent_connect(command_handle: i32, wallet_handle: i32, sender_did: *const c_char, receiver_did: *const c_char, connection_cb: Option<extern fn(xcommand_handle: i32, err: ErrorCode, connection_handle: i32)>, message_cb: Option<extern fn(xconnection_handle: i32, err: ErrorCode, message: *const c_char)>) -> ErrorCode { unimplemented!() } /// Starts listening of agent connections. /// /// On incomming connection listener performs wallet lookup to find corresponded receiver Identity /// information. Information about receiver Identity must be saved in the wallet with /// sovrin_create_and_store_my_did call before establishing of connection. /// /// Information about sender Identity for incomming connection validation can be saved in the wallet /// with sovrin_store_their_did call before establishing of connection. If there is no corresponded /// wallet record for sender Identity than listener will lookup Identity Ledger and cache this /// information in the wallet. /// /// Note that messages encryption/decryption will be performed automatically. /// /// #Params /// command_handle: command handle to map callback to caller context. /// wallet_handle: wallet handle (created by open_wallet). /// listener_cb: Callback that will be called after listening started or on error. /// connection_cb: Callback that will be called after establishing of incomming connection. /// message_cb: Callback that will be called on receiving of an incomming message. /// /// #Returns /// Error code /// listener_cb: /// - xcommand_handle: command handle to map callback to caller context. /// - err: Error code /// - listener_handle: Listener handle to use for mapping of incomming connections to this listener. /// connection_cb: /// - xlistener_handle: Listener handle. Identifies listener. /// - err: Error code /// - connection_handle: Connection handle to use for messages sending and mapping of incomming messages to to this connection. /// - sender_did: Id of sender Identity stored in secured Wallet. /// - receiver_did: Id of receiver Identity. /// message_cb: /// - xconnection_handle: Connection handle. Indetnifies connection. /// - err: Error code. /// - message: Received message. #[no_mangle] pub extern fn sovrin_agent_listen(command_handle: i32, wallet_handle: i32, listener_cb: Option<extern fn(xcommand_handle: i32, err: ErrorCode, listener_handle: i32)>, connection_cb: Option<extern fn(xlistener_handle: i32, err: ErrorCode, connection_handle: i32, sender_did: *const c_char, receiver_did: *const c_char)>, message_cb: Option<extern fn(xconnection_handle: i32, err: ErrorCode, message: *const c_char)>) -> ErrorCode { unimplemented!() } /// Sends message to connected agent. /// /// Note that this call works for both incoming and outgoing connections. /// Note that messages encryption/decryption will be performed automatically. /// /// #Params /// command_handle: command handle to map callback to caller context. /// connection_handle: Connection handle returned by sovrin_agent_connect or sovrin_agent_listen calls. /// message: Message to send. /// cb: Callback that will be called after message sent or on error. /// /// #Returns /// err: Error code /// cb: /// - xcommand_handle: Command handle to map callback to caller context. /// - err: Error code /// /// #Errors #[no_mangle] pub extern fn sovrin_agent_send(command_handle: i32, connection_handle: i32, message: *const c_char, cb: Option<extern fn(xcommand_handle: i32, err: ErrorCode)>) -> ErrorCode { unimplemented!() } /// Closes agent connection. /// /// Note that this call works for both incoming and outgoing connections. /// /// #Params /// command_handle: command handle to map callback to caller context. /// connection_handle: Connection handle returned by sovrin_agent_connect or sovrin_agent_listen calls. /// cb: Callback that will be called after connection closed or on error. /// /// #Returns /// Error code /// cb: /// - xcommand_handle: command handle to map callback to caller context. /// - err: Error code /// /// #Errors #[no_mangle] pub extern fn sovrin_agent_close_connection(command_handle: i32, connection_handle: i32, cb: Option<extern fn(xcommand_handle: i32, err: ErrorCode)>) -> ErrorCode { unimplemented!() } /// Closes listener and stops listening for agent connections. /// /// Note that all opened incomming connections will be closed automatically. /// /// #Params /// command_handle: command handle to map callback to caller context. /// listener_handle: Listener handle returned by sovrin_agent_listen call. /// cb: Callback that will be called after listener closed or on error. /// /// #Returns /// Error code /// cb: /// - xcommand_handle: command handle to map callback to caller context. /// - err: Error code /// /// #Errors #[no_mangle] pub extern fn sovrin_agent_close_listener(command_handle: i32, listener_handle: i32, cb: Option<extern fn(xcommand_handle: i32, err: ErrorCode)>) -> ErrorCode { unimplemented!() }
use bevy::{ core::Bytes, prelude::*, reflect::TypeUuid, render::{ mesh::shape, pipeline::{PipelineDescriptor, RenderPipeline}, render_graph::{base, AssetRenderResourcesNode, RenderGraph}, renderer::{RenderResource, RenderResourceType, RenderResources}, shader::{ShaderStage, ShaderStages}, }, }; struct Rotator; #[derive(RenderResources, Default, TypeUuid)] #[render_resources(from_self)] #[uuid = "1e08866c-0b8a-437e-8bce-37733b25127e"] #[repr(C)] struct BlendColors { pub color_a: Color, pub color_b: Color, pub start_lerp: f32, pub end_lerp: f32, } impl RenderResource for BlendColors { fn resource_type(&self) -> Option<RenderResourceType> { Some(RenderResourceType::Buffer) } fn buffer_byte_len(&self) -> Option<usize> { Some(40) } fn write_buffer_bytes(&self, buffer: &mut [u8]) { let (color_a_buf, rest) = buffer.split_at_mut(16); self.color_a.write_bytes(color_a_buf); let (color_b_buf, rest) = rest.split_at_mut(16); self.color_b.write_bytes(color_b_buf); let (start_lerp_buf, rest) = rest.split_at_mut(4); self.start_lerp.write_bytes(start_lerp_buf); self.end_lerp.write_bytes(rest); } fn texture(&self) -> Option<&Handle<Texture>> { None } } pub fn main() { App::build() .insert_resource(Msaa { samples: 4 }) .add_plugins(DefaultPlugins) .add_asset::<BlendColors>() .add_startup_system(setup.system()) .add_system(rotate_sphere.system()) .run(); } fn setup( mut commands: Commands, mut pipelines: ResMut<Assets<PipelineDescriptor>>, mut shaders: ResMut<Assets<Shader>>, mut meshes: ResMut<Assets<Mesh>>, mut materials: ResMut<Assets<BlendColors>>, mut render_graph: ResMut<RenderGraph>, ) { let pipeline_handle = pipelines.add(PipelineDescriptor::default_config(ShaderStages { vertex: shaders.add(Shader::from_glsl( ShaderStage::Vertex, include_str!("blend.vert"), )), fragment: Some(shaders.add(Shader::from_glsl( ShaderStage::Fragment, include_str!("blend.frag"), ))), })); render_graph.add_system_node( "blend_colors", AssetRenderResourcesNode::<BlendColors>::new(true), ); render_graph .add_node_edge("blend_colors", base::node::MAIN_PASS) .unwrap(); let material = materials.add(BlendColors { color_a: Color::rgb(0.0, 0.0, 1.0), color_b: Color::rgb(1.0, 0.0, 0.0), start_lerp: 0.25, end_lerp: 0.75, }); commands .spawn_bundle(MeshBundle { mesh: meshes.add(Mesh::from(shape::Icosphere { radius: 1.0, subdivisions: 10, })), render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle.clone(), )]), transform: Transform::from_xyz(-3.0, 0.0, 0.0), ..Default::default() }) .insert(Rotator) .insert(material.clone()); commands .spawn_bundle(MeshBundle { mesh: meshes.add(Mesh::from(shape::Quad { size: Vec2::new(3.0, 3.0), flip: true, })), render_pipelines: RenderPipelines::from_pipelines(vec![RenderPipeline::new( pipeline_handle, )]), transform: Transform::from_xyz(3.0, 0.0, 0.0), ..Default::default() }) .insert(material); commands.spawn_bundle(PerspectiveCameraBundle { transform: Transform::from_xyz(0.0, 0.0, -8.0).looking_at(Vec3::ZERO, -Vec3::Y), ..Default::default() }); } fn rotate_sphere(time: Res<Time>, mut query: Query<&mut Transform, With<Rotator>>) { for mut transform in query.iter_mut() { transform.rotation *= Quat::from_rotation_x(3.0 * time.delta_seconds()); } }
use itertools::Itertools; use std::collections::VecDeque; use std::io::{self, BufRead}; type Memory = Vec<i64>; type IO = VecDeque<i64>; struct VM { memory: Memory, ip: usize, input: IO, output: IO, } enum State { Running, Halted, NeedInput, } impl VM { fn new(program: &Memory, input: IO) -> Self { VM { memory: program.clone(), ip: 0, input, output: IO::new(), } } fn arg(&self, i: u32) -> i64 { let instruction = self.memory[self.ip]; let mode = (instruction / (10 * (10_i64.pow(i)))) % 10; let val = self.memory[self.ip + i as usize]; match mode { 0 => self.memory[val as usize], 1 => val, _ => panic!("{}", mode), } } fn int3<F>(&mut self, f: F) where F: Fn(i64, i64) -> i64, { let l = self.memory[self.ip + 3]; self.memory[l as usize] = f(self.arg(1), self.arg(2)); self.ip += 4 } fn step(&mut self) -> State { let instruction = self.memory[self.ip]; match instruction % 100 { 1 => self.int3(|a, b| a + b), 2 => self.int3(|a, b| a * b), 3 => { let j = self.memory[self.ip + 1]; match self.input.pop_front() { Some(val) => { self.memory[j as usize] = val; self.ip += 2; } None => { return State::NeedInput; } } } 4 => { self.output.push_back(self.arg(1)); self.ip += 2 } 5 => { if self.arg(1) != 0 { self.ip = self.arg(2) as usize } else { self.ip += 3; } } 6 => { if self.arg(1) == 0 { self.ip = self.arg(2) as usize } else { self.ip += 3; } } 7 => self.int3(|a, b| (a < b) as i64), 8 => self.int3(|a, b| (a == b) as i64), 99 => return State::Halted, x => panic!("the discotheque: ip {}: {}", self.ip, x), } State::Running } fn run(&mut self) -> State { loop { match self.step() { State::Running => {} x => return x, } } } } #[cfg(test)] mod tests { use super::*; #[test] fn test_day2() { let program = vec![1, 1, 1, 4, 99, 5, 6, 0, 99]; let input = VecDeque::new(); let mut vm = VM::new(&program, input); vm.run(); assert_eq!(vm.memory, vec![30, 1, 1, 4, 2, 5, 6, 0, 99]); } fn run_with_input(program: &Memory, input: IO) -> (Memory, IO) { let mut vm = VM::new(&program, input); vm.run(); (vm.memory, vm.output) } #[test] fn test_day5() { let program = vec![3, 3, 1107, -1, 8, 3, 4, 3, 99]; let input = IO::from(vec![7]); let (_, output) = run_with_input(&program, input); assert_eq!(output, IO::from(vec![1])); } } fn amplify(program: &Memory, sequence: Vec<i64>) -> i64 { // println!("- {:?}", sequence); let mut input = IO::from(vec![0]); for phase in sequence { // NB: prepend input.push_front(phase); // println!("{:?}", input); let mut vm = VM::new(&program, input); vm.run(); input = vm.output; } // println!(" --> {:?}", input); input.pop_front().expect("at least one output") } fn amplify_loop(program: &Memory, sequence: Vec<i64>) -> i64 { let mut vms: Vec<VM> = sequence .iter() .map(|phase| { let input = IO::from(vec![*phase]); VM::new(&program, input) }) .collect(); vms[0].input.push_back(0); let n = vms.len(); loop { for i in 0..n { let (result, mut output): (State, IO) = { let vm = &mut vms[i]; let r = vm.run(); let o = vm.output.drain(..).collect(); (r, o) }; if let State::Halted = result { if i == n - 1 { return output .pop_front() .expect("at least one output when final machine halts"); } } let next = &mut vms[(i + 1) % n]; next.input.append(&mut output); } } } fn main() { let stdin = io::stdin(); let handle = stdin.lock(); let line = handle .lines() .map(|l| l.unwrap()) .collect::<Vec<String>>() .join(""); let program: Memory = line.split(",").map(|s| s.parse().unwrap()).collect(); let part1 = (0..5) .permutations(5) .map(|sequence| amplify(&program, sequence)) .max() .expect("at least one element"); println!("{}", part1); let part2 = (5..10) .permutations(5) .map(|sequence| amplify_loop(&program, sequence)) .max() .expect("at least one element"); println!("{}", part2); }
// Copyright 2022 Datafuse Labs. // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. use common_exception::Result; use itertools::Itertools; use crate::optimizer::RelExpr; use crate::optimizer::SExpr; use crate::plans::AndExpr; use crate::plans::Filter; use crate::plans::OrExpr; use crate::ColumnSet; use crate::ScalarExpr; pub fn rewrite_predicates(s_expr: &SExpr) -> Result<Vec<ScalarExpr>> { let filter: Filter = s_expr.plan().clone().try_into()?; let join = s_expr.child(0)?; let mut new_predicates = Vec::new(); let mut origin_predicates = filter.predicates.clone(); for predicate in filter.predicates.iter() { if let ScalarExpr::OrExpr(or_expr) = predicate { for join_child in join.children().iter() { let rel_expr = RelExpr::with_s_expr(join_child); let used_columns = rel_expr.derive_relational_prop()?.used_columns; if let Some(predicate) = extract_or_predicate(or_expr, &used_columns)? { new_predicates.push(predicate) } } } } origin_predicates.extend(new_predicates); // Deduplicate predicates here to prevent handled by `EliminateFilter` rule later, // which may cause infinite loop. origin_predicates = origin_predicates.into_iter().unique().collect(); Ok(origin_predicates) } // Only need to be executed once fn extract_or_predicate( or_expr: &OrExpr, required_columns: &ColumnSet, ) -> Result<Option<ScalarExpr>> { let or_args = flatten_ors(or_expr.clone()); let mut extracted_scalars = Vec::new(); for or_arg in or_args.iter() { let mut sub_scalars = Vec::new(); if let ScalarExpr::AndExpr(and_expr) = or_arg { let and_args = flatten_ands(and_expr.clone()); for and_arg in and_args.iter() { if let ScalarExpr::OrExpr(or_expr) = and_arg { if let Some(scalar) = extract_or_predicate(or_expr, required_columns)? { sub_scalars.push(scalar); } } else { let used_columns = and_arg.used_columns(); if used_columns.is_subset(required_columns) { sub_scalars.push(and_arg.clone()); } } } } else { let used_columns = or_arg.used_columns(); if used_columns.is_subset(required_columns) { sub_scalars.push(or_arg.clone()); } } if sub_scalars.is_empty() { return Ok(None); } extracted_scalars.push(make_and_expr(&sub_scalars)); } if !extracted_scalars.is_empty() { return Ok(Some(make_or_expr(&extracted_scalars))); } Ok(None) } // Flatten nested ORs, such as `a=1 or b=1 or c=1` // It'll be flatten to [a=1, b=1, c=1] fn flatten_ors(or_expr: OrExpr) -> Vec<ScalarExpr> { let mut flattened_ors = Vec::new(); let or_args = vec![*or_expr.left, *or_expr.right]; for or_arg in or_args.iter() { match or_arg { ScalarExpr::OrExpr(or_expr) => flattened_ors.extend(flatten_ors(or_expr.clone())), _ => flattened_ors.push(or_arg.clone()), } } flattened_ors } // Flatten nested ORs, such as `a=1 and b=1 and c=1` // It'll be flatten to [a=1, b=1, c=1] fn flatten_ands(and_expr: AndExpr) -> Vec<ScalarExpr> { let mut flattened_ands = Vec::new(); let and_args = vec![*and_expr.left, *and_expr.right]; for and_arg in and_args.iter() { match and_arg { ScalarExpr::AndExpr(and_expr) => flattened_ands.extend(flatten_ands(and_expr.clone())), _ => flattened_ands.push(and_arg.clone()), } } flattened_ands } // Merge predicates to AND scalar fn make_and_expr(scalars: &[ScalarExpr]) -> ScalarExpr { if scalars.len() == 1 { return scalars[0].clone(); } ScalarExpr::AndExpr(AndExpr { left: Box::new(scalars[0].clone()), right: Box::new(make_and_expr(&scalars[1..])), }) } // Merge predicates to OR scalar fn make_or_expr(scalars: &[ScalarExpr]) -> ScalarExpr { if scalars.len() == 1 { return scalars[0].clone(); } ScalarExpr::OrExpr(OrExpr { left: Box::new(scalars[0].clone()), right: Box::new(make_or_expr(&scalars[1..])), }) }
use super::InternalEvent; use metrics::counter; #[derive(Debug)] pub struct AddFieldsEventProcessed; impl InternalEvent for AddFieldsEventProcessed { fn emit_metrics(&self) { counter!("events_processed", 1, "component_kind" => "transform", "component_type" => "add_fields", ); } }
use std::io; // Develop a programme to convert currency X to currency Y and vice versa. const _USD_TO_EUR: f64 = 0.8679; const _USD_TO_CAD: f64 = 1.2936; const _USD_TO_GBP: f64 = 0.7624; const _USD_TO_YEN: f64 = 113.7264; const _USD_TO_CHF: f64 = 0.9973; fn main() { println!("Welcome to the CurrencyExchange. We offer currency swapping between six currencies, as follows:\n"); println!("US Dollar: USD"); println!("EU Euro: EUR"); println!("Canadian Dollar: CAD"); println!("British Pound: GBP"); println!("Japanese Yen: YEN"); println!("Swiss Franc: CHF"); println!("Enter the three digit code of the currency you want to convert from:"); let mut from = String::new(); io::stdin().read_line(&mut from).expect("Failed to read line."); println!("Enter the three digit code of the currency you want to convert to:"); let mut to = String::new(); io::stdin().read_line(&mut to).expect("Failed to read line."); from = from.to_lowercase(); to = to.to_lowercase(); println!("Enter the amount of currency you want to exchange."); let mut text = String::new(); io::stdin().read_line(&mut text) .expect("Failed to read line."); let amt: f64 = text.trim().parse() .expect("N must be a number"); println!("addr from: {} addr to: {}", &from, &to); println!("~~~~~ Working Doot Doot ~~~~~"); let conv_amt = convert(amt, &from, &to); println!("You have converted {} {} into {} {}", amt, from, conv_amt, to); } fn convert(amount: f64, first_curr: &str, sec_curr: &str) -> f64 { if first_curr == "usd" { match sec_curr { "eur" => amount * _USD_TO_EUR, "cad" => amount * _USD_TO_CAD, "gbp" => amount * _USD_TO_GBP, "yen" => amount * _USD_TO_YEN, "chf" => amount * _USD_TO_CHF, _ => amount }; println!("we do match usd"); } if first_curr == "eur" { match sec_curr { "usd" => amount * _USD_TO_EUR.recip(), "cad" => amount * _USD_TO_EUR.recip() * _USD_TO_CAD, "gbp" => amount * _USD_TO_EUR.recip() * _USD_TO_GBP, "yen" => amount * _USD_TO_EUR.recip() * _USD_TO_YEN, "chf" => amount * _USD_TO_EUR.recip() * _USD_TO_CHF, _ => amount }; } if first_curr == "cad" { match sec_curr { "usd" => amount * _USD_TO_CAD.recip(), "eur" => amount * _USD_TO_CAD.recip() * _USD_TO_EUR, "gbp" => amount * _USD_TO_CAD.recip() * _USD_TO_GBP, "yen" => amount * _USD_TO_CAD.recip() * _USD_TO_YEN, "chf" => amount * _USD_TO_CAD.recip() * _USD_TO_CHF, _ => amount }; } if first_curr == "gbp" { match sec_curr { "usd" => amount * _USD_TO_GBP.recip(), "eur" => amount * _USD_TO_GBP.recip() * _USD_TO_EUR, "cad" => amount * _USD_TO_GBP.recip() * _USD_TO_CAD, "yen" => amount * _USD_TO_GBP.recip() * _USD_TO_YEN, "chf" => amount * _USD_TO_GBP.recip() * _USD_TO_CHF, _ => amount }; } if first_curr == "yen" { match sec_curr { "usd" => amount * _USD_TO_YEN.recip(), "eur" => amount * _USD_TO_YEN.recip() * _USD_TO_EUR, "cad" => amount * _USD_TO_YEN.recip() * _USD_TO_CAD, "gbp" => amount * _USD_TO_YEN.recip() * _USD_TO_GBP, "chf" => amount * _USD_TO_YEN.recip() * _USD_TO_CHF, _ => amount }; } if first_curr == "chf" { match sec_curr { "usd" => amount * _USD_TO_CHF.recip(), "eur" => amount * _USD_TO_CHF.recip() * _USD_TO_EUR, "cad" => amount * _USD_TO_CHF.recip() * _USD_TO_CAD, "gbp" => amount * _USD_TO_CHF.recip() * _USD_TO_GBP, "yen" => amount * _USD_TO_CHF.recip() * _USD_TO_YEN, _ => amount } } else { return amount; } }
//! # Equipment //! //! Though an equipment record is optional, when used it in a recipe or on its own it provides details needed to //! calculate total water usage as well as water needed for each step. //! It also contains information about the thermal parameters of the mash tun and large batch hop utilization factors. use crate::utils; use brew_calculator::units::*; use serde::Deserialize; #[derive(Deserialize, Debug, PartialEq)] #[serde(rename_all = "UPPERCASE")] pub struct Equipment { name: String, version: u8, ///The pre-boil volume used in this particular instance for this equipment setup. ///Note that this may be a calculated value depending on the `calc_boil_volume` parameter. boil_size: f32, ///The target volume of the batch at the start of fermentation. batch_size: f32, ///Volume of the mash tun in liters. tun_volume: Option<Liters>, ///Weight of the mash tun in kilograms. ///Used primarily to calculate the thermal parameters of ///the mash tun – in conjunction with the volume and specific heat. tun_weight: Option<f32>, ///Cal/(gram deg C) tun_specific_heat: Option<f32>, ///The amount of top up water normally added just prior to starting fermentation. top_up_water: Option<Liters>, ///The amount of wort normally lost during transition from the boiler to the fermentation vessel. ///Includes both unusable wort due to trub and wort lost to the chiller and transfer systems. trub_chiller_loss: Option<Liters>, ///The percentage of wort lost to evaporation per hour evap_rate: Option<f32>, boil_time: Option<Minutes>, ///If `true`, then ///`boil_size = (batch_size - top_up_water - trub_chiller_loss) * (1 + boil_time * evap_rate ///)`. ///Then `boil size` should match this value. #[serde(default)] #[serde(deserialize_with = "utils::opt_bool_de_from_str")] calc_boil_volume: Option<bool>, ///Amount lost to the lauter tun and equipment associated with the lautering process. lauter_deadspace: Option<Liters>, ///Amount normally added to the boil kettle before the boil. top_up_kettle: Option<Liters>, hop_utilization: Option<Percent>, notes: Option<String>, } #[cfg(test)] /// Official tests from 'http://www.beerxml.com/beerxml.htm' mod beerxml { use super::*; use serde_xml_rs; #[test] /// Modification to official example: /// Fixed incorrect closing tags: /// ``` /// <TUN_VOLUME>18.93</MASH_TUN_VOLUME> /// <TUN_WEIGHT>2.0</MASH_TUN_WEIGHT> /// ``` fn example() { let xml_input = r" <EQUIPMENT> <NAME>8 Gal pot with 5 gal Igloo Cooler</NAME> <VERSION>1</VERSION> <TUN_VOLUME>18.93</TUN_VOLUME> <TUN_WEIGHT>2.0</TUN_WEIGHT> <TUN_SPECIFIC_HEAT>0.3</TUN_SPECIFIC_HEAT> <BATCH_SIZE>18.93</BATCH_SIZE> <BOIL_SIZE>22.71</BOIL_SIZE> <TOP_UP_WATER>0.0</TOP_UP_WATER> <TRUB_CHILLER_LOSS>0.95</TRUB_CHILLER_LOSS> <EVAP_RATE>9.0</EVAP_RATE> <BOIL_TIME>60.0</BOIL_TIME> <CALC_BOIL_VOLUME>TRUE</CALC_BOIL_VOLUME> <LAUTER_DEADSPACE>0.95</LAUTER_DEADSPACE> <TOP_UP_KETTLE>0.0</TOP_UP_KETTLE> <HOP_UTILIZATION>100.0</HOP_UTILIZATION> <NOTES>Popular all grain setup. 5 Gallon Gott or Igloo cooler as mash tun with false bottom, and 7-9 gallon brewpot capable of boiling at least 6 gallons of wort. Primarily used for single infusion mashes.</NOTES> </EQUIPMENT> "; let parsed_equip: Equipment = serde_xml_rs::from_str(xml_input).unwrap(); let true_equip = Equipment { name: "8 Gal pot with 5 gal Igloo Cooler".into(), version: 1, boil_size: 22.71, batch_size: 18.93, tun_volume: Some(18.93), tun_weight: Some(2.0), tun_specific_heat: Some(0.3), top_up_water: Some(0.0), trub_chiller_loss: Some(0.95), evap_rate: Some(9.0), boil_time: Some(60.0), calc_boil_volume: Some(true), lauter_deadspace: Some(0.95), top_up_kettle: Some(0.0), hop_utilization: Some(100.0), notes: Some( "Popular all grain setup. 5 Gallon Gott or Igloo cooler as mash tun with false bottom, and 7-9 gallon brewpot capable of boiling at least 6 gallons of wort. Primarily used for single infusion mashes.".into()), }; assert_eq!(parsed_equip, true_equip); } }
use std::io::Read; fn main() { let mut stdin = std::io::stdin(); let mut input = String::new(); stdin.read_to_string(&mut input).expect("read from stdin"); let mut jumps = input.split_whitespace().map(|n| isize::from_str_radix(n, 10).expect("a number")).collect::<Vec<isize>>(); let mut offset = 0usize; let mut steps = 0u64; loop { steps += 1; let next_offset: isize = offset as isize + jumps[offset]; // Part 1: // jumps[offset] += 1; //Now part 2: if jumps[offset] >= 3 { jumps[offset] -= 1; } else { jumps[offset] += 1; } if next_offset < 0 || next_offset >= jumps.len() as isize { break; } offset = next_offset as usize; } println!("steps {}", steps); }
/** * @lc app=leetcode.cn id=48 lang=rust * * [48] 旋转图像 * * https://leetcode-cn.com/problems/rotate-image/description/ * * algorithms * Medium (60.29%) * Total Accepted: 17K * Total Submissions: 28.2K * Testcase Example: '[[1,2,3],[4,5,6],[7,8,9]]' * * 给定一个 n × n 的二维矩阵表示一个图像。 * * 将图像顺时针旋转 90 度。 * * 说明: * * 你必须在原地旋转图像,这意味着你需要直接修改输入的二维矩阵。请不要使用另一个矩阵来旋转图像。 * * 示例 1: * * 给定 matrix = * [ * ⁠ [1,2,3], * ⁠ [4,5,6], * ⁠ [7,8,9] * ], * * 原地旋转输入矩阵,使其变为: * [ * ⁠ [7,4,1], * ⁠ [8,5,2], * ⁠ [9,6,3] * ] * * * 示例 2: * * 给定 matrix = * [ * ⁠ [ 5, 1, 9,11], * ⁠ [ 2, 4, 8,10], * ⁠ [13, 3, 6, 7], * ⁠ [15,14,12,16] * ], * * 原地旋转输入矩阵,使其变为: * [ * ⁠ [15,13, 2, 5], * ⁠ [14, 3, 4, 1], * ⁠ [12, 6, 8, 9], * ⁠ [16, 7,10,11] * ] * * */ struct Solution {} impl Solution { pub fn rotate(matrix: &mut Vec<Vec<i32>>) { let n = matrix.len() - 1; let len = matrix.len(); for y in 0..(len / 2) { for x in y..(n - y) { let temp = matrix[x][y]; matrix[x][y] = matrix[n - y][x]; matrix[n - y][x] = matrix[n - x][n - y]; matrix[n - x][n - y] = matrix[y][n - x]; matrix[y][n - x] = temp; } } } } fn main() { let mut v = vec![ vec![5, 1, 9, 11], vec![2, 4, 8, 10], vec![13, 3, 6, 7], vec![15, 14, 12, 16], ]; Solution::rotate(&mut v); v.iter().for_each(|v| println!("{:?}", v)); }
#[doc = "Reader of register APBENR1"] pub type R = crate::R<u32, super::APBENR1>; #[doc = "Writer for register APBENR1"] pub type W = crate::W<u32, super::APBENR1>; #[doc = "Register APBENR1 `reset()`'s with value 0"] impl crate::ResetValue for super::APBENR1 { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Reader of field `TIM2EN`"] pub type TIM2EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `TIM2EN`"] pub struct TIM2EN_W<'a> { w: &'a mut W, } impl<'a> TIM2EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); self.w } } #[doc = "Reader of field `TIM3EN`"] pub type TIM3EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `TIM3EN`"] pub struct TIM3EN_W<'a> { w: &'a mut W, } impl<'a> TIM3EN_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 `RTCAPBEN`"] pub type RTCAPBEN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `RTCAPBEN`"] pub struct RTCAPBEN_W<'a> { w: &'a mut W, } impl<'a> RTCAPBEN_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 `WWDGEN`"] pub type WWDGEN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `WWDGEN`"] pub struct WWDGEN_W<'a> { w: &'a mut W, } impl<'a> WWDGEN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 11)) | (((value as u32) & 0x01) << 11); self.w } } #[doc = "Reader of field `SPI2EN`"] pub type SPI2EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `SPI2EN`"] pub struct SPI2EN_W<'a> { w: &'a mut W, } impl<'a> SPI2EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 14)) | (((value as u32) & 0x01) << 14); self.w } } #[doc = "Reader of field `USART2EN`"] pub type USART2EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `USART2EN`"] pub struct USART2EN_W<'a> { w: &'a mut W, } impl<'a> USART2EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 17)) | (((value as u32) & 0x01) << 17); self.w } } #[doc = "Reader of field `LPUART1EN`"] pub type LPUART1EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `LPUART1EN`"] pub struct LPUART1EN_W<'a> { w: &'a mut W, } impl<'a> LPUART1EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 20)) | (((value as u32) & 0x01) << 20); self.w } } #[doc = "Reader of field `I2C1EN`"] pub type I2C1EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `I2C1EN`"] pub struct I2C1EN_W<'a> { w: &'a mut W, } impl<'a> I2C1EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 21)) | (((value as u32) & 0x01) << 21); self.w } } #[doc = "Reader of field `I2C2EN`"] pub type I2C2EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `I2C2EN`"] pub struct I2C2EN_W<'a> { w: &'a mut W, } impl<'a> I2C2EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 22)) | (((value as u32) & 0x01) << 22); self.w } } #[doc = "Reader of field `DBGEN`"] pub type DBGEN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `DBGEN`"] pub struct DBGEN_W<'a> { w: &'a mut W, } impl<'a> DBGEN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 27)) | (((value as u32) & 0x01) << 27); self.w } } #[doc = "Reader of field `PWREN`"] pub type PWREN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `PWREN`"] pub struct PWREN_W<'a> { w: &'a mut W, } impl<'a> PWREN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 28)) | (((value as u32) & 0x01) << 28); self.w } } #[doc = "Reader of field `LPTIM2EN`"] pub type LPTIM2EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `LPTIM2EN`"] pub struct LPTIM2EN_W<'a> { w: &'a mut W, } impl<'a> LPTIM2EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 30)) | (((value as u32) & 0x01) << 30); self.w } } #[doc = "Reader of field `LPTIM1EN`"] pub type LPTIM1EN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `LPTIM1EN`"] pub struct LPTIM1EN_W<'a> { w: &'a mut W, } impl<'a> LPTIM1EN_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 31)) | (((value as u32) & 0x01) << 31); self.w } } impl R { #[doc = "Bit 0 - TIM2 timer clock enable"] #[inline(always)] pub fn tim2en(&self) -> TIM2EN_R { TIM2EN_R::new((self.bits & 0x01) != 0) } #[doc = "Bit 1 - TIM3 timer clock enable"] #[inline(always)] pub fn tim3en(&self) -> TIM3EN_R { TIM3EN_R::new(((self.bits >> 1) & 0x01) != 0) } #[doc = "Bit 10 - RTC APB clock enable"] #[inline(always)] pub fn rtcapben(&self) -> RTCAPBEN_R { RTCAPBEN_R::new(((self.bits >> 10) & 0x01) != 0) } #[doc = "Bit 11 - WWDG clock enable"] #[inline(always)] pub fn wwdgen(&self) -> WWDGEN_R { WWDGEN_R::new(((self.bits >> 11) & 0x01) != 0) } #[doc = "Bit 14 - SPI2 clock enable"] #[inline(always)] pub fn spi2en(&self) -> SPI2EN_R { SPI2EN_R::new(((self.bits >> 14) & 0x01) != 0) } #[doc = "Bit 17 - USART2 clock enable"] #[inline(always)] pub fn usart2en(&self) -> USART2EN_R { USART2EN_R::new(((self.bits >> 17) & 0x01) != 0) } #[doc = "Bit 20 - LPUART1 clock enable"] #[inline(always)] pub fn lpuart1en(&self) -> LPUART1EN_R { LPUART1EN_R::new(((self.bits >> 20) & 0x01) != 0) } #[doc = "Bit 21 - I2C1 clock enable"] #[inline(always)] pub fn i2c1en(&self) -> I2C1EN_R { I2C1EN_R::new(((self.bits >> 21) & 0x01) != 0) } #[doc = "Bit 22 - I2C2 clock enable"] #[inline(always)] pub fn i2c2en(&self) -> I2C2EN_R { I2C2EN_R::new(((self.bits >> 22) & 0x01) != 0) } #[doc = "Bit 27 - Debug support clock enable"] #[inline(always)] pub fn dbgen(&self) -> DBGEN_R { DBGEN_R::new(((self.bits >> 27) & 0x01) != 0) } #[doc = "Bit 28 - Power interface clock enable"] #[inline(always)] pub fn pwren(&self) -> PWREN_R { PWREN_R::new(((self.bits >> 28) & 0x01) != 0) } #[doc = "Bit 30 - LPTIM2 clock enable"] #[inline(always)] pub fn lptim2en(&self) -> LPTIM2EN_R { LPTIM2EN_R::new(((self.bits >> 30) & 0x01) != 0) } #[doc = "Bit 31 - LPTIM1 clock enable"] #[inline(always)] pub fn lptim1en(&self) -> LPTIM1EN_R { LPTIM1EN_R::new(((self.bits >> 31) & 0x01) != 0) } } impl W { #[doc = "Bit 0 - TIM2 timer clock enable"] #[inline(always)] pub fn tim2en(&mut self) -> TIM2EN_W { TIM2EN_W { w: self } } #[doc = "Bit 1 - TIM3 timer clock enable"] #[inline(always)] pub fn tim3en(&mut self) -> TIM3EN_W { TIM3EN_W { w: self } } #[doc = "Bit 10 - RTC APB clock enable"] #[inline(always)] pub fn rtcapben(&mut self) -> RTCAPBEN_W { RTCAPBEN_W { w: self } } #[doc = "Bit 11 - WWDG clock enable"] #[inline(always)] pub fn wwdgen(&mut self) -> WWDGEN_W { WWDGEN_W { w: self } } #[doc = "Bit 14 - SPI2 clock enable"] #[inline(always)] pub fn spi2en(&mut self) -> SPI2EN_W { SPI2EN_W { w: self } } #[doc = "Bit 17 - USART2 clock enable"] #[inline(always)] pub fn usart2en(&mut self) -> USART2EN_W { USART2EN_W { w: self } } #[doc = "Bit 20 - LPUART1 clock enable"] #[inline(always)] pub fn lpuart1en(&mut self) -> LPUART1EN_W { LPUART1EN_W { w: self } } #[doc = "Bit 21 - I2C1 clock enable"] #[inline(always)] pub fn i2c1en(&mut self) -> I2C1EN_W { I2C1EN_W { w: self } } #[doc = "Bit 22 - I2C2 clock enable"] #[inline(always)] pub fn i2c2en(&mut self) -> I2C2EN_W { I2C2EN_W { w: self } } #[doc = "Bit 27 - Debug support clock enable"] #[inline(always)] pub fn dbgen(&mut self) -> DBGEN_W { DBGEN_W { w: self } } #[doc = "Bit 28 - Power interface clock enable"] #[inline(always)] pub fn pwren(&mut self) -> PWREN_W { PWREN_W { w: self } } #[doc = "Bit 30 - LPTIM2 clock enable"] #[inline(always)] pub fn lptim2en(&mut self) -> LPTIM2EN_W { LPTIM2EN_W { w: self } } #[doc = "Bit 31 - LPTIM1 clock enable"] #[inline(always)] pub fn lptim1en(&mut self) -> LPTIM1EN_W { LPTIM1EN_W { w: self } } }
use P26::combinations; fn main() { let li = vec!['a', 'b', 'c', 'd', 'e', 'f']; println!("{:?}", combinations(3, &li)); }
use actix_web::middleware::cors::CorsBuilder; use actix_web::{http::Method, App, HttpResponse}; use controllers::*; use server::AppState; pub fn routes(app: &mut CorsBuilder<AppState>) -> App<AppState> { // Please try to keep in alphabetical order app.resource("/artists/{id}/toggle_privacy", |r| { r.method(Method::PUT).with(artists::toggle_privacy); }).resource("/artists/{id}", |r| { r.method(Method::GET).with(artists::show); r.method(Method::PUT).with(artists::update); }).resource("/artists", |r| { r.method(Method::GET).with(artists::index); r.method(Method::POST).with(artists::create); }).resource("/auth/token", |r| r.method(Method::POST).with(auth::token)) .resource("/auth/token/refresh", |r| { r.method(Method::POST).with(auth::token_refresh) }).resource("/cart", |r| { r.method(Method::POST).with(cart::add); r.method(Method::GET).with(cart::show); r.method(Method::DELETE).with(cart::remove); }).resource("/cart/checkout", |r| { r.method(Method::POST).with(cart::checkout); }).resource("/cart/{id}", |r| { r.method(Method::GET).with(cart::show); }).resource("/events", |r| { r.method(Method::GET).with(events::index); r.method(Method::POST).with(events::create); }).resource("/events/{id}", |r| { r.method(Method::GET).with(events::show); r.method(Method::PUT).with(events::update); r.method(Method::DELETE).with(events::cancel); }).resource("/events/{id}/artists", |r| { r.method(Method::POST).with(events::add_artist); r.method(Method::PUT).with(events::update_artists); }).resource("/events/{id}/guests", |r| { r.method(Method::GET).with(events::guest_list); }).resource("/events/{id}/interest", |r| { r.method(Method::GET).with(events::list_interested_users); r.method(Method::POST).with(events::add_interest); r.method(Method::DELETE).with(events::remove_interest); }).resource("/events/{id}/publish", |r| { r.method(Method::POST).with(events::publish); }).resource("/events/{id}/tickets", |r| { r.method(Method::GET).with(tickets::index); }).resource("/events/{id}/ticket_types", |r| { r.method(Method::GET).with(ticket_types::index); r.method(Method::POST).with(ticket_types::create); }).resource("/events/{event_id}/ticket_types/{ticket_type_id}", |r| { r.method(Method::PATCH).with(ticket_types::update); }).resource("/events/{id}/holds", |r| { r.method(Method::POST).with(holds::create); }).resource("/external/facebook/web_login", |r| { r.method(Method::POST).with(external::facebook::web_login) }).resource("/invitations/{id}", |r| { r.method(Method::GET).with(organization_invites::view); }).resource("/invitations", |r| { r.method(Method::POST) .with(organization_invites::accept_request); r.method(Method::DELETE) .with(organization_invites::decline_request); }).resource("/holds/{id}/tickets", |r| { r.method(Method::PUT).with(holds::add_remove_from_hold); }).resource("/holds/{id}", |r| { r.method(Method::PATCH).with(holds::update); }).resource("/orders", |r| { r.method(Method::GET).with(orders::index); }).resource("/orders/{id}", |r| { r.method(Method::GET).with(orders::show); }).resource("/organizations/{id}/artists", |r| { r.method(Method::GET).with(artists::show_from_organizations); r.method(Method::POST).with(organizations::add_artist); }).resource("/organizations/{id}/events", |r| { r.method(Method::GET).with(events::show_from_organizations); }).resource("/organizations/{id}/fee_schedule", |r| { r.method(Method::GET).with(organizations::show_fee_schedule); r.method(Method::POST).with(organizations::add_fee_schedule); }).resource("/organizations/{id}/invite", |r| { r.method(Method::POST).with(organization_invites::create); }).resource("/organizations/{id}/owner", |r| { r.method(Method::PUT).with(organizations::update_owner); }).resource("/organizations/{id}/users", |r| { r.method(Method::POST).with(organizations::add_user); r.method(Method::DELETE).with(organizations::remove_user); r.method(Method::GET) .with(organizations::list_organization_members); }).resource("/organizations/{id}/venues", |r| { r.method(Method::GET).with(venues::show_from_organizations); r.method(Method::POST).with(organizations::add_venue); }).resource("/organizations/{id}", |r| { r.method(Method::GET).with(organizations::show); r.method(Method::PATCH).with(organizations::update); }).resource("/organizations", |r| { r.method(Method::GET).with(organizations::index); r.method(Method::POST).with(organizations::create); }).resource("/password_reset", |r| { r.method(Method::POST).with(password_resets::create); r.method(Method::PUT).with(password_resets::update); }).resource("/payment_methods", |r| { r.method(Method::GET).with(payment_methods::index); }).resource("/regions/{id}", |r| { r.method(Method::GET).with(regions::show); r.method(Method::PUT).with(regions::update); }).resource("/regions", |r| { r.method(Method::GET).with(regions::index); r.method(Method::POST).with(regions::create) }).resource("/status", |r| { r.method(Method::GET).f(|_| HttpResponse::Ok()) }).resource("/tickets/transfer", |r| { r.method(Method::POST).with(tickets::transfer_authorization); }).resource("/tickets/receive", |r| { r.method(Method::POST).with(tickets::receive_transfer); }).resource("/tickets/send", |r| { r.method(Method::POST).with(tickets::send_via_email); }).resource("/tickets/{id}", |r| { r.method(Method::GET).with(tickets::show); }).resource("/tickets", |r| { r.method(Method::GET).with(tickets::index); }).resource("/tickets/{id}/redeem", |r| { r.method(Method::GET).with(tickets::show_redeemable_ticket); r.method(Method::POST).with(tickets::redeem); }).resource("/users/me", |r| { r.method(Method::GET).with(users::current_user); r.method(Method::PUT).with(users::update_current_user); }).resource("/users/register", |r| { r.method(Method::POST).with(users::register) }).resource("/users", |r| { r.method(Method::GET).with(users::find_by_email); }).resource("/users/{id}", |r| { r.method(Method::GET).with(users::show); }).resource("/users/{id}/organizations", |r| { r.method(Method::GET).with(users::list_organizations); }).resource("/venues/{id}/events", |r| { r.method(Method::GET).with(events::show_from_venues); }).resource("/venues/{id}/organizations", |r| { r.method(Method::POST).with(venues::add_to_organization); }).resource("/venues/{id}/toggle_privacy", |r| { r.method(Method::PUT).with(venues::toggle_privacy); }).resource("/venues/{id}", |r| { r.method(Method::GET).with(venues::show); r.method(Method::PUT).with(venues::update); }).resource("/venues", |r| { r.method(Method::GET).with(venues::index); r.method(Method::POST).with(venues::create); }).register() .default_resource(|r| { r.method(Method::GET) .f(|_req| HttpResponse::NotFound().json(json!({"error": "Not found".to_string()}))); }) }
//! ### TODO //! //! * offer GC interface and example GCs //! * rust currently doesn't allow generic static values - when it does, make this library //! truely generic: Add `read_pool`, `write_pool`. Keep `[Byte]Symbol`, `[Byte]SymbolPool` as //! useful aliases. //! #![feature(hashmap_hasher)] #![feature(set_recovery)] extern crate fnv; extern crate rustc_serialize; use std::borrow::Borrow; use std::collections::HashSet; use std::collections::hash_state; use std::fmt::{self, Debug, Display}; use std::hash::Hash; use std::sync::{Arc, RwLock, RwLockReadGuard, RwLockWriteGuard}; use std::marker::PhantomData; use std::ops::Deref; use rustc_serialize::{Encodable, Decodable}; // ++++++++++++++++++++ Interned ++++++++++++++++++++ #[derive(Hash, PartialOrd, Ord)] pub struct Interned<B: ?Sized, O>{ inner: Arc<O>, _phantom: PhantomData<B>, } impl<B: ?Sized, O> Interned<B, O> { fn new(inner: Arc<O>) -> Self { Interned{ inner: inner, _phantom: PhantomData } } } impl<B: ?Sized, O> Clone for Interned<B, O> { fn clone(&self) -> Self { Self::new(self.inner.clone()) } } impl<B: ?Sized, O> PartialEq for Interned<B, O> { fn eq(&self, rhs: &Self) -> bool { (&*self.inner) as *const _ as usize == (&*rhs.inner) as *const _ as usize } } impl<B: ?Sized, O> Eq for Interned<B, O> {} impl<B: ?Sized, O> Borrow<B> for Interned<B, O> where O: Borrow<B> { fn borrow(&self) -> &B { (*self.inner).borrow() } } //FIXME /*impl<B: ?Sized, O> Into<O> for Interned<B, O> where O: Clone { fn into(self) -> O { self.inner.clone() } }*/ impl<B: ?Sized, O> Debug for Interned<B, O> where O: Debug { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { (*self.inner).fmt(formatter) } } impl<B: ?Sized, O> Display for Interned<B, O> where O: Display { fn fmt(&self, formatter: &mut fmt::Formatter) -> Result<(), fmt::Error> { (*self.inner).fmt(formatter) } } impl<B: ?Sized, O> Deref for Interned<B, O> where O: Borrow<B> { type Target = B; fn deref(&self) -> &Self::Target { (*self.inner).borrow() } } impl<B: ?Sized, O> Encodable for Interned<B, O> where O: Encodable { fn encode<S: rustc_serialize::Encoder>(&self, s: &mut S) -> Result<(), S::Error> { (*self.inner).encode(s) } } impl<B: ?Sized, O> Decodable for Interned<B, O> where O: Decodable, Interned<B, O>: From<O> { fn decode<D: rustc_serialize::Decoder>(d: &mut D) -> Result<Self, D::Error> { Ok(Self::from(try!{O::decode(d)})) } } // ++++++++++++++++++++ InternPool ++++++++++++++++++++ pub struct InternPool<B: ?Sized, O> { data: HashSet<Interned<B, O>, hash_state::DefaultState<fnv::FnvHasher>>, } impl<B: ?Sized, O> InternPool<B, O> where B: Hash + Eq, O: Borrow<B> + Hash + Eq { fn new() -> Self { InternPool{ data: HashSet::default() } } pub fn get(&self, obj: &B) -> Option<&Interned<B, O>> { self.data.get(obj) } pub fn intern<X>(&mut self, obj: X) -> Interned<B, O> where X: Borrow<B>, X: Into<O> { match self.get(obj.borrow()) { Some(ret) => { return (*ret).clone(); } None => {} } let ret: Interned<B, O> = Interned::new(Arc::new(obj.into())); self.data.insert(ret.clone()); ret } } // ++++++++++++++++++++ Symbol, SymbolPool ++++++++++++++++++++ pub type Symbol = Interned<str, String>; pub type SymbolPool = InternPool<str, String>; fn symbol_pool_instance() -> &'static RwLock<SymbolPool> { static POOL: Option<RwLock<SymbolPool>> = None; match &POOL { &Some(ref r) => r, // beware of racey hack! pool => unsafe { let init = Some(RwLock::new(SymbolPool::new())); ::std::ptr::write(pool as *const _ as *mut Option<RwLock<SymbolPool>>, init); POOL.as_ref().unwrap() } } } pub fn read_symbol_pool() -> RwLockReadGuard<'static, SymbolPool> { symbol_pool_instance().read().unwrap() } pub fn write_symbol_pool() -> RwLockWriteGuard<'static, SymbolPool> { symbol_pool_instance().write().unwrap() } impl<'a> From<&'a str> for Symbol { fn from(s: &'a str) -> Symbol { write_symbol_pool().intern(s) } } impl<'a> From<String> for Symbol { fn from(s: String) -> Symbol { write_symbol_pool().intern(s) } } // ++++++++++++++++++++ ByteSymbol, ByteSymbolPool ++++++++++++++++++++ pub type ByteSymbol = Interned<[u8], Vec<u8>>; pub type ByteSymbolPool = InternPool<[u8], Vec<u8>>; fn byte_symbol_pool_instance() -> &'static RwLock<ByteSymbolPool> { static POOL: Option<RwLock<ByteSymbolPool>> = None; match &POOL { &Some(ref r) => r, // beware of racey hack! pool => unsafe { let init = Some(RwLock::new(ByteSymbolPool::new())); ::std::ptr::write(pool as *const _ as *mut Option<RwLock<ByteSymbolPool>>, init); POOL.as_ref().unwrap() } } } pub fn read_byte_symbol_pool() -> RwLockReadGuard<'static, ByteSymbolPool> { byte_symbol_pool_instance().read().unwrap() } pub fn write_byte_symbol_pool() -> RwLockWriteGuard<'static, ByteSymbolPool> { byte_symbol_pool_instance().write().unwrap() } impl<'a> From<&'a [u8]> for ByteSymbol { fn from(s: &'a [u8]) -> ByteSymbol { write_byte_symbol_pool().intern(s) } } impl<'a> From<Vec<u8>> for ByteSymbol { fn from(s: Vec<u8>) -> ByteSymbol { write_byte_symbol_pool().intern(s) } }
#![no_std] #![cfg_attr(docsrs, feature(doc_auto_cfg))] #![doc = include_str!("../README.md")] #![doc( html_logo_url = "https://raw.githubusercontent.com/RustCrypto/media/7f79a5e/img/ring-compat/logo-sq.png" )] #![forbid(unsafe_code)] #![warn(missing_docs, rust_2018_idioms)] //! # Features //! //! Functionality in this crate is gated under the following features: //! //! - `aead`: Authenticated Encryption with Associated Data algorithms: AES-GCM, ChaCha20Poly1305 //! - `digest`: Cryptographic Hash Functions: SHA-1, SHA-256, SHA-384, SHA-512, SHA-512/256 //! - `signature`: Digital Signature Algorithms, gated under the following features: //! - `ecdsa`: Elliptic Curve Digital Signature Algorithm //! - `ed25519`: Edwards Digital Signature Algorithm instantiated over Curve25519 //! - `p256`: ECDSA/NIST P-256 //! - `p384`: ECDSA/NIST P-384 #[cfg(feature = "std")] extern crate std; #[cfg(feature = "aead")] pub mod aead; #[cfg(feature = "digest")] pub mod digest; #[cfg(feature = "signature")] pub mod signature; pub use generic_array; #[cfg(feature = "signature")] pub use pkcs8; pub use ring;
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[repr(transparent)] #[doc(hidden)] pub struct IVpnAppId(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnAppId { type Vtable = IVpnAppId_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7b06a635_5c58_41d9_94a7_bfbcf1d8ca54); } #[repr(C)] #[doc(hidden)] pub struct IVpnAppId_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 VpnAppIdType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnAppIdType) -> ::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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnAppIdFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnAppIdFactory { type Vtable = IVpnAppIdFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x46adfd2a_0aab_4fdb_821d_d3ddc919788b); } #[repr(C)] #[doc(hidden)] pub struct IVpnAppIdFactory_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, r#type: VpnAppIdType, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannel(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannel { type Vtable = IVpnChannel_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ac78d07_d1a8_4303_a091_c8d2e0915bc3); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannel_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, mainoutertunneltransport: ::windows::core::RawPtr, optionaloutertunneltransport: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, assignedclientipv4list: ::windows::core::RawPtr, assignedclientipv6list: ::windows::core::RawPtr, vpninterfaceid: ::windows::core::RawPtr, routescope: ::windows::core::RawPtr, namespacescope: ::windows::core::RawPtr, mtusize: u32, maxframesize: u32, optimizeforlowcostnetwork: bool, mainoutertunneltransport: ::windows::core::RawPtr, optionaloutertunneltransport: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(feature = "Security_Cryptography_Certificates")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, credtype: VpnCredentialType, isretry: bool, issinglesignoncredential: bool, certificate: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Cryptography_Certificates"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, r#type: VpnDataPathType, vpnpacketbuffer: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, message: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::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, handler: ::windows::core::RawPtr, result__: *mut 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::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, 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, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, customprompt: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, message: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, tunneltransport: ::windows::core::RawPtr, usetls12: bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannel2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannel2 { type Vtable = IVpnChannel2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2255d165_993b_4629_ad60_f1c3f3537f50); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannel2_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, assignedclientipv4list: ::windows::core::RawPtr, assignedclientipv6list: ::windows::core::RawPtr, vpninterfaceid: ::windows::core::RawPtr, assignedroutes: ::windows::core::RawPtr, assigneddomainname: ::windows::core::RawPtr, mtusize: u32, maxframesize: u32, reserved: bool, mainoutertunneltransport: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, assignedclientipv4list: ::windows::core::RawPtr, assignedclientipv6list: ::windows::core::RawPtr, vpninterfaceid: ::windows::core::RawPtr, assignedroutes: ::windows::core::RawPtr, assigneddomainname: ::windows::core::RawPtr, mtusize: u32, maxframesize: u32, reserved: bool) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut 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::Foundation::EventRegistrationToken) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, 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, #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, custompromptelement: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize, #[cfg(all(feature = "Foundation", feature = "Security_Cryptography_Certificates"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, credtype: VpnCredentialType, credoptions: u32, certificate: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Security_Cryptography_Certificates")))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, credtype: VpnCredentialType, credoptions: u32, 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, credtype: VpnCredentialType, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, message: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn( this: ::windows::core::RawPtr, assignedclientipv4list: ::windows::core::RawPtr, assignedclientipv6list: ::windows::core::RawPtr, vpninterfaceid: ::windows::core::RawPtr, assignedroutes: ::windows::core::RawPtr, assignednamespace: ::windows::core::RawPtr, mtusize: u32, maxframesize: u32, reserved: bool, mainoutertunneltransport: ::windows::core::RawPtr, optionaloutertunneltransport: ::windows::core::RawPtr, assignedtrafficfilters: ::windows::core::RawPtr, ) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannel4(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannel4 { type Vtable = IVpnChannel4_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd7266ede_2937_419d_9570_486aebb81803); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannel4_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, transport: ::windows::core::RawPtr, context: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, assignedclientipv4addresses: ::windows::core::RawPtr, assignedclientipv6addresses: ::windows::core::RawPtr, vpninterfaceid: ::windows::core::RawPtr, assignedroutes: ::windows::core::RawPtr, assignednamespace: ::windows::core::RawPtr, mtusize: u32, maxframesize: u32, reserved: bool, transports: ::windows::core::RawPtr, assignedtrafficfilters: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, transport: ::windows::core::RawPtr, context: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, transport: ::windows::core::RawPtr, context: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(feature = "Networking_Sockets")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, context: ::windows::core::RawPtr, result__: *mut super::Sockets::ControlChannelTriggerStatus) -> ::windows::core::HRESULT, #[cfg(not(feature = "Networking_Sockets"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannel5(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannel5 { type Vtable = IVpnChannel5_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xde7a0992_8384_4fbc_882c_1fd23124cd3b); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannel5_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, decapsulatedpacketbuffer: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, encapsulatedpacketbuffer: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannel6(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannel6 { type Vtable = IVpnChannel6_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x55843696_bd63_49c5_abca_5da77885551a); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannel6_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, packagerelativeappid: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, sharedcontext: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannelActivityEventArgs(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannelActivityEventArgs { type Vtable = IVpnChannelActivityEventArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa36c88f2_afdc_4775_855d_d4ac0a35fc55); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannelActivityEventArgs_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 VpnChannelActivityEventType) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannelActivityStateChangedArgs(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannelActivityStateChangedArgs { type Vtable = IVpnChannelActivityStateChangedArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3d750565_fdc0_4bbe_a23b_45fffc6d97a1); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannelActivityStateChangedArgs_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 VpnChannelActivityEventType) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannelConfiguration(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannelConfiguration { type Vtable = IVpnChannelConfiguration_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0e2ddca2_2012_4fe4_b179_8c652c6d107e); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannelConfiguration_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, #[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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnChannelConfiguration2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannelConfiguration2 { type Vtable = IVpnChannelConfiguration2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf30b574c_7824_471c_a118_63dbc93ae4c7); } #[repr(C)] #[doc(hidden)] pub struct IVpnChannelConfiguration2_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(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnChannelStatics(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnChannelStatics { type Vtable = IVpnChannelStatics_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x88eb062d_e818_4ffd_98a6_363e3736c95d); } impl IVpnChannelStatics { pub fn ProcessEventAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, thirdpartyplugin: Param0, event: Param1) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), thirdpartyplugin.into_param().abi(), event.into_param().abi()).ok() } } } unsafe impl ::windows::core::RuntimeType for IVpnChannelStatics { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{88eb062d-e818-4ffd-98a6-363e3736c95d}"); } impl ::core::convert::From<IVpnChannelStatics> for ::windows::core::IUnknown { fn from(value: IVpnChannelStatics) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnChannelStatics> for ::windows::core::IUnknown { fn from(value: &IVpnChannelStatics) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnChannelStatics { 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 IVpnChannelStatics { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnChannelStatics> for ::windows::core::IInspectable { fn from(value: IVpnChannelStatics) -> Self { value.0 } } impl ::core::convert::From<&IVpnChannelStatics> for ::windows::core::IInspectable { fn from(value: &IVpnChannelStatics) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnChannelStatics { 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 IVpnChannelStatics { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnChannelStatics_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, thirdpartyplugin: ::windows::core::RawPtr, event: ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnCredential(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCredential { type Vtable = IVpnCredential_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb7e78af3_a46d_404b_8729_1832522853ac); } impl IVpnCredential { #[cfg(feature = "Security_Credentials")] pub fn PasskeyCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::Security::Credentials::PasswordCredential>(result__) } } #[cfg(feature = "Security_Cryptography_Certificates")] pub fn CertificateCredential(&self) -> ::windows::core::Result<super::super::Security::Cryptography::Certificates::Certificate> { 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::super::Security::Cryptography::Certificates::Certificate>(result__) } } pub fn AdditionalPin(&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).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } #[cfg(feature = "Security_Credentials")] pub fn OldPasswordCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::<super::super::Security::Credentials::PasswordCredential>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnCredential { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{b7e78af3-a46d-404b-8729-1832522853ac}"); } impl ::core::convert::From<IVpnCredential> for ::windows::core::IUnknown { fn from(value: IVpnCredential) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnCredential> for ::windows::core::IUnknown { fn from(value: &IVpnCredential) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnCredential { 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 IVpnCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnCredential> for ::windows::core::IInspectable { fn from(value: IVpnCredential) -> Self { value.0 } } impl ::core::convert::From<&IVpnCredential> for ::windows::core::IInspectable { fn from(value: &IVpnCredential) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnCredential { 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 IVpnCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnCredential_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 = "Security_Credentials")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Credentials"))] usize, #[cfg(feature = "Security_Cryptography_Certificates")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Cryptography_Certificates"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, #[cfg(feature = "Security_Credentials")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Credentials"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomCheckBox(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomCheckBox { type Vtable = IVpnCustomCheckBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43878753_03c5_4e61_93d7_a957714c4282); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomCheckBox_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: bool) -> ::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, result__: *mut bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomComboBox(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomComboBox { type Vtable = IVpnCustomComboBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9a24158e_dba1_4c6f_8270_dcf3c9761c4c); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomComboBox_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, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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 u32) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomEditBox(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomEditBox { type Vtable = IVpnCustomEditBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3002d9a0_cfbf_4c0b_8f3c_66f503c20b39); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomEditBox_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: ::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: bool) -> ::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, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomErrorBox(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomErrorBox { type Vtable = IVpnCustomErrorBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9ec4efb2_c942_42af_b223_588b48328721); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomErrorBox_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)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnCustomPrompt(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPrompt { type Vtable = IVpnCustomPrompt_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9b2ebe7b_87d5_433c_b4f6_eee6aa68a244); } impl IVpnCustomPrompt { 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).6)(::core::mem::transmute_copy(this), value.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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&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 Compulsory(&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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&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__) } } } unsafe impl ::windows::core::RuntimeType for IVpnCustomPrompt { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{9b2ebe7b-87d5-433c-b4f6-eee6aa68a244}"); } impl ::core::convert::From<IVpnCustomPrompt> for ::windows::core::IUnknown { fn from(value: IVpnCustomPrompt) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnCustomPrompt> for ::windows::core::IUnknown { fn from(value: &IVpnCustomPrompt) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnCustomPrompt { 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 IVpnCustomPrompt { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnCustomPrompt> for ::windows::core::IInspectable { fn from(value: IVpnCustomPrompt) -> Self { value.0 } } impl ::core::convert::From<&IVpnCustomPrompt> for ::windows::core::IInspectable { fn from(value: &IVpnCustomPrompt) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnCustomPrompt { 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 IVpnCustomPrompt { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPrompt_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: ::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: bool) -> ::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 bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomPromptBooleanInput(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPromptBooleanInput { type Vtable = IVpnCustomPromptBooleanInput_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc4c9a69e_ff47_4527_9f27_a49292019979); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPromptBooleanInput_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: bool) -> ::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, result__: *mut bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnCustomPromptElement(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPromptElement { type Vtable = IVpnCustomPromptElement_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x73bd5638_6f04_404d_93dd_50a44924a38b); } impl IVpnCustomPromptElement { pub fn SetDisplayName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayName(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&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 Compulsory(&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__) } } pub fn SetEmphasized(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Emphasized(&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__) } } } unsafe impl ::windows::core::RuntimeType for IVpnCustomPromptElement { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{73bd5638-6f04-404d-93dd-50a44924a38b}"); } impl ::core::convert::From<IVpnCustomPromptElement> for ::windows::core::IUnknown { fn from(value: IVpnCustomPromptElement) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnCustomPromptElement> for ::windows::core::IUnknown { fn from(value: &IVpnCustomPromptElement) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnCustomPromptElement { 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 IVpnCustomPromptElement { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnCustomPromptElement> for ::windows::core::IInspectable { fn from(value: IVpnCustomPromptElement) -> Self { value.0 } } impl ::core::convert::From<&IVpnCustomPromptElement> for ::windows::core::IInspectable { fn from(value: &IVpnCustomPromptElement) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnCustomPromptElement { 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 IVpnCustomPromptElement { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPromptElement_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: ::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: bool) -> ::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 bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomPromptOptionSelector(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPromptOptionSelector { type Vtable = IVpnCustomPromptOptionSelector_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3b8f34d9_8ec1_4e95_9a4e_7ba64d38f330); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPromptOptionSelector_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, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomPromptText(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPromptText { type Vtable = IVpnCustomPromptText_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3bc8bdee_3a42_49a3_abdd_07b2edea752d); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPromptText_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: ::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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomPromptTextInput(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomPromptTextInput { type Vtable = IVpnCustomPromptTextInput_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc9da9c75_913c_47d5_88ba_48fc48930235); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomPromptTextInput_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: ::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: bool) -> ::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, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnCustomTextBox(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnCustomTextBox { type Vtable = IVpnCustomTextBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdaa4c3ca_8f23_4d36_91f1_76d937827942); } #[repr(C)] #[doc(hidden)] pub struct IVpnCustomTextBox_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: ::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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnDomainNameAssignment(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnDomainNameAssignment { type Vtable = IVpnDomainNameAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4135b141_ccdb_49b5_9401_039a8ae767e9); } #[repr(C)] #[doc(hidden)] pub struct IVpnDomainNameAssignment_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, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnDomainNameInfo(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnDomainNameInfo { type Vtable = IVpnDomainNameInfo_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xad2eb82f_ea8e_4f7a_843e_1a87e32e1b9a); } #[repr(C)] #[doc(hidden)] pub struct IVpnDomainNameInfo_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: ::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: VpnDomainNameType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnDomainNameType) -> ::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, #[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 IVpnDomainNameInfo2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnDomainNameInfo2 { type Vtable = IVpnDomainNameInfo2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xab871151_6c53_4828_9883_d886de104407); } #[repr(C)] #[doc(hidden)] pub struct IVpnDomainNameInfo2_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(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnDomainNameInfoFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnDomainNameInfoFactory { type Vtable = IVpnDomainNameInfoFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2507bb75_028f_4688_8d3a_c4531df37da8); } impl IVpnDomainNameInfoFactory { #[cfg(feature = "Foundation_Collections")] pub fn CreateVpnDomainNameInfo<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>>(&self, name: Param0, nametype: VpnDomainNameType, dnsserverlist: Param2, proxyserverlist: Param3) -> ::windows::core::Result<VpnDomainNameInfo> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), name.into_param().abi(), nametype, dnsserverlist.into_param().abi(), proxyserverlist.into_param().abi(), &mut result__).from_abi::<VpnDomainNameInfo>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnDomainNameInfoFactory { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{2507bb75-028f-4688-8d3a-c4531df37da8}"); } impl ::core::convert::From<IVpnDomainNameInfoFactory> for ::windows::core::IUnknown { fn from(value: IVpnDomainNameInfoFactory) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnDomainNameInfoFactory> for ::windows::core::IUnknown { fn from(value: &IVpnDomainNameInfoFactory) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnDomainNameInfoFactory { 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 IVpnDomainNameInfoFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnDomainNameInfoFactory> for ::windows::core::IInspectable { fn from(value: IVpnDomainNameInfoFactory) -> Self { value.0 } } impl ::core::convert::From<&IVpnDomainNameInfoFactory> for ::windows::core::IInspectable { fn from(value: &IVpnDomainNameInfoFactory) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnDomainNameInfoFactory { 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 IVpnDomainNameInfoFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnDomainNameInfoFactory_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, name: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, nametype: VpnDomainNameType, dnsserverlist: ::windows::core::RawPtr, proxyserverlist: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnForegroundActivatedEventArgs(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnForegroundActivatedEventArgs { type Vtable = IVpnForegroundActivatedEventArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x85b465b0_cadb_4d70_ac92_543a24dc9ebc); } #[repr(C)] #[doc(hidden)] pub struct IVpnForegroundActivatedEventArgs_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, #[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 ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnForegroundActivationOperation(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnForegroundActivationOperation { type Vtable = IVpnForegroundActivationOperation_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e010d57_f17a_4bd5_9b6d_f984f1297d3c); } #[repr(C)] #[doc(hidden)] pub struct IVpnForegroundActivationOperation_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: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnInterfaceId(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnInterfaceId { type Vtable = IVpnInterfaceId_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e2ddca2_1712_4ce4_b179_8c652c6d1011); } #[repr(C)] #[doc(hidden)] pub struct IVpnInterfaceId_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, id_array_size: *mut u32, id: *mut *mut u8) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnInterfaceIdFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnInterfaceIdFactory { type Vtable = IVpnInterfaceIdFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e2ddca2_1712_4ce4_b179_8c652c6d1000); } impl IVpnInterfaceIdFactory { pub fn CreateVpnInterfaceId(&self, address: &[<u8 as ::windows::core::DefaultType>::DefaultType]) -> ::windows::core::Result<VpnInterfaceId> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), address.len() as u32, ::core::mem::transmute(address.as_ptr()), &mut result__).from_abi::<VpnInterfaceId>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnInterfaceIdFactory { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{9e2ddca2-1712-4ce4-b179-8c652c6d1000}"); } impl ::core::convert::From<IVpnInterfaceIdFactory> for ::windows::core::IUnknown { fn from(value: IVpnInterfaceIdFactory) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnInterfaceIdFactory> for ::windows::core::IUnknown { fn from(value: &IVpnInterfaceIdFactory) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnInterfaceIdFactory { 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 IVpnInterfaceIdFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnInterfaceIdFactory> for ::windows::core::IInspectable { fn from(value: IVpnInterfaceIdFactory) -> Self { value.0 } } impl ::core::convert::From<&IVpnInterfaceIdFactory> for ::windows::core::IInspectable { fn from(value: &IVpnInterfaceIdFactory) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnInterfaceIdFactory { 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 IVpnInterfaceIdFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnInterfaceIdFactory_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, address_array_size: u32, address: *const u8, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnManagementAgent(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnManagementAgent { type Vtable = IVpnManagementAgent_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x193696cd_a5c4_4abe_852b_785be4cb3e34); } #[repr(C)] #[doc(hidden)] pub struct IVpnManagementAgent_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, xml: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, 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, profile: ::windows::core::RawPtr, 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, xml: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, 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, profile: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, profile: ::windows::core::RawPtr, 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, profile: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, #[cfg(all(feature = "Foundation", feature = "Security_Credentials"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, profile: ::windows::core::RawPtr, passwordcredential: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", feature = "Security_Credentials")))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, profile: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnNamespaceAssignment(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnNamespaceAssignment { type Vtable = IVpnNamespaceAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd7f7db18_307d_4c0e_bd62_8fa270bbadd6); } #[repr(C)] #[doc(hidden)] pub struct IVpnNamespaceAssignment_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, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, #[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnNamespaceInfo(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnNamespaceInfo { type Vtable = IVpnNamespaceInfo_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x30edfb43_444f_44c5_8167_a35a91f1af94); } #[repr(C)] #[doc(hidden)] pub struct IVpnNamespaceInfo_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: ::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, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnNamespaceInfoFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnNamespaceInfoFactory { type Vtable = IVpnNamespaceInfoFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xcb3e951a_b0ce_442b_acbb_5f99b202c31c); } impl IVpnNamespaceInfoFactory { #[cfg(feature = "Foundation_Collections")] pub fn CreateVpnNamespaceInfo<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>>(&self, name: Param0, dnsserverlist: Param1, proxyserverlist: Param2) -> ::windows::core::Result<VpnNamespaceInfo> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), name.into_param().abi(), dnsserverlist.into_param().abi(), proxyserverlist.into_param().abi(), &mut result__).from_abi::<VpnNamespaceInfo>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnNamespaceInfoFactory { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{cb3e951a-b0ce-442b-acbb-5f99b202c31c}"); } impl ::core::convert::From<IVpnNamespaceInfoFactory> for ::windows::core::IUnknown { fn from(value: IVpnNamespaceInfoFactory) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnNamespaceInfoFactory> for ::windows::core::IUnknown { fn from(value: &IVpnNamespaceInfoFactory) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnNamespaceInfoFactory { 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 IVpnNamespaceInfoFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnNamespaceInfoFactory> for ::windows::core::IInspectable { fn from(value: IVpnNamespaceInfoFactory) -> Self { value.0 } } impl ::core::convert::From<&IVpnNamespaceInfoFactory> for ::windows::core::IInspectable { fn from(value: &IVpnNamespaceInfoFactory) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnNamespaceInfoFactory { 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 IVpnNamespaceInfoFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnNamespaceInfoFactory_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, name: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, dnsserverlist: ::windows::core::RawPtr, proxyserverlist: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnNativeProfile(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnNativeProfile { type Vtable = IVpnNativeProfile_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa4aee29e_6417_4333_9842_f0a66db69802); } #[repr(C)] #[doc(hidden)] pub struct IVpnNativeProfile_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, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnRoutingPolicyType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnRoutingPolicyType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnNativeProtocolType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnNativeProtocolType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnAuthenticationMethod) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnAuthenticationMethod) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnAuthenticationMethod) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnAuthenticationMethod) -> ::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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnNativeProfile2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnNativeProfile2 { type Vtable = IVpnNativeProfile2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0fec2467_cdb5_4ac7_b5a3_0afb5ec47682); } #[repr(C)] #[doc(hidden)] pub struct IVpnNativeProfile2_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 VpnManagementConnectionStatus) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPacketBuffer(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBuffer { type Vtable = IVpnPacketBuffer_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc2f891fc_4d5c_4a63_b70d_4e307eacce55); } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBuffer_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 = "Storage_Streams")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Storage_Streams"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnPacketBufferStatus) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnPacketBufferStatus) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: u32) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPacketBuffer2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBuffer2 { type Vtable = IVpnPacketBuffer2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x665e91f0_8805_4bf5_a619_2e84882e6b4f); } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBuffer2_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 IVpnPacketBuffer3(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBuffer3 { type Vtable = IVpnPacketBuffer3_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe256072f_107b_4c40_b127_5bc53e0ad960); } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBuffer3_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: ::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 IVpnPacketBufferFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBufferFactory { type Vtable = IVpnPacketBufferFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e2ddca2_1712_4ce4_b179_8c652c6d9999); } impl IVpnPacketBufferFactory { pub fn CreateVpnPacketBuffer<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(&self, parentbuffer: Param0, offset: u32, length: u32) -> ::windows::core::Result<VpnPacketBuffer> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), parentbuffer.into_param().abi(), offset, length, &mut result__).from_abi::<VpnPacketBuffer>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnPacketBufferFactory { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{9e2ddca2-1712-4ce4-b179-8c652c6d9999}"); } impl ::core::convert::From<IVpnPacketBufferFactory> for ::windows::core::IUnknown { fn from(value: IVpnPacketBufferFactory) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnPacketBufferFactory> for ::windows::core::IUnknown { fn from(value: &IVpnPacketBufferFactory) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnPacketBufferFactory { 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 IVpnPacketBufferFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnPacketBufferFactory> for ::windows::core::IInspectable { fn from(value: IVpnPacketBufferFactory) -> Self { value.0 } } impl ::core::convert::From<&IVpnPacketBufferFactory> for ::windows::core::IInspectable { fn from(value: &IVpnPacketBufferFactory) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnPacketBufferFactory { 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 IVpnPacketBufferFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBufferFactory_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, parentbuffer: ::windows::core::RawPtr, offset: u32, length: u32, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPacketBufferList(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBufferList { type Vtable = IVpnPacketBufferList_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc2f891fc_4d5c_4a63_b70d_4e307eacce77); } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBufferList_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, nextvpnpacketbuffer: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, nextvpnpacketbuffer: ::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) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnPacketBufferStatus) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VpnPacketBufferStatus) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u32) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPacketBufferList2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPacketBufferList2 { type Vtable = IVpnPacketBufferList2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3e7acfe5_ea1e_482a_8d98_c065f57d89ea); } #[repr(C)] #[doc(hidden)] pub struct IVpnPacketBufferList2_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, nextvpnpacketbuffer: ::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, nextvpnpacketbuffer: ::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 IVpnPickedCredential(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPickedCredential { type Vtable = IVpnPickedCredential_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9a793ac7_8854_4e52_ad97_24dd9a842bce); } #[repr(C)] #[doc(hidden)] pub struct IVpnPickedCredential_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 = "Security_Credentials")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Credentials"))] usize, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT, #[cfg(feature = "Security_Credentials")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Security_Credentials"))] usize, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnPlugIn(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPlugIn { type Vtable = IVpnPlugIn_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xceb78d07_d0a8_4703_a091_c8c2c0915bc4); } impl IVpnPlugIn { pub fn Connect<'a, Param0: ::windows::core::IntoParam<'a, VpnChannel>>(&self, channel: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), channel.into_param().abi()).ok() } } pub fn Disconnect<'a, Param0: ::windows::core::IntoParam<'a, VpnChannel>>(&self, channel: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), channel.into_param().abi()).ok() } } pub fn GetKeepAlivePayload<'a, Param0: ::windows::core::IntoParam<'a, VpnChannel>>(&self, channel: Param0, keepalivepacket: &mut ::core::option::Option<VpnPacketBuffer>) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), channel.into_param().abi(), keepalivepacket as *mut _ as _).ok() } } pub fn Encapsulate<'a, Param0: ::windows::core::IntoParam<'a, VpnChannel>, Param1: ::windows::core::IntoParam<'a, VpnPacketBufferList>, Param2: ::windows::core::IntoParam<'a, VpnPacketBufferList>>(&self, channel: Param0, packets: Param1, encapulatedpackets: Param2) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), channel.into_param().abi(), packets.into_param().abi(), encapulatedpackets.into_param().abi()).ok() } } pub fn Decapsulate<'a, Param0: ::windows::core::IntoParam<'a, VpnChannel>, Param1: ::windows::core::IntoParam<'a, VpnPacketBuffer>, Param2: ::windows::core::IntoParam<'a, VpnPacketBufferList>, Param3: ::windows::core::IntoParam<'a, VpnPacketBufferList>>(&self, channel: Param0, encapbuffer: Param1, decapsulatedpackets: Param2, controlpacketstosend: Param3) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), channel.into_param().abi(), encapbuffer.into_param().abi(), decapsulatedpackets.into_param().abi(), controlpacketstosend.into_param().abi()).ok() } } } unsafe impl ::windows::core::RuntimeType for IVpnPlugIn { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{ceb78d07-d0a8-4703-a091-c8c2c0915bc4}"); } impl ::core::convert::From<IVpnPlugIn> for ::windows::core::IUnknown { fn from(value: IVpnPlugIn) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnPlugIn> for ::windows::core::IUnknown { fn from(value: &IVpnPlugIn) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnPlugIn { 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 IVpnPlugIn { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnPlugIn> for ::windows::core::IInspectable { fn from(value: IVpnPlugIn) -> Self { value.0 } } impl ::core::convert::From<&IVpnPlugIn> for ::windows::core::IInspectable { fn from(value: &IVpnPlugIn) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnPlugIn { 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 IVpnPlugIn { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnPlugIn_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, channel: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, channel: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, channel: ::windows::core::RawPtr, keepalivepacket: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, channel: ::windows::core::RawPtr, packets: ::windows::core::RawPtr, encapulatedpackets: ::windows::core::RawPtr) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, channel: ::windows::core::RawPtr, encapbuffer: ::windows::core::RawPtr, decapsulatedpackets: ::windows::core::RawPtr, controlpacketstosend: ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPlugInProfile(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPlugInProfile { type Vtable = IVpnPlugInProfile_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0edf0da4_4f00_4589_8d7b_4bf988f6542c); } #[repr(C)] #[doc(hidden)] pub struct IVpnPlugInProfile_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(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(all(feature = "Foundation", 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, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnPlugInProfile2(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnPlugInProfile2 { type Vtable = IVpnPlugInProfile2_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x611c4892_cf94_4ad6_ba99_00f4ff34565e); } #[repr(C)] #[doc(hidden)] pub struct IVpnPlugInProfile2_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 VpnManagementConnectionStatus) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnProfile(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnProfile { type Vtable = IVpnProfile_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7875b751_b0d7_43db_8a93_d3fe2479e56a); } impl IVpnProfile { pub fn ProfileName(&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 SetProfileName<'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 = "Foundation_Collections")] pub fn AppTriggers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnAppId>> { 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::super::Foundation::Collections::IVector<VpnAppId>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn Routes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { 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::<super::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn DomainNameInfoList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnDomainNameInfo>> { 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::Foundation::Collections::IVector<VpnDomainNameInfo>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn TrafficFilters(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnTrafficFilter>> { 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::<super::super::Foundation::Collections::IVector<VpnTrafficFilter>>(result__) } } pub fn RememberCredentials(&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 SetRememberCredentials(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() } } pub fn AlwaysOn(&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 SetAlwaysOn(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() } } } unsafe impl ::windows::core::RuntimeType for IVpnProfile { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{7875b751-b0d7-43db-8a93-d3fe2479e56a}"); } impl ::core::convert::From<IVpnProfile> for ::windows::core::IUnknown { fn from(value: IVpnProfile) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnProfile> for ::windows::core::IUnknown { fn from(value: &IVpnProfile) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnProfile { 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 IVpnProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnProfile> for ::windows::core::IInspectable { fn from(value: IVpnProfile) -> Self { value.0 } } impl ::core::convert::From<&IVpnProfile> for ::windows::core::IInspectable { fn from(value: &IVpnProfile) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnProfile { 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 IVpnProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnProfile_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 = "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, #[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, #[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, #[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 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 bool) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnRoute(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnRoute { type Vtable = IVpnRoute_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb5731b83_0969_4699_938e_7776db29cfb3); } #[repr(C)] #[doc(hidden)] pub struct IVpnRoute_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: ::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: u8) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut u8) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnRouteAssignment(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnRouteAssignment { type Vtable = IVpnRouteAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdb64de22_ce39_4a76_9550_f61039f80e48); } #[repr(C)] #[doc(hidden)] pub struct IVpnRouteAssignment_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, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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, #[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, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] usize, #[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Foundation_Collections"))] 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, #[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, value: bool) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct IVpnRouteFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnRouteFactory { type Vtable = IVpnRouteFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xbdeab5ff_45cf_4b99_83fb_db3bc2672b02); } impl IVpnRouteFactory { pub fn CreateVpnRoute<'a, Param0: ::windows::core::IntoParam<'a, super::HostName>>(&self, address: Param0, prefixsize: u8) -> ::windows::core::Result<VpnRoute> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), address.into_param().abi(), prefixsize, &mut result__).from_abi::<VpnRoute>(result__) } } } unsafe impl ::windows::core::RuntimeType for IVpnRouteFactory { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"{bdeab5ff-45cf-4b99-83fb-db3bc2672b02}"); } impl ::core::convert::From<IVpnRouteFactory> for ::windows::core::IUnknown { fn from(value: IVpnRouteFactory) -> Self { value.0 .0 } } impl ::core::convert::From<&IVpnRouteFactory> for ::windows::core::IUnknown { fn from(value: &IVpnRouteFactory) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for IVpnRouteFactory { 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 IVpnRouteFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<IVpnRouteFactory> for ::windows::core::IInspectable { fn from(value: IVpnRouteFactory) -> Self { value.0 } } impl ::core::convert::From<&IVpnRouteFactory> for ::windows::core::IInspectable { fn from(value: &IVpnRouteFactory) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for IVpnRouteFactory { 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 IVpnRouteFactory { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[repr(C)] #[doc(hidden)] pub struct IVpnRouteFactory_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, address: ::windows::core::RawPtr, prefixsize: u8, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnSystemHealth(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnSystemHealth { type Vtable = IVpnSystemHealth_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x99a8f8af_c0ee_4e75_817a_f231aee5123d); } #[repr(C)] #[doc(hidden)] pub struct IVpnSystemHealth_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 = "Storage_Streams")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT, #[cfg(not(feature = "Storage_Streams"))] usize, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnTrafficFilter(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnTrafficFilter { type Vtable = IVpnTrafficFilter_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2f691b60_6c9f_47f5_ac36_bb1b042e2c50); } #[repr(C)] #[doc(hidden)] pub struct IVpnTrafficFilter_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_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 VpnIPProtocol) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnIPProtocol) -> ::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, #[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, #[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, #[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 VpnRoutingPolicyType) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VpnRoutingPolicyType) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnTrafficFilterAssignment(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnTrafficFilterAssignment { type Vtable = IVpnTrafficFilterAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x56ccd45c_e664_471e_89cd_601603b9e0f3); } #[repr(C)] #[doc(hidden)] pub struct IVpnTrafficFilterAssignment_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, 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 bool) -> ::windows::core::HRESULT, pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT, ); #[repr(transparent)] #[doc(hidden)] pub struct IVpnTrafficFilterFactory(pub ::windows::core::IInspectable); unsafe impl ::windows::core::Interface for IVpnTrafficFilterFactory { type Vtable = IVpnTrafficFilterFactory_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x480d41d5_7f99_474c_86ee_96df168318f1); } #[repr(C)] #[doc(hidden)] pub struct IVpnTrafficFilterFactory_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, appid: ::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 VpnAppId(pub ::windows::core::IInspectable); impl VpnAppId { pub fn Type(&self) -> ::windows::core::Result<VpnAppIdType> { let this = self; unsafe { let mut result__: VpnAppIdType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnAppIdType>(result__) } } pub fn SetType(&self, value: VpnAppIdType) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() } } pub fn Value(&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).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetValue<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&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 Create<'a, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(r#type: VpnAppIdType, value: Param1) -> ::windows::core::Result<VpnAppId> { Self::IVpnAppIdFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), r#type, value.into_param().abi(), &mut result__).from_abi::<VpnAppId>(result__) }) } pub fn IVpnAppIdFactory<R, F: FnOnce(&IVpnAppIdFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnAppId, IVpnAppIdFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnAppId { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnAppId;{7b06a635-5c58-41d9-94a7-bfbcf1d8ca54})"); } unsafe impl ::windows::core::Interface for VpnAppId { type Vtable = IVpnAppId_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7b06a635_5c58_41d9_94a7_bfbcf1d8ca54); } impl ::windows::core::RuntimeName for VpnAppId { const NAME: &'static str = "Windows.Networking.Vpn.VpnAppId"; } impl ::core::convert::From<VpnAppId> for ::windows::core::IUnknown { fn from(value: VpnAppId) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnAppId> for ::windows::core::IUnknown { fn from(value: &VpnAppId) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnAppId { 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 VpnAppId { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnAppId> for ::windows::core::IInspectable { fn from(value: VpnAppId) -> Self { value.0 } } impl ::core::convert::From<&VpnAppId> for ::windows::core::IInspectable { fn from(value: &VpnAppId) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnAppId { 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 VpnAppId { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnAppId {} unsafe impl ::core::marker::Sync for VpnAppId {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnAppIdType(pub i32); impl VpnAppIdType { pub const PackageFamilyName: VpnAppIdType = VpnAppIdType(0i32); pub const FullyQualifiedBinaryName: VpnAppIdType = VpnAppIdType(1i32); pub const FilePath: VpnAppIdType = VpnAppIdType(2i32); } impl ::core::convert::From<i32> for VpnAppIdType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnAppIdType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnAppIdType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnAppIdType;i4)"); } impl ::windows::core::DefaultType for VpnAppIdType { 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 VpnAuthenticationMethod(pub i32); impl VpnAuthenticationMethod { pub const Mschapv2: VpnAuthenticationMethod = VpnAuthenticationMethod(0i32); pub const Eap: VpnAuthenticationMethod = VpnAuthenticationMethod(1i32); pub const Certificate: VpnAuthenticationMethod = VpnAuthenticationMethod(2i32); pub const PresharedKey: VpnAuthenticationMethod = VpnAuthenticationMethod(3i32); } impl ::core::convert::From<i32> for VpnAuthenticationMethod { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnAuthenticationMethod { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnAuthenticationMethod { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnAuthenticationMethod;i4)"); } impl ::windows::core::DefaultType for VpnAuthenticationMethod { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnChannel(pub ::windows::core::IInspectable); impl VpnChannel { pub fn AssociateTransport<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, mainoutertunneltransport: Param0, optionaloutertunneltransport: Param1) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), mainoutertunneltransport.into_param().abi(), optionaloutertunneltransport.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn Start< 'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param2: ::windows::core::IntoParam<'a, VpnInterfaceId>, Param3: ::windows::core::IntoParam<'a, VpnRouteAssignment>, Param4: ::windows::core::IntoParam<'a, VpnNamespaceAssignment>, Param8: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param9: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, >( &self, assignedclientipv4list: Param0, assignedclientipv6list: Param1, vpninterfaceid: Param2, routescope: Param3, namespacescope: Param4, mtusize: u32, maxframesize: u32, optimizeforlowcostnetwork: bool, mainoutertunneltransport: Param8, optionaloutertunneltransport: Param9, ) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).7)( ::core::mem::transmute_copy(this), assignedclientipv4list.into_param().abi(), assignedclientipv6list.into_param().abi(), vpninterfaceid.into_param().abi(), routescope.into_param().abi(), namespacescope.into_param().abi(), mtusize, maxframesize, optimizeforlowcostnetwork, mainoutertunneltransport.into_param().abi(), optionaloutertunneltransport.into_param().abi(), ) .ok() } } pub fn Stop(&self) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this)).ok() } } #[cfg(feature = "Security_Cryptography_Certificates")] pub fn RequestCredentials<'a, Param3: ::windows::core::IntoParam<'a, super::super::Security::Cryptography::Certificates::Certificate>>(&self, credtype: VpnCredentialType, isretry: bool, issinglesignoncredential: bool, certificate: Param3) -> ::windows::core::Result<VpnPickedCredential> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), credtype, isretry, issinglesignoncredential, certificate.into_param().abi(), &mut result__).from_abi::<VpnPickedCredential>(result__) } } pub fn RequestVpnPacketBuffer(&self, r#type: VpnDataPathType, vpnpacketbuffer: &mut ::core::option::Option<VpnPacketBuffer>) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), r#type, vpnpacketbuffer as *mut _ as _).ok() } } pub fn LogDiagnosticMessage<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, message: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), message.into_param().abi()).ok() } } pub fn Id(&self) -> ::windows::core::Result<u32> { let this = self; unsafe { let mut result__: u32 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__) } } pub fn Configuration(&self) -> ::windows::core::Result<VpnChannelConfiguration> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnChannelConfiguration>(result__) } } #[cfg(feature = "Foundation")] pub fn ActivityChange<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VpnChannel, VpnChannelActivityEventArgs>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::Foundation::EventRegistrationToken> { let this = self; unsafe { let mut result__: 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::Foundation::EventRegistrationToken>(result__) } } #[cfg(feature = "Foundation")] pub fn RemoveActivityChange<'a, Param0: ::windows::core::IntoParam<'a, 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 SetPlugInContext<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&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() } } pub fn PlugInContext(&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).17)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::IInspectable>(result__) } } pub fn SystemHealth(&self) -> ::windows::core::Result<VpnSystemHealth> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnSystemHealth>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn RequestCustomPrompt<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<IVpnCustomPrompt>>>(&self, customprompt: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).19)(::core::mem::transmute_copy(this), customprompt.into_param().abi()).ok() } } pub fn SetErrorMessage<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, message: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), message.into_param().abi()).ok() } } pub fn SetAllowedSslTlsVersions<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, tunneltransport: Param0, usetls12: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this), tunneltransport.into_param().abi(), usetls12).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn StartWithMainTransport< 'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param2: ::windows::core::IntoParam<'a, VpnInterfaceId>, Param3: ::windows::core::IntoParam<'a, VpnRouteAssignment>, Param4: ::windows::core::IntoParam<'a, VpnDomainNameAssignment>, Param8: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, >( &self, assignedclientipv4list: Param0, assignedclientipv6list: Param1, vpninterfaceid: Param2, assignedroutes: Param3, assigneddomainname: Param4, mtusize: u32, maxframesize: u32, reserved: bool, mainoutertunneltransport: Param8, ) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)( ::core::mem::transmute_copy(this), assignedclientipv4list.into_param().abi(), assignedclientipv6list.into_param().abi(), vpninterfaceid.into_param().abi(), assignedroutes.into_param().abi(), assigneddomainname.into_param().abi(), mtusize, maxframesize, reserved, mainoutertunneltransport.into_param().abi(), ) .ok() } } #[cfg(feature = "Foundation_Collections")] pub fn StartExistingTransports<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param2: ::windows::core::IntoParam<'a, VpnInterfaceId>, Param3: ::windows::core::IntoParam<'a, VpnRouteAssignment>, Param4: ::windows::core::IntoParam<'a, VpnDomainNameAssignment>>( &self, assignedclientipv4list: Param0, assignedclientipv6list: Param1, vpninterfaceid: Param2, assignedroutes: Param3, assigneddomainname: Param4, mtusize: u32, maxframesize: u32, reserved: bool, ) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), assignedclientipv4list.into_param().abi(), assignedclientipv6list.into_param().abi(), vpninterfaceid.into_param().abi(), assignedroutes.into_param().abi(), assigneddomainname.into_param().abi(), mtusize, maxframesize, reserved).ok() } } #[cfg(feature = "Foundation")] pub fn ActivityStateChange<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VpnChannel, VpnChannelActivityStateChangedArgs>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::Foundation::EventRegistrationToken> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { let mut result__: 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::Foundation::EventRegistrationToken>(result__) } } #[cfg(feature = "Foundation")] pub fn RemoveActivityStateChange<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() } } pub fn GetVpnSendPacketBuffer(&self) -> ::windows::core::Result<VpnPacketBuffer> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(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::<VpnPacketBuffer>(result__) } } pub fn GetVpnReceivePacketBuffer(&self) -> ::windows::core::Result<VpnPacketBuffer> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(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::<VpnPacketBuffer>(result__) } } #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub fn RequestCustomPromptAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<IVpnCustomPromptElement>>>(&self, custompromptelement: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), custompromptelement.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__) } } #[cfg(all(feature = "Foundation", feature = "Security_Cryptography_Certificates"))] pub fn RequestCredentialsWithCertificateAsync<'a, Param2: ::windows::core::IntoParam<'a, super::super::Security::Cryptography::Certificates::Certificate>>(&self, credtype: VpnCredentialType, credoptions: u32, certificate: Param2) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnCredential>> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), credtype, credoptions, certificate.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnCredential>>(result__) } } #[cfg(feature = "Foundation")] pub fn RequestCredentialsWithOptionsAsync(&self, credtype: VpnCredentialType, credoptions: u32) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnCredential>> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), credtype, credoptions, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnCredential>>(result__) } } #[cfg(feature = "Foundation")] pub fn RequestCredentialsSimpleAsync(&self, credtype: VpnCredentialType) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnCredential>> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), credtype, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnCredential>>(result__) } } pub fn TerminateConnection<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, message: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), message.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn StartWithTrafficFilter< 'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<super::HostName>>, Param2: ::windows::core::IntoParam<'a, VpnInterfaceId>, Param3: ::windows::core::IntoParam<'a, VpnRouteAssignment>, Param4: ::windows::core::IntoParam<'a, VpnDomainNameAssignment>, Param8: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param9: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param10: ::windows::core::IntoParam<'a, VpnTrafficFilterAssignment>, >( &self, assignedclientipv4list: Param0, assignedclientipv6list: Param1, vpninterfaceid: Param2, assignedroutes: Param3, assignednamespace: Param4, mtusize: u32, maxframesize: u32, reserved: bool, mainoutertunneltransport: Param8, optionaloutertunneltransport: Param9, assignedtrafficfilters: Param10, ) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel2>(self)?; unsafe { (::windows::core::Interface::vtable(this).17)( ::core::mem::transmute_copy(this), assignedclientipv4list.into_param().abi(), assignedclientipv6list.into_param().abi(), vpninterfaceid.into_param().abi(), assignedroutes.into_param().abi(), assignednamespace.into_param().abi(), mtusize, maxframesize, reserved, mainoutertunneltransport.into_param().abi(), optionaloutertunneltransport.into_param().abi(), assignedtrafficfilters.into_param().abi(), ) .ok() } } pub fn ProcessEventAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(thirdpartyplugin: Param0, event: Param1) -> ::windows::core::Result<()> { Self::IVpnChannelStatics(|this| unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), thirdpartyplugin.into_param().abi(), event.into_param().abi()).ok() }) } pub fn AddAndAssociateTransport<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, transport: Param0, context: Param1) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), transport.into_param().abi(), context.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn StartWithMultipleTransports< 'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>, Param2: ::windows::core::IntoParam<'a, VpnInterfaceId>, Param3: ::windows::core::IntoParam<'a, VpnRouteAssignment>, Param4: ::windows::core::IntoParam<'a, VpnDomainNameAssignment>, Param8: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<::windows::core::IInspectable>>, Param9: ::windows::core::IntoParam<'a, VpnTrafficFilterAssignment>, >( &self, assignedclientipv4addresses: Param0, assignedclientipv6addresses: Param1, vpninterfaceid: Param2, assignedroutes: Param3, assignednamespace: Param4, mtusize: u32, maxframesize: u32, reserved: bool, transports: Param8, assignedtrafficfilters: Param9, ) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)( ::core::mem::transmute_copy(this), assignedclientipv4addresses.into_param().abi(), assignedclientipv6addresses.into_param().abi(), vpninterfaceid.into_param().abi(), assignedroutes.into_param().abi(), assignednamespace.into_param().abi(), mtusize, maxframesize, reserved, transports.into_param().abi(), assignedtrafficfilters.into_param().abi(), ) .ok() } } pub fn ReplaceAndAssociateTransport<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, transport: Param0, context: Param1) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), transport.into_param().abi(), context.into_param().abi()).ok() } } pub fn StartReconnectingTransport<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>, Param1: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, transport: Param0, context: Param1) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(self)?; unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), transport.into_param().abi(), context.into_param().abi()).ok() } } #[cfg(feature = "Networking_Sockets")] pub fn GetSlotTypeForTransportContext<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, context: Param0) -> ::windows::core::Result<super::Sockets::ControlChannelTriggerStatus> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(self)?; unsafe { let mut result__: super::Sockets::ControlChannelTriggerStatus = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), context.into_param().abi(), &mut result__).from_abi::<super::Sockets::ControlChannelTriggerStatus>(result__) } } pub fn CurrentRequestTransportContext(&self) -> ::windows::core::Result<::windows::core::IInspectable> { let this = &::windows::core::Interface::cast::<IVpnChannel4>(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::<::windows::core::IInspectable>(result__) } } pub fn AppendVpnReceivePacketBuffer<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(&self, decapsulatedpacketbuffer: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel5>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), decapsulatedpacketbuffer.into_param().abi()).ok() } } pub fn AppendVpnSendPacketBuffer<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(&self, encapsulatedpacketbuffer: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel5>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), encapsulatedpacketbuffer.into_param().abi()).ok() } } pub fn FlushVpnReceivePacketBuffers(&self) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel5>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this)).ok() } } pub fn FlushVpnSendPacketBuffers(&self) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnChannel5>(self)?; unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this)).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn ActivateForeground<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::ValueSet>>(&self, packagerelativeappid: Param0, sharedcontext: Param1) -> ::windows::core::Result<super::super::Foundation::Collections::ValueSet> { let this = &::windows::core::Interface::cast::<IVpnChannel6>(self)?; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), packagerelativeappid.into_param().abi(), sharedcontext.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::Collections::ValueSet>(result__) } } pub fn IVpnChannelStatics<R, F: FnOnce(&IVpnChannelStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnChannel, IVpnChannelStatics> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnChannel { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnChannel;{4ac78d07-d1a8-4303-a091-c8d2e0915bc3})"); } unsafe impl ::windows::core::Interface for VpnChannel { type Vtable = IVpnChannel_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4ac78d07_d1a8_4303_a091_c8d2e0915bc3); } impl ::windows::core::RuntimeName for VpnChannel { const NAME: &'static str = "Windows.Networking.Vpn.VpnChannel"; } impl ::core::convert::From<VpnChannel> for ::windows::core::IUnknown { fn from(value: VpnChannel) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnChannel> for ::windows::core::IUnknown { fn from(value: &VpnChannel) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnChannel { 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 VpnChannel { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnChannel> for ::windows::core::IInspectable { fn from(value: VpnChannel) -> Self { value.0 } } impl ::core::convert::From<&VpnChannel> for ::windows::core::IInspectable { fn from(value: &VpnChannel) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnChannel { 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 VpnChannel { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnChannel {} unsafe impl ::core::marker::Sync for VpnChannel {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnChannelActivityEventArgs(pub ::windows::core::IInspectable); impl VpnChannelActivityEventArgs { pub fn Type(&self) -> ::windows::core::Result<VpnChannelActivityEventType> { let this = self; unsafe { let mut result__: VpnChannelActivityEventType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnChannelActivityEventType>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnChannelActivityEventArgs { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnChannelActivityEventArgs;{a36c88f2-afdc-4775-855d-d4ac0a35fc55})"); } unsafe impl ::windows::core::Interface for VpnChannelActivityEventArgs { type Vtable = IVpnChannelActivityEventArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa36c88f2_afdc_4775_855d_d4ac0a35fc55); } impl ::windows::core::RuntimeName for VpnChannelActivityEventArgs { const NAME: &'static str = "Windows.Networking.Vpn.VpnChannelActivityEventArgs"; } impl ::core::convert::From<VpnChannelActivityEventArgs> for ::windows::core::IUnknown { fn from(value: VpnChannelActivityEventArgs) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnChannelActivityEventArgs> for ::windows::core::IUnknown { fn from(value: &VpnChannelActivityEventArgs) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnChannelActivityEventArgs { 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 VpnChannelActivityEventArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnChannelActivityEventArgs> for ::windows::core::IInspectable { fn from(value: VpnChannelActivityEventArgs) -> Self { value.0 } } impl ::core::convert::From<&VpnChannelActivityEventArgs> for ::windows::core::IInspectable { fn from(value: &VpnChannelActivityEventArgs) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnChannelActivityEventArgs { 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 VpnChannelActivityEventArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnChannelActivityEventArgs {} unsafe impl ::core::marker::Sync for VpnChannelActivityEventArgs {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnChannelActivityEventType(pub i32); impl VpnChannelActivityEventType { pub const Idle: VpnChannelActivityEventType = VpnChannelActivityEventType(0i32); pub const Active: VpnChannelActivityEventType = VpnChannelActivityEventType(1i32); } impl ::core::convert::From<i32> for VpnChannelActivityEventType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnChannelActivityEventType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnChannelActivityEventType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnChannelActivityEventType;i4)"); } impl ::windows::core::DefaultType for VpnChannelActivityEventType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnChannelActivityStateChangedArgs(pub ::windows::core::IInspectable); impl VpnChannelActivityStateChangedArgs { pub fn ActivityState(&self) -> ::windows::core::Result<VpnChannelActivityEventType> { let this = self; unsafe { let mut result__: VpnChannelActivityEventType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnChannelActivityEventType>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnChannelActivityStateChangedArgs { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnChannelActivityStateChangedArgs;{3d750565-fdc0-4bbe-a23b-45fffc6d97a1})"); } unsafe impl ::windows::core::Interface for VpnChannelActivityStateChangedArgs { type Vtable = IVpnChannelActivityStateChangedArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3d750565_fdc0_4bbe_a23b_45fffc6d97a1); } impl ::windows::core::RuntimeName for VpnChannelActivityStateChangedArgs { const NAME: &'static str = "Windows.Networking.Vpn.VpnChannelActivityStateChangedArgs"; } impl ::core::convert::From<VpnChannelActivityStateChangedArgs> for ::windows::core::IUnknown { fn from(value: VpnChannelActivityStateChangedArgs) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnChannelActivityStateChangedArgs> for ::windows::core::IUnknown { fn from(value: &VpnChannelActivityStateChangedArgs) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnChannelActivityStateChangedArgs { 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 VpnChannelActivityStateChangedArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnChannelActivityStateChangedArgs> for ::windows::core::IInspectable { fn from(value: VpnChannelActivityStateChangedArgs) -> Self { value.0 } } impl ::core::convert::From<&VpnChannelActivityStateChangedArgs> for ::windows::core::IInspectable { fn from(value: &VpnChannelActivityStateChangedArgs) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnChannelActivityStateChangedArgs { 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 VpnChannelActivityStateChangedArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnChannelActivityStateChangedArgs {} unsafe impl ::core::marker::Sync for VpnChannelActivityStateChangedArgs {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnChannelConfiguration(pub ::windows::core::IInspectable); impl VpnChannelConfiguration { pub fn ServerServiceName(&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__) } } #[cfg(feature = "Foundation_Collections")] pub fn ServerHostNameList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<super::HostName>> { 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::super::Foundation::Collections::IVectorView<super::HostName>>(result__) } } pub fn CustomField(&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).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub fn ServerUris(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<super::super::Foundation::Uri>> { let this = &::windows::core::Interface::cast::<IVpnChannelConfiguration2>(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::Foundation::Collections::IVectorView<super::super::Foundation::Uri>>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnChannelConfiguration { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnChannelConfiguration;{0e2ddca2-2012-4fe4-b179-8c652c6d107e})"); } unsafe impl ::windows::core::Interface for VpnChannelConfiguration { type Vtable = IVpnChannelConfiguration_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0e2ddca2_2012_4fe4_b179_8c652c6d107e); } impl ::windows::core::RuntimeName for VpnChannelConfiguration { const NAME: &'static str = "Windows.Networking.Vpn.VpnChannelConfiguration"; } impl ::core::convert::From<VpnChannelConfiguration> for ::windows::core::IUnknown { fn from(value: VpnChannelConfiguration) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnChannelConfiguration> for ::windows::core::IUnknown { fn from(value: &VpnChannelConfiguration) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnChannelConfiguration { 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 VpnChannelConfiguration { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnChannelConfiguration> for ::windows::core::IInspectable { fn from(value: VpnChannelConfiguration) -> Self { value.0 } } impl ::core::convert::From<&VpnChannelConfiguration> for ::windows::core::IInspectable { fn from(value: &VpnChannelConfiguration) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnChannelConfiguration { 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 VpnChannelConfiguration { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnChannelConfiguration {} unsafe impl ::core::marker::Sync for VpnChannelConfiguration {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnChannelRequestCredentialsOptions(pub u32); impl VpnChannelRequestCredentialsOptions { pub const None: VpnChannelRequestCredentialsOptions = VpnChannelRequestCredentialsOptions(0u32); pub const Retrying: VpnChannelRequestCredentialsOptions = VpnChannelRequestCredentialsOptions(1u32); pub const UseForSingleSignIn: VpnChannelRequestCredentialsOptions = VpnChannelRequestCredentialsOptions(2u32); } impl ::core::convert::From<u32> for VpnChannelRequestCredentialsOptions { fn from(value: u32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnChannelRequestCredentialsOptions { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnChannelRequestCredentialsOptions { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnChannelRequestCredentialsOptions;u4)"); } impl ::windows::core::DefaultType for VpnChannelRequestCredentialsOptions { type DefaultType = Self; } impl ::core::ops::BitOr for VpnChannelRequestCredentialsOptions { type Output = Self; fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } } impl ::core::ops::BitAnd for VpnChannelRequestCredentialsOptions { type Output = Self; fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } } impl ::core::ops::BitOrAssign for VpnChannelRequestCredentialsOptions { fn bitor_assign(&mut self, rhs: Self) { self.0.bitor_assign(rhs.0) } } impl ::core::ops::BitAndAssign for VpnChannelRequestCredentialsOptions { fn bitand_assign(&mut self, rhs: Self) { self.0.bitand_assign(rhs.0) } } impl ::core::ops::Not for VpnChannelRequestCredentialsOptions { 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 VpnCredential(pub ::windows::core::IInspectable); impl VpnCredential { #[cfg(feature = "Security_Credentials")] pub fn PasskeyCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::Security::Credentials::PasswordCredential>(result__) } } #[cfg(feature = "Security_Cryptography_Certificates")] pub fn CertificateCredential(&self) -> ::windows::core::Result<super::super::Security::Cryptography::Certificates::Certificate> { 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::super::Security::Cryptography::Certificates::Certificate>(result__) } } pub fn AdditionalPin(&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).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } #[cfg(feature = "Security_Credentials")] pub fn OldPasswordCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::<super::super::Security::Credentials::PasswordCredential>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnCredential { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCredential;{b7e78af3-a46d-404b-8729-1832522853ac})"); } unsafe impl ::windows::core::Interface for VpnCredential { type Vtable = IVpnCredential_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb7e78af3_a46d_404b_8729_1832522853ac); } impl ::windows::core::RuntimeName for VpnCredential { const NAME: &'static str = "Windows.Networking.Vpn.VpnCredential"; } impl ::core::convert::From<VpnCredential> for ::windows::core::IUnknown { fn from(value: VpnCredential) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCredential> for ::windows::core::IUnknown { fn from(value: &VpnCredential) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCredential { 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 VpnCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCredential> for ::windows::core::IInspectable { fn from(value: VpnCredential) -> Self { value.0 } } impl ::core::convert::From<&VpnCredential> for ::windows::core::IInspectable { fn from(value: &VpnCredential) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCredential { 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 VpnCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::From<VpnCredential> for IVpnCredential { fn from(value: VpnCredential) -> Self { unsafe { ::core::mem::transmute(value) } } } impl ::core::convert::From<&VpnCredential> for IVpnCredential { fn from(value: &VpnCredential) -> Self { ::core::convert::From::from(::core::clone::Clone::clone(value)) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCredential> for VpnCredential { fn into_param(self) -> ::windows::core::Param<'a, IVpnCredential> { ::windows::core::Param::Owned(unsafe { ::core::mem::transmute(self) }) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCredential> for &VpnCredential { fn into_param(self) -> ::windows::core::Param<'a, IVpnCredential> { ::windows::core::Param::Borrowed(unsafe { ::core::mem::transmute(self) }) } } unsafe impl ::core::marker::Send for VpnCredential {} unsafe impl ::core::marker::Sync for VpnCredential {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnCredentialType(pub i32); impl VpnCredentialType { pub const UsernamePassword: VpnCredentialType = VpnCredentialType(0i32); pub const UsernameOtpPin: VpnCredentialType = VpnCredentialType(1i32); pub const UsernamePasswordAndPin: VpnCredentialType = VpnCredentialType(2i32); pub const UsernamePasswordChange: VpnCredentialType = VpnCredentialType(3i32); pub const SmartCard: VpnCredentialType = VpnCredentialType(4i32); pub const ProtectedCertificate: VpnCredentialType = VpnCredentialType(5i32); pub const UnProtectedCertificate: VpnCredentialType = VpnCredentialType(6i32); } impl ::core::convert::From<i32> for VpnCredentialType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnCredentialType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnCredentialType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnCredentialType;i4)"); } impl ::windows::core::DefaultType for VpnCredentialType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomCheckBox(pub ::windows::core::IInspectable); impl VpnCustomCheckBox { 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<VpnCustomCheckBox, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetInitialCheckState(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value).ok() } } pub fn InitialCheckState(&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 Checked(&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 SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomCheckBox { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomCheckBox;{43878753-03c5-4e61-93d7-a957714c4282})"); } unsafe impl ::windows::core::Interface for VpnCustomCheckBox { type Vtable = IVpnCustomCheckBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x43878753_03c5_4e61_93d7_a957714c4282); } impl ::windows::core::RuntimeName for VpnCustomCheckBox { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomCheckBox"; } impl ::core::convert::From<VpnCustomCheckBox> for ::windows::core::IUnknown { fn from(value: VpnCustomCheckBox) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomCheckBox> for ::windows::core::IUnknown { fn from(value: &VpnCustomCheckBox) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomCheckBox { 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 VpnCustomCheckBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomCheckBox> for ::windows::core::IInspectable { fn from(value: VpnCustomCheckBox) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomCheckBox> for ::windows::core::IInspectable { fn from(value: &VpnCustomCheckBox) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomCheckBox { 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 VpnCustomCheckBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomCheckBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: VpnCustomCheckBox) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomCheckBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomCheckBox) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for VpnCustomCheckBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for &VpnCustomCheckBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::core::convert::TryInto::<IVpnCustomPrompt>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomCheckBox {} unsafe impl ::core::marker::Sync for VpnCustomCheckBox {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomComboBox(pub ::windows::core::IInspectable); impl VpnCustomComboBox { 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<VpnCustomComboBox, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn SetOptionsText<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVectorView<::windows::core::HSTRING>>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn OptionsText(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<::windows::core::HSTRING>> { 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::super::Foundation::Collections::IVectorView<::windows::core::HSTRING>>(result__) } } pub fn Selected(&self) -> ::windows::core::Result<u32> { let this = self; unsafe { let mut result__: u32 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__) } } pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomComboBox { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomComboBox;{9a24158e-dba1-4c6f-8270-dcf3c9761c4c})"); } unsafe impl ::windows::core::Interface for VpnCustomComboBox { type Vtable = IVpnCustomComboBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9a24158e_dba1_4c6f_8270_dcf3c9761c4c); } impl ::windows::core::RuntimeName for VpnCustomComboBox { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomComboBox"; } impl ::core::convert::From<VpnCustomComboBox> for ::windows::core::IUnknown { fn from(value: VpnCustomComboBox) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomComboBox> for ::windows::core::IUnknown { fn from(value: &VpnCustomComboBox) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomComboBox { 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 VpnCustomComboBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomComboBox> for ::windows::core::IInspectable { fn from(value: VpnCustomComboBox) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomComboBox> for ::windows::core::IInspectable { fn from(value: &VpnCustomComboBox) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomComboBox { 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 VpnCustomComboBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomComboBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: VpnCustomComboBox) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomComboBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomComboBox) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for VpnCustomComboBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for &VpnCustomComboBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::core::convert::TryInto::<IVpnCustomPrompt>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomComboBox {} unsafe impl ::core::marker::Sync for VpnCustomComboBox {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomEditBox(pub ::windows::core::IInspectable); impl VpnCustomEditBox { 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<VpnCustomEditBox, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetDefaultText<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DefaultText(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetNoEcho(&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 NoEcho(&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__) } } pub fn Text(&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).10)(::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 = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomEditBox { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomEditBox;{3002d9a0-cfbf-4c0b-8f3c-66f503c20b39})"); } unsafe impl ::windows::core::Interface for VpnCustomEditBox { type Vtable = IVpnCustomEditBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3002d9a0_cfbf_4c0b_8f3c_66f503c20b39); } impl ::windows::core::RuntimeName for VpnCustomEditBox { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomEditBox"; } impl ::core::convert::From<VpnCustomEditBox> for ::windows::core::IUnknown { fn from(value: VpnCustomEditBox) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomEditBox> for ::windows::core::IUnknown { fn from(value: &VpnCustomEditBox) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomEditBox { 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 VpnCustomEditBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomEditBox> for ::windows::core::IInspectable { fn from(value: VpnCustomEditBox) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomEditBox> for ::windows::core::IInspectable { fn from(value: &VpnCustomEditBox) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomEditBox { 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 VpnCustomEditBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomEditBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: VpnCustomEditBox) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomEditBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomEditBox) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for VpnCustomEditBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for &VpnCustomEditBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::core::convert::TryInto::<IVpnCustomPrompt>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomEditBox {} unsafe impl ::core::marker::Sync for VpnCustomEditBox {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomErrorBox(pub ::windows::core::IInspectable); impl VpnCustomErrorBox { 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<VpnCustomErrorBox, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetLabel<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomErrorBox { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomErrorBox;{9ec4efb2-c942-42af-b223-588b48328721})"); } unsafe impl ::windows::core::Interface for VpnCustomErrorBox { type Vtable = IVpnCustomErrorBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9ec4efb2_c942_42af_b223_588b48328721); } impl ::windows::core::RuntimeName for VpnCustomErrorBox { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomErrorBox"; } impl ::core::convert::From<VpnCustomErrorBox> for ::windows::core::IUnknown { fn from(value: VpnCustomErrorBox) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomErrorBox> for ::windows::core::IUnknown { fn from(value: &VpnCustomErrorBox) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomErrorBox { 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 VpnCustomErrorBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomErrorBox> for ::windows::core::IInspectable { fn from(value: VpnCustomErrorBox) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomErrorBox> for ::windows::core::IInspectable { fn from(value: &VpnCustomErrorBox) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomErrorBox { 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 VpnCustomErrorBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomErrorBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: VpnCustomErrorBox) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomErrorBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomErrorBox) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for VpnCustomErrorBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for &VpnCustomErrorBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::core::convert::TryInto::<IVpnCustomPrompt>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomErrorBox {} unsafe impl ::core::marker::Sync for VpnCustomErrorBox {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomPromptBooleanInput(pub ::windows::core::IInspectable); impl VpnCustomPromptBooleanInput { 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<VpnCustomPromptBooleanInput, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetInitialValue(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value).ok() } } pub fn InitialValue(&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 Value(&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 SetDisplayName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } pub fn SetEmphasized(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Emphasized(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomPromptBooleanInput { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomPromptBooleanInput;{c4c9a69e-ff47-4527-9f27-a49292019979})"); } unsafe impl ::windows::core::Interface for VpnCustomPromptBooleanInput { type Vtable = IVpnCustomPromptBooleanInput_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc4c9a69e_ff47_4527_9f27_a49292019979); } impl ::windows::core::RuntimeName for VpnCustomPromptBooleanInput { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomPromptBooleanInput"; } impl ::core::convert::From<VpnCustomPromptBooleanInput> for ::windows::core::IUnknown { fn from(value: VpnCustomPromptBooleanInput) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomPromptBooleanInput> for ::windows::core::IUnknown { fn from(value: &VpnCustomPromptBooleanInput) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomPromptBooleanInput { 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 VpnCustomPromptBooleanInput { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomPromptBooleanInput> for ::windows::core::IInspectable { fn from(value: VpnCustomPromptBooleanInput) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomPromptBooleanInput> for ::windows::core::IInspectable { fn from(value: &VpnCustomPromptBooleanInput) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomPromptBooleanInput { 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 VpnCustomPromptBooleanInput { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomPromptBooleanInput> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: VpnCustomPromptBooleanInput) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomPromptBooleanInput> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomPromptBooleanInput) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for VpnCustomPromptBooleanInput { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for &VpnCustomPromptBooleanInput { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::core::convert::TryInto::<IVpnCustomPromptElement>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomPromptBooleanInput {} unsafe impl ::core::marker::Sync for VpnCustomPromptBooleanInput {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomPromptOptionSelector(pub ::windows::core::IInspectable); impl VpnCustomPromptOptionSelector { 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<VpnCustomPromptOptionSelector, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn Options(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { 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::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } pub fn SelectedIndex(&self) -> ::windows::core::Result<u32> { let this = self; unsafe { let mut result__: u32 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__) } } pub fn SetDisplayName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } pub fn SetEmphasized(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Emphasized(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomPromptOptionSelector { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomPromptOptionSelector;{3b8f34d9-8ec1-4e95-9a4e-7ba64d38f330})"); } unsafe impl ::windows::core::Interface for VpnCustomPromptOptionSelector { type Vtable = IVpnCustomPromptOptionSelector_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3b8f34d9_8ec1_4e95_9a4e_7ba64d38f330); } impl ::windows::core::RuntimeName for VpnCustomPromptOptionSelector { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomPromptOptionSelector"; } impl ::core::convert::From<VpnCustomPromptOptionSelector> for ::windows::core::IUnknown { fn from(value: VpnCustomPromptOptionSelector) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomPromptOptionSelector> for ::windows::core::IUnknown { fn from(value: &VpnCustomPromptOptionSelector) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomPromptOptionSelector { 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 VpnCustomPromptOptionSelector { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomPromptOptionSelector> for ::windows::core::IInspectable { fn from(value: VpnCustomPromptOptionSelector) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomPromptOptionSelector> for ::windows::core::IInspectable { fn from(value: &VpnCustomPromptOptionSelector) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomPromptOptionSelector { 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 VpnCustomPromptOptionSelector { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomPromptOptionSelector> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: VpnCustomPromptOptionSelector) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomPromptOptionSelector> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomPromptOptionSelector) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for VpnCustomPromptOptionSelector { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for &VpnCustomPromptOptionSelector { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::core::convert::TryInto::<IVpnCustomPromptElement>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomPromptOptionSelector {} unsafe impl ::core::marker::Sync for VpnCustomPromptOptionSelector {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomPromptText(pub ::windows::core::IInspectable); impl VpnCustomPromptText { 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<VpnCustomPromptText, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetText<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Text(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetDisplayName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } pub fn SetEmphasized(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Emphasized(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomPromptText { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomPromptText;{3bc8bdee-3a42-49a3-abdd-07b2edea752d})"); } unsafe impl ::windows::core::Interface for VpnCustomPromptText { type Vtable = IVpnCustomPromptText_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x3bc8bdee_3a42_49a3_abdd_07b2edea752d); } impl ::windows::core::RuntimeName for VpnCustomPromptText { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomPromptText"; } impl ::core::convert::From<VpnCustomPromptText> for ::windows::core::IUnknown { fn from(value: VpnCustomPromptText) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomPromptText> for ::windows::core::IUnknown { fn from(value: &VpnCustomPromptText) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomPromptText { 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 VpnCustomPromptText { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomPromptText> for ::windows::core::IInspectable { fn from(value: VpnCustomPromptText) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomPromptText> for ::windows::core::IInspectable { fn from(value: &VpnCustomPromptText) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomPromptText { 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 VpnCustomPromptText { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomPromptText> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: VpnCustomPromptText) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomPromptText> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomPromptText) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for VpnCustomPromptText { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for &VpnCustomPromptText { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::core::convert::TryInto::<IVpnCustomPromptElement>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomPromptText {} unsafe impl ::core::marker::Sync for VpnCustomPromptText {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomPromptTextInput(pub ::windows::core::IInspectable); impl VpnCustomPromptTextInput { 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<VpnCustomPromptTextInput, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetPlaceholderText<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn PlaceholderText(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetIsTextHidden(&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 IsTextHidden(&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__) } } pub fn Text(&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).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetDisplayName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } pub fn SetEmphasized(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Emphasized(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPromptElement>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomPromptTextInput { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomPromptTextInput;{c9da9c75-913c-47d5-88ba-48fc48930235})"); } unsafe impl ::windows::core::Interface for VpnCustomPromptTextInput { type Vtable = IVpnCustomPromptTextInput_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc9da9c75_913c_47d5_88ba_48fc48930235); } impl ::windows::core::RuntimeName for VpnCustomPromptTextInput { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomPromptTextInput"; } impl ::core::convert::From<VpnCustomPromptTextInput> for ::windows::core::IUnknown { fn from(value: VpnCustomPromptTextInput) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomPromptTextInput> for ::windows::core::IUnknown { fn from(value: &VpnCustomPromptTextInput) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomPromptTextInput { 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 VpnCustomPromptTextInput { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomPromptTextInput> for ::windows::core::IInspectable { fn from(value: VpnCustomPromptTextInput) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomPromptTextInput> for ::windows::core::IInspectable { fn from(value: &VpnCustomPromptTextInput) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomPromptTextInput { 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 VpnCustomPromptTextInput { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomPromptTextInput> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: VpnCustomPromptTextInput) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomPromptTextInput> for IVpnCustomPromptElement { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomPromptTextInput) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for VpnCustomPromptTextInput { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPromptElement> for &VpnCustomPromptTextInput { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPromptElement> { ::core::convert::TryInto::<IVpnCustomPromptElement>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomPromptTextInput {} unsafe impl ::core::marker::Sync for VpnCustomPromptTextInput {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnCustomTextBox(pub ::windows::core::IInspectable); impl VpnCustomTextBox { 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<VpnCustomTextBox, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } pub fn SetDisplayText<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DisplayText(&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).7)(::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 = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Label(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCompulsory(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn Compulsory(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } pub fn SetBordered(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(self)?; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn Bordered(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnCustomPrompt>(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__) } } } unsafe impl ::windows::core::RuntimeType for VpnCustomTextBox { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnCustomTextBox;{daa4c3ca-8f23-4d36-91f1-76d937827942})"); } unsafe impl ::windows::core::Interface for VpnCustomTextBox { type Vtable = IVpnCustomTextBox_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdaa4c3ca_8f23_4d36_91f1_76d937827942); } impl ::windows::core::RuntimeName for VpnCustomTextBox { const NAME: &'static str = "Windows.Networking.Vpn.VpnCustomTextBox"; } impl ::core::convert::From<VpnCustomTextBox> for ::windows::core::IUnknown { fn from(value: VpnCustomTextBox) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnCustomTextBox> for ::windows::core::IUnknown { fn from(value: &VpnCustomTextBox) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnCustomTextBox { 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 VpnCustomTextBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnCustomTextBox> for ::windows::core::IInspectable { fn from(value: VpnCustomTextBox) -> Self { value.0 } } impl ::core::convert::From<&VpnCustomTextBox> for ::windows::core::IInspectable { fn from(value: &VpnCustomTextBox) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnCustomTextBox { 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 VpnCustomTextBox { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnCustomTextBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: VpnCustomTextBox) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnCustomTextBox> for IVpnCustomPrompt { type Error = ::windows::core::Error; fn try_from(value: &VpnCustomTextBox) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for VpnCustomTextBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnCustomPrompt> for &VpnCustomTextBox { fn into_param(self) -> ::windows::core::Param<'a, IVpnCustomPrompt> { ::core::convert::TryInto::<IVpnCustomPrompt>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnCustomTextBox {} unsafe impl ::core::marker::Sync for VpnCustomTextBox {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnDataPathType(pub i32); impl VpnDataPathType { pub const Send: VpnDataPathType = VpnDataPathType(0i32); pub const Receive: VpnDataPathType = VpnDataPathType(1i32); } impl ::core::convert::From<i32> for VpnDataPathType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnDataPathType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnDataPathType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnDataPathType;i4)"); } impl ::windows::core::DefaultType for VpnDataPathType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnDomainNameAssignment(pub ::windows::core::IInspectable); impl VpnDomainNameAssignment { 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<VpnDomainNameAssignment, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn DomainNameList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnDomainNameInfo>> { 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::Foundation::Collections::IVector<VpnDomainNameInfo>>(result__) } } #[cfg(feature = "Foundation")] pub fn SetProxyAutoConfigurationUri<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>>(&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 ProxyAutoConfigurationUri(&self) -> ::windows::core::Result<super::super::Foundation::Uri> { 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::super::Foundation::Uri>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnDomainNameAssignment { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnDomainNameAssignment;{4135b141-ccdb-49b5-9401-039a8ae767e9})"); } unsafe impl ::windows::core::Interface for VpnDomainNameAssignment { type Vtable = IVpnDomainNameAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4135b141_ccdb_49b5_9401_039a8ae767e9); } impl ::windows::core::RuntimeName for VpnDomainNameAssignment { const NAME: &'static str = "Windows.Networking.Vpn.VpnDomainNameAssignment"; } impl ::core::convert::From<VpnDomainNameAssignment> for ::windows::core::IUnknown { fn from(value: VpnDomainNameAssignment) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnDomainNameAssignment> for ::windows::core::IUnknown { fn from(value: &VpnDomainNameAssignment) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnDomainNameAssignment { 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 VpnDomainNameAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnDomainNameAssignment> for ::windows::core::IInspectable { fn from(value: VpnDomainNameAssignment) -> Self { value.0 } } impl ::core::convert::From<&VpnDomainNameAssignment> for ::windows::core::IInspectable { fn from(value: &VpnDomainNameAssignment) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnDomainNameAssignment { 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 VpnDomainNameAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnDomainNameAssignment {} unsafe impl ::core::marker::Sync for VpnDomainNameAssignment {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnDomainNameInfo(pub ::windows::core::IInspectable); impl VpnDomainNameInfo { pub fn SetDomainName<'a, Param0: ::windows::core::IntoParam<'a, super::HostName>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn DomainName(&self) -> ::windows::core::Result<super::HostName> { 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::HostName>(result__) } } pub fn SetDomainNameType(&self, value: VpnDomainNameType) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn DomainNameType(&self) -> ::windows::core::Result<VpnDomainNameType> { let this = self; unsafe { let mut result__: VpnDomainNameType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnDomainNameType>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn DnsServers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::HostName>> { 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::Foundation::Collections::IVector<super::HostName>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn WebProxyServers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::HostName>> { 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::<super::super::Foundation::Collections::IVector<super::HostName>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn CreateVpnDomainNameInfo<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>, Param3: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<super::HostName>>>(name: Param0, nametype: VpnDomainNameType, dnsserverlist: Param2, proxyserverlist: Param3) -> ::windows::core::Result<VpnDomainNameInfo> { Self::IVpnDomainNameInfoFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), name.into_param().abi(), nametype, dnsserverlist.into_param().abi(), proxyserverlist.into_param().abi(), &mut result__).from_abi::<VpnDomainNameInfo>(result__) }) } #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub fn WebProxyUris(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::super::Foundation::Uri>> { let this = &::windows::core::Interface::cast::<IVpnDomainNameInfo2>(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::Foundation::Collections::IVector<super::super::Foundation::Uri>>(result__) } } pub fn IVpnDomainNameInfoFactory<R, F: FnOnce(&IVpnDomainNameInfoFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnDomainNameInfo, IVpnDomainNameInfoFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnDomainNameInfo { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnDomainNameInfo;{ad2eb82f-ea8e-4f7a-843e-1a87e32e1b9a})"); } unsafe impl ::windows::core::Interface for VpnDomainNameInfo { type Vtable = IVpnDomainNameInfo_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xad2eb82f_ea8e_4f7a_843e_1a87e32e1b9a); } impl ::windows::core::RuntimeName for VpnDomainNameInfo { const NAME: &'static str = "Windows.Networking.Vpn.VpnDomainNameInfo"; } impl ::core::convert::From<VpnDomainNameInfo> for ::windows::core::IUnknown { fn from(value: VpnDomainNameInfo) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnDomainNameInfo> for ::windows::core::IUnknown { fn from(value: &VpnDomainNameInfo) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnDomainNameInfo { 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 VpnDomainNameInfo { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnDomainNameInfo> for ::windows::core::IInspectable { fn from(value: VpnDomainNameInfo) -> Self { value.0 } } impl ::core::convert::From<&VpnDomainNameInfo> for ::windows::core::IInspectable { fn from(value: &VpnDomainNameInfo) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnDomainNameInfo { 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 VpnDomainNameInfo { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnDomainNameInfo {} unsafe impl ::core::marker::Sync for VpnDomainNameInfo {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnDomainNameType(pub i32); impl VpnDomainNameType { pub const Suffix: VpnDomainNameType = VpnDomainNameType(0i32); pub const FullyQualified: VpnDomainNameType = VpnDomainNameType(1i32); pub const Reserved: VpnDomainNameType = VpnDomainNameType(65535i32); } impl ::core::convert::From<i32> for VpnDomainNameType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnDomainNameType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnDomainNameType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnDomainNameType;i4)"); } impl ::windows::core::DefaultType for VpnDomainNameType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnForegroundActivatedEventArgs(pub ::windows::core::IInspectable); impl VpnForegroundActivatedEventArgs { #[cfg(feature = "ApplicationModel_Activation")] pub fn Kind(&self) -> ::windows::core::Result<super::super::ApplicationModel::Activation::ActivationKind> { let this = &::windows::core::Interface::cast::<super::super::ApplicationModel::Activation::IActivatedEventArgs>(self)?; unsafe { let mut result__: super::super::ApplicationModel::Activation::ActivationKind = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::ApplicationModel::Activation::ActivationKind>(result__) } } #[cfg(feature = "ApplicationModel_Activation")] pub fn PreviousExecutionState(&self) -> ::windows::core::Result<super::super::ApplicationModel::Activation::ApplicationExecutionState> { let this = &::windows::core::Interface::cast::<super::super::ApplicationModel::Activation::IActivatedEventArgs>(self)?; unsafe { let mut result__: super::super::ApplicationModel::Activation::ApplicationExecutionState = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::ApplicationModel::Activation::ApplicationExecutionState>(result__) } } #[cfg(feature = "ApplicationModel_Activation")] pub fn SplashScreen(&self) -> ::windows::core::Result<super::super::ApplicationModel::Activation::SplashScreen> { let this = &::windows::core::Interface::cast::<super::super::ApplicationModel::Activation::IActivatedEventArgs>(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::super::ApplicationModel::Activation::SplashScreen>(result__) } } #[cfg(all(feature = "ApplicationModel_Activation", feature = "System"))] pub fn User(&self) -> ::windows::core::Result<super::super::System::User> { let this = &::windows::core::Interface::cast::<super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser>(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::System::User>(result__) } } pub fn ProfileName(&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__) } } #[cfg(feature = "Foundation_Collections")] pub fn SharedContext(&self) -> ::windows::core::Result<super::super::Foundation::Collections::ValueSet> { 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::super::Foundation::Collections::ValueSet>(result__) } } pub fn ActivationOperation(&self) -> ::windows::core::Result<VpnForegroundActivationOperation> { 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::<VpnForegroundActivationOperation>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnForegroundActivatedEventArgs { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnForegroundActivatedEventArgs;{85b465b0-cadb-4d70-ac92-543a24dc9ebc})"); } unsafe impl ::windows::core::Interface for VpnForegroundActivatedEventArgs { type Vtable = IVpnForegroundActivatedEventArgs_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x85b465b0_cadb_4d70_ac92_543a24dc9ebc); } impl ::windows::core::RuntimeName for VpnForegroundActivatedEventArgs { const NAME: &'static str = "Windows.Networking.Vpn.VpnForegroundActivatedEventArgs"; } impl ::core::convert::From<VpnForegroundActivatedEventArgs> for ::windows::core::IUnknown { fn from(value: VpnForegroundActivatedEventArgs) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnForegroundActivatedEventArgs> for ::windows::core::IUnknown { fn from(value: &VpnForegroundActivatedEventArgs) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnForegroundActivatedEventArgs { 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 VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnForegroundActivatedEventArgs> for ::windows::core::IInspectable { fn from(value: VpnForegroundActivatedEventArgs) -> Self { value.0 } } impl ::core::convert::From<&VpnForegroundActivatedEventArgs> for ::windows::core::IInspectable { fn from(value: &VpnForegroundActivatedEventArgs) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnForegroundActivatedEventArgs { 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 VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[cfg(feature = "ApplicationModel_Activation")] impl ::core::convert::TryFrom<VpnForegroundActivatedEventArgs> for super::super::ApplicationModel::Activation::IActivatedEventArgs { type Error = ::windows::core::Error; fn try_from(value: VpnForegroundActivatedEventArgs) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } #[cfg(feature = "ApplicationModel_Activation")] impl ::core::convert::TryFrom<&VpnForegroundActivatedEventArgs> for super::super::ApplicationModel::Activation::IActivatedEventArgs { type Error = ::windows::core::Error; fn try_from(value: &VpnForegroundActivatedEventArgs) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } #[cfg(feature = "ApplicationModel_Activation")] impl<'a> ::windows::core::IntoParam<'a, super::super::ApplicationModel::Activation::IActivatedEventArgs> for VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, super::super::ApplicationModel::Activation::IActivatedEventArgs> { ::windows::core::IntoParam::into_param(&self) } } #[cfg(feature = "ApplicationModel_Activation")] impl<'a> ::windows::core::IntoParam<'a, super::super::ApplicationModel::Activation::IActivatedEventArgs> for &VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, super::super::ApplicationModel::Activation::IActivatedEventArgs> { ::core::convert::TryInto::<super::super::ApplicationModel::Activation::IActivatedEventArgs>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } #[cfg(feature = "ApplicationModel_Activation")] impl ::core::convert::TryFrom<VpnForegroundActivatedEventArgs> for super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser { type Error = ::windows::core::Error; fn try_from(value: VpnForegroundActivatedEventArgs) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } #[cfg(feature = "ApplicationModel_Activation")] impl ::core::convert::TryFrom<&VpnForegroundActivatedEventArgs> for super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser { type Error = ::windows::core::Error; fn try_from(value: &VpnForegroundActivatedEventArgs) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } #[cfg(feature = "ApplicationModel_Activation")] impl<'a> ::windows::core::IntoParam<'a, super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser> for VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser> { ::windows::core::IntoParam::into_param(&self) } } #[cfg(feature = "ApplicationModel_Activation")] impl<'a> ::windows::core::IntoParam<'a, super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser> for &VpnForegroundActivatedEventArgs { fn into_param(self) -> ::windows::core::Param<'a, super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser> { ::core::convert::TryInto::<super::super::ApplicationModel::Activation::IActivatedEventArgsWithUser>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnForegroundActivatedEventArgs {} unsafe impl ::core::marker::Sync for VpnForegroundActivatedEventArgs {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnForegroundActivationOperation(pub ::windows::core::IInspectable); impl VpnForegroundActivationOperation { #[cfg(feature = "Foundation_Collections")] pub fn Complete<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::ValueSet>>(&self, result: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), result.into_param().abi()).ok() } } } unsafe impl ::windows::core::RuntimeType for VpnForegroundActivationOperation { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnForegroundActivationOperation;{9e010d57-f17a-4bd5-9b6d-f984f1297d3c})"); } unsafe impl ::windows::core::Interface for VpnForegroundActivationOperation { type Vtable = IVpnForegroundActivationOperation_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e010d57_f17a_4bd5_9b6d_f984f1297d3c); } impl ::windows::core::RuntimeName for VpnForegroundActivationOperation { const NAME: &'static str = "Windows.Networking.Vpn.VpnForegroundActivationOperation"; } impl ::core::convert::From<VpnForegroundActivationOperation> for ::windows::core::IUnknown { fn from(value: VpnForegroundActivationOperation) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnForegroundActivationOperation> for ::windows::core::IUnknown { fn from(value: &VpnForegroundActivationOperation) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnForegroundActivationOperation { 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 VpnForegroundActivationOperation { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnForegroundActivationOperation> for ::windows::core::IInspectable { fn from(value: VpnForegroundActivationOperation) -> Self { value.0 } } impl ::core::convert::From<&VpnForegroundActivationOperation> for ::windows::core::IInspectable { fn from(value: &VpnForegroundActivationOperation) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnForegroundActivationOperation { 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 VpnForegroundActivationOperation { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnForegroundActivationOperation {} unsafe impl ::core::marker::Sync for VpnForegroundActivationOperation {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnIPProtocol(pub i32); impl VpnIPProtocol { pub const None: VpnIPProtocol = VpnIPProtocol(0i32); pub const Tcp: VpnIPProtocol = VpnIPProtocol(6i32); pub const Udp: VpnIPProtocol = VpnIPProtocol(17i32); pub const Icmp: VpnIPProtocol = VpnIPProtocol(1i32); pub const Ipv6Icmp: VpnIPProtocol = VpnIPProtocol(58i32); pub const Igmp: VpnIPProtocol = VpnIPProtocol(2i32); pub const Pgm: VpnIPProtocol = VpnIPProtocol(113i32); } impl ::core::convert::From<i32> for VpnIPProtocol { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnIPProtocol { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnIPProtocol { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnIPProtocol;i4)"); } impl ::windows::core::DefaultType for VpnIPProtocol { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnInterfaceId(pub ::windows::core::IInspectable); impl VpnInterfaceId { pub fn GetAddressInfo(&self, id: &mut ::windows::core::Array<u8>) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), id.set_abi_len(), id as *mut _ as _).ok() } } pub fn CreateVpnInterfaceId(address: &[<u8 as ::windows::core::DefaultType>::DefaultType]) -> ::windows::core::Result<VpnInterfaceId> { Self::IVpnInterfaceIdFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), address.len() as u32, ::core::mem::transmute(address.as_ptr()), &mut result__).from_abi::<VpnInterfaceId>(result__) }) } pub fn IVpnInterfaceIdFactory<R, F: FnOnce(&IVpnInterfaceIdFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnInterfaceId, IVpnInterfaceIdFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnInterfaceId { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnInterfaceId;{9e2ddca2-1712-4ce4-b179-8c652c6d1011})"); } unsafe impl ::windows::core::Interface for VpnInterfaceId { type Vtable = IVpnInterfaceId_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9e2ddca2_1712_4ce4_b179_8c652c6d1011); } impl ::windows::core::RuntimeName for VpnInterfaceId { const NAME: &'static str = "Windows.Networking.Vpn.VpnInterfaceId"; } impl ::core::convert::From<VpnInterfaceId> for ::windows::core::IUnknown { fn from(value: VpnInterfaceId) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnInterfaceId> for ::windows::core::IUnknown { fn from(value: &VpnInterfaceId) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnInterfaceId { 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 VpnInterfaceId { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnInterfaceId> for ::windows::core::IInspectable { fn from(value: VpnInterfaceId) -> Self { value.0 } } impl ::core::convert::From<&VpnInterfaceId> for ::windows::core::IInspectable { fn from(value: &VpnInterfaceId) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnInterfaceId { 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 VpnInterfaceId { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnInterfaceId {} unsafe impl ::core::marker::Sync for VpnInterfaceId {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnManagementAgent(pub ::windows::core::IInspectable); impl VpnManagementAgent { 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<VpnManagementAgent, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation")] pub fn AddProfileFromXmlAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, xml: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), xml.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(feature = "Foundation")] pub fn AddProfileFromObjectAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>>(&self, profile: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), profile.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(feature = "Foundation")] pub fn UpdateProfileFromXmlAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, xml: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), xml.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(feature = "Foundation")] pub fn UpdateProfileFromObjectAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>>(&self, profile: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), profile.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub fn GetProfilesAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IVectorView<IVpnProfile>>> { 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::Foundation::IAsyncOperation<super::super::Foundation::Collections::IVectorView<IVpnProfile>>>(result__) } } #[cfg(feature = "Foundation")] pub fn DeleteProfileAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>>(&self, profile: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), profile.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(feature = "Foundation")] pub fn ConnectProfileAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>>(&self, profile: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), profile.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(all(feature = "Foundation", feature = "Security_Credentials"))] pub fn ConnectProfileWithPasswordCredentialAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>, Param1: ::windows::core::IntoParam<'a, super::super::Security::Credentials::PasswordCredential>>(&self, profile: Param0, passwordcredential: Param1) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), profile.into_param().abi(), passwordcredential.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } #[cfg(feature = "Foundation")] pub fn DisconnectProfileAsync<'a, Param0: ::windows::core::IntoParam<'a, IVpnProfile>>(&self, profile: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), profile.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VpnManagementErrorStatus>>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnManagementAgent { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnManagementAgent;{193696cd-a5c4-4abe-852b-785be4cb3e34})"); } unsafe impl ::windows::core::Interface for VpnManagementAgent { type Vtable = IVpnManagementAgent_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x193696cd_a5c4_4abe_852b_785be4cb3e34); } impl ::windows::core::RuntimeName for VpnManagementAgent { const NAME: &'static str = "Windows.Networking.Vpn.VpnManagementAgent"; } impl ::core::convert::From<VpnManagementAgent> for ::windows::core::IUnknown { fn from(value: VpnManagementAgent) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnManagementAgent> for ::windows::core::IUnknown { fn from(value: &VpnManagementAgent) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnManagementAgent { 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 VpnManagementAgent { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnManagementAgent> for ::windows::core::IInspectable { fn from(value: VpnManagementAgent) -> Self { value.0 } } impl ::core::convert::From<&VpnManagementAgent> for ::windows::core::IInspectable { fn from(value: &VpnManagementAgent) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnManagementAgent { 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 VpnManagementAgent { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnManagementAgent {} unsafe impl ::core::marker::Sync for VpnManagementAgent {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnManagementConnectionStatus(pub i32); impl VpnManagementConnectionStatus { pub const Disconnected: VpnManagementConnectionStatus = VpnManagementConnectionStatus(0i32); pub const Disconnecting: VpnManagementConnectionStatus = VpnManagementConnectionStatus(1i32); pub const Connected: VpnManagementConnectionStatus = VpnManagementConnectionStatus(2i32); pub const Connecting: VpnManagementConnectionStatus = VpnManagementConnectionStatus(3i32); } impl ::core::convert::From<i32> for VpnManagementConnectionStatus { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnManagementConnectionStatus { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnManagementConnectionStatus { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnManagementConnectionStatus;i4)"); } impl ::windows::core::DefaultType for VpnManagementConnectionStatus { 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 VpnManagementErrorStatus(pub i32); impl VpnManagementErrorStatus { pub const Ok: VpnManagementErrorStatus = VpnManagementErrorStatus(0i32); pub const Other: VpnManagementErrorStatus = VpnManagementErrorStatus(1i32); pub const InvalidXmlSyntax: VpnManagementErrorStatus = VpnManagementErrorStatus(2i32); pub const ProfileNameTooLong: VpnManagementErrorStatus = VpnManagementErrorStatus(3i32); pub const ProfileInvalidAppId: VpnManagementErrorStatus = VpnManagementErrorStatus(4i32); pub const AccessDenied: VpnManagementErrorStatus = VpnManagementErrorStatus(5i32); pub const CannotFindProfile: VpnManagementErrorStatus = VpnManagementErrorStatus(6i32); pub const AlreadyDisconnecting: VpnManagementErrorStatus = VpnManagementErrorStatus(7i32); pub const AlreadyConnected: VpnManagementErrorStatus = VpnManagementErrorStatus(8i32); pub const GeneralAuthenticationFailure: VpnManagementErrorStatus = VpnManagementErrorStatus(9i32); pub const EapFailure: VpnManagementErrorStatus = VpnManagementErrorStatus(10i32); pub const SmartCardFailure: VpnManagementErrorStatus = VpnManagementErrorStatus(11i32); pub const CertificateFailure: VpnManagementErrorStatus = VpnManagementErrorStatus(12i32); pub const ServerConfiguration: VpnManagementErrorStatus = VpnManagementErrorStatus(13i32); pub const NoConnection: VpnManagementErrorStatus = VpnManagementErrorStatus(14i32); pub const ServerConnection: VpnManagementErrorStatus = VpnManagementErrorStatus(15i32); pub const UserNamePassword: VpnManagementErrorStatus = VpnManagementErrorStatus(16i32); pub const DnsNotResolvable: VpnManagementErrorStatus = VpnManagementErrorStatus(17i32); pub const InvalidIP: VpnManagementErrorStatus = VpnManagementErrorStatus(18i32); } impl ::core::convert::From<i32> for VpnManagementErrorStatus { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnManagementErrorStatus { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnManagementErrorStatus { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnManagementErrorStatus;i4)"); } impl ::windows::core::DefaultType for VpnManagementErrorStatus { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnNamespaceAssignment(pub ::windows::core::IInspectable); impl VpnNamespaceAssignment { 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<VpnNamespaceAssignment, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn SetNamespaceList<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<VpnNamespaceInfo>>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn NamespaceList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnNamespaceInfo>> { 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::super::Foundation::Collections::IVector<VpnNamespaceInfo>>(result__) } } #[cfg(feature = "Foundation")] pub fn SetProxyAutoConfigUri<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>>(&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() } } #[cfg(feature = "Foundation")] pub fn ProxyAutoConfigUri(&self) -> ::windows::core::Result<super::super::Foundation::Uri> { 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::<super::super::Foundation::Uri>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnNamespaceAssignment { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnNamespaceAssignment;{d7f7db18-307d-4c0e-bd62-8fa270bbadd6})"); } unsafe impl ::windows::core::Interface for VpnNamespaceAssignment { type Vtable = IVpnNamespaceAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd7f7db18_307d_4c0e_bd62_8fa270bbadd6); } impl ::windows::core::RuntimeName for VpnNamespaceAssignment { const NAME: &'static str = "Windows.Networking.Vpn.VpnNamespaceAssignment"; } impl ::core::convert::From<VpnNamespaceAssignment> for ::windows::core::IUnknown { fn from(value: VpnNamespaceAssignment) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnNamespaceAssignment> for ::windows::core::IUnknown { fn from(value: &VpnNamespaceAssignment) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnNamespaceAssignment { 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 VpnNamespaceAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnNamespaceAssignment> for ::windows::core::IInspectable { fn from(value: VpnNamespaceAssignment) -> Self { value.0 } } impl ::core::convert::From<&VpnNamespaceAssignment> for ::windows::core::IInspectable { fn from(value: &VpnNamespaceAssignment) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnNamespaceAssignment { 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 VpnNamespaceAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnNamespaceAssignment {} unsafe impl ::core::marker::Sync for VpnNamespaceAssignment {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnNamespaceInfo(pub ::windows::core::IInspectable); impl VpnNamespaceInfo { pub fn SetNamespace<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Namespace(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn SetDnsServers<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>>(&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() } } #[cfg(feature = "Foundation_Collections")] pub fn DnsServers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::HostName>> { 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::<super::super::Foundation::Collections::IVector<super::HostName>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn SetWebProxyServers<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>>(&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() } } #[cfg(feature = "Foundation_Collections")] pub fn WebProxyServers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::HostName>> { 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::<super::super::Foundation::Collections::IVector<super::HostName>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn CreateVpnNamespaceInfo<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>, Param2: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<super::HostName>>>(name: Param0, dnsserverlist: Param1, proxyserverlist: Param2) -> ::windows::core::Result<VpnNamespaceInfo> { Self::IVpnNamespaceInfoFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), name.into_param().abi(), dnsserverlist.into_param().abi(), proxyserverlist.into_param().abi(), &mut result__).from_abi::<VpnNamespaceInfo>(result__) }) } pub fn IVpnNamespaceInfoFactory<R, F: FnOnce(&IVpnNamespaceInfoFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnNamespaceInfo, IVpnNamespaceInfoFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnNamespaceInfo { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnNamespaceInfo;{30edfb43-444f-44c5-8167-a35a91f1af94})"); } unsafe impl ::windows::core::Interface for VpnNamespaceInfo { type Vtable = IVpnNamespaceInfo_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x30edfb43_444f_44c5_8167_a35a91f1af94); } impl ::windows::core::RuntimeName for VpnNamespaceInfo { const NAME: &'static str = "Windows.Networking.Vpn.VpnNamespaceInfo"; } impl ::core::convert::From<VpnNamespaceInfo> for ::windows::core::IUnknown { fn from(value: VpnNamespaceInfo) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnNamespaceInfo> for ::windows::core::IUnknown { fn from(value: &VpnNamespaceInfo) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnNamespaceInfo { 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 VpnNamespaceInfo { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnNamespaceInfo> for ::windows::core::IInspectable { fn from(value: VpnNamespaceInfo) -> Self { value.0 } } impl ::core::convert::From<&VpnNamespaceInfo> for ::windows::core::IInspectable { fn from(value: &VpnNamespaceInfo) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnNamespaceInfo { 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 VpnNamespaceInfo { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnNamespaceInfo {} unsafe impl ::core::marker::Sync for VpnNamespaceInfo {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnNativeProfile(pub ::windows::core::IInspectable); impl VpnNativeProfile { 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<VpnNativeProfile, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn Servers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { 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::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } pub fn RoutingPolicyType(&self) -> ::windows::core::Result<VpnRoutingPolicyType> { let this = self; unsafe { let mut result__: VpnRoutingPolicyType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnRoutingPolicyType>(result__) } } pub fn SetRoutingPolicyType(&self, value: VpnRoutingPolicyType) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn NativeProtocolType(&self) -> ::windows::core::Result<VpnNativeProtocolType> { let this = self; unsafe { let mut result__: VpnNativeProtocolType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnNativeProtocolType>(result__) } } pub fn SetNativeProtocolType(&self, value: VpnNativeProtocolType) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } pub fn UserAuthenticationMethod(&self) -> ::windows::core::Result<VpnAuthenticationMethod> { let this = self; unsafe { let mut result__: VpnAuthenticationMethod = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnAuthenticationMethod>(result__) } } pub fn SetUserAuthenticationMethod(&self, value: VpnAuthenticationMethod) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() } } pub fn TunnelAuthenticationMethod(&self) -> ::windows::core::Result<VpnAuthenticationMethod> { let this = self; unsafe { let mut result__: VpnAuthenticationMethod = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnAuthenticationMethod>(result__) } } pub fn SetTunnelAuthenticationMethod(&self, value: VpnAuthenticationMethod) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), value).ok() } } pub fn EapConfiguration(&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).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetEapConfiguration<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&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() } } pub fn ProfileName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetProfileName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn AppTriggers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnAppId>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::super::Foundation::Collections::IVector<VpnAppId>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn Routes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::<super::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn DomainNameInfoList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnDomainNameInfo>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::Foundation::Collections::IVector<VpnDomainNameInfo>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn TrafficFilters(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnTrafficFilter>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::<super::super::Foundation::Collections::IVector<VpnTrafficFilter>>(result__) } } pub fn RememberCredentials(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetRememberCredentials(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() } } pub fn AlwaysOn(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetAlwaysOn(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() } } pub fn RequireVpnClientAppUI(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnNativeProfile2>(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 SetRequireVpnClientAppUI(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnNativeProfile2>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() } } pub fn ConnectionStatus(&self) -> ::windows::core::Result<VpnManagementConnectionStatus> { let this = &::windows::core::Interface::cast::<IVpnNativeProfile2>(self)?; unsafe { let mut result__: VpnManagementConnectionStatus = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnManagementConnectionStatus>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnNativeProfile { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnNativeProfile;{a4aee29e-6417-4333-9842-f0a66db69802})"); } unsafe impl ::windows::core::Interface for VpnNativeProfile { type Vtable = IVpnNativeProfile_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xa4aee29e_6417_4333_9842_f0a66db69802); } impl ::windows::core::RuntimeName for VpnNativeProfile { const NAME: &'static str = "Windows.Networking.Vpn.VpnNativeProfile"; } impl ::core::convert::From<VpnNativeProfile> for ::windows::core::IUnknown { fn from(value: VpnNativeProfile) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnNativeProfile> for ::windows::core::IUnknown { fn from(value: &VpnNativeProfile) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnNativeProfile { 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 VpnNativeProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnNativeProfile> for ::windows::core::IInspectable { fn from(value: VpnNativeProfile) -> Self { value.0 } } impl ::core::convert::From<&VpnNativeProfile> for ::windows::core::IInspectable { fn from(value: &VpnNativeProfile) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnNativeProfile { 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 VpnNativeProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnNativeProfile> for IVpnProfile { type Error = ::windows::core::Error; fn try_from(value: VpnNativeProfile) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnNativeProfile> for IVpnProfile { type Error = ::windows::core::Error; fn try_from(value: &VpnNativeProfile) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnProfile> for VpnNativeProfile { fn into_param(self) -> ::windows::core::Param<'a, IVpnProfile> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnProfile> for &VpnNativeProfile { fn into_param(self) -> ::windows::core::Param<'a, IVpnProfile> { ::core::convert::TryInto::<IVpnProfile>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnNativeProfile {} unsafe impl ::core::marker::Sync for VpnNativeProfile {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnNativeProtocolType(pub i32); impl VpnNativeProtocolType { pub const Pptp: VpnNativeProtocolType = VpnNativeProtocolType(0i32); pub const L2tp: VpnNativeProtocolType = VpnNativeProtocolType(1i32); pub const IpsecIkev2: VpnNativeProtocolType = VpnNativeProtocolType(2i32); } impl ::core::convert::From<i32> for VpnNativeProtocolType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnNativeProtocolType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnNativeProtocolType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnNativeProtocolType;i4)"); } impl ::windows::core::DefaultType for VpnNativeProtocolType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnPacketBuffer(pub ::windows::core::IInspectable); impl VpnPacketBuffer { #[cfg(feature = "Storage_Streams")] pub fn Buffer(&self) -> ::windows::core::Result<super::super::Storage::Streams::Buffer> { 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::Storage::Streams::Buffer>(result__) } } pub fn SetStatus(&self, value: VpnPacketBufferStatus) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() } } pub fn Status(&self) -> ::windows::core::Result<VpnPacketBufferStatus> { let this = self; unsafe { let mut result__: VpnPacketBufferStatus = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnPacketBufferStatus>(result__) } } pub fn SetTransportAffinity(&self, value: u32) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() } } pub fn TransportAffinity(&self) -> ::windows::core::Result<u32> { let this = self; unsafe { let mut result__: u32 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__) } } pub fn AppId(&self) -> ::windows::core::Result<VpnAppId> { let this = &::windows::core::Interface::cast::<IVpnPacketBuffer2>(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::<VpnAppId>(result__) } } pub fn CreateVpnPacketBuffer<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(parentbuffer: Param0, offset: u32, length: u32) -> ::windows::core::Result<VpnPacketBuffer> { Self::IVpnPacketBufferFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), parentbuffer.into_param().abi(), offset, length, &mut result__).from_abi::<VpnPacketBuffer>(result__) }) } pub fn SetTransportContext<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::IInspectable>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnPacketBuffer3>(self)?; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn TransportContext(&self) -> ::windows::core::Result<::windows::core::IInspectable> { let this = &::windows::core::Interface::cast::<IVpnPacketBuffer3>(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::<::windows::core::IInspectable>(result__) } } pub fn IVpnPacketBufferFactory<R, F: FnOnce(&IVpnPacketBufferFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnPacketBuffer, IVpnPacketBufferFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnPacketBuffer { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnPacketBuffer;{c2f891fc-4d5c-4a63-b70d-4e307eacce55})"); } unsafe impl ::windows::core::Interface for VpnPacketBuffer { type Vtable = IVpnPacketBuffer_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc2f891fc_4d5c_4a63_b70d_4e307eacce55); } impl ::windows::core::RuntimeName for VpnPacketBuffer { const NAME: &'static str = "Windows.Networking.Vpn.VpnPacketBuffer"; } impl ::core::convert::From<VpnPacketBuffer> for ::windows::core::IUnknown { fn from(value: VpnPacketBuffer) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnPacketBuffer> for ::windows::core::IUnknown { fn from(value: &VpnPacketBuffer) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnPacketBuffer { 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 VpnPacketBuffer { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnPacketBuffer> for ::windows::core::IInspectable { fn from(value: VpnPacketBuffer) -> Self { value.0 } } impl ::core::convert::From<&VpnPacketBuffer> for ::windows::core::IInspectable { fn from(value: &VpnPacketBuffer) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnPacketBuffer { 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 VpnPacketBuffer { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnPacketBuffer {} unsafe impl ::core::marker::Sync for VpnPacketBuffer {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnPacketBufferList(pub ::windows::core::IInspectable); impl VpnPacketBufferList { pub fn Append<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(&self, nextvpnpacketbuffer: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), nextvpnpacketbuffer.into_param().abi()).ok() } } pub fn AddAtBegin<'a, Param0: ::windows::core::IntoParam<'a, VpnPacketBuffer>>(&self, nextvpnpacketbuffer: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), nextvpnpacketbuffer.into_param().abi()).ok() } } pub fn RemoveAtEnd(&self) -> ::windows::core::Result<VpnPacketBuffer> { 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::<VpnPacketBuffer>(result__) } } pub fn RemoveAtBegin(&self) -> ::windows::core::Result<VpnPacketBuffer> { 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::<VpnPacketBuffer>(result__) } } pub fn Clear(&self) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this)).ok() } } pub fn SetStatus(&self, value: VpnPacketBufferStatus) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value).ok() } } pub fn Status(&self) -> ::windows::core::Result<VpnPacketBufferStatus> { let this = self; unsafe { let mut result__: VpnPacketBufferStatus = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnPacketBufferStatus>(result__) } } pub fn Size(&self) -> ::windows::core::Result<u32> { let this = self; unsafe { let mut result__: u32 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u32>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn First(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IIterator<VpnPacketBuffer>> { let this = &::windows::core::Interface::cast::<super::super::Foundation::Collections::IIterable<VpnPacketBuffer>>(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::Foundation::Collections::IIterator<VpnPacketBuffer>>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnPacketBufferList { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnPacketBufferList;{c2f891fc-4d5c-4a63-b70d-4e307eacce77})"); } unsafe impl ::windows::core::Interface for VpnPacketBufferList { type Vtable = IVpnPacketBufferList_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc2f891fc_4d5c_4a63_b70d_4e307eacce77); } impl ::windows::core::RuntimeName for VpnPacketBufferList { const NAME: &'static str = "Windows.Networking.Vpn.VpnPacketBufferList"; } impl ::core::convert::From<VpnPacketBufferList> for ::windows::core::IUnknown { fn from(value: VpnPacketBufferList) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnPacketBufferList> for ::windows::core::IUnknown { fn from(value: &VpnPacketBufferList) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnPacketBufferList { 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 VpnPacketBufferList { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnPacketBufferList> for ::windows::core::IInspectable { fn from(value: VpnPacketBufferList) -> Self { value.0 } } impl ::core::convert::From<&VpnPacketBufferList> for ::windows::core::IInspectable { fn from(value: &VpnPacketBufferList) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnPacketBufferList { 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 VpnPacketBufferList { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } #[cfg(feature = "Foundation_Collections")] impl ::core::convert::TryFrom<VpnPacketBufferList> for super::super::Foundation::Collections::IIterable<VpnPacketBuffer> { type Error = ::windows::core::Error; fn try_from(value: VpnPacketBufferList) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } #[cfg(feature = "Foundation_Collections")] impl ::core::convert::TryFrom<&VpnPacketBufferList> for super::super::Foundation::Collections::IIterable<VpnPacketBuffer> { type Error = ::windows::core::Error; fn try_from(value: &VpnPacketBufferList) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } #[cfg(feature = "Foundation_Collections")] impl<'a> ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<VpnPacketBuffer>> for VpnPacketBufferList { fn into_param(self) -> ::windows::core::Param<'a, super::super::Foundation::Collections::IIterable<VpnPacketBuffer>> { ::windows::core::IntoParam::into_param(&self) } } #[cfg(feature = "Foundation_Collections")] impl<'a> ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<VpnPacketBuffer>> for &VpnPacketBufferList { fn into_param(self) -> ::windows::core::Param<'a, super::super::Foundation::Collections::IIterable<VpnPacketBuffer>> { ::core::convert::TryInto::<super::super::Foundation::Collections::IIterable<VpnPacketBuffer>>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnPacketBufferList {} unsafe impl ::core::marker::Sync for VpnPacketBufferList {} #[cfg(all(feature = "Foundation_Collections"))] impl ::core::iter::IntoIterator for VpnPacketBufferList { type Item = VpnPacketBuffer; type IntoIter = super::super::Foundation::Collections::IIterator<Self::Item>; fn into_iter(self) -> Self::IntoIter { ::core::iter::IntoIterator::into_iter(&self) } } #[cfg(all(feature = "Foundation_Collections"))] impl ::core::iter::IntoIterator for &VpnPacketBufferList { type Item = VpnPacketBuffer; type IntoIter = super::super::Foundation::Collections::IIterator<Self::Item>; fn into_iter(self) -> Self::IntoIter { self.First().unwrap() } } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnPacketBufferStatus(pub i32); impl VpnPacketBufferStatus { pub const Ok: VpnPacketBufferStatus = VpnPacketBufferStatus(0i32); pub const InvalidBufferSize: VpnPacketBufferStatus = VpnPacketBufferStatus(1i32); } impl ::core::convert::From<i32> for VpnPacketBufferStatus { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnPacketBufferStatus { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnPacketBufferStatus { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnPacketBufferStatus;i4)"); } impl ::windows::core::DefaultType for VpnPacketBufferStatus { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnPickedCredential(pub ::windows::core::IInspectable); impl VpnPickedCredential { #[cfg(feature = "Security_Credentials")] pub fn PasskeyCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::Security::Credentials::PasswordCredential>(result__) } } pub fn AdditionalPin(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } #[cfg(feature = "Security_Credentials")] pub fn OldPasswordCredential(&self) -> ::windows::core::Result<super::super::Security::Credentials::PasswordCredential> { 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::super::Security::Credentials::PasswordCredential>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnPickedCredential { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnPickedCredential;{9a793ac7-8854-4e52-ad97-24dd9a842bce})"); } unsafe impl ::windows::core::Interface for VpnPickedCredential { type Vtable = IVpnPickedCredential_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9a793ac7_8854_4e52_ad97_24dd9a842bce); } impl ::windows::core::RuntimeName for VpnPickedCredential { const NAME: &'static str = "Windows.Networking.Vpn.VpnPickedCredential"; } impl ::core::convert::From<VpnPickedCredential> for ::windows::core::IUnknown { fn from(value: VpnPickedCredential) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnPickedCredential> for ::windows::core::IUnknown { fn from(value: &VpnPickedCredential) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnPickedCredential { 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 VpnPickedCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnPickedCredential> for ::windows::core::IInspectable { fn from(value: VpnPickedCredential) -> Self { value.0 } } impl ::core::convert::From<&VpnPickedCredential> for ::windows::core::IInspectable { fn from(value: &VpnPickedCredential) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnPickedCredential { 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 VpnPickedCredential { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnPickedCredential {} unsafe impl ::core::marker::Sync for VpnPickedCredential {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnPlugInProfile(pub ::windows::core::IInspectable); impl VpnPlugInProfile { 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<VpnPlugInProfile, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub fn ServerUris(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<super::super::Foundation::Uri>> { 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::Foundation::Collections::IVector<super::super::Foundation::Uri>>(result__) } } pub fn CustomConfiguration(&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).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetCustomConfiguration<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&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 VpnPluginPackageFamilyName(&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).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__) } } pub fn SetVpnPluginPackageFamilyName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&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 ProfileName(&self) -> ::windows::core::Result<::windows::core::HSTRING> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetProfileName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn AppTriggers(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnAppId>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::super::Foundation::Collections::IVector<VpnAppId>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn Routes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::<super::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn DomainNameInfoList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnDomainNameInfo>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::Foundation::Collections::IVector<VpnDomainNameInfo>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn TrafficFilters(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnTrafficFilter>> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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::<super::super::Foundation::Collections::IVector<VpnTrafficFilter>>(result__) } } pub fn RememberCredentials(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetRememberCredentials(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() } } pub fn AlwaysOn(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnProfile>(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 SetAlwaysOn(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnProfile>(self)?; unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() } } pub fn RequireVpnClientAppUI(&self) -> ::windows::core::Result<bool> { let this = &::windows::core::Interface::cast::<IVpnPlugInProfile2>(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 SetRequireVpnClientAppUI(&self, value: bool) -> ::windows::core::Result<()> { let this = &::windows::core::Interface::cast::<IVpnPlugInProfile2>(self)?; unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() } } pub fn ConnectionStatus(&self) -> ::windows::core::Result<VpnManagementConnectionStatus> { let this = &::windows::core::Interface::cast::<IVpnPlugInProfile2>(self)?; unsafe { let mut result__: VpnManagementConnectionStatus = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnManagementConnectionStatus>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnPlugInProfile { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnPlugInProfile;{0edf0da4-4f00-4589-8d7b-4bf988f6542c})"); } unsafe impl ::windows::core::Interface for VpnPlugInProfile { type Vtable = IVpnPlugInProfile_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0edf0da4_4f00_4589_8d7b_4bf988f6542c); } impl ::windows::core::RuntimeName for VpnPlugInProfile { const NAME: &'static str = "Windows.Networking.Vpn.VpnPlugInProfile"; } impl ::core::convert::From<VpnPlugInProfile> for ::windows::core::IUnknown { fn from(value: VpnPlugInProfile) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnPlugInProfile> for ::windows::core::IUnknown { fn from(value: &VpnPlugInProfile) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnPlugInProfile { 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 VpnPlugInProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnPlugInProfile> for ::windows::core::IInspectable { fn from(value: VpnPlugInProfile) -> Self { value.0 } } impl ::core::convert::From<&VpnPlugInProfile> for ::windows::core::IInspectable { fn from(value: &VpnPlugInProfile) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnPlugInProfile { 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 VpnPlugInProfile { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } impl ::core::convert::TryFrom<VpnPlugInProfile> for IVpnProfile { type Error = ::windows::core::Error; fn try_from(value: VpnPlugInProfile) -> ::windows::core::Result<Self> { ::core::convert::TryFrom::try_from(&value) } } impl ::core::convert::TryFrom<&VpnPlugInProfile> for IVpnProfile { type Error = ::windows::core::Error; fn try_from(value: &VpnPlugInProfile) -> ::windows::core::Result<Self> { ::windows::core::Interface::cast(value) } } impl<'a> ::windows::core::IntoParam<'a, IVpnProfile> for VpnPlugInProfile { fn into_param(self) -> ::windows::core::Param<'a, IVpnProfile> { ::windows::core::IntoParam::into_param(&self) } } impl<'a> ::windows::core::IntoParam<'a, IVpnProfile> for &VpnPlugInProfile { fn into_param(self) -> ::windows::core::Param<'a, IVpnProfile> { ::core::convert::TryInto::<IVpnProfile>::try_into(self).map(::windows::core::Param::Owned).unwrap_or(::windows::core::Param::None) } } unsafe impl ::core::marker::Send for VpnPlugInProfile {} unsafe impl ::core::marker::Sync for VpnPlugInProfile {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnRoute(pub ::windows::core::IInspectable); impl VpnRoute { pub fn SetAddress<'a, Param0: ::windows::core::IntoParam<'a, super::HostName>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } pub fn Address(&self) -> ::windows::core::Result<super::HostName> { 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::HostName>(result__) } } pub fn SetPrefixSize(&self, value: u8) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), value).ok() } } pub fn PrefixSize(&self) -> ::windows::core::Result<u8> { let this = self; unsafe { let mut result__: u8 = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<u8>(result__) } } pub fn CreateVpnRoute<'a, Param0: ::windows::core::IntoParam<'a, super::HostName>>(address: Param0, prefixsize: u8) -> ::windows::core::Result<VpnRoute> { Self::IVpnRouteFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), address.into_param().abi(), prefixsize, &mut result__).from_abi::<VpnRoute>(result__) }) } pub fn IVpnRouteFactory<R, F: FnOnce(&IVpnRouteFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnRoute, IVpnRouteFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnRoute { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnRoute;{b5731b83-0969-4699-938e-7776db29cfb3})"); } unsafe impl ::windows::core::Interface for VpnRoute { type Vtable = IVpnRoute_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb5731b83_0969_4699_938e_7776db29cfb3); } impl ::windows::core::RuntimeName for VpnRoute { const NAME: &'static str = "Windows.Networking.Vpn.VpnRoute"; } impl ::core::convert::From<VpnRoute> for ::windows::core::IUnknown { fn from(value: VpnRoute) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnRoute> for ::windows::core::IUnknown { fn from(value: &VpnRoute) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnRoute { 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 VpnRoute { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnRoute> for ::windows::core::IInspectable { fn from(value: VpnRoute) -> Self { value.0 } } impl ::core::convert::From<&VpnRoute> for ::windows::core::IInspectable { fn from(value: &VpnRoute) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnRoute { 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 VpnRoute { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnRoute {} unsafe impl ::core::marker::Sync for VpnRoute {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnRouteAssignment(pub ::windows::core::IInspectable); impl VpnRouteAssignment { 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<VpnRouteAssignment, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn SetIpv4InclusionRoutes<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<VpnRoute>>>(&self, value: Param0) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn SetIpv6InclusionRoutes<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<VpnRoute>>>(&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_Collections")] pub fn Ipv4InclusionRoutes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { 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::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn Ipv6InclusionRoutes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { 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::<super::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn SetIpv4ExclusionRoutes<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<VpnRoute>>>(&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() } } #[cfg(feature = "Foundation_Collections")] pub fn SetIpv6ExclusionRoutes<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IVector<VpnRoute>>>(&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() } } #[cfg(feature = "Foundation_Collections")] pub fn Ipv4ExclusionRoutes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { 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::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn Ipv6ExclusionRoutes(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnRoute>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::Collections::IVector<VpnRoute>>(result__) } } pub fn SetExcludeLocalSubnets(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), value).ok() } } pub fn ExcludeLocalSubnets(&self) -> ::windows::core::Result<bool> { let this = self; unsafe { let mut result__: bool = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnRouteAssignment { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnRouteAssignment;{db64de22-ce39-4a76-9550-f61039f80e48})"); } unsafe impl ::windows::core::Interface for VpnRouteAssignment { type Vtable = IVpnRouteAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xdb64de22_ce39_4a76_9550_f61039f80e48); } impl ::windows::core::RuntimeName for VpnRouteAssignment { const NAME: &'static str = "Windows.Networking.Vpn.VpnRouteAssignment"; } impl ::core::convert::From<VpnRouteAssignment> for ::windows::core::IUnknown { fn from(value: VpnRouteAssignment) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnRouteAssignment> for ::windows::core::IUnknown { fn from(value: &VpnRouteAssignment) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnRouteAssignment { 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 VpnRouteAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnRouteAssignment> for ::windows::core::IInspectable { fn from(value: VpnRouteAssignment) -> Self { value.0 } } impl ::core::convert::From<&VpnRouteAssignment> for ::windows::core::IInspectable { fn from(value: &VpnRouteAssignment) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnRouteAssignment { 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 VpnRouteAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnRouteAssignment {} unsafe impl ::core::marker::Sync for VpnRouteAssignment {} #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct VpnRoutingPolicyType(pub i32); impl VpnRoutingPolicyType { pub const SplitRouting: VpnRoutingPolicyType = VpnRoutingPolicyType(0i32); pub const ForceAllTrafficOverVpn: VpnRoutingPolicyType = VpnRoutingPolicyType(1i32); } impl ::core::convert::From<i32> for VpnRoutingPolicyType { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for VpnRoutingPolicyType { type Abi = Self; } unsafe impl ::windows::core::RuntimeType for VpnRoutingPolicyType { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.Networking.Vpn.VpnRoutingPolicyType;i4)"); } impl ::windows::core::DefaultType for VpnRoutingPolicyType { type DefaultType = Self; } #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnSystemHealth(pub ::windows::core::IInspectable); impl VpnSystemHealth { #[cfg(feature = "Storage_Streams")] pub fn StatementOfHealth(&self) -> ::windows::core::Result<super::super::Storage::Streams::Buffer> { 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::Storage::Streams::Buffer>(result__) } } } unsafe impl ::windows::core::RuntimeType for VpnSystemHealth { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnSystemHealth;{99a8f8af-c0ee-4e75-817a-f231aee5123d})"); } unsafe impl ::windows::core::Interface for VpnSystemHealth { type Vtable = IVpnSystemHealth_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x99a8f8af_c0ee_4e75_817a_f231aee5123d); } impl ::windows::core::RuntimeName for VpnSystemHealth { const NAME: &'static str = "Windows.Networking.Vpn.VpnSystemHealth"; } impl ::core::convert::From<VpnSystemHealth> for ::windows::core::IUnknown { fn from(value: VpnSystemHealth) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnSystemHealth> for ::windows::core::IUnknown { fn from(value: &VpnSystemHealth) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnSystemHealth { 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 VpnSystemHealth { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnSystemHealth> for ::windows::core::IInspectable { fn from(value: VpnSystemHealth) -> Self { value.0 } } impl ::core::convert::From<&VpnSystemHealth> for ::windows::core::IInspectable { fn from(value: &VpnSystemHealth) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnSystemHealth { 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 VpnSystemHealth { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnSystemHealth {} unsafe impl ::core::marker::Sync for VpnSystemHealth {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnTrafficFilter(pub ::windows::core::IInspectable); impl VpnTrafficFilter { pub fn AppId(&self) -> ::windows::core::Result<VpnAppId> { 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::<VpnAppId>(result__) } } pub fn SetAppId<'a, Param0: ::windows::core::IntoParam<'a, VpnAppId>>(&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_Collections")] pub fn AppClaims(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { 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::super::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } pub fn Protocol(&self) -> ::windows::core::Result<VpnIPProtocol> { let this = self; unsafe { let mut result__: VpnIPProtocol = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnIPProtocol>(result__) } } pub fn SetProtocol(&self, value: VpnIPProtocol) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } #[cfg(feature = "Foundation_Collections")] pub fn LocalPortRanges(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { 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::<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn RemotePortRanges(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { 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::super::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn LocalAddressRanges(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } #[cfg(feature = "Foundation_Collections")] pub fn RemoteAddressRanges(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>> { let this = self; unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::Collections::IVector<::windows::core::HSTRING>>(result__) } } pub fn RoutingPolicyType(&self) -> ::windows::core::Result<VpnRoutingPolicyType> { let this = self; unsafe { let mut result__: VpnRoutingPolicyType = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VpnRoutingPolicyType>(result__) } } pub fn SetRoutingPolicyType(&self, value: VpnRoutingPolicyType) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), value).ok() } } pub fn Create<'a, Param0: ::windows::core::IntoParam<'a, VpnAppId>>(appid: Param0) -> ::windows::core::Result<VpnTrafficFilter> { Self::IVpnTrafficFilterFactory(|this| unsafe { let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed(); (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), appid.into_param().abi(), &mut result__).from_abi::<VpnTrafficFilter>(result__) }) } pub fn IVpnTrafficFilterFactory<R, F: FnOnce(&IVpnTrafficFilterFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> { static mut SHARED: ::windows::core::FactoryCache<VpnTrafficFilter, IVpnTrafficFilterFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } } unsafe impl ::windows::core::RuntimeType for VpnTrafficFilter { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnTrafficFilter;{2f691b60-6c9f-47f5-ac36-bb1b042e2c50})"); } unsafe impl ::windows::core::Interface for VpnTrafficFilter { type Vtable = IVpnTrafficFilter_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2f691b60_6c9f_47f5_ac36_bb1b042e2c50); } impl ::windows::core::RuntimeName for VpnTrafficFilter { const NAME: &'static str = "Windows.Networking.Vpn.VpnTrafficFilter"; } impl ::core::convert::From<VpnTrafficFilter> for ::windows::core::IUnknown { fn from(value: VpnTrafficFilter) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnTrafficFilter> for ::windows::core::IUnknown { fn from(value: &VpnTrafficFilter) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnTrafficFilter { 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 VpnTrafficFilter { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnTrafficFilter> for ::windows::core::IInspectable { fn from(value: VpnTrafficFilter) -> Self { value.0 } } impl ::core::convert::From<&VpnTrafficFilter> for ::windows::core::IInspectable { fn from(value: &VpnTrafficFilter) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnTrafficFilter { 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 VpnTrafficFilter { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnTrafficFilter {} unsafe impl ::core::marker::Sync for VpnTrafficFilter {} #[repr(transparent)] #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)] pub struct VpnTrafficFilterAssignment(pub ::windows::core::IInspectable); impl VpnTrafficFilterAssignment { 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<VpnTrafficFilterAssignment, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new(); unsafe { SHARED.call(callback) } } #[cfg(feature = "Foundation_Collections")] pub fn TrafficFilterList(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVector<VpnTrafficFilter>> { 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::Foundation::Collections::IVector<VpnTrafficFilter>>(result__) } } pub fn AllowOutbound(&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 SetAllowOutbound(&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 AllowInbound(&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__) } } pub fn SetAllowInbound(&self, value: bool) -> ::windows::core::Result<()> { let this = self; unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), value).ok() } } } unsafe impl ::windows::core::RuntimeType for VpnTrafficFilterAssignment { const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.Networking.Vpn.VpnTrafficFilterAssignment;{56ccd45c-e664-471e-89cd-601603b9e0f3})"); } unsafe impl ::windows::core::Interface for VpnTrafficFilterAssignment { type Vtable = IVpnTrafficFilterAssignment_abi; const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x56ccd45c_e664_471e_89cd_601603b9e0f3); } impl ::windows::core::RuntimeName for VpnTrafficFilterAssignment { const NAME: &'static str = "Windows.Networking.Vpn.VpnTrafficFilterAssignment"; } impl ::core::convert::From<VpnTrafficFilterAssignment> for ::windows::core::IUnknown { fn from(value: VpnTrafficFilterAssignment) -> Self { value.0 .0 } } impl ::core::convert::From<&VpnTrafficFilterAssignment> for ::windows::core::IUnknown { fn from(value: &VpnTrafficFilterAssignment) -> Self { value.0 .0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VpnTrafficFilterAssignment { 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 VpnTrafficFilterAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> { ::windows::core::Param::Borrowed(&self.0 .0) } } impl ::core::convert::From<VpnTrafficFilterAssignment> for ::windows::core::IInspectable { fn from(value: VpnTrafficFilterAssignment) -> Self { value.0 } } impl ::core::convert::From<&VpnTrafficFilterAssignment> for ::windows::core::IInspectable { fn from(value: &VpnTrafficFilterAssignment) -> Self { value.0.clone() } } impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VpnTrafficFilterAssignment { 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 VpnTrafficFilterAssignment { fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> { ::windows::core::Param::Borrowed(&self.0) } } unsafe impl ::core::marker::Send for VpnTrafficFilterAssignment {} unsafe impl ::core::marker::Sync for VpnTrafficFilterAssignment {}
use game::{State, Event, Transition}; use renderer::{Renderer, Color}; pub struct GameOverState { } impl State for GameOverState { fn update(&mut self) -> Transition { Transition::None } fn render(&self, renderer: &mut Renderer) { let msg = [ "╔═══════════╗", "║ GAME OVER ║", "╚═══════════╝", ]; for (y, line) in msg.iter().enumerate() { for (x, c) in line.chars().enumerate() { renderer.put_cell(x as u16 + 34, y as u16 + 11, c, Color::White); } } } fn render_parent(&self) -> bool { true } fn handle_event(&mut self, _event: Event) -> Transition { Transition::Pop(2) } }
mod app; mod body; mod client; mod compress; mod conf; mod config; mod matcher; mod mime; mod option; mod server; mod util; use app::{run, RunType}; use body::BodyStream; use config::{default, Headers, ServerConfig, Setting, SiteConfig, Var}; use futures_util::future::join_all; use hyper::header::{ HeaderName, HeaderValue, ACCEPT_ENCODING, CONTENT_ENCODING, CONTENT_LENGTH, CONTENT_TYPE, HOST, LOCATION, SERVER, }; use hyper::Result as HyperResult; use hyper::{Body, HeaderMap, Request, Response, StatusCode, Version}; use std::net::IpAddr; use std::path::Path; use tokio::fs::{self, File}; use tokio::net::TcpListener; use tokio::runtime; fn main() { runtime::Builder::new_multi_thread() .thread_name(default::SERVER_NAME) .enable_all() .build() .unwrap_or_else(|err| exit!("Cannot create async runtime\n{:?}", err)) .block_on(async_main()); } async fn async_main() { let configs = match run() { RunType::Start(addr, path) => { let config = default::quick_start_config(path.clone(), addr); let port = match addr.port() { 80 => String::new(), _ => format!(":{}", addr.port()), }; println!("Serving path : {}", path.display()); println!( "Serving address: {}", format!("http://{}{}", addr.ip(), port) ); vec![config] } RunType::Config(config_path, is_test) => { let configs = ServerConfig::new(&config_path).await; // Check configuration file if is_test { return println!( "There are no errors in the configuration file '{}'", config_path ); } configs } }; bind_tcp(configs).await; } async fn bind_tcp(configs: Vec<ServerConfig>) { let mut servers = Vec::with_capacity(configs.len()); for config in configs { let listener = TcpListener::bind(&config.listen) .await .unwrap_or_else(|err| exit!("Cannot bind to address: '{}'\n{:?}", &config.listen, err)); servers.push(server::run(listener, config)); } join_all(servers).await; } fn get_match_config( req: &Request<Body>, configs: Vec<SiteConfig>, ) -> Result<Option<SiteConfig>, ()> { match req.version() { Version::HTTP_2 => { // todo Ok(Some(configs[0].clone())) } Version::HTTP_11 => { let host = match req.headers().get(HOST) { Some(header) => { // Delete port header .to_str() .unwrap_or_default() .split(':') .next() .unwrap_or_default() } // A Host header field must be sent in all HTTP/1.1 request messages // https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Host None => return Err(()), }; // Use the host in config to match the header host Ok(configs .into_iter() .find(|config| config.host.is_match(host))) } _ => { // No header host Ok(configs.into_iter().find(|config| config.host.is_empty())) } } } pub async fn connect( req: Request<Body>, remote: IpAddr, configs: Vec<SiteConfig>, ) -> HyperResult<Response<Body>> { let mut config = match get_match_config(&req, configs) { Ok(opt) => match opt { Some(config) => config, None => { return Ok(Response::error(StatusCode::FORBIDDEN)); } }, Err(_) => { return Ok(Response::error(StatusCode::BAD_REQUEST)); } }; // Decode request path let req_path = percent_encoding::percent_decode_str(req.uri().path()) .decode_utf8_lossy() .to_string(); // Merge location to config config = config.merge(&req_path); let mut header_map = HeaderMap::new(); if let Setting::Value(headers) = config.headers.clone() { headers_merge(&mut header_map, headers, &req); } let mut res = handle(req, req_path, remote, config).await; res.headers_mut().extend(header_map); // Add server name for all responses res.headers_mut() .insert(SERVER, HeaderValue::from_static(default::SERVER_NAME)); Ok(res) } async fn handle( req: Request<Body>, req_path: String, ip: IpAddr, mut config: SiteConfig, ) -> Response<Body> { // Record request log if let Setting::Value(logger) = &mut config.log { logger.write(&req).await; } // IP allow and deny if let Setting::Value(matcher) = &config.ip { if !matcher.is_pass(ip) { return Response::error(StatusCode::FORBIDDEN); } } // HTTP auth if let Setting::Value(auth) = &config.auth { if let Some(res) = auth.response(&req) { return res; } } // Proxy request if config.proxy.is_value() { let proxy = config.proxy.into_value(); config.proxy = Setting::None; return proxy.request(req, &config).await; } // Not allowed request method if let Setting::Value(method) = &config.method { if let Some(res) = method.response(&req) { return res; } } // echo: Output plain text if config.echo.is_value() { let echo = config.echo.into_value().map(|s, r| r.replace(s, &req)); return Response::new(Body::from(echo)).header(CONTENT_TYPE, mime::text_plain()); } // rewrite if config.rewrite.is_value() { return config.rewrite.into_value().response(&req); } let cur_path = format!(".{}", req_path); let path = match &config.root { Some(root) => { if let Setting::Value(p) = &config.file { p.clone() } else { Path::new(root).join(&cur_path) } } None => { if let Setting::Value(p) = &config.file { p.clone() } else { return response_error_page( req.headers().get(ACCEPT_ENCODING), &config, StatusCode::FORBIDDEN, ) .await; } } }; match FileRoute::new(&path, &req_path).await { FileRoute::Ok => { // . match File::open(&path).await { Ok(file) => { return response_file( StatusCode::OK, file, util::get_extension(&path), req.headers().get(ACCEPT_ENCODING), &config, ) .await; } Err(_) => { return response_error_page( req.headers().get(ACCEPT_ENCODING), &config, StatusCode::INTERNAL_SERVER_ERROR, ) .await; } } } FileRoute::Redirect => { let location = match req.uri().query() { Some(query) => format!("{}/{}", &req_path, query), None => format!("{}/", &req_path), }; Response::new(Body::empty()) .status(StatusCode::MOVED_PERMANENTLY) .header(LOCATION, HeaderValue::from_str(&location).unwrap()) } FileRoute::Directory => { if let Setting::Value(directory) = &config.directory { return match directory.render(&path, &req_path).await { Ok(html) => response_html(html, &req, &config).await, Err(_) => { response_error_page( req.headers().get(ACCEPT_ENCODING), &config, StatusCode::FORBIDDEN, ) .await } }; } if let Setting::Value(index) = &config.index { if let Some((file, ext)) = index.from_directory(path).await { return response_file( StatusCode::OK, file, Some(&ext), req.headers().get(ACCEPT_ENCODING), &config, ) .await; } } response_error_page( req.headers().get(ACCEPT_ENCODING), &config, StatusCode::NOT_FOUND, ) .await } FileRoute::Error => { // Use the 'config try' file to roll back if let Setting::Value(try_) = &config.try_ { if let Some((file, ext)) = try_files(&path, try_, &req).await { return response_file( StatusCode::OK, file, Some(&ext), req.headers().get(ACCEPT_ENCODING), &config, ) .await; } } response_error_page( req.headers().get(ACCEPT_ENCODING), &config, StatusCode::NOT_FOUND, ) .await } } } pub fn headers_merge(headers: &mut HeaderMap, new_headers: Headers, req: &Request<Body>) { for (name, value) in new_headers { let val = value.map(|s, r| { let v = r.replace(s, req); HeaderValue::from_str(&v).unwrap() }); headers.insert(name, val); } } pub async fn response_error_page( encoding: Option<&HeaderValue>, config: &SiteConfig, status: StatusCode, ) -> Response<Body> { if let Setting::Value(pages) = &config.error { if let Some(setting) = pages.get(&status) { if let Setting::Value(path) = setting { if util::is_file(path).await { if let Ok(f) = File::open(&path).await { return response_file( status, f, util::get_extension(path), encoding, config, ) .await; } } } } } Response::error(status) } async fn response_html(html: String, req: &Request<Body>, config: &SiteConfig) -> Response<Body> { let encoding = match &config.compress { Setting::Value(compress) => match req.headers().get(ACCEPT_ENCODING) { Some(header) => compress.get_compress_mode(header, "html"), None => None, }, _ => None, }; let (k, v) = match encoding { Some(encoding) => (CONTENT_ENCODING, encoding.to_header_value()), None => (CONTENT_LENGTH, HeaderValue::from(html.len())), }; let body = BodyStream::new(encoding).text(html); Response::new(body) .header(CONTENT_TYPE, mime::text_html()) .header(k, v) } async fn response_file( status: StatusCode, file: File, ext: Option<&str>, header: Option<&HeaderValue>, config: &SiteConfig, ) -> Response<Body> { let encoding = match &config.compress { Setting::Value(compress) => ext .map(|ext| { header .map(|header| compress.get_compress_mode(header, ext)) .unwrap_or_default() }) .unwrap_or_default(), _ => None, }; let header = match encoding { Some(encoding) => (CONTENT_ENCODING, encoding.to_header_value()), None => { let meta = file.metadata().await.unwrap(); (CONTENT_LENGTH, HeaderValue::from(meta.len())) } }; let body = BodyStream::new(encoding).file(file); Response::new(body) .status(status) .header(CONTENT_TYPE, mime::from_extension(ext.unwrap_or_default())) .header(header.0, header.1) } async fn try_files(_: &Path, _: &[Var<String>], _: &Request<Body>) -> Option<(File, String)> { todo!(); } trait ResponseExt<Body> { fn error(status: StatusCode) -> Self; fn status(self, status: StatusCode) -> Self; fn header(self, key: HeaderName, val: HeaderValue) -> Self; } impl ResponseExt<Body> for Response<Body> { fn error(status: StatusCode) -> Self { Response::new(Body::from(status.to_string())) .status(status) .header(CONTENT_TYPE, mime::text_plain()) } fn status(mut self, status: StatusCode) -> Self { *self.status_mut() = status; self } fn header(mut self, key: HeaderName, val: HeaderValue) -> Self { self.headers_mut().insert(key, val); self } } enum FileRoute { Error, Ok, Directory, Redirect, } impl FileRoute { async fn new(path: &Path, req_path: &str) -> Self { match fs::metadata(path).await { Ok(meta) => { if meta.is_dir() { if req_path.ends_with('/') { Self::Directory } else { Self::Redirect } } else { Self::Ok } } Err(_) => Self::Error, } } }
use proconio::input; fn main() { input! { n: usize, st: [(String, String); n], }; for i in 0..n { let (si, ti) = &st[i]; let mut ok_s = true; let mut ok_t = true; for j in 0..n { if i == j { continue; } let (sj, tj) = &st[j]; if si == sj || si == tj { ok_s = false; } if ti == sj || ti == tj { ok_t = false; } } if ok_s || ok_t { // ok } else { println!("No"); return; } } println!("Yes"); }
use crate::*; use rand::prelude::thread_rng; use wasmer_runtime::Ctx; pub fn rand_i32(ctx: &mut Ctx) -> Result<i32, ()> { let (_, env) = Process::get_memory_and_environment(ctx, 0); env.log_call("random_i32".to_string()); Ok(thread_rng().next_u32() as i32) } pub fn rand_u32(ctx: &mut Ctx) -> Result<u32, ()> { let (_, env) = Process::get_memory_and_environment(ctx, 0); env.log_call("random_u32".to_string()); Ok(thread_rng().next_u32()) } pub fn rand_i64(ctx: &mut Ctx) -> Result<i64, ()> { let (_, env) = Process::get_memory_and_environment(ctx, 0); env.log_call("random_i64".to_string()); Ok(thread_rng().next_u64() as i64) } pub fn rand_u64(ctx: &mut Ctx) -> Result<u64, ()> { let (_, env) = Process::get_memory_and_environment(ctx, 0); env.log_call("random_u64".to_string()); Ok(thread_rng().next_u64()) }
mod lib; fn main() { let rgb = lib::get_complementary_color(100, 150, 200); println!("{:?}", rgb); }
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[cfg(feature = "System_Power_Diagnostics")] pub mod Diagnostics; #[link(name = "windows")] extern "system" {} #[repr(transparent)] pub struct BatteryStatus(pub i32); impl BatteryStatus { pub const NotPresent: Self = Self(0i32); pub const Discharging: Self = Self(1i32); pub const Idle: Self = Self(2i32); pub const Charging: Self = Self(3i32); } impl ::core::marker::Copy for BatteryStatus {} impl ::core::clone::Clone for BatteryStatus { fn clone(&self) -> Self { *self } } #[repr(transparent)] pub struct EnergySaverStatus(pub i32); impl EnergySaverStatus { pub const Disabled: Self = Self(0i32); pub const Off: Self = Self(1i32); pub const On: Self = Self(2i32); } impl ::core::marker::Copy for EnergySaverStatus {} impl ::core::clone::Clone for EnergySaverStatus { fn clone(&self) -> Self { *self } } #[repr(transparent)] pub struct PowerSupplyStatus(pub i32); impl PowerSupplyStatus { pub const NotPresent: Self = Self(0i32); pub const Inadequate: Self = Self(1i32); pub const Adequate: Self = Self(2i32); } impl ::core::marker::Copy for PowerSupplyStatus {} impl ::core::clone::Clone for PowerSupplyStatus { fn clone(&self) -> Self { *self } }
use crate::dr; use crate::grammar; use crate::spirv; use std::collections; use crate::grammar::GlslStd450InstructionTable as GGlInstTable; use crate::grammar::OpenCLStd100InstructionTable as GClInstTable; type GExtInstRef = &'static grammar::ExtendedInstruction<'static>; // TODO: Add support for other types. #[derive(Clone, Copy, Debug, Eq, PartialEq)] pub enum Type { /// Integer type (size, signed). Integer(u32, bool), Float(u32), } /// Tracks ids to their types. /// /// If the type of an id cannot be resolved due to some reason, this will /// silently ignore that id instead of erroring out. #[derive(Debug)] pub struct TypeTracker { /// Mapping from an id to its type. /// /// Ids for both defining and using types are all kept here. types: collections::HashMap<spirv::Word, Type>, } impl TypeTracker { pub fn new() -> TypeTracker { TypeTracker { types: collections::HashMap::new(), } } pub fn track(&mut self, inst: &dr::Instruction) { if let Some(rid) = inst.result_id { if grammar::reflect::is_type(inst.class.opcode) { match inst.class.opcode { spirv::Op::TypeInt => { if let ( &dr::Operand::LiteralBit32(bits), &dr::Operand::LiteralBit32(sign), ) = (&inst.operands[0], &inst.operands[1]) { self.types.insert(rid, Type::Integer(bits, sign == 1)); } } spirv::Op::TypeFloat => { if let dr::Operand::LiteralBit32(bits) = inst.operands[0] { self.types.insert(rid, Type::Float(bits)); } } // TODO: handle the other types here. _ => (), } } else { inst.result_type .and_then(|t| self.resolve(t)) .map(|t| self.types.insert(rid, t)); } } } pub fn resolve(&self, id: spirv::Word) -> Option<Type> { self.types.get(&id).cloned() } } #[allow(clippy::upper_case_acronyms)] enum ExtInstSet { GlslStd450, OpenCLStd100, } /// Struct for tracking extended instruction sets. /// /// If a given extended instruction set is not supported, it will just be /// silently ignored. pub struct ExtInstSetTracker { sets: collections::HashMap<spirv::Word, ExtInstSet>, } impl ExtInstSetTracker { pub fn new() -> ExtInstSetTracker { ExtInstSetTracker { sets: collections::HashMap::new(), } } /// Tracks the extended instruction set declared by the given `inst`. /// /// If the given extended instruction set is not recognized, it will /// be silently ignored. pub fn track(&mut self, inst: &dr::Instruction) { if inst.class.opcode != spirv::Op::ExtInstImport || inst.result_id.is_none() || inst.operands.is_empty() { return; } if let dr::Operand::LiteralString(ref s) = inst.operands[0] { if s == "GLSL.std.450" { self.sets .insert(inst.result_id.unwrap(), ExtInstSet::GlslStd450); } else if s == "OpenCL.std" { self.sets .insert(inst.result_id.unwrap(), ExtInstSet::OpenCLStd100); } } } /// Returns true if the given extended instruction `set` has been /// recognized thus tracked. pub fn have(&self, set: spirv::Word) -> bool { self.sets.get(&set).is_some() } /// Resolves the extended instruction with `opcode` in set `set`. /// /// This method will return `None` for both untracked instruction /// sets and unknown opcode in tracked instruction sets. pub fn resolve(&self, set: spirv::Word, opcode: spirv::Word) -> Option<GExtInstRef> { if let Some(ext_inst_set) = self.sets.get(&set) { match *ext_inst_set { ExtInstSet::GlslStd450 => GGlInstTable::lookup_opcode(opcode), ExtInstSet::OpenCLStd100 => GClInstTable::lookup_opcode(opcode), } } else { None } } }
use crate::parser::{Handle, NodeData}; use std::collections::VecDeque; use std::io; use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode}; use html5ever::serialize::{Serialize, Serializer, TraversalScope}; use html5ever::QualName; enum SerializeOp { Open(Handle), Close(QualName), } pub struct SerializableHandle(Handle); impl From<Handle> for SerializableHandle { fn from(h: Handle) -> SerializableHandle { SerializableHandle(h) } } impl Serialize for SerializableHandle { fn serialize<S>(&self, serializer: &mut S, traversal_scope: TraversalScope) -> io::Result<()> where S: Serializer, { let mut ops = VecDeque::new(); match traversal_scope { IncludeNode => ops.push_back(SerializeOp::Open(self.0.clone())), ChildrenOnly(_) => ops.extend( self.0 .children .borrow() .iter() .map(|h| SerializeOp::Open(h.clone())), ), } while let Some(op) = ops.pop_front() { match op { SerializeOp::Open(handle) => match handle.data { NodeData::Element { ref name, ref attrs, .. } => { serializer.start_elem( name.clone(), attrs.borrow().iter().map(|at| (&at.name, &at.value[..])), )?; ops.reserve(1 + handle.children.borrow().len()); ops.push_front(SerializeOp::Close(name.clone())); for child in handle.children.borrow().iter().rev() { ops.push_front(SerializeOp::Open(child.clone())); } } NodeData::Doctype { ref name, .. } => serializer.write_doctype(&name)?, NodeData::Text { ref contents } => serializer.write_text(&contents.borrow())?, NodeData::Comment { ref contents } => serializer.write_comment(&contents)?, NodeData::ProcessingInstruction { ref target, ref contents, } => serializer.write_processing_instruction(target, contents)?, NodeData::Document => panic!("Can't serialize Document node itself"), }, SerializeOp::Close(name) => { serializer.end_elem(name)?; } } } Ok(()) } }
#[macro_use] extern crate bitflags; #[macro_use] extern crate lazy_static; extern crate winapi; #[cfg(feature="flexbox")] pub extern crate stretch; #[cfg(feature="all")] #[cfg(test)] mod tests; mod errors; pub use errors::{NwgError}; mod events; pub use events::*; mod common_types; pub use common_types::*; pub(crate) mod win32; pub use win32::{ dispatch_thread_events, dispatch_thread_events_with_callback, stop_thread_dispatch, enable_visual_styles, init_common_controls, window::{ EventHandler, RawEventHandler, full_bind_event_handler, bind_event_handler, unbind_event_handler, bind_raw_event_handler, has_raw_handler, unbind_raw_event_handler }, message_box::* }; pub(crate) use win32::window::bind_raw_event_handler_inner; #[allow(deprecated)] pub use win32::high_dpi::{set_dpi_awareness, scale_factor, dpi}; pub use win32::monitor::Monitor; #[cfg(feature="cursor")] pub use win32::cursor::GlobalCursor; #[cfg(feature="clipboard")] pub use win32::clipboard::{Clipboard, ClipboardFormat, ClipboardData}; mod resources; pub use resources::*; mod controls; pub use controls::*; mod layouts; pub use layouts::*; #[cfg(feature = "winnls")] mod winnls; #[cfg(feature = "winnls")] pub use winnls::*; /** A structure that implements this trait is considered a GUI structure. The structure will hold GUI components and possibly user data. A structure that implements `PartialUi` must be part of another UI structure and cannot be used as it is. It will most likely be used as the struct member of another struct that implements `NativeUi`. The goal of `NativeUi` and `PartialUi` is to provide a common way to define NWG applications. Native-windows-derive can automatically implement this trait. For an example on how to implement this trait, see the **Small application layout** section in the NWG documentation. */ pub trait PartialUi { /** Should initialize the GUI components. Similar to `NativeUi::build_ui` except it doesn't handle event binding. Parameters: - `data`: A reference to the struct data from the parent struct - `parent`: An optional reference to the parent UI control. If this is defined, the ui controls of the partial should be children of this value. */ fn build_partial<W: Into<ControlHandle>>(data: &mut Self, parent: Option<W>) -> Result<(), NwgError>; /** Should process the events of the partial. This method will probably be called from an event handler bound in the parent GUI structure. Parameters: - `base`: A reference to the parent struct data - `evt`: The event raised - `evt_data`: The data of the event raised - `handle`: Handle of the control that raised the event */ fn process_event(&self, _evt: Event, _evt_data: &EventData, _handle: ControlHandle) {} /** Should return the handles of the top level parent controls (such as Windows). Those handle should be used to bind the default events handler. */ fn handles<'a>(&'a self) -> Vec<&'a ControlHandle> { vec![] } } /** A structure that implements this trait is considered a GUI structure. The structure will hold GUI components and possibly user data. The goal of `NativeUi` and `PartialUi` is to provide a common way to define NWG applications. Native-windows-derive can automatically implement this trait. For an example on how to implement this trait, see the **Small application layout** section in the NWG documentation. */ pub trait NativeUi<UI> { /** A constructor for the structure. It should initialize the GUI components and bind GUI events. Parameters: - `inital_state`: should contain the initial user data. `NativeUi` assumes this data will be wrapped in another type (`UI`). */ fn build_ui(inital_state: Self) -> Result<UI, NwgError>; } /// Initializes some application wide GUI settings. /// This includes default styling and common controls resources. pub fn init() -> std::result::Result<(), errors::NwgError> { if cfg!(not(feature="no-styling")) { enable_visual_styles(); } init_common_controls() }
#[macro_use] extern crate log; use std::env; use std::error::Error; use std::io::Write; use std::os::unix::net::UnixStream; use clap::Clap; use env_logger::Env; use crate::cli::Opts; mod cli; fn current_exe() -> String { std::env::current_exe() .ok() .unwrap() .file_name() .unwrap() .to_str() .unwrap() .to_owned() } /// Initialize the logger. fn init_logger(opts: &Opts) { let app = current_exe(); let env = Env::default().default_filter_or(match opts.verbose { 0 => format!("{}=error", app), 1 => format!("{}=info", app), 2 => format!("{}=debug", app), _ => "trace".to_string(), }); env_logger::from_env(env) .format(|buf, record| { let level_style = buf.default_level_style(record.level()); writeln!( buf, "[{} {:>5}]: {}", buf.timestamp(), level_style.value(record.level()), record.args() ) }) .init(); } fn main() -> Result<(), Box<dyn Error>> { let opts: Opts = Opts::parse(); init_logger(&opts); let mut stream = UnixStream::connect(&opts.socket).unwrap_or_else(|e| { error!("Cannot connect to the socket \"{}\" : {}.", opts.socket, e); std::process::exit(1); }); let args: Vec<String> = env::args().collect(); stream.write_all(args.join(" ").as_bytes())?; // TODO: Wait for a reply. Ok(()) }
use std::collections::HashMap; use std::fs::File; use std::rc::Rc; use std::str::FromStr; use bigint::{Address, Gas, H256, M256, U256}; use block::TransactionAction; use evm::errors::RequireError; use evm::{AccountChange, AccountCommitment, HeaderParams, Log, Patch, SeqTransactionVM, ValidTransaction, VM}; use evm_network_classic::{MainnetEIP150Patch, MainnetEIP160Patch, MainnetFrontierPatch, MainnetHomesteadPatch}; use gethrpc::{ CachedGethRPCClient, GethRPCClient, NormalGethRPCClient, RPCBlock, RPCLog, RPCTransaction, RecordGethRPCClient, }; use hexutil::*; fn from_rpc_block(block: &RPCBlock) -> HeaderParams { HeaderParams { beneficiary: Address::from_str(&block.miner).unwrap(), timestamp: U256::from_str(&block.timestamp).unwrap().into(), number: U256::from_str(&block.number.as_ref().unwrap()).unwrap(), difficulty: U256::from_str(&block.difficulty).unwrap(), gas_limit: Gas::from_str(&block.gas_limit).unwrap(), } } fn from_rpc_transaction(transaction: &RPCTransaction) -> ValidTransaction { ValidTransaction { caller: Some(Address::from_str(&transaction.from).unwrap()), action: if transaction.to.is_none() { TransactionAction::Create } else { TransactionAction::Call(Address::from_str(&transaction.to.as_ref().unwrap()).unwrap()) }, value: U256::from_str(&transaction.value).unwrap(), gas_limit: Gas::from_str(&transaction.gas).unwrap(), gas_price: Gas::from_str(&transaction.gas_price).unwrap(), input: Rc::new(read_hex(&transaction.input).unwrap()), nonce: U256::from_str(&transaction.nonce).unwrap(), } } fn from_rpc_log(log: &RPCLog) -> Log { let mut topics: Vec<H256> = Vec::new(); for topic in &log.topics { topics.push(H256::from_str(&topic).unwrap()); } Log { address: Address::from_str(&log.address).unwrap(), data: read_hex(&log.data).unwrap(), topics, } } fn handle_fire<T: GethRPCClient, P: Patch>(client: &mut T, vm: &mut SeqTransactionVM<P>, last_block_id: usize) { let last_block_number = format!("0x{:x}", last_block_id); loop { match vm.fire() { Ok(()) => { println!("VM exited with {:?}.", vm.status()); break; } Err(RequireError::Account(address)) => { println!("Feeding VM account at 0x{:x} ...", address); let nonce = U256::from_str(&client.get_transaction_count(&format!("0x{:x}", address), &last_block_number)) .unwrap(); let balance = U256::from_str(&client.get_balance(&format!("0x{:x}", address), &last_block_number)).unwrap(); let code = read_hex(&client.get_code(&format!("0x{:x}", address), &last_block_number)).unwrap(); if !client.account_exist(&format!("0x{:x}", address), last_block_id) { vm.commit_account(AccountCommitment::Nonexist(address)).unwrap(); } else { vm.commit_account(AccountCommitment::Full { nonce, address, balance, code: Rc::new(code), }) .unwrap(); } } Err(RequireError::AccountStorage(address, index)) => { println!( "Feeding VM account storage at 0x{:x} with index 0x{:x} ...", address, index ); let value = M256::from_str(&client.get_storage_at( &format!("0x{:x}", address), &format!("0x{:x}", index), &last_block_number, )) .unwrap(); vm.commit_account(AccountCommitment::Storage { address, index, value }) .unwrap(); } Err(RequireError::AccountCode(address)) => { println!("Feeding VM account code at 0x{:x} ...", address); let code = read_hex(&client.get_code(&format!("0x{:x}", address), &last_block_number)).unwrap(); vm.commit_account(AccountCommitment::Code { address, code: Rc::new(code), }) .unwrap(); } Err(RequireError::Blockhash(number)) => { println!("Feeding blockhash with number 0x{:x} ...", number); let hash = H256::from_str( &client .get_block_by_number(&format!("0x{:x}", number)) .unwrap() .hash .unwrap(), ) .unwrap(); vm.commit_blockhash(number, hash).unwrap(); } } } } fn is_miner_or_uncle<T: GethRPCClient>(client: &mut T, address: Address, block: &RPCBlock) -> bool { // Give up balance testing if the address is a miner or an uncle. let miner = Address::from_str(&block.miner).unwrap(); if miner == address { return true; } if !block.uncles.is_empty() { for i in 0..block.uncles.len() { let uncle = client .get_uncle_by_block_number_and_index(block.number.as_ref().unwrap(), &format!("0x{:x}", i)) .unwrap(); let uncle_miner = Address::from_str(&uncle.miner).unwrap(); if uncle_miner == address { return true; } } } false } fn test_block<T: GethRPCClient, P: Patch + Default + Clone>(client: &mut T, number: usize) { let block = client.get_block_by_number(format!("0x{:x}", number).as_str()).unwrap(); println!( "block {} ({}), transaction count: {}", number, block.number.as_ref().unwrap(), block.transactions.len() ); let last_id = number - 1; let last_number = format!("0x{:x}", last_id); let cur_number = block.number.clone().unwrap(); let block_header = from_rpc_block(&block); let patch = P::default(); let mut last_vm: Option<SeqTransactionVM<P>> = None; for transaction_hash in &block.transactions { println!("\nworking on transaction {}", transaction_hash); let transaction = from_rpc_transaction(&client.get_transaction_by_hash(&transaction_hash).unwrap()); let receipt = client.get_transaction_receipt(&transaction_hash).unwrap(); let mut vm = if let Some(last_vm) = last_vm.take() { SeqTransactionVM::with_previous(transaction, block_header.clone(), &last_vm) } else { SeqTransactionVM::new(&patch, transaction, block_header.clone()) }; handle_fire(client, &mut vm, last_id); assert_eq!(Gas::from_str(&receipt.gas_used).unwrap(), vm.used_gas()); assert_eq!(receipt.logs.len(), vm.logs().len()); for i in 0..receipt.logs.len() { assert_eq!(from_rpc_log(&receipt.logs[i]), vm.logs()[i]); } last_vm = Some(vm); } if last_vm.is_some() { for account in last_vm.as_ref().unwrap().accounts() { match *account { AccountChange::Full { address, balance, ref changing_storage, .. } => { if !is_miner_or_uncle(client, address, &block) { let expected_balance = client.get_balance(&format!("0x{:x}", address), &cur_number); assert!(U256::from_str(&expected_balance).unwrap() == balance); } let changing_storage: HashMap<U256, M256> = changing_storage.clone().into(); for (key, value) in changing_storage { let expected_value = client.get_storage_at(&format!("0x{:x}", address), &format!("0x{:x}", key), &cur_number); assert_eq!(M256::from_str(&expected_value).unwrap(), value); } } AccountChange::Create { address, balance, ref storage, .. } => { if !is_miner_or_uncle(client, address, &block) { let expected_balance = client.get_balance(&format!("0x{:x}", address), &cur_number); assert!(U256::from_str(&expected_balance).unwrap() == balance); } let storage: HashMap<U256, M256> = storage.clone().into(); for (key, value) in storage { let expected_value = client.get_storage_at(&format!("0x{:x}", address), &format!("0x{:x}", key), &cur_number); assert_eq!(M256::from_str(&expected_value).unwrap(), value); } } AccountChange::IncreaseBalance(address, balance) => { if !is_miner_or_uncle(client, address, &block) { let last_balance = client.get_balance(&format!("0x{:x}", address), &last_number); let cur_balance = client.get_balance(&format!("0x{:x}", address), &cur_number); assert_eq!( U256::from_str(&last_balance).unwrap() + balance, U256::from_str(&cur_balance).unwrap() ); } } AccountChange::Nonexist(address) => { if !is_miner_or_uncle(client, address, &block) { let expected_balance = client.get_balance(&format!("0x{:x}", address), &cur_number); assert_eq!(U256::from_str(&expected_balance).unwrap(), U256::zero()); } } } } } } fn test_blocks_patch<T: GethRPCClient>(client: &mut T, number: &str, patch: Option<&str>) { match patch { Some("frontier") => test_blocks::<_, MainnetFrontierPatch>(client, number), Some("homestead") => test_blocks::<_, MainnetHomesteadPatch>(client, number), Some("eip150") => test_blocks::<_, MainnetEIP150Patch>(client, number), Some("eip160") => test_blocks::<_, MainnetEIP160Patch>(client, number), _ => panic!("Unknown patch."), } } fn test_blocks<T: GethRPCClient, P: Patch + Default + Clone>(client: &mut T, number: &str) { if number.contains(".json") { let file = File::open(number).unwrap(); let numbers: Vec<usize> = serde_json::from_reader(file).unwrap(); for n in numbers { test_block::<_, P>(client, n); } } else if number.contains("..") { let number: Vec<&str> = number.split("..").collect(); let from = usize::from_str_radix(&number[0], 10).unwrap(); let to = usize::from_str_radix(&number[1], 10).unwrap(); for n in from..to { test_block::<_, P>(client, n); } } else if number.contains(',') { let numbers: Vec<&str> = number.split("..").collect(); for number in numbers { let n = usize::from_str_radix(number, 10).unwrap(); test_block::<_, P>(client, n); } } else { let number = usize::from_str_radix(&number, 10).unwrap(); test_block::<_, P>(client, number); } } use clap::clap_app; fn main() { let matches = clap_app!(regtests => (version: "0.1") (author: "Ethereum Classic Contributors") (about: "Performs an regression test on the entire Ethereum Classic blockchain.\n\nSteps to reproduce:\n* Install Ethereum Classic Geth: `$ go install github.com/ethereumproject/go-ethereum/cmd/geth`.\n* Run Geth with this command: `$ ~/go/bin/geth --rpc --rpcaddr 127.0.0.1 --rpcport 8545`.\n* Wait for the chain to sync.\n* Change directory into the `regtests` directory `$ cd regtests`\n* Run this command: `$ RUST_BACKTRACE=1 cargo run --bin regtests -- -r http://127.0.0.1:8545") (@arg RPC: -r --rpc +takes_value +required "Domain of Ethereum Classic Geth's RPC endpoint. e.g. `-r http://127.0.0.1:8545`.") (@arg NUMBER: -n --number +takes_value +required "Block number to run this test. Radix is 10. e.g. `-n 49439`.") (@arg RECORD: --record +takes_value "Record to file path.") (@arg PATCH: -p --patch +takes_value +required "Patch to be used, homestead or frontier.") ).get_matches(); let address = matches.value_of("RPC").unwrap(); let number = matches.value_of("NUMBER").unwrap(); let record = matches.value_of("RECORD"); let patch = matches.value_of("PATCH"); if address.contains(".json") { let file = File::open(address).unwrap(); let cached: serde_json::Value = serde_json::from_reader(file).unwrap(); let mut client = CachedGethRPCClient::from_value(cached); test_blocks_patch(&mut client, number, patch); } else { match record { Some(val) => { let mut file = File::create(val).unwrap(); let mut client = RecordGethRPCClient::new(address); test_blocks_patch(&mut client, number, patch); serde_json::to_writer(&mut file, &client.to_value()).unwrap(); } None => { let mut client = NormalGethRPCClient::new(address); test_blocks_patch(&mut client, number, patch); } } } } #[cfg(test)] #[test] fn test_all_previously_failed_frontier_blocks() { let cached: serde_json::Value = serde_json::from_str(include_str!("../../res/frontier_records.json")).unwrap(); let numbers: Vec<usize> = serde_json::from_str(include_str!("../../res/frontier_numbers.json")).unwrap(); let mut client = CachedGethRPCClient::from_value(cached); for n in numbers { test_block::<_, MainnetFrontierPatch>(&mut client, n); } } #[cfg(test)] #[test] fn test_all_previously_failed_homestead_blocks() { let cached: serde_json::Value = serde_json::from_str(include_str!("../../res/homestead_records.json")).unwrap(); let numbers: Vec<usize> = serde_json::from_str(include_str!("../../res/homestead_numbers.json")).unwrap(); let mut client = CachedGethRPCClient::from_value(cached); for n in numbers { test_block::<_, MainnetHomesteadPatch>(&mut client, n); } } #[cfg(test)] #[test] fn test_all_previously_failed_eip150_blocks() { let cached: serde_json::Value = serde_json::from_str(include_str!("../../res/eip150_records.json")).unwrap(); let numbers: Vec<usize> = serde_json::from_str(include_str!("../../res/eip150_numbers.json")).unwrap(); let mut client = CachedGethRPCClient::from_value(cached); for n in numbers { test_block::<_, MainnetEIP150Patch>(&mut client, n); } }
//! Tool to clean up old object store files that don't appear in the catalog. #![deny( rustdoc::broken_intra_doc_links, rust_2018_idioms, missing_debug_implementations, unreachable_pub )] #![warn( missing_docs, clippy::todo, clippy::dbg_macro, clippy::clone_on_ref_ptr, // See https://github.com/influxdata/influxdb_iox/pull/1671 clippy::future_not_send, clippy::todo, clippy::dbg_macro, unused_crate_dependencies )] #![allow(clippy::missing_docs_in_private_items)] // Workaround for "unused crate" lint false positives. use workspace_hack as _; use async_trait::async_trait; use futures::{ future::{BoxFuture, Shared}, prelude::*, }; use garbage_collector::GarbageCollector; use hyper::{Body, Request, Response}; use ioxd_common::{ http::error::{HttpApiError, HttpApiErrorCode, HttpApiErrorSource}, rpc::RpcBuilderInput, serve_builder, server_type::{RpcError, ServerType}, setup_builder, }; use metric::Registry; use snafu::prelude::*; use std::{fmt::Debug, sync::Arc, time::Duration}; use tokio::{select, sync::broadcast, task::JoinError, time}; use tokio_util::sync::CancellationToken; use trace::TraceCollector; pub use garbage_collector::Config; /// The object store garbage collection server pub struct Server { metric_registry: Arc<metric::Registry>, worker: SharedCloneError<(), JoinError>, shutdown_tx: broadcast::Sender<()>, } impl Debug for Server { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { f.debug_struct("Server(GarbageCollector)") .finish_non_exhaustive() } } impl Server { /// Construct and start the object store garbage collector pub fn start(metric_registry: Arc<metric::Registry>, config: Config) -> Self { let (shutdown_tx, shutdown_rx) = broadcast::channel(1); let worker = tokio::spawn(Self::worker_task(config, shutdown_rx)); let worker = shared_clone_error(worker); Self { metric_registry, worker, shutdown_tx, } } async fn worker_task(config: Config, mut shutdown_rx: broadcast::Receiver<()>) { const ONE_HOUR: u64 = 60 * 60; let mut minimum_next_start_time = time::interval(Duration::from_secs(ONE_HOUR)); loop { // Avoid a hot infinite loop when there's nothing to delete select! { _ = shutdown_rx.recv() => return, _ = minimum_next_start_time.tick() => {}, } let handle = GarbageCollector::start(config.clone()) .context(StartGarbageCollectorSnafu) .unwrap_or_report(); let shutdown_garbage_collector = handle.shutdown_handle(); let mut complete = shared_clone_error(handle.join()); loop { select! { _ = shutdown_rx.recv() => { shutdown_garbage_collector(); complete.await.context(JoinGarbageCollectorSnafu).unwrap_or_report(); return; }, v = &mut complete => { v.context(JoinGarbageCollectorSnafu).unwrap_or_report(); break; }, } } } } } #[async_trait] impl ServerType for Server { fn name(&self) -> &str { "gc" } fn metric_registry(&self) -> Arc<Registry> { Arc::clone(&self.metric_registry) } fn trace_collector(&self) -> Option<Arc<dyn TraceCollector>> { None } async fn route_http_request( &self, _req: Request<Body>, ) -> Result<Response<Body>, Box<dyn HttpApiErrorSource>> { Err(Box::new(HttpNotFound)) } async fn server_grpc(self: Arc<Self>, builder_input: RpcBuilderInput) -> Result<(), RpcError> { let builder = setup_builder!(builder_input, self); serve_builder!(builder); Ok(()) } async fn join(self: Arc<Self>) { self.worker .clone() .await .context(JoinWorkerSnafu) .unwrap_or_report(); } fn shutdown(&self, frontend: CancellationToken) { frontend.cancel(); self.shutdown_tx.send(()).ok(); } } #[derive(Debug, Snafu)] struct HttpNotFound; impl HttpApiErrorSource for HttpNotFound { fn to_http_api_error(&self) -> HttpApiError { HttpApiError::new(HttpApiErrorCode::NotFound, self.to_string()) } } #[derive(Debug, Snafu)] #[allow(missing_docs)] pub enum Error { #[snafu(display("Could not start the garbage collector"))] StartGarbageCollector { source: garbage_collector::Error }, #[snafu(display("Could not join the garbage collector"))] JoinGarbageCollector { source: Arc<garbage_collector::Error>, }, #[snafu(display("Could not join the garbage collector worker task"))] JoinWorker { source: Arc<JoinError> }, } #[allow(missing_docs)] pub type Result<T, E = Error> = std::result::Result<T, E>; trait UnwrapOrReportExt<T> { fn unwrap_or_report(self) -> T; } impl<T> UnwrapOrReportExt<T> for Result<T> { fn unwrap_or_report(self) -> T { match self { Ok(v) => v, Err(e) => { use snafu::ErrorCompat; use std::fmt::Write; let mut message = String::new(); writeln!(message, "{e}").unwrap(); for cause in ErrorCompat::iter_chain(&e).skip(1) { writeln!(message, "Caused by: {cause}").unwrap(); } panic!("{message}"); } } } } type SharedCloneError<T, E> = Shared<BoxFuture<'static, Result<T, Arc<E>>>>; fn shared_clone_error<F>(handle: F) -> SharedCloneError<F::Ok, F::Error> where F: TryFuture + Send + 'static, F::Ok: Clone, { handle.map_err(Arc::new).boxed().shared() }
pub fn initialize() { unsafe { ::libnx::consoleInit(std::ptr::null_mut()); } } pub fn exit() { unsafe { ::libnx::consoleExit(std::ptr::null_mut()); } } pub fn clear() { unsafe { ::libnx::consoleClear(); } } pub fn flush() { unsafe { ::libnx::consoleUpdate(std::ptr::null_mut()); } }
use crate::AbstractContext; use crate::Context; use crate::NativeVertexBuffer; /// Holds a GL buffer and lets you upload it to the GPU. pub struct VertexBuffer { buffer: NativeVertexBuffer, } impl VertexBuffer { /// Creates a new buffor of the selected type. pub fn new() -> Self { let context = Context::get_context(); let buffer = context .create_vertexbuffer() .expect("Failed to create frame buffer"); VertexBuffer { buffer } } /// Binds the buffer to the GPU. pub fn bind(&self) { let context = Context::get_context(); context.bind_vertexbuffer(Some(&self.buffer)); } pub fn unbind(&self) { let context = Context::get_context(); context.bind_vertexbuffer(None); } } impl Drop for VertexBuffer { fn drop(&mut self) { let context = Context::get_context(); context.delete_vertexbuffer(&self.buffer); } }
tonic::include_proto!("engine");
//! Adapted from: //! - https://doc.rust-lang.org/src/std/sys/unix/pipe.rs.html //! - https://doc.rust-lang.org/src/std/sys/unix/fd.rs.html#385 //! - https://github.com/rust-lang/rust/blob/master/library/std/src/sys/mod.rs#L57 //! - https://github.com/oconnor663/os_pipe.rs use std::fs::File; /// Open a new pipe and return a pair of [`File`] objects for the reader and writer. /// /// This corresponds to the `pipe2` library call on Posix and the /// `CreatePipe` library call on Windows (though these implementation /// details might change). These pipes are non-inheritable, so new child /// processes won't receive a copy of them unless they're explicitly /// passed as stdin/stdout/stderr. pub fn pipe() -> std::io::Result<(File, File)> { sys::pipe() } #[cfg(unix)] #[path = "os_pipe/unix.rs"] mod sys; #[cfg(windows)] #[path = "os_pipe/windows.rs"] mod sys; #[cfg(all(not(unix), not(windows)))] compile_error!("Only unix and windows support os_pipe!");
use criterion::{criterion_group, criterion_main, Criterion}; use crypto::{ encryption::ElGamal, helper::Helper, proofs::keygen::KeyGenerationProof, types::{Cipher, PublicKey}, }; use num_bigint::BigUint; use num_traits::One; fn setup_shuffling( nr_of_votes: usize, encoded: bool, pk: PublicKey, ) -> (Vec<Cipher>, Vec<usize>, Vec<BigUint>, PublicKey) { let q = pk.params.q(); // encryption of three and one let three = BigUint::from(3u32); let r = BigUint::parse_bytes(b"1234", 10).unwrap(); let one = BigUint::one(); let r_ = BigUint::parse_bytes(b"4321", 10).unwrap(); let enc_three: Cipher; let enc_one: Cipher; if encoded { enc_three = ElGamal::encrypt_encode(&three, &r, &pk); enc_one = ElGamal::encrypt_encode(&one, &r_, &pk); } else { enc_three = ElGamal::encrypt(&three, &r, &pk); enc_one = ElGamal::encrypt(&one, &r_, &pk); } let mut encryptions: Vec<Cipher> = Vec::new(); let mut randoms: Vec<BigUint> = Vec::new(); let power = BigUint::parse_bytes(b"ABCDEF123456789ABCDEF123412341241241241124", 16).unwrap(); let mut permutation: Vec<usize> = Vec::new(); for i in 0..nr_of_votes { permutation.push(i); let mut random = BigUint::from(i); random *= BigUint::from(i); random = random.modpow(&power, &q); randoms.push(random); if i % 2 == 0 { encryptions.push(enc_three.clone()); } else { encryptions.push(enc_one.clone()); } } // create a fake permutation permutation.reverse(); assert!(encryptions.len() == randoms.len()); assert!(encryptions.len() == permutation.len()); assert!(encryptions.len() == nr_of_votes); (encryptions, permutation, randoms, pk) } fn bench_elgamal(c: &mut Criterion) { // benchmark config let mut group = c.benchmark_group("elgamal"); group.bench_function("encryption_encoded", |b| { b.iter_with_setup( || { let (_, _, pk) = Helper::setup_lg_system(); let message = BigUint::from(1u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); (message, random, pk) }, |(m, r, pk)| ElGamal::encrypt_encode(&m, &r, &pk), ) }); group.bench_function("decryption_encoded", |b| { b.iter_with_setup( || { let (_, sk, pk) = Helper::setup_lg_system(); let message = BigUint::from(1u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // encrypt the message let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); (encrypted_message, sk) }, |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), ) }); group.bench_function("encryption", |b| { b.iter_with_setup( || { let (_, _, pk) = Helper::setup_lg_system(); let message = BigUint::from(1u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); (message, random, pk) }, |(m, r, pk)| ElGamal::encrypt(&m, &r, &pk), ) }); group.bench_function("decryption", |b| { b.iter_with_setup( || { let (_, sk, pk) = Helper::setup_lg_system(); let message = BigUint::from(1u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // encrypt the message let encrypted_message = ElGamal::encrypt(&message, &random, &pk); (encrypted_message, sk) }, |(encrypted_message, sk)| ElGamal::decrypt(&encrypted_message, &sk), ) }); group.bench_function("homomorphic addition", |b| { b.iter_with_setup( || { let (params, _, pk) = Helper::setup_lg_system(); let one = BigUint::one(); // encrypt the message let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); let enc_one = ElGamal::encrypt_encode(&one, &r, &pk); // encrypt the message again let r_ = BigUint::parse_bytes(b"170141183460469231731687303712342", 10).unwrap(); let enc_one_ = ElGamal::encrypt_encode(&one, &r_, &pk); (enc_one, enc_one_, params.p) }, |(enc_one, enc_one_, p)| ElGamal::homomorphic_addition(&enc_one, &enc_one_, &p), ) }); group.bench_function("re_encryption_encoded", |b| { b.iter_with_setup( || { let (_, _, pk) = Helper::setup_lg_system(); let one = BigUint::one(); // encrypt the message let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); let encryption = ElGamal::encrypt_encode(&one, &r, &pk); // use another random value for the re_encryption let r_ = BigUint::parse_bytes(b"170141183460469231731687303712342", 10).unwrap(); (encryption, r_, pk) }, |(encryption, r_, pk)| ElGamal::re_encrypt(&encryption, &r_, &pk), ) }); group.bench_function("re_encryption", |b| { b.iter_with_setup( || { let (_, _, pk) = Helper::setup_lg_system(); let one = BigUint::one(); // encrypt the message let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); let encryption = ElGamal::encrypt(&one, &r, &pk); // use another random value for the re_encryption let r_ = BigUint::parse_bytes(b"170141183460469231731687303712342", 10).unwrap(); (encryption, r_, pk) }, |(encryption, r_, pk)| ElGamal::re_encrypt(&encryption, &r_, &pk), ) }); group.bench_function("re_encryption by homomorphic addition zero (g^0)", |b| { b.iter_with_setup( || { let (_, _, pk) = Helper::setup_lg_system(); let one = BigUint::one(); // encrypt the message let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); let encryption = ElGamal::encrypt_encode(&one, &r, &pk); // use another random value for the re_encryption let r_ = BigUint::parse_bytes(b"170141183460469231731687303712342", 10).unwrap(); (encryption, r_, pk) }, |(encryption, r_, pk)| ElGamal::re_encrypt_via_addition(&encryption, &r_, &pk), ) }); } fn bench_proofs(c: &mut Criterion) { // benchmark config let mut group = c.benchmark_group("proofs"); group.bench_function("keygen proof: generate proof", |b| { b.iter_with_setup( || { let sealer_id = "Bob".as_bytes(); let (params, sk, pk) = Helper::setup_lg_system(); let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); (params, sk.x, pk.h, r, sealer_id) }, |(params, x, h, r, sealer_id)| { KeyGenerationProof::generate(&params, &x, &h, &r, sealer_id) }, ) }); group.bench_function("keygen proof: verify proof", |b| { b.iter_with_setup( || { let sealer_id = "Bob".as_bytes(); let (params, sk, pk) = Helper::setup_lg_system(); let r = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); let proof = KeyGenerationProof::generate(&params, &sk.x, &pk.h, &r, sealer_id); (params, pk.h, proof, sealer_id) }, |(params, h, proof, sealer_id)| { KeyGenerationProof::verify(&params, &h, &proof, sealer_id) }, ) }); } fn bench_shuffle(c: &mut Criterion) { let (_, _, pk1) = Helper::setup_256bit_system(); let (_, _, pk2) = Helper::setup_512bit_system(); let (_, _, pk3) = Helper::setup_md_system(); let (_, _, pk4) = Helper::setup_lg_system(); let (_, _, pk5) = Helper::setup_xl_system(); let setups = vec![ (pk1, "shuffling 256bit"), (pk2, "shuffling 512bit"), (pk3, "shuffling 1024bit"), (pk4, "shuffling 2048bit"), (pk5, "shuffling 3072bit"), ]; for (pk, name) in setups { // benchmark config let mut group = c.benchmark_group(name); group.sample_size(10); group.bench_function("3 votes", |b| { b.iter_with_setup( || setup_shuffling(3, false, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("10 votes", |b| { b.iter_with_setup( || setup_shuffling(10, false, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("30 votes", |b| { b.iter_with_setup( || setup_shuffling(30, false, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("100 votes", |b| { b.iter_with_setup( || setup_shuffling(100, false, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("1000 votes", |b| { b.iter_with_setup( || setup_shuffling(1000, false, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("3 votes (encoded)", |b| { b.iter_with_setup( || setup_shuffling(3, true, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("10 votes (encoded)", |b| { b.iter_with_setup( || setup_shuffling(10, true, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("30 votes (encoded)", |b| { b.iter_with_setup( || setup_shuffling(30, true, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("100 votes (encoded)", |b| { b.iter_with_setup( || setup_shuffling(100, true, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.bench_function("1000 votes (encoded)", |b| { b.iter_with_setup( || setup_shuffling(1000, true, pk.clone()), |(encryptions, permutation, randoms, pk)| { ElGamal::shuffle(&encryptions, &permutation, &randoms, &pk) }, ) }); group.finish(); } } fn bench_decryption_encoded_different_votes(c: &mut Criterion) { // benchmark config let mut group = c.benchmark_group("decryption_encoded different votes"); group.bench_function("decryption_encoded - vote 0", |b| { b.iter_with_setup( || { let (_, sk, pk) = Helper::setup_lg_system(); let message = BigUint::from(0u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // encrypt the message let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); (encrypted_message, sk) }, |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), ) }); group.bench_function("decryption_encoded - vote 1", |b| { b.iter_with_setup( || { let (_, sk, pk) = Helper::setup_lg_system(); let message = BigUint::from(1u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // encrypt the message let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); (encrypted_message, sk) }, |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), ) }); group.bench_function("decryption_encoded - votes from 0-10", |b| { for vote in 0..10 { b.iter_with_setup( || { let (_, sk, pk) = Helper::setup_lg_system(); let message = BigUint::from(vote as u32); let random = BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // encrypt the message let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); (encrypted_message, sk) }, |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), ) } }); // takes long... // group.bench_function("decryption_encoded - votes from 0-100", |b| { // for vote in 0..100 { // b.iter_with_setup( // || { // let (_, sk, pk) = Helper::setup_lg_system(); // let message = BigUint::from(vote as u32); // let random = // BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // // encrypt the message // let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); // (encrypted_message, sk) // }, // |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), // ) // } // }); // takes very long... // group.bench_function("decryption_encoded - votes from 0-1000", |b| { // for vote in 0..1000 { // b.iter_with_setup( // || { // let (_, sk, pk) = Helper::setup_lg_system(); // let message = BigUint::from(vote as u32); // let random = // BigUint::parse_bytes(b"170141183460469231731687303715884", 10).unwrap(); // // encrypt the message // let encrypted_message = ElGamal::encrypt_encode(&message, &random, &pk); // (encrypted_message, sk) // }, // |(encrypted_message, sk)| ElGamal::decrypt_decode(&encrypted_message, &sk), // ) // } // }); group.finish(); } criterion_group!( benches, bench_elgamal, bench_proofs, bench_shuffle, bench_decryption_encoded_different_votes ); criterion_main!(benches);
pub mod parser; pub mod bin_op;
use crate::edge_angle::edge_angle; use petgraph::visit::{EdgeRef, IntoEdgeReferences}; use petgraph_drawing::{Drawing, DrawingIndex}; use std::f32::consts::PI; pub fn crossing_edges<G>( graph: G, drawing: &Drawing<G::NodeId, f32>, ) -> Vec<((G::NodeId, G::NodeId), (G::NodeId, G::NodeId))> where G: IntoEdgeReferences, G::NodeId: DrawingIndex, { let edges = graph .edge_references() .map(|e| { let u = e.source(); let v = e.target(); let (x1, y1) = drawing.position(u).unwrap(); let (x2, y2) = drawing.position(v).unwrap(); (u, v, x1, y1, x2, y2) }) .collect::<Vec<_>>(); let mut crossing_edges = vec![]; let m = edges.len(); for i in 1..m { let (source1, target1, x11, y11, x12, y12) = edges[i]; for j in 0..i { let (source2, target2, x21, y21, x22, y22) = edges[j]; if source1 == source2 || target1 == target2 { continue; } let s = (x12 - x11) * (y21 - y11) - (y11 - y12) * (x21 - x11); let t = (x12 - x11) * (y22 - y11) - (y11 - y12) * (x22 - x11); if s * t > 0. { continue; } let s = (x21 - x22) * (y11 - y21) - (y21 - y22) * (x11 - x21); let t = (x21 - x22) * (y12 - y21) - (y21 - y22) * (x12 - x21); if s * t > 0. { continue; } crossing_edges.push(((source1, target1), (source2, target2))); } } crossing_edges } pub fn crossing_number<G>(graph: G, drawing: &Drawing<G::NodeId, f32>) -> f32 where G: IntoEdgeReferences, G::NodeId: DrawingIndex, { let crossing_edges = crossing_edges(graph, drawing); crossing_number_with_crossing_edges(&crossing_edges) } pub fn crossing_number_with_crossing_edges<E>(crossing_edges: &[(E, E)]) -> f32 { crossing_edges.len() as f32 } pub fn crossing_angle<G>(graph: G, drawing: &Drawing<G::NodeId, f32>) -> f32 where G: IntoEdgeReferences, G::NodeId: DrawingIndex, { let crossing_edges = crossing_edges(graph, drawing); crossing_angle_with_crossing_edges(drawing, &crossing_edges) } pub fn crossing_angle_with_crossing_edges<N>( drawing: &Drawing<N, f32>, crossing_edges: &[((N, N), (N, N))], ) -> f32 where N: Copy + DrawingIndex, { let mut s = 0.; for &((source1, target1), (source2, target2)) in crossing_edges.iter() { let (x11, y11) = drawing.position(source1).unwrap(); let (x12, y12) = drawing.position(target1).unwrap(); let (x21, y21) = drawing.position(source2).unwrap(); let (x22, y22) = drawing.position(target2).unwrap(); if let Some(t) = edge_angle(x11 - x12, y11 - y12, x21 - x22, y21 - y22) { let t = t.min(PI - t); s += t.cos().powi(2); } } s }
pub mod input; pub mod navigation; pub mod prefab; pub mod project;
use std::io; fn gcd(a: u64, b: u64) -> u64 { if b == 0 { a } else { gcd(b, a % b) } } fn lcm(a: u64, b: u64) -> u64 { a * b / gcd(a, b) } fn main() { let mut input = String::new(); io::stdin().read_line(&mut input).unwrap(); input.clear(); io::stdin().read_line(&mut input).unwrap(); let (_, offset) = input .trim() .split(",") .enumerate() .filter(|&(_, x)| x != "x") .fold((1, 0), |(old_period, offset), (n, x)| { let new_period = x.parse().unwrap(); ( lcm(old_period, new_period), (0..).map(|y| old_period * y + offset).find(|y| (y + n as u64) % new_period == 0).unwrap(), ) }); println!("{}", offset); }
use super::*; mod with_timer; #[test] fn without_timer_returns_ok_and_sends_read_timer_message() { with_process(|process| { let timer_reference = process.next_reference(); assert_eq!( result(process, timer_reference, options(process)), Ok(Atom::str_to_term("ok")) ); assert_eq!( receive_message(process), Some(read_timer_message(timer_reference, false.into(), process)) ); }); } fn options(process: &Process) -> Term { process.cons(async_option(true, process), Term::NIL) }
use pipewire_sys as pw; use std::ptr; /// A PipeWire main loop. /// /// See [MainLoop::new]. pub struct MainLoop { handle: ptr::NonNull<pw::pw_main_loop>, } impl MainLoop { /// Construct a new main loop object. /// /// # Examples /// /// ```rust,no_run /// use audio_device::pipewire; /// /// # fn main() -> anyhow::Result<()> { /// let m = pipewire::MainLoop::new(); /// # Ok(()) } /// ``` pub fn new() -> Self { unsafe { let mut handle = ptr::NonNull::new_unchecked(pw::pw_main_loop_new(ptr::null())); Self { handle } } } } impl Drop for MainLoop { fn drop(&mut self) { unsafe { pw::pw_main_loop_destroy(self.handle.as_mut()); } } }
use std::{ str::FromStr, collections::HashMap }; use url::Url; use tokio_tungstenite::tungstenite::protocol::Message; use rust_decimal::Decimal; use pretty_assertions::assert_eq; use crate::services::types::{WebAppConfig, OutputData, Asset, ExchangeRate}; use crate::services::data_processor::deserialize_stream; #[test] fn test_deserialize_config(){ let data = r#"{ "web_socket_url": "wss://observer.terra.dev", "web_socket_feed": "{\"subscribe\": \"new_block\", \"chain_id\": \"tequila-0004\"}", "server_address": "127.0.0.1", "server_port": 8080 }"#; let expected = WebAppConfig{ web_socket_url: Url::parse("wss://observer.terra.dev").unwrap(), web_socket_feed: Message::text("{\"subscribe\": \"new_block\", \"chain_id\": \"tequila-0004\"}"), server_address: "127.0.0.1".to_string(), server_port: 8080_u16 }; let result= WebAppConfig::new(data.to_string()).unwrap(); assert_eq!(expected, result); } #[test] fn test_deserialize_stream(){ // super::setup(); let data = r#" { "chain_id": "columbus-4", "type": "new_block", "data": { "txs": [ { "logs": [ { "msg_index": 0, "log": "", "events": [ { "type": "aggregate_vote", "attributes": [ { "key": "voter", "value": "terravaloper10lk5rrz3srq28ap6x68c9hs86zvvtpm0jkn5qh" }, { "key": "exchange_rates", "value": "52.634119837760564508uaud,48.352968234552155517ucad,35.59545083416239871uchf,246.466768644419850917ucny,245.257640387642196568udkk,33.005740201513804404ueur,28.243996927431822597ugbp,297.644465482137718753uhkd,2834.493685892844001877uinr,4246.205482740957679647ujpy,45105.738551278812757673ukrw,108846.146106784313515381umnt,330.039235451102953546unok,27.096290779791758406usdr,334.494135897282764838usek,51.898507853232289836usgd,1284.094820624236417267uthb,38.245397968611556217uusd" }, { "key": "feeder", "value": "terra1t6elycv27d4qd3n6fecv6fxwd23sacq8dg4rn5" } ] }, { "type": "message", "attributes": [ { "key": "action", "value": "aggregateexchangeratevote" }, { "key": "module", "value": "oracle" } ] } ] }, { "msg_index": 1, "log": "", "events": [ { "type": "aggregate_prevote", "attributes": [ { "key": "voter", "value": "terravaloper10lk5rrz3srq28ap6x68c9hs86zvvtpm0jkn5qh" }, { "key": "feeder", "value": "terra1t6elycv27d4qd3n6fecv6fxwd23sacq8dg4rn5" } ] }, { "type": "message", "attributes": [ { "key": "action", "value": "aggregateexchangerateprevote" }, { "key": "module", "value": "oracle" } ] } ] } ] } ] } }"#; let mut hash_map: HashMap<Asset, ExchangeRate> = HashMap::new(); hash_map.insert("udkk".to_owned(), Decimal::from_str("245.257640387642196568").unwrap()); hash_map.insert("ugbp".to_owned(), Decimal::from_str("28.243996927431822597").unwrap()); hash_map.insert("uhkd".to_owned(), Decimal::from_str("297.644465482137718753").unwrap()); hash_map.insert("ujpy".to_owned(), Decimal::from_str("4246.205482740957679647").unwrap()); hash_map.insert("uaud".to_owned(), Decimal::from_str("52.634119837760564508").unwrap()); hash_map.insert("umnt".to_owned(), Decimal::from_str("108846.146106784313515381").unwrap()); hash_map.insert("unok".to_owned(), Decimal::from_str("330.039235451102953546").unwrap()); hash_map.insert("usdr".to_owned(), Decimal::from_str("27.096290779791758406").unwrap()); hash_map.insert("ucad".to_owned(), Decimal::from_str("48.352968234552155517").unwrap()); hash_map.insert("ucny".to_owned(), Decimal::from_str("246.466768644419850917").unwrap()); hash_map.insert("usgd".to_owned(), Decimal::from_str("51.898507853232289836").unwrap()); hash_map.insert("uchf".to_owned(), Decimal::from_str("35.59545083416239871").unwrap()); hash_map.insert("uthb".to_owned(), Decimal::from_str("1284.094820624236417267").unwrap()); hash_map.insert("uusd".to_owned(), Decimal::from_str("38.245397968611556217").unwrap()); hash_map.insert("uinr".to_owned(), Decimal::from_str("2834.493685892844001877").unwrap()); hash_map.insert("ukrw".to_owned(), Decimal::from_str("45105.738551278812757673").unwrap()); hash_map.insert("usek".to_owned(), Decimal::from_str("334.494135897282764838").unwrap()); hash_map.insert("ueur".to_owned(), Decimal::from_str("33.005740201513804404").unwrap()); let expected = OutputData{ luna_exch_rates: hash_map }; let result = deserialize_stream(data.to_string()).unwrap(); println!("{:?}", result); assert_eq!(expected, result); }
#[macro_use] extern crate serde_derive; extern crate image; extern crate rayon; extern crate docopt; extern crate sprack; mod demo; use demo::*; use docopt::Docopt; const USAGE: &'static str = " Usage: rectgen [options] Options: -c, --count=COUNT Amount of rectangles to generate [default: 10]. -o, --out=DIR Output dir for results, overwrites existing files [default: .]. -p, --prefix=PREFIX Prefix of generated files [default: rectgen_]. -h, --help Show this help message. "; #[derive(Deserialize, Debug)] struct Args { flag_count: usize, flag_out: String, flag_prefix: String, flag_help: bool, } fn main() { let args: Args = Docopt::new(USAGE) .and_then(|d| d.deserialize()) .unwrap_or_else(|e| e.exit()); // todo: println!("Args: {:?}", args); let samples = generate_rectangles(args.flag_count); draw_samples(&args.flag_out, &args.flag_prefix, &samples); }
use mask::MaskError; use std::process::Command; pub fn git_rev_parse() -> Command { let mut revparse = Command::new("git"); revparse.arg("rev-parse"); revparse } pub fn git_dir() -> Result<String,MaskError> { let mut revparse = git_rev_parse(); revparse.arg("--git-dir"); let output = try!(revparse.output()); let untrimmed = try!(String::from_utf8(output.stdout)); Ok(untrimmed.trim().to_string()) } fn add_global(cmd: &mut Command, global: bool) { if global { cmd.arg("--global"); } } pub fn git_config() -> Command { let mut config = Command::new("git"); config.arg("config"); config } pub fn set_config(key: &str, val: &str, g: bool) -> Result<(),MaskError> { let mut cfg = git_config(); add_global(&mut cfg, g); cfg.arg(key); cfg.arg(val); try!(cfg.output()); Ok(()) } pub fn unset_config(key: &str, g: bool) -> Result<(),MaskError> { let mut cfg = git_config(); add_global(&mut cfg, g); cfg.arg("--unset"); cfg.arg(key); try!(cfg.output()); Ok(()) } #[cfg(test)] mod test { use super::*; #[test] fn test_git_dir() { let gd = match git_dir() { Ok(gd) => gd, Err(_) => String::from(""), }; assert!(&gd[..] != ""); } }
//! Safe rust bindings for libopenmpt, built on top of the C API. //! //! See openmpt_sys for the unsafe bindings. extern crate openmpt_sys; #[macro_use] mod string_helper; pub mod info; pub mod mod_command; pub mod module;
use nalgebra_glm as glm; use sepia::app::*; use sepia::camera::*; use sepia::skybox::*; const ONES: &[GLfloat; 1] = &[1.0]; #[derive(Default)] struct MainState { camera: Camera, skybox: Skybox, } impl State for MainState { fn initialize(&mut self) { self.skybox = Skybox::new(&[ "assets/textures/skyboxes/mountains/right.tga".to_string(), "assets/textures/skyboxes/mountains/left.tga".to_string(), "assets/textures/skyboxes/mountains/top.tga".to_string(), "assets/textures/skyboxes/mountains/bottom.tga".to_string(), "assets/textures/skyboxes/mountains/back.tga".to_string(), "assets/textures/skyboxes/mountains/front.tga".to_string(), ]); } fn handle_events(&mut self, state_data: &mut StateData, event: &glfw::WindowEvent) { match *event { glfw::WindowEvent::Key(Key::Escape, _, Action::Press, _) => { state_data.window.set_should_close(true); } WindowEvent::CursorPos(cursor_x, cursor_y) => { let (window_width, window_height) = state_data.window.get_size(); self.camera.process_mouse_movement( (window_width as f32 / 2.0) - cursor_x as f32, (window_height as f32 / 2.0) - cursor_y as f32, ); } _ => (), } } fn update(&mut self, state_data: &mut StateData) { if state_data.window.get_key(glfw::Key::W) == glfw::Action::Press { self.camera .translate(CameraDirection::Forward, state_data.delta_time); } if state_data.window.get_key(glfw::Key::A) == glfw::Action::Press { self.camera .translate(CameraDirection::Left, state_data.delta_time); } if state_data.window.get_key(glfw::Key::S) == glfw::Action::Press { self.camera .translate(CameraDirection::Backward, state_data.delta_time); } if state_data.window.get_key(glfw::Key::D) == glfw::Action::Press { self.camera .translate(CameraDirection::Right, state_data.delta_time); } let (window_width, window_height) = state_data.window.get_size(); state_data.window.set_cursor_pos( f64::from(window_width) / 2.0, f64::from(window_height) / 2.0, ); state_data.window.set_cursor_mode(CursorMode::Disabled); } fn render(&mut self, state_data: &mut StateData) { let projection = glm::perspective( state_data.aspect_ratio, 50_f32.to_degrees(), 0.1_f32, 1000_f32, ); unsafe { gl::DepthFunc(gl::LEQUAL); gl::ClearBufferfv(gl::DEPTH, 0, ONES as *const f32); self.skybox.render(&projection, &self.camera.view_matrix()); gl::DepthFunc(gl::LESS); } } } fn main() { let mut state = MainState::default(); let mut state_machine: Vec<&mut dyn State> = Vec::new(); state_machine.push(&mut state); App::new(state_machine).run(); }
use std::error::Error; #[derive(Debug)] pub enum RuntimeError { Timer(Box<Error>), Stdio(Box<Error>), Channel, Executor, }
// 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_arrow::arrow::datatypes::Schema as ArrowSchema; use common_arrow::arrow::io::parquet::read as pread; use common_catalog::plan::ParquetReadOptions; use common_catalog::table::Table; use common_exception::ErrorCode; use common_exception::Result; use common_meta_app::principal::StageInfo; use common_storage::StageFileInfo; use common_storage::StageFilesInfo; use opendal::Operator; use super::table::create_parquet_table_info; use crate::ParquetTable; impl ParquetTable { pub fn blocking_create( operator: Operator, read_options: ParquetReadOptions, stage_info: StageInfo, files_info: StageFilesInfo, files_to_read: Option<Vec<StageFileInfo>>, ) -> Result<Arc<dyn Table>> { let first_file = match &files_to_read { Some(files) => files[0].path.clone(), None => files_info.blocking_first_file(&operator)?.path, }; let arrow_schema = Self::blocking_prepare_metas(&first_file, operator.clone())?; let table_info = create_parquet_table_info(arrow_schema.clone()); Ok(Arc::new(ParquetTable { table_info, arrow_schema, operator, read_options, stage_info, files_info, files_to_read, })) } fn blocking_prepare_metas(path: &str, operator: Operator) -> Result<ArrowSchema> { // Infer schema from the first parquet file. // Assume all parquet files have the same schema. // If not, throw error during reading. let mut reader = operator.blocking().reader(path)?; let first_meta = pread::read_metadata(&mut reader).map_err(|e| { ErrorCode::Internal(format!("Read parquet file '{}''s meta error: {}", path, e)) })?; let arrow_schema = pread::infer_schema(&first_meta)?; Ok(arrow_schema) } }
#![no_std] #![no_main] extern crate panic_itm; use cortex_m::{iprintln, iprint}; use cortex_m_rt::entry; use embedded_hal::digital::v2::OutputPin; use embedded_hal::blocking::delay::DelayMs; use stm32f4xx_hal::{ rcc::RccExt, gpio::GpioExt, time::U32Ext, stm32::{CorePeripherals, Peripherals}, delay::Delay, spi::Spi, time::Hertz }; use enc424j600; use enc424j600::EthController; #[entry] fn main() -> ! { let mut cp = CorePeripherals::take().unwrap(); cp.SCB.enable_icache(); cp.SCB.enable_dcache(&mut cp.CPUID); let dp = Peripherals::take().unwrap(); let clocks = dp.RCC.constrain() .cfgr .sysclk(168.mhz()) .hclk(168.mhz()) .pclk1(32.mhz()) .pclk2(64.mhz()) .freeze(); let mut delay = Delay::new(cp.SYST, clocks); // Init ITM & use Stimulus Port 0 let mut itm = cp.ITM; let stim0 = &mut itm.stim[0]; iprintln!(stim0, "Eth TX Pinging on STM32-F407 via NIC100/ENC424J600"); // NIC100 / ENC424J600 Set-up let spi1 = dp.SPI1; let gpioa = dp.GPIOA.split(); // Mapping: see Table 9, STM32F407ZG Manual let spi1_sck = gpioa.pa5.into_alternate_af5(); let spi1_miso = gpioa.pa6.into_alternate_af5(); let spi1_mosi = gpioa.pa7.into_alternate_af5(); let spi1_nss = gpioa.pa4.into_push_pull_output(); // Map SPISEL: see Table 1, NIC100 Manual let mut spisel = gpioa.pa1.into_push_pull_output(); spisel.set_high().unwrap(); delay.delay_ms(1_u32); spisel.set_low().unwrap(); // Create SPI1 for HAL let spi_eth_port = Spi::spi1( spi1, (spi1_sck, spi1_miso, spi1_mosi), enc424j600::spi::interfaces::SPI_MODE, Hertz(enc424j600::spi::interfaces::SPI_CLOCK_FREQ), clocks); let mut spi_eth = enc424j600::SpiEth::new(spi_eth_port, spi1_nss); // Init match spi_eth.init_dev(&mut delay) { Ok(_) => { iprintln!(stim0, "Ethernet initialized") } Err(_) => { panic!("Ethernet initialization failed!") } } // Read MAC let mut eth_mac_addr: [u8; 6] = [0; 6]; spi_eth.read_from_mac(&mut eth_mac_addr); for i in 0..6 { let byte = eth_mac_addr[i]; match i { 0 => iprint!(stim0, "MAC Address = {:02x}-", byte), 1..=4 => iprint!(stim0, "{:02x}-", byte), 5 => iprint!(stim0, "{:02x}\n", byte), _ => () }; } // Init Rx/Tx buffers spi_eth.init_rxbuf(); spi_eth.init_txbuf(); // Testing Eth TX let eth_tx_dat: [u8; 64] = [ 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x08, 0x60, 0x6e, 0x44, 0x42, 0x95, 0x08, 0x06, 0x00, 0x01, 0x08, 0x00, 0x06, 0x04, 0x00, 0x01, 0x08, 0x60, 0x6e, 0x44, 0x42, 0x95, 0xc0, 0xa8, 0x01, 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0xa8, 0x01, 0xe7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x69, 0xd0, 0x85, 0x9f ]; loop { let mut eth_tx_packet = enc424j600::tx::TxPacket::new(); eth_tx_packet.update_frame(&eth_tx_dat, 64); iprint!(stim0, "Sending packet (len={:}): ", eth_tx_packet.get_frame_length()); for i in 0..20 { let byte = eth_tx_packet.get_frame_byte(i); match i { 0 => iprint!(stim0, "dest={:02x}-", byte), 6 => iprint!(stim0, "src={:02x}-", byte), 12 => iprint!(stim0, "data={:02x}", byte), 1..=4 | 7..=10 => iprint!(stim0, "{:02x}-", byte), 13..=14 | 16..=18 => iprint!(stim0, "{:02x}", byte), 5 | 11 | 15 => iprint!(stim0, "{:02x} ", byte), 19 => iprint!(stim0, "{:02x} ...\n", byte), _ => () }; } spi_eth.send_raw_packet(&eth_tx_packet); iprintln!(stim0, "Packet sent"); delay.delay_ms(100_u32); } }
extern crate gcc; fn main(){ gcc::Config::new().file("huhu.c").compile("libhuhu.a"); }
// Generated by gir (https://github.com/gtk-rs/gir @ e8f82cf) // from ../gir-files (@ 3cba654+) // DO NOT EDIT #[cfg(not(feature = "dox"))] use std::process; #[cfg(feature = "dox")] fn main() {} // prevent linking libraries to avoid documentation failure #[cfg(not(feature = "dox"))] fn main() { if let Err(s) = system_deps::Config::new().probe() { println!("cargo:warning={}", s); process::exit(1); } }
use std; import std::str; #[test] fn test_bytes_len() { assert (str::byte_len("") == 0u); assert (str::byte_len("hello world") == 11u); assert (str::byte_len("\x63") == 1u); assert (str::byte_len("\xa2") == 2u); assert (str::byte_len("\u03c0") == 2u); assert (str::byte_len("\u2620") == 3u); assert (str::byte_len("\U0001d11e") == 4u); } #[test] fn test_index_and_rindex() { assert (str::index("hello", 'e' as u8) == 1); assert (str::index("hello", 'o' as u8) == 4); assert (str::index("hello", 'z' as u8) == -1); assert (str::rindex("hello", 'l' as u8) == 3); assert (str::rindex("hello", 'h' as u8) == 0); assert (str::rindex("hello", 'z' as u8) == -1); } #[test] fn test_split() { fn t(s: &str, c: char, i: int, k: &str) { log "splitting: " + s; log i; let v = str::split(s, c as u8); log "split to: "; for z: str in v { log z; } log "comparing: " + v.(i) + " vs. " + k; assert (str::eq(v.(i), k)); } t("abc.hello.there", '.', 0, "abc"); t("abc.hello.there", '.', 1, "hello"); t("abc.hello.there", '.', 2, "there"); t(".hello.there", '.', 0, ""); t(".hello.there", '.', 1, "hello"); t("...hello.there.", '.', 3, "hello"); t("...hello.there.", '.', 5, ""); } #[test] fn test_find() { fn t(haystack: &str, needle: &str, i: int) { let j: int = str::find(haystack, needle); log "searched for " + needle; log j; assert (i == j); } t("this is a simple", "is a", 5); t("this is a simple", "is z", -1); t("this is a simple", "", 0); t("this is a simple", "simple", 10); t("this", "simple", -1); } #[test] fn test_substr() { fn t(a: &str, b: &str, start: int) { assert (str::eq(str::substr(a, start as uint, str::byte_len(b)), b)); } t("hello", "llo", 2); t("hello", "el", 1); t("substr should not be a challenge", "not", 14); } #[test] fn test_concat() { fn t(v: &vec[str], s: &str) { assert (str::eq(str::concat(v), s)); } t(["you", "know", "I'm", "no", "good"], "youknowI'mnogood"); let v: vec[str] = []; t(v, ""); t(["hi"], "hi"); } #[test] fn test_connect() { fn t(v: &vec[str], sep: &str, s: &str) { assert (str::eq(str::connect(v, sep), s)); } t(["you", "know", "I'm", "no", "good"], " ", "you know I'm no good"); let v: vec[str] = []; t(v, " ", ""); t(["hi"], " ", "hi"); } #[test] fn test_to_upper() { // to_upper doesn't understand unicode yet, // but we need to at least preserve it let unicode = "\u65e5\u672c"; let input = "abcDEF" + unicode + "xyz:.;"; let expected = "ABCDEF" + unicode + "XYZ:.;"; let actual = str::to_upper(input); assert (str::eq(expected, actual)); } #[test] fn test_slice() { assert (str::eq("ab", str::slice("abc", 0u, 2u))); assert (str::eq("bc", str::slice("abc", 1u, 3u))); assert (str::eq("", str::slice("abc", 1u, 1u))); fn a_million_letter_a() -> str { let i = 0; let rs = ""; while i < 100000 { rs += "aaaaaaaaaa"; i += 1; } ret rs; } fn half_a_million_letter_a() -> str { let i = 0; let rs = ""; while i < 100000 { rs += "aaaaa"; i += 1; } ret rs; } assert (str::eq(half_a_million_letter_a(), str::slice(a_million_letter_a(), 0u, 500000u))); } #[test] fn test_ends_with() { assert (str::ends_with("", "")); assert (str::ends_with("abc", "")); assert (str::ends_with("abc", "c")); assert (!str::ends_with("a", "abc")); assert (!str::ends_with("", "abc")); } #[test] fn test_is_empty() { assert (str::is_empty("")); assert (!str::is_empty("a")); } #[test] fn test_is_not_empty() { assert (str::is_not_empty("a")); assert (!str::is_not_empty("")); } #[test] fn test_replace() { let a = "a"; check (str::is_not_empty(a)); assert (str::replace("", a, "b") == ""); assert (str::replace("a", a, "b") == "b"); assert (str::replace("ab", a, "b") == "bb"); let test = "test"; check (str::is_not_empty(test)); assert (str::replace(" test test ", test, "toast") == " toast toast "); assert (str::replace(" test test ", test, "") == " "); } #[test] fn test_char_slice() { assert (str::eq("ab", str::char_slice("abc", 0u, 2u))); assert (str::eq("bc", str::char_slice("abc", 1u, 3u))); assert (str::eq("", str::char_slice("abc", 1u, 1u))); assert (str::eq("\u65e5", str::char_slice("\u65e5\u672c", 0u, 1u))); } #[test] fn trim_left() { assert str::trim_left("") == ""; assert str::trim_left("a") == "a"; assert str::trim_left(" ") == ""; assert str::trim_left(" blah") == "blah"; assert str::trim_left(" \u3000 wut") == "wut"; assert str::trim_left("hey ") == "hey "; } #[test] fn trim_right() { assert str::trim_right("") == ""; assert str::trim_right("a") == "a"; assert str::trim_right(" ") == ""; assert str::trim_right("blah ") == "blah"; assert str::trim_right("wut \u3000 ") == "wut"; assert str::trim_right(" hey") == " hey"; } #[test] fn trim() { assert str::trim("") == ""; assert str::trim("a") == "a"; assert str::trim(" ") == ""; assert str::trim(" blah ") == "blah"; assert str::trim("\nwut \u3000 ") == "wut"; assert str::trim(" hey dude ") == "hey dude"; } #[test] fn is_whitespace() { assert str::is_whitespace(""); assert str::is_whitespace(" "); assert str::is_whitespace("\u2009"); // Thin space assert str::is_whitespace(" \n\t "); assert !str::is_whitespace(" _ "); } // Local Variables: // mode: rust; // fill-column: 78; // indent-tabs-mode: nil // c-basic-offset: 4 // buffer-file-coding-system: utf-8-unix // compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'"; // End:
//! Terminal-related `ioctl` functions. use crate::fd::AsFd; use crate::{backend, io}; /// `ioctl(fd, TIOCEXCL)`—Enables exclusive mode on a terminal. /// /// # References /// - [Linux] /// - [FreeBSD] /// - [NetBSD] /// - [OpenBSD] /// /// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 /// [NetBSD]: https://man.netbsd.org/tty.4 /// [OpenBSD]: https://man.openbsd.org/tty.4 #[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))] #[inline] #[doc(alias = "TIOCEXCL")] pub fn ioctl_tiocexcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { backend::termios::syscalls::ioctl_tiocexcl(fd.as_fd()) } /// `ioctl(fd, TIOCNXCL)`—Disables exclusive mode on a terminal. /// /// # References /// - [Linux] /// - [FreeBSD] /// - [NetBSD] /// - [OpenBSD] /// /// [Linux]: https://man7.org/linux/man-pages/man4/tty_ioctl.4.html /// [FreeBSD]: https://man.freebsd.org/cgi/man.cgi?query=tty&sektion=4 /// [NetBSD]: https://man.netbsd.org/tty.4 /// [OpenBSD]: https://man.openbsd.org/tty.4 #[cfg(not(any(windows, target_os = "redox", target_os = "wasi")))] #[inline] #[doc(alias = "TIOCNXCL")] pub fn ioctl_tiocnxcl<Fd: AsFd>(fd: Fd) -> io::Result<()> { backend::termios::syscalls::ioctl_tiocnxcl(fd.as_fd()) }
use std::str; use std::vec::Vec; use nom::{ErrorKind, IResult, eol, space}; const ERR_WRONG_INDENT: u32 = 0x01; #[derive(Debug)] pub struct Expression { indent: i8, pub operator: Operator, pub elements: Vec<Element> } #[derive(Debug)] pub enum Operator { Store, Add, Substract, Multitply, Divide, Print, } #[derive(Debug)] pub enum Element { Name(String), Value(i8), Expression(Expression) } enum CompilerError<'a> { NotAnOperator(&'a str), } impl Expression { fn guess_indent(indent: Option<&[u8]>) -> Result<i8, CompilerError> { match indent { Some(a) => Ok(a.len() as i8), None => Ok(0) } } } impl Operator { fn from_utf8(v: &[u8]) -> Result<Operator, CompilerError> { match str::from_utf8(v).unwrap() { "🍱" => Ok(Operator::Store), "🍳" => Ok(Operator::Add), "🏧" => Ok(Operator::Substract), "🍇" => Ok(Operator::Multitply), "🔪" => Ok(Operator::Divide), "🖨️" => Ok(Operator::Print), r => Err(CompilerError::NotAnOperator(r)), } } } impl Element { fn from_utf8(v: &[u8]) -> Result<Element, CompilerError> { let v = str::from_utf8(v).unwrap(); match v.parse::<i8>() { Ok(n) => Ok(Element::Value(n)), Err(_) => Ok(Element::Name(v.to_string())) } } } pub fn run(source: &str) -> Vec<Element> { let (_, r) = expressions(&source.trim().as_bytes()).unwrap(); r } // Parsers fn indent(input: &[u8], parent_indent: i8) -> IResult<&[u8], i8> { let indent_result = map_res!(input, opt!(preceded!(eol, space)), Expression::guess_indent); let (_, current_indent) = indent_result.clone().unwrap(); match current_indent - 1 { c if c == parent_indent => indent_result, c if c > parent_indent => panic!("Indentation isn't consistent"), _ => IResult::Error(ErrorKind::Custom(ERR_WRONG_INDENT)) } } named!(operator<Operator>, map_res!(alt!( tag!("🍱") | tag!("🍳") | tag!("🏧") | tag!("🍇") | tag!("🔪") | tag!("🖨️") ), Operator::from_utf8)); fn token(input: &[u8]) -> IResult<&[u8], Element> { map_res!( input, do_parse!(opt!(space) >> token:take_while!(call!(|c| c != '\n' as u8 && c != ' ' as u8)) >> (token)), Element::from_utf8 ) } fn elements(input: &[u8], parent_indent: i8) -> IResult<&[u8], Vec<Element>> { many1!(input, alt!(apply!(expression, parent_indent) | token)) } fn expression(input: &[u8], parent_indent: i8) -> IResult<&[u8], Element> { do_parse!(input, current_indent: apply!(indent, parent_indent) >> operator: operator >> elements: apply!(elements, current_indent) >> (Element::Expression(Expression { indent: current_indent, operator: operator, elements: elements})) ) } named!(expressions<Vec<Element> >, many1!(do_parse!(opt!(eol) >> exp: apply!(expression, -1) >> (exp))));
use std::borrow::Cow; use std::io; use std::iter::Peekable; use std::str; use serde_bencode::de::from_bytes; use serde_bytes; use sha1::Sha1; #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] pub struct Sha1Hash(Vec<u8>); impl Sha1Hash { pub fn new(input: Vec<u8>) -> Option<Sha1Hash> { if input.len() == 20 { Some(Sha1Hash(input)) } else { None } } pub fn to_vec(self) -> Vec<u8> { self.0 } pub fn as_bytes(&self) -> &[u8] { &self.0 } } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] pub struct MetaInfo<'a> { #[serde(borrow)] pub announce: Cow<'a, str>, pub info: Info<'a>, // Optional data #[serde(borrow)] #[serde(rename = "announce-list")] pub announce_list: Option<Vec<Vec<Cow<'a, str>>>>, #[serde(borrow)] #[serde(rename = "url-list")] pub url_list: Option<Vec<Cow<'a, str>>>, #[serde(borrow)] #[serde(rename = "created by")] pub created_by: Option<Cow<'a, str>>, #[serde(borrow)] pub comment: Option<Cow<'a, str>>, #[serde(rename = "creation date")] pub creation_date: Option<i64>, } pub fn get_info_hash(source: Vec<u8>) -> io::Result<Sha1> { value_in_dict(source, b"info").map(|bytes| { let mut sha = Sha1::new(); sha.update(&bytes); sha }) } pub fn value_in_dict(source: Vec<u8>, key: &[u8]) -> io::Result<Vec<u8>> { let mut iter = source.into_iter().peekable(); if iter.next() != Some(b'd') { return Err(io::Error::new(io::ErrorKind::Other, "Not a dict")); } let mut found = read_bytes(&mut iter)?; //let key = key.to_owned(); while found.get(2) != Some(&key.to_owned()) { read_element(&mut iter)?; if iter.peek() == Some(&b'e') { return Err(io::Error::new( io::ErrorKind::Other, "Key not found" )) } found = read_bytes(&mut iter)?; } let chunks = read_element(&mut iter)?; let capacity = chunks.iter().fold(0, |sum, chunk| sum + chunk.len()); let mut out = Vec::with_capacity(capacity); for chunk in chunks { out.extend(chunk); } Ok(out) } fn is_digit(n: u8) -> bool { n >= b'0' && n <= b'9' } pub fn read_element<I: Iterator<Item = u8>>(source: &mut Peekable<I>) -> io::Result<Vec<Vec<u8>>> { let mut reads = Vec::with_capacity(16); let initial = *source .peek() .ok_or(io::Error::new(io::ErrorKind::Other, "source was empty"))?; let result = match initial { b'd' => read_dict(source), b'l' => read_list(source), b'i' => read_integer(source), b'0' | b'1' | b'2' | b'3' | b'4' | b'5' | b'6' | b'7' | b'8' | b'9' => read_bytes(source), _ => Err(io::Error::new( io::ErrorKind::Other, "Invalid start character", )), }?; reads.extend(result); Ok(reads) } pub fn read_integer<I: Iterator<Item = u8>>(source: &mut Peekable<I>) -> io::Result<Vec<Vec<u8>>> { let mut buf = Vec::with_capacity(16); let i = source.next().and_then(|c| if c != b'i' { None } else { Some(c) }) .ok_or(io::Error::new(io::ErrorKind::Other, "integer didn't start with i"))?; buf.push(i); while let Some(byte) = source.next() { buf.push(byte); if byte == b'e' { return Ok(vec![buf]); } if byte < b'0' || byte > b'9' { return Err(io::Error::new( io::ErrorKind::Other, format!("Non-numeric {} found in expected integer", byte), )); } } Err(io::Error::new( io::ErrorKind::Other, "Integer is never closed", )) } pub fn read_bytes<I: Iterator<Item = u8>>(source: &mut Peekable<I>) -> io::Result<Vec<Vec<u8>>> { //! Redo this to use Peekable<I> let mut lengthbuf = Vec::with_capacity(10); while source .peek() .ok_or(io::Error::new(io::ErrorKind::Other, "No next"))? != &b':' { let next = source.next().unwrap(); // Infallible due to peek() above. if is_digit(next) { lengthbuf.push(next); } else { return Err(io::Error::new(io::ErrorKind::Other, "Not a number")); } } let colon = vec![ source .next() .ok_or(io::Error::new(io::ErrorKind::Other, "No next"))?, ]; // Safe due to is_digit() check above let bytes_length = unsafe { str::from_utf8_unchecked(&lengthbuf) } .parse() .unwrap(); let mut data = Vec::with_capacity(bytes_length); for _ in 0..bytes_length { data.push(source .next() .ok_or(io::Error::new(io::ErrorKind::Other, "No next"))?); } Ok(vec![lengthbuf, colon, data]) } pub fn read_list<I: Iterator<Item = u8>>(source: &mut Peekable<I>) -> io::Result<Vec<Vec<u8>>> { let mut buf = Vec::with_capacity(1024); let l = source .next() .ok_or(io::Error::new(io::ErrorKind::Other, "No data"))?; if l != b'l' { Err(io::Error::new( io::ErrorKind::Other, "Didn't find leading `l`", )) } else { buf.push(vec![l]); while source .peek() .ok_or(io::Error::new(io::ErrorKind::Other, "List didn't end"))? != &b'e' { buf.extend(read_element(source)?); } Ok(buf) } } pub fn read_dict<I: Iterator<Item = u8>>(source: &mut Peekable<I>) -> io::Result<Vec<Vec<u8>>> { let mut buf = Vec::with_capacity(1024); let d = source .next() .ok_or(io::Error::new(io::ErrorKind::Other, "No data"))?; if d != b'd' { Err(io::Error::new( io::ErrorKind::Other, "Didn't find leading `d`", )) } else { buf.push(vec![d]); while source .peek() .ok_or(io::Error::new(io::ErrorKind::Other, "Dict didn't end"))? != &b'e' { buf.extend(read_bytes(source)?); buf.extend(read_element(source)?); } Ok(buf) } } impl<'a> MetaInfo<'a> { pub fn from_bytes(bytes: &'a [u8]) -> Option<MetaInfo> { from_bytes(bytes).ok() } } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] #[serde(untagged)] pub enum Info<'a> { MiInfo(MiInfo<'a>), MiMultiInfo(MiMultiInfo<'a>), } impl <'a> Info<'a> { pub fn length(&self) -> u64 { match *self { Info::MiInfo(ref info) => info.length, Info::MiMultiInfo(ref info) => info.files.iter().fold(0, |sum, filedata| sum + filedata.length), } } } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] pub struct MiInfo<'a> { pub name: Cow<'a, str>, #[serde(rename = "piece length")] pub piece_length: u64, #[serde(deserialize_with = "pieces_from_bytes")] pub pieces: Vec<Sha1Hash>, pub length: u64, } #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] pub struct MiMultiInfo<'a> { pub name: Cow<'a, str>, #[serde(rename = "piece length")] pub piece_length: u64, #[serde(deserialize_with = "pieces_from_bytes")] pub pieces: Vec<Sha1Hash>, pub files: Vec<MiFileData<'a>>, } fn pieces_from_bytes<'de, D>(deserializer: D) -> Result<Vec<Sha1Hash>, D::Error> where D: ::serde::de::Deserializer<'de>, { println!("HI"); let b: serde_bytes::ByteBuf = ::serde::de::Deserialize::deserialize(deserializer)?; println!("Got a b"); b.chunks(20) .map(|x| Sha1Hash::new(x.to_vec())) .map(|x| x.ok_or_else(|| ::serde::de::Error::custom("oops"))) .collect() } #[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq)] pub struct MiFileData<'a> { length: u64, path: Vec<Cow<'a, str>>, } #[cfg(test)] mod tests { use super::*; use std::fs::File; use std::io::prelude::*; #[test] fn into_metainfo() { let mut b = vec![]; let filename = "data/archlinux-2017.12.01-x86_64.iso.torrent"; let mut f = File::open(&filename).unwrap(); f.read_to_end(&mut b).expect("read"); let mi = MetaInfo::from_bytes(&b).expect("deserialize"); assert_eq!(mi.announce, "http://tracker.archlinux.org:6969/announce") } #[test] fn into_moby_metainfo() { let mut b = vec![]; let mut f = File::open("data/These Systems Are Failing.torrent").unwrap(); f.read_to_end(&mut b).expect("read"); let mi = MetaInfo::from_bytes(&b).expect("deserialize"); assert_eq!( mi.announce, "http://tracker.bundles.bittorrent.com/announce" ) } #[test] fn error_if_pieces_not_multiples_of_20_chars() { let mut b = vec![]; let mut f = File::open("data/archerror.torrent").unwrap(); f.read_to_end(&mut b).expect("read"); if let Some(mi) = MetaInfo::from_bytes(&b) { panic!("Unexpected success {:?}", mi); } } }
#[doc = "Reader of register CFG"] pub type R = crate::R<u32, super::CFG>; #[doc = "Writer for register CFG"] pub type W = crate::W<u32, super::CFG>; #[doc = "Register CFG `reset()`'s with value 0"] impl crate::ResetValue for super::CFG { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Mode Select\n\nValue on reset: 0"] #[derive(Clone, Copy, Debug, PartialEq)] #[repr(u8)] pub enum MODE_A { #[doc = "0: General Purpose"] NONE = 0, #[doc = "1: SDRAM"] SDRAM = 1, #[doc = "2: 8-Bit Host-Bus (HB8)"] HB8 = 2, #[doc = "3: 16-Bit Host-Bus (HB16)"] HB16 = 3, } impl From<MODE_A> for u8 { #[inline(always)] fn from(variant: MODE_A) -> Self { variant as _ } } #[doc = "Reader of field `MODE`"] pub type MODE_R = crate::R<u8, MODE_A>; impl MODE_R { #[doc = r"Get enumerated values variant"] #[inline(always)] pub fn variant(&self) -> crate::Variant<u8, MODE_A> { use crate::Variant::*; match self.bits { 0 => Val(MODE_A::NONE), 1 => Val(MODE_A::SDRAM), 2 => Val(MODE_A::HB8), 3 => Val(MODE_A::HB16), i => Res(i), } } #[doc = "Checks if the value of the field is `NONE`"] #[inline(always)] pub fn is_none(&self) -> bool { *self == MODE_A::NONE } #[doc = "Checks if the value of the field is `SDRAM`"] #[inline(always)] pub fn is_sdram(&self) -> bool { *self == MODE_A::SDRAM } #[doc = "Checks if the value of the field is `HB8`"] #[inline(always)] pub fn is_hb8(&self) -> bool { *self == MODE_A::HB8 } #[doc = "Checks if the value of the field is `HB16`"] #[inline(always)] pub fn is_hb16(&self) -> bool { *self == MODE_A::HB16 } } #[doc = "Write proxy for field `MODE`"] pub struct MODE_W<'a> { w: &'a mut W, } impl<'a> MODE_W<'a> { #[doc = r"Writes `variant` to the field"] #[inline(always)] pub fn variant(self, variant: MODE_A) -> &'a mut W { unsafe { self.bits(variant.into()) } } #[doc = "General Purpose"] #[inline(always)] pub fn none(self) -> &'a mut W { self.variant(MODE_A::NONE) } #[doc = "SDRAM"] #[inline(always)] pub fn sdram(self) -> &'a mut W { self.variant(MODE_A::SDRAM) } #[doc = "8-Bit Host-Bus (HB8)"] #[inline(always)] pub fn hb8(self) -> &'a mut W { self.variant(MODE_A::HB8) } #[doc = "16-Bit Host-Bus (HB16)"] #[inline(always)] pub fn hb16(self) -> &'a mut W { self.variant(MODE_A::HB16) } #[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 & !0x0f) | ((value as u32) & 0x0f); self.w } } #[doc = "Reader of field `BLKEN`"] pub type BLKEN_R = crate::R<bool, bool>; #[doc = "Write proxy for field `BLKEN`"] pub struct BLKEN_W<'a> { w: &'a mut W, } impl<'a> BLKEN_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 `INTDIV`"] pub type INTDIV_R = crate::R<bool, bool>; #[doc = "Write proxy for field `INTDIV`"] pub struct INTDIV_W<'a> { w: &'a mut W, } impl<'a> INTDIV_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 } } impl R { #[doc = "Bits 0:3 - Mode Select"] #[inline(always)] pub fn mode(&self) -> MODE_R { MODE_R::new((self.bits & 0x0f) as u8) } #[doc = "Bit 4 - Block Enable"] #[inline(always)] pub fn blken(&self) -> BLKEN_R { BLKEN_R::new(((self.bits >> 4) & 0x01) != 0) } #[doc = "Bit 8 - Integer Clock Divider Enable"] #[inline(always)] pub fn intdiv(&self) -> INTDIV_R { INTDIV_R::new(((self.bits >> 8) & 0x01) != 0) } } impl W { #[doc = "Bits 0:3 - Mode Select"] #[inline(always)] pub fn mode(&mut self) -> MODE_W { MODE_W { w: self } } #[doc = "Bit 4 - Block Enable"] #[inline(always)] pub fn blken(&mut self) -> BLKEN_W { BLKEN_W { w: self } } #[doc = "Bit 8 - Integer Clock Divider Enable"] #[inline(always)] pub fn intdiv(&mut self) -> INTDIV_W { INTDIV_W { w: self } } }
// Copyright 2019 The Fuchsia Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. use { failure::{bail, Error, ResultExt}, fidl_fuchsia_net_oldhttp::{self as http, HttpServiceProxy}, fuchsia_async as fasync, fuchsia_syslog::fx_log_info, fuchsia_zircon as zx, futures::io::{AllowStdIo, AsyncReadExt}, }; pub fn create_url_request<S: ToString>(url_string: S) -> http::UrlRequest { http::UrlRequest { url: url_string.to_string(), method: String::from("GET"), headers: None, body: None, response_body_buffer_size: 0, auto_follow_redirects: true, cache_mode: http::CacheMode::Default, response_body_mode: http::ResponseBodyMode::Stream, } } // Object to hold results of a single download #[derive(Default)] pub struct IndividualDownload { pub bytes: u64, pub nanos: u64, pub goodput_mbps: f64, } // TODO (NET-1664): verify checksum on data received pub async fn fetch_and_discard_url( http_service: &HttpServiceProxy, mut url_request: http::UrlRequest, ) -> Result<IndividualDownload, Error> { // Create a UrlLoader instance let (s, p) = zx::Channel::create().context("failed to create zx channel")?; let proxy = fasync::Channel::from_channel(p).context("failed to make async channel")?; let loader_server = fidl::endpoints::ServerEnd::<http::UrlLoaderMarker>::new(s); http_service.create_url_loader(loader_server)?; let loader_proxy = http::UrlLoaderProxy::new(proxy); let start_time = zx::Time::get(zx::ClockId::Monotonic); let response = loader_proxy.start(&mut url_request).await?; if let Some(e) = response.error { bail!("UrlLoaderProxy error - code:{} ({})", e.code, e.description.unwrap_or("".into())) } let socket = match response.body.map(|x| *x) { Some(http::UrlBody::Stream(s)) => fasync::Socket::from_socket(s)?, _ => { bail!("failed to read UrlBody from the stream - error: {}", zx::Status::BAD_STATE); } }; // discard the bytes let mut stdio_sink = AllowStdIo::new(::std::io::sink()); let bytes_received = socket.copy_into(&mut stdio_sink).await?; let stop_time = zx::Time::get(zx::ClockId::Monotonic); let time_nanos = (stop_time - start_time).into_nanos() as u64; let time_seconds = time_nanos as f64 * 1e-9; let bits_received = (bytes_received * 8) as f64; fx_log_info!("Received {} bytes in {:.3} seconds", bytes_received, time_seconds); if bytes_received < 1 { bail!("Failed to download data from url! bytes_received = {}", bytes_received); } let megabits_per_sec = bits_received * 1e-6 / time_seconds; let mut individual_download = IndividualDownload::default(); individual_download.goodput_mbps = megabits_per_sec; individual_download.bytes = bytes_received; individual_download.nanos = time_nanos; Ok(individual_download) } #[cfg(test)] mod tests { use { super::*, fidl::endpoints, //fidl::endpoints::RequestStream, fidl_fuchsia_net_oldhttp as http, fidl_fuchsia_net_oldhttp::HttpError, fidl_fuchsia_net_oldhttp::{HttpServiceMarker, HttpServiceProxy}, fidl_fuchsia_net_oldhttp::{HttpServiceRequest, HttpServiceRequestStream}, fidl_fuchsia_net_oldhttp::{UrlBody, UrlRequest, UrlResponse}, fidl_fuchsia_net_oldhttp::{UrlLoaderRequest, UrlLoaderRequestStream}, fuchsia_async as fasync, futures::stream::{StreamExt, StreamFuture}, futures::task::Poll, pin_utils::pin_mut, }; #[test] fn verify_basic_url_request_creation() { let test_url = "https://test.example/sample/url"; let url_req = create_url_request(test_url.to_string()); assert_eq!(url_req.url, test_url); assert_eq!(url_req.method, "GET".to_string()); assert!(url_req.headers.is_none()); assert!(url_req.body.is_none()); assert_eq!(url_req.response_body_buffer_size, 0); assert!(url_req.auto_follow_redirects); assert_eq!(url_req.cache_mode, http::CacheMode::Default); assert_eq!(url_req.response_body_mode, http::ResponseBodyMode::Stream); } #[test] fn response_error_triggers_error_path() { let test_url = "https://test.example/sample/url"; let url_req = create_url_request(test_url.to_string()); let url_response = create_url_response(None, None, 404); let download_result = trigger_download_with_supplied_response(url_req, url_response); assert!(download_result.is_err()); } #[test] fn successful_download_returns_valid_indvidual_download_data() { let test_url = "https://test.example/sample/url"; let url_req = create_url_request(test_url.to_string()); // creating a response with some bytes "downloaded" let bytes = "there are some bytes".as_bytes(); let (s1, s2) = zx::Socket::create(zx::SocketOpts::STREAM).unwrap(); let url_body = Some(Box::new(http::UrlBody::Stream(s2))); let expected_num_bytes = s1.write(bytes).expect("failed to write response body") as u64; drop(s1); let url_response = create_url_response(None, url_body, 200); let request_result = trigger_download_with_supplied_response(url_req, url_response); let download_result = request_result.expect("failed to get individual_download"); assert_eq!(download_result.bytes, expected_num_bytes); } #[test] fn zero_byte_download_triggers_error() { let test_url = "https://test.example/sample/url"; let url_req = create_url_request(test_url.to_string()); // creating a response with some bytes "downloaded" let bytes = "".as_bytes(); let (s1, s2) = zx::Socket::create(zx::SocketOpts::STREAM).unwrap(); let url_body = Some(Box::new(http::UrlBody::Stream(s2))); let expected_num_bytes = s1.write(bytes).expect("failed to write response body") as u64; drop(s1); assert_eq!(expected_num_bytes, 0); let url_response = create_url_response(None, url_body, 200); let download_result = trigger_download_with_supplied_response(url_req, url_response); assert!(download_result.is_err()); } #[test] fn null_response_body_triggers_error() { let test_url = "https://test.example/sample/url"; let url_req = create_url_request(test_url.to_string()); // creating a response with 0 bytes downloaded let url_response = create_url_response(None, None, 200); let download_result = trigger_download_with_supplied_response(url_req, url_response); assert!(download_result.is_err()); } fn trigger_download_with_supplied_response( request: UrlRequest, mut response: UrlResponse, ) -> Result<IndividualDownload, Error> { let mut exec = fasync::Executor::new().expect("failed to create an executor"); let (http_service, server) = create_http_service_util(); let mut next_http_service_req = server.into_future(); let url_target = (&request).url.clone(); let fut = fetch_and_discard_url(&http_service, request); pin_mut!(fut); assert!(exec.run_until_stalled(&mut fut).is_pending()); let (url_loader_responder, _service_control_handle) = match poll_http_service_request(&mut exec, &mut next_http_service_req) { Poll::Ready(HttpServiceRequest::CreateUrlLoader { loader, control_handle }) => { (loader, control_handle) } Poll::Pending => panic!("expected something"), }; assert!(exec.run_until_stalled(&mut fut).is_pending()); let mut next_url_loader_req = url_loader_responder .into_stream() .expect("failed to create a url_loader response stream") .into_future(); let (url_request, url_request_responder) = match poll_url_loader_request(&mut exec, &mut next_url_loader_req) { Poll::Ready(UrlLoaderRequest::Start { request, responder }) => (request, responder), Poll::Pending => panic!("expected something"), _ => panic!("got something unexpected!"), }; assert_eq!(url_target, url_request.url); url_request_responder.send(&mut response).expect("failed to send UrlResponse"); let complete = exec.run_until_stalled(&mut fut); match complete { Poll::Ready(result) => result, Poll::Pending => panic!("future is pending and not ready"), } } fn create_url_response( error: Option<Box<HttpError>>, body: Option<Box<UrlBody>>, status_code: u32, ) -> http::UrlResponse { http::UrlResponse { error: error, body: body, url: None, status_code: status_code, status_line: None, headers: None, mime_type: None, charset: None, redirect_method: None, redirect_url: None, redirect_referrer: None, } } fn poll_http_service_request( exec: &mut fasync::Executor, next_http_service_req: &mut StreamFuture<HttpServiceRequestStream>, ) -> Poll<HttpServiceRequest> { exec.run_until_stalled(next_http_service_req).map(|(req, stream)| { *next_http_service_req = stream.into_future(); req.expect("did not expect the HttpServiceRequestStream to end") .expect("error polling http service request stream") }) } fn poll_url_loader_request( exec: &mut fasync::Executor, next_url_loader_req: &mut StreamFuture<UrlLoaderRequestStream>, ) -> Poll<UrlLoaderRequest> { exec.run_until_stalled(next_url_loader_req).map(|(req, stream)| { *next_url_loader_req = stream.into_future(); req.expect("did not expect the UrlLoaderRequestStream to end") .expect("error polling url loader request stream") }) } fn create_http_service_util() -> (HttpServiceProxy, HttpServiceRequestStream) { let (proxy, server) = endpoints::create_proxy::<HttpServiceMarker>() .expect("falied to create a http_service_channel for tests"); let server = server.into_stream().expect("failed to create a http_service response stream"); (proxy, server) } }
#![no_main] #![no_std] extern crate stm32f1xx_hal as hal; extern crate panic_semihosting; use cortex_m_semihosting::hprintln; use cortex_m::asm::delay; use rtfm::app; use hal::gpio::gpiob::*; use hal::gpio::*; use hal::prelude::*; use hal::spi::Spi; use hal::time::MegaHertz; use ws2812::Ws2812; use ws2812_spi as ws2812; use stm32_usbd::{UsbBus, UsbBusType}; use usb_device::bus; use usb_device::prelude::*; use usbd_serial::{SerialPort, USB_CLASS_CDC}; #[app(device = stm32f1xx_hal::stm32)] const APP: () = { static mut LED_COUNT: usize = 8; static mut LEDS: Ws2812< Spi< hal::pac::SPI1, ( PB3<Alternate<PushPull>>, PB4<Input<Floating>>, PB5<Alternate<PushPull>>, ), >, > = (); static mut USB_DEV: UsbDevice<'static, UsbBusType> = (); static mut SERIAL: SerialPort<'static, UsbBusType> = (); #[init] fn init() -> init::LateResources { static mut USB_BUS: Option<bus::UsbBusAllocator<UsbBusType>> = None; // Cortex-M peripherals let _core: rtfm::Peripherals = core; let mut rcc = device.RCC.constrain(); let mut afio = device.AFIO.constrain(&mut rcc.apb2); let mut flash = device.FLASH.constrain(); let clocks = rcc.cfgr .use_hse(8.mhz()) .sysclk(48.mhz()) .pclk1(24.mhz()) .freeze(&mut flash.acr); // Init USB serial hprintln!("Initialising USB serial device").unwrap(); assert!(clocks.usbclk_valid()); let mut gpioa = device.GPIOA.split(&mut rcc.apb2); // BluePill board has a pull-up resistor on the D+ line. // Pull the D+ pin down to send a RESET condition to the USB bus. let mut usb_dp = gpioa.pa12.into_push_pull_output(&mut gpioa.crh); usb_dp.set_low(); delay(clocks.sysclk().0 / 100); let usb_dm = gpioa.pa11; let usb_dp = usb_dp.into_floating_input(&mut gpioa.crh); *USB_BUS = Some(UsbBus::new(device.USB, (usb_dm, usb_dp))); let serial = SerialPort::new(USB_BUS.as_ref().unwrap()); let usb_dev = UsbDeviceBuilder::new(USB_BUS.as_ref().unwrap(), UsbVidPid(0x16c0, 0x27dd)) .manufacturer("Fake company") .product("Serial port") .serial_number("TEST") .device_class(USB_CLASS_CDC) .max_power(500) .build(); hprintln!("Initialising Ws2812 LEDs").unwrap(); let mut portb = device.GPIOB.split(&mut rcc.apb2); // Setup SPI1 // MOSI PB5 // MISO PB4 // SCK PB3 let mosi = portb.pb5.into_alternate_push_pull(&mut portb.crl); let miso = portb.pb4.into_floating_input(&mut portb.crl); let sck = portb.pb3.into_alternate_push_pull(&mut portb.crl); /*let spi_mode = Mode{ polarity: Polarity::IdleLow, phase: Phase::CaptureOnFirstTransition, };*/ let spi_freq: MegaHertz = 3.mhz(); let mut spi = Spi::spi1( device.SPI1, (sck, miso, mosi), &mut afio.mapr, ws2812::MODE, spi_freq, clocks, &mut rcc.apb2, ); let mut leds = Ws2812::new(spi); init::LateResources { LEDS: leds, USB_DEV: usb_dev, SERIAL: serial } } #[interrupt(resources = [USB_DEV, SERIAL])] fn USB_HP_CAN_TX() { usb_poll(&mut resources.USB_DEV, &mut resources.SERIAL); } #[interrupt(resources = [USB_DEV, SERIAL])] fn USB_LP_CAN_RX0() { usb_poll(&mut resources.USB_DEV, &mut resources.SERIAL); } }; fn usb_poll<B: bus::UsbBus>( usb_dev: &mut UsbDevice<'static, B>, serial: &mut SerialPort<'static, B>, ) { if !usb_dev.poll(&mut [serial]) { return; } let mut buf = [0u8; 8]; match serial.read(&mut buf) { Ok(count) if count > 0 => { // Echo back in upper case for c in buf[0..count].iter_mut() { if 0x61 <= *c && *c <= 0x7a { *c &= !0x20; } } serial.write(&buf[0..count]).ok(); } _ => {} } }
// revisions: base nll // ignore-compare-mode-nll //[nll] compile-flags: -Z borrowck=mir trait T<'a> { fn a(&'a self) -> &'a bool; fn b(&self) { self.a(); //[base]~^ ERROR cannot infer //[nll]~^^ ERROR lifetime may not live long enough } } fn main() {}
#[doc = "Writer for register C4IFCR"] pub type W = crate::W<u32, super::C4IFCR>; #[doc = "Register C4IFCR `reset()`'s with value 0"] impl crate::ResetValue for super::C4IFCR { type Type = u32; #[inline(always)] fn reset_value() -> Self::Type { 0 } } #[doc = "Write proxy for field `CTEIF4`"] pub struct CTEIF4_W<'a> { w: &'a mut W, } impl<'a> CTEIF4_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !0x01) | ((value as u32) & 0x01); self.w } } #[doc = "Write proxy for field `CCTCIF4`"] pub struct CCTCIF4_W<'a> { w: &'a mut W, } impl<'a> CCTCIF4_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 = "Write proxy for field `CBRTIF4`"] pub struct CBRTIF4_W<'a> { w: &'a mut W, } impl<'a> CBRTIF4_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2); self.w } } #[doc = "Write proxy for field `CBTIF4`"] pub struct CBTIF4_W<'a> { w: &'a mut W, } impl<'a> CBTIF4_W<'a> { #[doc = r"Sets the field bit"] #[inline(always)] pub fn set_bit(self) -> &'a mut W { self.bit(true) } #[doc = r"Clears the field bit"] #[inline(always)] pub fn clear_bit(self) -> &'a mut W { self.bit(false) } #[doc = r"Writes raw bits to the field"] #[inline(always)] pub fn bit(self, value: bool) -> &'a mut W { self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3); self.w } } #[doc = "Write proxy for field `CLTCIF4`"] pub struct CLTCIF4_W<'a> { w: &'a mut W, } impl<'a> CLTCIF4_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 } } impl W { #[doc = "Bit 0 - Channel x clear transfer error interrupt flag Writing a 1 into this bit clears TEIFx in the MDMA_ISRy register"] #[inline(always)] pub fn cteif4(&mut self) -> CTEIF4_W { CTEIF4_W { w: self } } #[doc = "Bit 1 - Clear Channel transfer complete interrupt flag for channel x Writing a 1 into this bit clears CTCIFx in the MDMA_ISRy register"] #[inline(always)] pub fn cctcif4(&mut self) -> CCTCIF4_W { CCTCIF4_W { w: self } } #[doc = "Bit 2 - Channel x clear block repeat transfer complete interrupt flag Writing a 1 into this bit clears BRTIFx in the MDMA_ISRy register"] #[inline(always)] pub fn cbrtif4(&mut self) -> CBRTIF4_W { CBRTIF4_W { w: self } } #[doc = "Bit 3 - Channel x Clear block transfer complete interrupt flag Writing a 1 into this bit clears BTIFx in the MDMA_ISRy register"] #[inline(always)] pub fn cbtif4(&mut self) -> CBTIF4_W { CBTIF4_W { w: self } } #[doc = "Bit 4 - CLear buffer Transfer Complete Interrupt Flag for channel x Writing a 1 into this bit clears TCIFx in the MDMA_ISRy register"] #[inline(always)] pub fn cltcif4(&mut self) -> CLTCIF4_W { CLTCIF4_W { w: self } } }
use bindgen::callbacks::ParseCallbacks; use bindgen::{Builder, RustTarget}; use std::path::PathBuf; #[derive(Debug)] struct CustomCallbacks; impl ParseCallbacks for CustomCallbacks { fn process_comment(&self, comment: &str) -> Option<String> { Some(doxygen_rs::transform(comment)) } } fn main() { let devkitpro = std::env::var("DEVKITPRO").expect("DEVKITPRO not set in environment"); let devkitarm = std::env::var("DEVKITARM").expect("DEVKITARM not set in environment"); let include_path = PathBuf::from_iter([devkitpro.as_str(), "libctru", "include"]); let ctru_header = include_path.join("3ds.h"); let sysroot = PathBuf::from(devkitarm).join("arm-none-eabi"); let system_include = sysroot.join("include"); let errno_header = system_include.join("errno.h"); let bindings = Builder::default() .header(ctru_header.to_str().unwrap()) .header(errno_header.to_str().unwrap()) .rust_target(RustTarget::Nightly) .use_core() .trust_clang_mangling(false) .must_use_type("Result") .layout_tests(false) .ctypes_prefix("::libc") .prepend_enum_name(false) .blocklist_type("u(8|16|32|64)") .blocklist_type("__builtin_va_list") .blocklist_type("__va_list") .opaque_type("MiiData") .derive_default(true) .clang_args([ "--target=arm-none-eabi", "--sysroot", sysroot.to_str().unwrap(), "-isystem", system_include.to_str().unwrap(), "-I", include_path.to_str().unwrap(), "-mfloat-abi=hard", "-march=armv6k", "-mtune=mpcore", "-mfpu=vfp", "-DARM11", "-D__3DS__", ]) .parse_callbacks(Box::new(CustomCallbacks)) .generate() .expect("unable to generate bindings"); bindings .write(Box::new(std::io::stdout())) .expect("failed to write bindings"); }
use notify::{DebouncedEvent, RecommendedWatcher, RecursiveMode, Result, Watcher}; use std::fs; use std::path::{Path, PathBuf}; use std::sync::mpsc::channel; use std::time::Duration; struct App { src: &'static str, dst: FileType, } struct FileType { img: String, audio: String, video: String, doc: String, doc_book: String, archive: String, } impl FileType { fn new() -> Self { Self { img: "/home/susilo/Pictures".to_owned(), audio: "/home/susilo/Music".to_owned(), video: "/home/susilo/Videos".to_owned(), doc: "/home/susilo/Documents".to_owned(), doc_book: "/home/susilo/Documents/eBooks".to_owned(), archive: "/home/susilo/var/backup".to_owned(), } } } impl App { fn watch(&self) -> Result<()> { let (tx, rx) = channel(); let mut watcher: RecommendedWatcher = Watcher::new(tx, Duration::from_millis(500)).unwrap(); watcher.watch(self.src, RecursiveMode::Recursive).unwrap(); loop { match rx.recv() { Ok(event) => { println!("{:?}", event); match event { DebouncedEvent::Create(path) => { handle_file(path, &self.dst) }, DebouncedEvent::Write(path) => { handle_file(path, &self.dst) }, _ => (), } } Err(e) => println!("watch error: {:?}", e), } } } } fn handle_file(path: PathBuf, ftype: &FileType) { let fpath = path.clone(); let file_name = Path::new(path.to_str().unwrap()) .file_name() .unwrap() .to_str() .unwrap(); let ext = Path::new(file_name).extension().unwrap().to_str().unwrap(); let video = vec!["mp4", "mov", "mkv", "mpg", "mpeg"]; let audio = vec!["mp3", "ogg", "wav", "flac"]; let img = vec!["jpg", "jpeg", "png", "svg", "bmp"]; let archive = vec![ "rar", "zip", "tar", "tar.gz", "tar.xz", "tar.bz", "tar.bz2", "tgz", ]; let doc = vec![ "odt", "ods", "odp", "doc", "docx", "xls", "xlsx", "ppt", "pptx", "pdf", "epub", "xlsm", ]; let root = fpath.parent().unwrap().to_str().unwrap(); let src = format!("{}/{}", root, file_name); if video.contains(&ext) { let dst = format!("{}/{}", &ftype.video, file_name); let _ = fs::copy(&src, &dst); let _ = fs::remove_file(&src); println!("Menyalin file {} ke {}", file_name, &ftype.video); } else if audio.contains(&ext) { let dst = format!("{}/{}", &ftype.audio, file_name); let _ = fs::copy(&src, &dst); let _ = fs::remove_file(&src); println!("Menyalin file {} ke {}", file_name, &ftype.audio); } else if img.contains(&ext) { let dst = format!("{}/{}", &ftype.img, file_name); let _ = fs::copy(&src, &dst); let _ = fs::remove_file(&src); println!("Menyalin file {} ke {}", file_name, &ftype.img); } else if archive.contains(&ext) { let dst = format!("{}/{}", &ftype.archive, file_name); let _ = fs::copy(&src, &dst); let _ = fs::remove_file(&src); println!("Menyalin file {} ke {}", file_name, &ftype.archive); } else if doc.contains(&ext) { let dst = format!("{}/{}", &ftype.doc, file_name); let _ = fs::copy(&src, &dst); let _ = fs::remove_file(&src); println!("Menyalin file {} ke {}", file_name, &ftype.doc); } } fn main() { let app = App { src: "/home/susilo/Downloads", dst: FileType::new(), }; if let Err(e) = app.watch() { println!("error: {:?}", e) } }
#![deny(missing_docs, clippy::missing_safety_doc)] //! Arbitrary precision integer and rational arithmetic library wrapping //! [`imath`](https://github.com/creachadair/imath/) #[macro_use] pub(crate) mod error; pub(crate) mod integer; pub(crate) mod rational; pub use crate::{ error::Error, integer::Integer, rational::{Rational, RoundMode}, };
#[repr(C)] #[simd] pub struct u64x8(pub u64, pub u64, pub u64, pub u64, pub u64, pub u64, pub u64, pub u64);
use super::command::{Command, CommandContext}; use super::debugger::{Debugger, RunResult}; use std::io::Write; use structopt::StructOpt; use anyhow::Result; pub struct RunCommand {} impl RunCommand { pub fn new() -> Self { Self {} } } #[derive(StructOpt)] struct Opts { #[structopt(name = "FUNCTION NAME")] name: Option<String>, } impl<D: Debugger> Command<D> for RunCommand { fn name(&self) -> &'static str { "run" } fn description(&self) -> &'static str { "Launch the executable in the debugger." } fn run(&self, debugger: &mut D, _context: &CommandContext, args: Vec<&str>) -> Result<()> { let opts = Opts::from_iter_safe(args)?; if debugger.is_running() { print!("There is a running process, kill it and restart?: [Y/n] "); std::io::stdout().flush().unwrap(); let stdin = std::io::stdin(); let mut input = String::new(); stdin.read_line(&mut input).unwrap(); if input != "Y\n" { return Ok(()); } } match debugger.run(opts.name) { Ok(RunResult::Finish(values)) => { println!("{:?}", values); } Ok(RunResult::Breakpoint) => { println!("Hit breakpoint"); } Err(msg) => { eprintln!("{}", msg); } } Ok(()) } }
use amethyst::renderer::light::{Light, PointLight}; use amethyst::renderer::palette::rgb::Rgb; use amethyst::{ animation::{ get_animation_set, AnimationBundle, AnimationCommand, AnimationControlSet, AnimationSet, EndControl, VertexSkinningBundle, }, assets::{ AssetLoaderSystemData, AssetPrefab, Completion, Handle, Prefab, PrefabData, PrefabLoader, PrefabLoaderSystemDesc, ProgressCounter, RonFormat, }, controls::{ControlTagPrefab, FlyControlBundle}, core::transform::{Transform, TransformBundle}, derive::PrefabData, ecs::{Entity, ReadStorage, Write, WriteStorage}, input::{is_close_requested, is_key_down, StringBindings, VirtualKeyCode}, prelude::*, renderer::{ camera::Camera, camera::CameraPrefab, light::LightPrefab, mtl::{Material, MaterialDefaults}, plugins::{RenderPbr3D, RenderSkybox, RenderToWindow}, rendy::mesh::{Normal, Position, Tangent, TexCoord}, shape::Shape, types::DefaultBackend, Mesh, RenderingBundle, }, utils::{ application_root_dir, auto_fov::{AutoFov, AutoFovSystem}, tag::{Tag, TagFinder}, }, Error, }; use amethyst_gltf::{GltfSceneAsset, GltfSceneFormat, GltfSceneLoaderSystemDesc}; use serde::{Deserialize, Serialize}; #[derive(Default)] struct GameState { entity: Option<Entity>, initialised: bool, progress: Option<ProgressCounter>, } #[derive(Clone, Serialize, Deserialize)] struct AnimationMarker; #[derive(Default)] struct Scene { handle: Option<Handle<Prefab<ScenePrefabData>>>, animation_index: usize, } #[derive(Default, Deserialize, Serialize, PrefabData)] #[serde(default)] struct ScenePrefabData { transform: Option<Transform>, gltf: Option<AssetPrefab<GltfSceneAsset, GltfSceneFormat>>, camera: Option<CameraPrefab>, auto_fov: Option<AutoFov>, light: Option<LightPrefab>, tag: Option<Tag<AnimationMarker>>, fly_tag: Option<ControlTagPrefab>, } impl SimpleState for GameState { fn on_start(&mut self, data: StateData<'_, GameData<'_, '_>>) { let StateData { world, .. } = data; self.progress = Some(ProgressCounter::default()); world.exec( |(loader, mut scene): (PrefabLoader<'_, ScenePrefabData>, Write<'_, Scene>)| { scene.handle = Some(loader.load( "prefab/mclaren_mp4-12c.ron", // "prefab/renderable.ron", RonFormat, self.progress.as_mut().unwrap(), )); }, ); // initialize_camera(state_data.world); // initialize_player(state_data.world); // initialize_light(state_data.world); } fn handle_event( &mut self, data: StateData<'_, GameData<'_, '_>>, event: StateEvent, ) -> SimpleTrans { let StateData { world, .. } = data; if let StateEvent::Window(event) = &event { if is_close_requested(&event) || is_key_down(&event, VirtualKeyCode::Escape) { Trans::Quit } else if is_key_down(&event, VirtualKeyCode::Space) { // toggle_or_cycle_animation( // self.entity, // &mut world.write_resource(), // &world.read_storage(), // &mut world.write_storage(), // ); Trans::None } else { Trans::None } } else { Trans::None } } fn update(&mut self, data: &mut StateData<'_, GameData<'_, '_>>) -> SimpleTrans { if !self.initialised { let remove = match self.progress.as_ref().map(|p| p.complete()) { None | Some(Completion::Loading) => false, Some(Completion::Complete) => { let scene_handle = data .world .read_resource::<Scene>() .handle .as_ref() .unwrap() .clone(); data.world.create_entity().with(scene_handle).build(); true } Some(Completion::Failed) => { println!("Error: {:?}", self.progress.as_ref().unwrap().errors()); return Trans::Quit; } }; if remove { self.progress = None; } if self.entity.is_none() { if let Some(entity) = data .world .exec(|finder: TagFinder<'_, AnimationMarker>| finder.find()) { self.entity = Some(entity); self.initialised = true; } } } Trans::None } } fn main() -> Result<(), amethyst::Error> { amethyst::start_logger(Default::default()); let app_root = application_root_dir()?; let config_dir = app_root.join("config/"); let display_config_path = config_dir.join("display.ron"); let assets_dir = app_root.join("assets/"); let game_data = GameDataBuilder::default() .with(AutoFovSystem::default(), "auto_fov", &[]) .with_system_desc( PrefabLoaderSystemDesc::<ScenePrefabData>::default(), "scene_loader", &[], ) .with_system_desc( GltfSceneLoaderSystemDesc::default(), "gltf_loader", &["scene_loader"], // This is important so that entity instantiation is performed in a single frame. ) .with_bundle( AnimationBundle::<usize, Transform>::new("animation_control", "sampler_interpolation") .with_dep(&["gltf_loader"]), )? .with_bundle( FlyControlBundle::<StringBindings>::new(None, None, None) .with_sensitivity(0.1, 0.1) .with_speed(5.), )? .with_bundle(TransformBundle::new().with_dep(&[ "animation_control", "sampler_interpolation", "fly_movement", ]))? .with_bundle(VertexSkinningBundle::new().with_dep(&[ "transform_system", "animation_control", "sampler_interpolation", ]))? .with_bundle( RenderingBundle::<DefaultBackend>::new() .with_plugin(RenderToWindow::from_config_path(display_config_path)?) .with_plugin(RenderPbr3D::default().with_skinning()) .with_plugin(RenderSkybox::default()), )?; let mut game = Application::build(assets_dir, GameState::default())?.build(game_data)?; game.run(); Ok(()) } // fn initialize_camera(world: &mut World) { // let mut transform = Transform::default(); // transform.set_translation_xyz(0.0, 0.0, 10.0); // world // .create_entity() // .with(Camera::standard_3d(1920.0, 1080.0)) // .with(transform) // .build(); // } // fn initialize_player(world: &mut World) { // let mesh = world.exec(|loader: AssetLoaderSystemData<'_, Mesh>| { // loader.load_from_data( // Shape::Sphere(100, 100) // .generate::<(Vec<Position>, Vec<Normal>, Vec<Tangent>, Vec<TexCoord>)>(None) // .into(), // (), // ) // }); // let material_defaults = world.read_resource::<MaterialDefaults>().0.clone(); // let material = world.exec(|loader: AssetLoaderSystemData<'_, Material>| { // loader.load_from_data( // Material { // ..material_defaults // }, // (), // ) // }); // let mut transform = Transform::default(); // transform.set_translation_xyz(0.0, 0.0, 0.0); // world // .create_entity() // .with(mesh) // .with(material) // .with(transform) // // .with(Type::Player) // // .with(Hp { hp: 100 }) // .build(); // } // fn initialize_scene(world: &mut World) { // let StateData { world, .. } = data; // world.exec( // |(loader, mut scene): (PrefabLoader<'_, ScenePrefabData>, Write<'_, Scene>)| { // scene.handle = Some(loader.load( // "prefab/puffy_scene.ron", // RonFormat, // self.progress.as_mut().unwrap(), // )); // }, // ); // } // fn initialize_light(world: &mut World) { // let light: Light = PointLight { // intensity: 10.0, // color: Rgb::new(1.0, 1.0, 1.0), // ..PointLight::default() // } // .into(); // let mut transform = Transform::default(); // transform.set_translation_xyz(5.0, 5.0, 20.0); // world.create_entity().with(light).with(transform).build(); // }
pub struct Solution; impl Solution { pub fn contains_nearby_almost_duplicate(nums: Vec<i32>, k: i32, t: i32) -> bool { let mut pairs = nums .into_iter() .enumerate() .map(|(i, v)| (v, i)) .collect::<Vec<_>>(); pairs.sort_unstable(); for i in 0..pairs.len() { let mut j = i + 1; while j < pairs.len() && pairs[j].0 <= pairs[i].0 + t { if abs_diff(pairs[i].1, pairs[j].1) <= k { return true; } j += 1; } } return false; } } fn abs_diff(i: usize, j: usize) -> i32 { (i as i32 - j as i32).abs() } #[test] fn test0220() { fn case(nums: Vec<i32>, k: i32, t: i32, want: bool) { let got = Solution::contains_nearby_almost_duplicate(nums, k, t); assert_eq!(got, want); } case(vec![1, 2, 3, 1], 3, 0, true); case(vec![1, 0, 1, 1], 1, 2, true); case(vec![1, 5, 9, 1, 5, 9], 2, 3, false); }
#![allow(non_snake_case)] #[allow(unused_doc_comments)] // Multisig Schnorr // Copyright 2018 by Kzen Networks // This file is part of Multisig Schnorr library // (https://github.com/KZen-networks/multisig-schnorr) // Multisig Schnorr is free software: you can redistribute // it and/or modify it under the terms of the GNU General Public // License as published by the Free Software Foundation, either // version 3 of the License, or (at your option) any later version. // @license GPL-3.0+ <https://github.com/KZen-networks/multisig-schnorr/blob/master/LICENSE> use mohan::{ mohan_rand, hash::{ blake256, H256 }, dalek::{ constants::RISTRETTO_BASEPOINT_POINT, ristretto::RistrettoPoint, scalar::Scalar, } }; use crate::{ Signature, feldman_vss::{ VerifiableSS, ShamirSecretSharing }, SchnorrError }; use serde::{ Serialize, Deserialize}; pub struct Keys { pub u_i: Scalar, pub y_i: RistrettoPoint, pub party_index: usize, } pub struct KeyGenBroadcastMessage1 { commitment: H256, } #[derive(Clone, Serialize, Deserialize)] pub struct SharedKeys { pub y: RistrettoPoint, pub x_i: Scalar } // // 4.1 Key generation protocol // impl Keys { /// Phase 1 /// Each player selects a random Scalar and computes its /// assoicated "Public Point" basically raised to the group basepoint /// This is a keypair pub fn phase1_create(index: usize) -> Keys { let u: Scalar = Scalar::random(&mut mohan_rand()); let y = RISTRETTO_BASEPOINT_POINT * u; Keys { u_i: u, y_i: y, party_index: index.clone(), } } /// Phase 1.1 /// Each Player samples a random nonce Scalar to produce /// a commitment to the PublicPoint and shares this hash based /// commitement with the other players. pub fn phase1_broadcast(&self) -> (KeyGenBroadcastMessage1, Scalar) { let blind_factor = Scalar::random(&mut mohan_rand()); let mut buf = Vec::new(); buf.extend_from_slice(self.y_i.compress().as_bytes()); buf.extend_from_slice(blind_factor.as_bytes()); let commitment = blake256(&buf); let bcm1 = KeyGenBroadcastMessage1 { commitment }; (bcm1, blind_factor) } pub fn phase1_verify_com_phase2_distribute( &self, params: &ShamirSecretSharing, blind_vec: &Vec<Scalar>, y_vec: &Vec<RistrettoPoint>, bc1_vec: &Vec<KeyGenBroadcastMessage1>, parties: &[usize], ) -> Result<(VerifiableSS, Vec<Scalar>, usize), SchnorrError> { // test length: assert_eq!(blind_vec.len(), params.share_count); assert_eq!(bc1_vec.len(), params.share_count); assert_eq!(y_vec.len(), params.share_count); // test decommitments let correct_key_correct_decom_all = (0..bc1_vec.len()) .map(|i| { let mut buf = Vec::new(); buf.extend_from_slice(y_vec[i].compress().as_bytes()); buf.extend_from_slice(blind_vec[i].as_bytes()); blake256(&buf) == bc1_vec[i].commitment }) .all(|x| x == true); let (vss_scheme, secret_shares) = VerifiableSS::share_at_indices( params.threshold, params.share_count, &self.u_i, &parties, ); match correct_key_correct_decom_all { true => Ok((vss_scheme, secret_shares, self.party_index.clone())), false => Err(SchnorrError::VerifyError), } } pub fn phase2_verify_vss_construct_keypair( &self, params: &ShamirSecretSharing, y_vec: &Vec<RistrettoPoint>, secret_shares_vec: &Vec<Scalar>, vss_scheme_vec: &Vec<VerifiableSS>, index: &usize, ) -> Result<SharedKeys, SchnorrError> { assert_eq!(y_vec.len(), params.share_count); assert_eq!(secret_shares_vec.len(), params.share_count); assert_eq!(vss_scheme_vec.len(), params.share_count); let correct_ss_verify = (0..y_vec.len()) .map(|i| { vss_scheme_vec[i] .validate_share(&secret_shares_vec[i], *index) .is_ok() && vss_scheme_vec[i].commitments[0] == y_vec[i] }) .all(|x| x == true); match correct_ss_verify { true => { let mut y_vec_iter = y_vec.iter(); let y0 = y_vec_iter.next().unwrap(); let y = y_vec_iter.fold(y0.clone(), |acc, x| acc + x); let x_i = secret_shares_vec.iter().fold(Scalar::zero(), |acc, x| acc + x); Ok(SharedKeys { y, x_i }) } false => Err(SchnorrError::VerifyShareError), } } // remove secret shares from x_i for parties that are not participating in signing pub fn update_shared_key( shared_key: &SharedKeys, parties_in: &[usize], secret_shares_vec: &Vec<Scalar>, ) -> SharedKeys { let mut new_xi: Scalar = Scalar::zero(); for i in 0..secret_shares_vec.len() { if parties_in.iter().find(|&&x| x == i).is_some() { new_xi = new_xi + &secret_shares_vec[i] } } SharedKeys { y: shared_key.y.clone(), x_i: new_xi, } } } pub struct LocalSig { gamma_i: Scalar, e: Scalar, } impl LocalSig { pub fn compute( message: &[u8], local_ephemaral_key: &SharedKeys, local_private_key: &SharedKeys, ) -> LocalSig { let beta_i = local_ephemaral_key.x_i.clone(); let alpha_i = local_private_key.x_i.clone(); let mut buf = Vec::new(); buf.extend_from_slice(local_ephemaral_key.y.compress().as_bytes()); buf.extend_from_slice(local_private_key.y.compress().as_bytes()); buf.extend_from_slice(message); let e = blake256(&buf).into_scalar(); let gamma_i = beta_i + e.clone() * alpha_i; LocalSig { gamma_i, e } } // section 4.2 step 3 #[allow(unused_doc_comments)] pub fn verify_local_sigs( gamma_vec: &Vec<LocalSig>, parties_index_vec: &[usize], vss_private_keys: &Vec<VerifiableSS>, vss_ephemeral_keys: &Vec<VerifiableSS>, ) -> Result<(VerifiableSS), SchnorrError> { //parties_index_vec is a vector with indices of the parties that are participating and provided gamma_i for this step // test that enough parties are in this round assert!(parties_index_vec.len() > vss_private_keys[0].parameters.threshold); // Vec of joint commitments: // n' = num of signers, n - num of parties in keygen // [com0_eph_0,... ,com0_eph_n', e*com0_kg_0, ..., e*com0_kg_n ; // ... ; // comt_eph_0,... ,comt_eph_n', e*comt_kg_0, ..., e*comt_kg_n ] let comm_vec = (0..vss_private_keys[0].parameters.threshold + 1) .map(|i| { let mut key_gen_comm_i_vec = (0..vss_private_keys.len()) .map(|j| vss_private_keys[j].commitments[i].clone() * &gamma_vec[i].e) .collect::<Vec<RistrettoPoint>>(); let mut eph_comm_i_vec = (0..vss_ephemeral_keys.len()) .map(|j| vss_ephemeral_keys[j].commitments[i].clone()) .collect::<Vec<RistrettoPoint>>(); key_gen_comm_i_vec.append(&mut eph_comm_i_vec); let mut comm_i_vec_iter = key_gen_comm_i_vec.iter(); let comm_i_0 = comm_i_vec_iter.next().unwrap(); comm_i_vec_iter.fold(comm_i_0.clone(), |acc, x| acc + x) }) .collect::<Vec<RistrettoPoint>>(); let vss_sum = VerifiableSS { parameters: vss_ephemeral_keys[0].parameters.clone(), commitments: comm_vec, }; let g = RISTRETTO_BASEPOINT_POINT; let correct_ss_verify = (0..parties_index_vec.len()) .map(|i| { let gamma_i_g = &g * &gamma_vec[i].gamma_i; vss_sum .validate_share_public(&gamma_i_g, parties_index_vec[i] + 1) .is_ok() }) .collect::<Vec<bool>>(); match correct_ss_verify.iter().all(|x| x.clone() == true) { true => Ok(vss_sum), false => Err(SchnorrError::VerifyShareError), } } } impl Signature { pub fn sign_threshold( vss_sum_local_sigs: &VerifiableSS, local_sig_vec: &Vec<LocalSig>, parties_index_vec: &[usize], R: RistrettoPoint, ) -> Signature { let gamma_vec = (0..parties_index_vec.len()) .map(|i| local_sig_vec[i].gamma_i.clone()) .collect::<Vec<Scalar>>(); let reconstruct_limit = vss_sum_local_sigs.parameters.threshold.clone() + 1; let s = vss_sum_local_sigs.reconstruct( &parties_index_vec[0..reconstruct_limit.clone()], &gamma_vec[0..reconstruct_limit.clone()], ); Signature { s, R: R.compress() } } pub fn verify_threshold(&self, message: &[u8], pubkey_y: &RistrettoPoint) -> Result<(), SchnorrError> { let mut buf = Vec::new(); buf.extend_from_slice(self.R.as_bytes()); buf.extend_from_slice(pubkey_y.compress().as_bytes()); buf.extend_from_slice(message); let e = blake256(&buf).into_scalar(); let g = RISTRETTO_BASEPOINT_POINT; let sigma_g = g * &self.s; let e_y = pubkey_y * &e; match self.R.decompress() { None => return Err(SchnorrError::InvalidSignature), Some(big_r) => { let e_y_plus_v = e_y + big_r; if e_y_plus_v == sigma_g { return Ok(()); } else { return Err(SchnorrError::VerifyShareError); } } } } }
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)] #[inline] pub unsafe fn AddPointerInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, pointerid: u32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn AddPointerInteractionContext(interactioncontext: HINTERACTIONCONTEXT, pointerid: u32) -> ::windows::core::HRESULT; } AddPointerInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(pointerid)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] #[inline] pub unsafe fn BufferPointerPacketsInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, entriescount: u32, pointerinfo: *const super::Input::Pointer::POINTER_INFO) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn BufferPointerPacketsInteractionContext(interactioncontext: HINTERACTIONCONTEXT, entriescount: u32, pointerinfo: *const super::Input::Pointer::POINTER_INFO) -> ::windows::core::HRESULT; } BufferPointerPacketsInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(entriescount), ::core::mem::transmute(pointerinfo)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct CROSS_SLIDE_FLAGS(pub u32); pub const CROSS_SLIDE_FLAGS_NONE: CROSS_SLIDE_FLAGS = CROSS_SLIDE_FLAGS(0u32); pub const CROSS_SLIDE_FLAGS_SELECT: CROSS_SLIDE_FLAGS = CROSS_SLIDE_FLAGS(1u32); pub const CROSS_SLIDE_FLAGS_SPEED_BUMP: CROSS_SLIDE_FLAGS = CROSS_SLIDE_FLAGS(2u32); pub const CROSS_SLIDE_FLAGS_REARRANGE: CROSS_SLIDE_FLAGS = CROSS_SLIDE_FLAGS(4u32); pub const CROSS_SLIDE_FLAGS_MAX: CROSS_SLIDE_FLAGS = CROSS_SLIDE_FLAGS(4294967295u32); impl ::core::convert::From<u32> for CROSS_SLIDE_FLAGS { fn from(value: u32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for CROSS_SLIDE_FLAGS { type Abi = Self; } impl ::core::ops::BitOr for CROSS_SLIDE_FLAGS { type Output = Self; fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } } impl ::core::ops::BitAnd for CROSS_SLIDE_FLAGS { type Output = Self; fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } } impl ::core::ops::BitOrAssign for CROSS_SLIDE_FLAGS { fn bitor_assign(&mut self, rhs: Self) { self.0.bitor_assign(rhs.0) } } impl ::core::ops::BitAndAssign for CROSS_SLIDE_FLAGS { fn bitand_assign(&mut self, rhs: Self) { self.0.bitand_assign(rhs.0) } } impl ::core::ops::Not for CROSS_SLIDE_FLAGS { type Output = Self; fn not(self) -> Self { Self(self.0.not()) } } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct CROSS_SLIDE_PARAMETER { pub threshold: CROSS_SLIDE_THRESHOLD, pub distance: f32, } impl CROSS_SLIDE_PARAMETER {} impl ::core::default::Default for CROSS_SLIDE_PARAMETER { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for CROSS_SLIDE_PARAMETER { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("CROSS_SLIDE_PARAMETER").field("threshold", &self.threshold).field("distance", &self.distance).finish() } } impl ::core::cmp::PartialEq for CROSS_SLIDE_PARAMETER { fn eq(&self, other: &Self) -> bool { self.threshold == other.threshold && self.distance == other.distance } } impl ::core::cmp::Eq for CROSS_SLIDE_PARAMETER {} unsafe impl ::windows::core::Abi for CROSS_SLIDE_PARAMETER { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct CROSS_SLIDE_THRESHOLD(pub i32); pub const CROSS_SLIDE_THRESHOLD_SELECT_START: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(0i32); pub const CROSS_SLIDE_THRESHOLD_SPEED_BUMP_START: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(1i32); pub const CROSS_SLIDE_THRESHOLD_SPEED_BUMP_END: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(2i32); pub const CROSS_SLIDE_THRESHOLD_REARRANGE_START: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(3i32); pub const CROSS_SLIDE_THRESHOLD_COUNT: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(4i32); pub const CROSS_SLIDE_THRESHOLD_MAX: CROSS_SLIDE_THRESHOLD = CROSS_SLIDE_THRESHOLD(-1i32); impl ::core::convert::From<i32> for CROSS_SLIDE_THRESHOLD { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for CROSS_SLIDE_THRESHOLD { type Abi = Self; } #[inline] pub unsafe fn CreateInteractionContext() -> ::windows::core::Result<HINTERACTIONCONTEXT> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn CreateInteractionContext(interactioncontext: *mut HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } let mut result__: <HINTERACTIONCONTEXT as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); CreateInteractionContext(&mut result__).from_abi::<HINTERACTIONCONTEXT>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn DestroyInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn DestroyInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } DestroyInteractionContext(interactioncontext.into_param().abi()).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetCrossSlideParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, threshold: CROSS_SLIDE_THRESHOLD) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetCrossSlideParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, threshold: CROSS_SLIDE_THRESHOLD, distance: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetCrossSlideParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(threshold), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetHoldParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: HOLD_PARAMETER) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetHoldParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: HOLD_PARAMETER, value: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetHoldParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetInertiaParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, inertiaparameter: INERTIA_PARAMETER) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetInertiaParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, inertiaparameter: INERTIA_PARAMETER, value: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetInertiaParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(inertiaparameter), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetInteractionConfigurationInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, configurationcount: u32, configuration: *mut INTERACTION_CONTEXT_CONFIGURATION) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetInteractionConfigurationInteractionContext(interactioncontext: HINTERACTIONCONTEXT, configurationcount: u32, configuration: *mut INTERACTION_CONTEXT_CONFIGURATION) -> ::windows::core::HRESULT; } GetInteractionConfigurationInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(configurationcount), ::core::mem::transmute(configuration)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetMouseWheelParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: MOUSE_WHEEL_PARAMETER) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetMouseWheelParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: MOUSE_WHEEL_PARAMETER, value: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetMouseWheelParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetPropertyInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, contextproperty: INTERACTION_CONTEXT_PROPERTY) -> ::windows::core::Result<u32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetPropertyInteractionContext(interactioncontext: HINTERACTIONCONTEXT, contextproperty: INTERACTION_CONTEXT_PROPERTY, value: *mut u32) -> ::windows::core::HRESULT; } let mut result__: <u32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetPropertyInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(contextproperty), &mut result__).from_abi::<u32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] #[inline] pub unsafe fn GetStateInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, pointerinfo: *const super::Input::Pointer::POINTER_INFO) -> ::windows::core::Result<INTERACTION_STATE> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetStateInteractionContext(interactioncontext: HINTERACTIONCONTEXT, pointerinfo: *const super::Input::Pointer::POINTER_INFO, state: *mut INTERACTION_STATE) -> ::windows::core::HRESULT; } let mut result__: <INTERACTION_STATE as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetStateInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(pointerinfo), &mut result__).from_abi::<INTERACTION_STATE>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetTapParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: TAP_PARAMETER) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetTapParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: TAP_PARAMETER, value: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetTapParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn GetTranslationParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: TRANSLATION_PARAMETER) -> ::windows::core::Result<f32> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn GetTranslationParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: TRANSLATION_PARAMETER, value: *mut f32) -> ::windows::core::HRESULT; } let mut result__: <f32 as ::windows::core::Abi>::Abi = ::core::mem::zeroed(); GetTranslationParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), &mut result__).from_abi::<f32>(result__) } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy, :: core :: fmt :: Debug, :: core :: cmp :: PartialEq, :: core :: cmp :: Eq)] #[repr(transparent)] pub struct HINTERACTIONCONTEXT(pub isize); impl ::core::default::Default for HINTERACTIONCONTEXT { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } unsafe impl ::windows::core::Handle for HINTERACTIONCONTEXT {} unsafe impl ::windows::core::Abi for HINTERACTIONCONTEXT { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct HOLD_PARAMETER(pub i32); pub const HOLD_PARAMETER_MIN_CONTACT_COUNT: HOLD_PARAMETER = HOLD_PARAMETER(0i32); pub const HOLD_PARAMETER_MAX_CONTACT_COUNT: HOLD_PARAMETER = HOLD_PARAMETER(1i32); pub const HOLD_PARAMETER_THRESHOLD_RADIUS: HOLD_PARAMETER = HOLD_PARAMETER(2i32); pub const HOLD_PARAMETER_THRESHOLD_START_DELAY: HOLD_PARAMETER = HOLD_PARAMETER(3i32); pub const HOLD_PARAMETER_MAX: HOLD_PARAMETER = HOLD_PARAMETER(-1i32); impl ::core::convert::From<i32> for HOLD_PARAMETER { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for HOLD_PARAMETER { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INERTIA_PARAMETER(pub i32); pub const INERTIA_PARAMETER_TRANSLATION_DECELERATION: INERTIA_PARAMETER = INERTIA_PARAMETER(1i32); pub const INERTIA_PARAMETER_TRANSLATION_DISPLACEMENT: INERTIA_PARAMETER = INERTIA_PARAMETER(2i32); pub const INERTIA_PARAMETER_ROTATION_DECELERATION: INERTIA_PARAMETER = INERTIA_PARAMETER(3i32); pub const INERTIA_PARAMETER_ROTATION_ANGLE: INERTIA_PARAMETER = INERTIA_PARAMETER(4i32); pub const INERTIA_PARAMETER_EXPANSION_DECELERATION: INERTIA_PARAMETER = INERTIA_PARAMETER(5i32); pub const INERTIA_PARAMETER_EXPANSION_EXPANSION: INERTIA_PARAMETER = INERTIA_PARAMETER(6i32); pub const INERTIA_PARAMETER_MAX: INERTIA_PARAMETER = INERTIA_PARAMETER(-1i32); impl ::core::convert::From<i32> for INERTIA_PARAMETER { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INERTIA_PARAMETER { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct INTERACTION_ARGUMENTS_CROSS_SLIDE { pub flags: CROSS_SLIDE_FLAGS, } impl INTERACTION_ARGUMENTS_CROSS_SLIDE {} impl ::core::default::Default for INTERACTION_ARGUMENTS_CROSS_SLIDE { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for INTERACTION_ARGUMENTS_CROSS_SLIDE { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("INTERACTION_ARGUMENTS_CROSS_SLIDE").field("flags", &self.flags).finish() } } impl ::core::cmp::PartialEq for INTERACTION_ARGUMENTS_CROSS_SLIDE { fn eq(&self, other: &Self) -> bool { self.flags == other.flags } } impl ::core::cmp::Eq for INTERACTION_ARGUMENTS_CROSS_SLIDE {} unsafe impl ::windows::core::Abi for INTERACTION_ARGUMENTS_CROSS_SLIDE { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct INTERACTION_ARGUMENTS_MANIPULATION { pub delta: MANIPULATION_TRANSFORM, pub cumulative: MANIPULATION_TRANSFORM, pub velocity: MANIPULATION_VELOCITY, pub railsState: MANIPULATION_RAILS_STATE, } impl INTERACTION_ARGUMENTS_MANIPULATION {} impl ::core::default::Default for INTERACTION_ARGUMENTS_MANIPULATION { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for INTERACTION_ARGUMENTS_MANIPULATION { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("INTERACTION_ARGUMENTS_MANIPULATION").field("delta", &self.delta).field("cumulative", &self.cumulative).field("velocity", &self.velocity).field("railsState", &self.railsState).finish() } } impl ::core::cmp::PartialEq for INTERACTION_ARGUMENTS_MANIPULATION { fn eq(&self, other: &Self) -> bool { self.delta == other.delta && self.cumulative == other.cumulative && self.velocity == other.velocity && self.railsState == other.railsState } } impl ::core::cmp::Eq for INTERACTION_ARGUMENTS_MANIPULATION {} unsafe impl ::windows::core::Abi for INTERACTION_ARGUMENTS_MANIPULATION { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct INTERACTION_ARGUMENTS_TAP { pub count: u32, } impl INTERACTION_ARGUMENTS_TAP {} impl ::core::default::Default for INTERACTION_ARGUMENTS_TAP { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for INTERACTION_ARGUMENTS_TAP { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("INTERACTION_ARGUMENTS_TAP").field("count", &self.count).finish() } } impl ::core::cmp::PartialEq for INTERACTION_ARGUMENTS_TAP { fn eq(&self, other: &Self) -> bool { self.count == other.count } } impl ::core::cmp::Eq for INTERACTION_ARGUMENTS_TAP {} unsafe impl ::windows::core::Abi for INTERACTION_ARGUMENTS_TAP { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INTERACTION_CONFIGURATION_FLAGS(pub u32); pub const INTERACTION_CONFIGURATION_FLAG_NONE: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(0u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_X: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(2u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_Y: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(4u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_ROTATION: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(8u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_SCALING: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(16u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_TRANSLATION_INERTIA: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(32u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_ROTATION_INERTIA: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(64u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_SCALING_INERTIA: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(128u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_RAILS_X: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(256u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_RAILS_Y: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(512u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_EXACT: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1024u32); pub const INTERACTION_CONFIGURATION_FLAG_MANIPULATION_MULTIPLE_FINGER_PANNING: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(2048u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_HORIZONTAL: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(2u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_SELECT: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(4u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_SPEED_BUMP: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(8u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_REARRANGE: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(16u32); pub const INTERACTION_CONFIGURATION_FLAG_CROSS_SLIDE_EXACT: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(32u32); pub const INTERACTION_CONFIGURATION_FLAG_TAP: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_TAP_DOUBLE: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(2u32); pub const INTERACTION_CONFIGURATION_FLAG_TAP_MULTIPLE_FINGER: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(4u32); pub const INTERACTION_CONFIGURATION_FLAG_SECONDARY_TAP: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_HOLD: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_HOLD_MOUSE: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(2u32); pub const INTERACTION_CONFIGURATION_FLAG_HOLD_MULTIPLE_FINGER: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(4u32); pub const INTERACTION_CONFIGURATION_FLAG_DRAG: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(1u32); pub const INTERACTION_CONFIGURATION_FLAG_MAX: INTERACTION_CONFIGURATION_FLAGS = INTERACTION_CONFIGURATION_FLAGS(4294967295u32); impl ::core::convert::From<u32> for INTERACTION_CONFIGURATION_FLAGS { fn from(value: u32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INTERACTION_CONFIGURATION_FLAGS { type Abi = Self; } impl ::core::ops::BitOr for INTERACTION_CONFIGURATION_FLAGS { type Output = Self; fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } } impl ::core::ops::BitAnd for INTERACTION_CONFIGURATION_FLAGS { type Output = Self; fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } } impl ::core::ops::BitOrAssign for INTERACTION_CONFIGURATION_FLAGS { fn bitor_assign(&mut self, rhs: Self) { self.0.bitor_assign(rhs.0) } } impl ::core::ops::BitAndAssign for INTERACTION_CONFIGURATION_FLAGS { fn bitand_assign(&mut self, rhs: Self) { self.0.bitand_assign(rhs.0) } } impl ::core::ops::Not for INTERACTION_CONFIGURATION_FLAGS { type Output = Self; fn not(self) -> Self { Self(self.0.not()) } } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct INTERACTION_CONTEXT_CONFIGURATION { pub interactionId: INTERACTION_ID, pub enable: INTERACTION_CONFIGURATION_FLAGS, } impl INTERACTION_CONTEXT_CONFIGURATION {} impl ::core::default::Default for INTERACTION_CONTEXT_CONFIGURATION { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for INTERACTION_CONTEXT_CONFIGURATION { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("INTERACTION_CONTEXT_CONFIGURATION").field("interactionId", &self.interactionId).field("enable", &self.enable).finish() } } impl ::core::cmp::PartialEq for INTERACTION_CONTEXT_CONFIGURATION { fn eq(&self, other: &Self) -> bool { self.interactionId == other.interactionId && self.enable == other.enable } } impl ::core::cmp::Eq for INTERACTION_CONTEXT_CONFIGURATION {} unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_CONFIGURATION { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub struct INTERACTION_CONTEXT_OUTPUT { pub interactionId: INTERACTION_ID, pub interactionFlags: INTERACTION_FLAGS, pub inputType: super::WindowsAndMessaging::POINTER_INPUT_TYPE, pub x: f32, pub y: f32, pub arguments: INTERACTION_CONTEXT_OUTPUT_0, } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl INTERACTION_CONTEXT_OUTPUT {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::default::Default for INTERACTION_CONTEXT_OUTPUT { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::PartialEq for INTERACTION_CONTEXT_OUTPUT { fn eq(&self, _other: &Self) -> bool { unimplemented!() } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::Eq for INTERACTION_CONTEXT_OUTPUT {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_OUTPUT { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub union INTERACTION_CONTEXT_OUTPUT_0 { pub manipulation: INTERACTION_ARGUMENTS_MANIPULATION, pub tap: INTERACTION_ARGUMENTS_TAP, pub crossSlide: INTERACTION_ARGUMENTS_CROSS_SLIDE, } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl INTERACTION_CONTEXT_OUTPUT_0 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::default::Default for INTERACTION_CONTEXT_OUTPUT_0 { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::PartialEq for INTERACTION_CONTEXT_OUTPUT_0 { fn eq(&self, _other: &Self) -> bool { unimplemented!() } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::Eq for INTERACTION_CONTEXT_OUTPUT_0 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_OUTPUT_0 { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub struct INTERACTION_CONTEXT_OUTPUT2 { pub interactionId: INTERACTION_ID, pub interactionFlags: INTERACTION_FLAGS, pub inputType: super::WindowsAndMessaging::POINTER_INPUT_TYPE, pub contactCount: u32, pub currentContactCount: u32, pub x: f32, pub y: f32, pub arguments: INTERACTION_CONTEXT_OUTPUT2_0, } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl INTERACTION_CONTEXT_OUTPUT2 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::default::Default for INTERACTION_CONTEXT_OUTPUT2 { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::PartialEq for INTERACTION_CONTEXT_OUTPUT2 { fn eq(&self, _other: &Self) -> bool { unimplemented!() } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::Eq for INTERACTION_CONTEXT_OUTPUT2 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_OUTPUT2 { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub union INTERACTION_CONTEXT_OUTPUT2_0 { pub manipulation: INTERACTION_ARGUMENTS_MANIPULATION, pub tap: INTERACTION_ARGUMENTS_TAP, pub crossSlide: INTERACTION_ARGUMENTS_CROSS_SLIDE, } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl INTERACTION_CONTEXT_OUTPUT2_0 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::default::Default for INTERACTION_CONTEXT_OUTPUT2_0 { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::PartialEq for INTERACTION_CONTEXT_OUTPUT2_0 { fn eq(&self, _other: &Self) -> bool { unimplemented!() } } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] impl ::core::cmp::Eq for INTERACTION_CONTEXT_OUTPUT2_0 {} #[cfg(feature = "Win32_UI_WindowsAndMessaging")] unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_OUTPUT2_0 { type Abi = Self; } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub type INTERACTION_CONTEXT_OUTPUT_CALLBACK = unsafe extern "system" fn(clientdata: *const ::core::ffi::c_void, output: *const INTERACTION_CONTEXT_OUTPUT); #[cfg(feature = "Win32_UI_WindowsAndMessaging")] pub type INTERACTION_CONTEXT_OUTPUT_CALLBACK2 = unsafe extern "system" fn(clientdata: *const ::core::ffi::c_void, output: *const INTERACTION_CONTEXT_OUTPUT2); #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INTERACTION_CONTEXT_PROPERTY(pub i32); pub const INTERACTION_CONTEXT_PROPERTY_MEASUREMENT_UNITS: INTERACTION_CONTEXT_PROPERTY = INTERACTION_CONTEXT_PROPERTY(1i32); pub const INTERACTION_CONTEXT_PROPERTY_INTERACTION_UI_FEEDBACK: INTERACTION_CONTEXT_PROPERTY = INTERACTION_CONTEXT_PROPERTY(2i32); pub const INTERACTION_CONTEXT_PROPERTY_FILTER_POINTERS: INTERACTION_CONTEXT_PROPERTY = INTERACTION_CONTEXT_PROPERTY(3i32); pub const INTERACTION_CONTEXT_PROPERTY_MAX: INTERACTION_CONTEXT_PROPERTY = INTERACTION_CONTEXT_PROPERTY(-1i32); impl ::core::convert::From<i32> for INTERACTION_CONTEXT_PROPERTY { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INTERACTION_CONTEXT_PROPERTY { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INTERACTION_FLAGS(pub u32); pub const INTERACTION_FLAG_NONE: INTERACTION_FLAGS = INTERACTION_FLAGS(0u32); pub const INTERACTION_FLAG_BEGIN: INTERACTION_FLAGS = INTERACTION_FLAGS(1u32); pub const INTERACTION_FLAG_END: INTERACTION_FLAGS = INTERACTION_FLAGS(2u32); pub const INTERACTION_FLAG_CANCEL: INTERACTION_FLAGS = INTERACTION_FLAGS(4u32); pub const INTERACTION_FLAG_INERTIA: INTERACTION_FLAGS = INTERACTION_FLAGS(8u32); pub const INTERACTION_FLAG_MAX: INTERACTION_FLAGS = INTERACTION_FLAGS(4294967295u32); impl ::core::convert::From<u32> for INTERACTION_FLAGS { fn from(value: u32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INTERACTION_FLAGS { type Abi = Self; } impl ::core::ops::BitOr for INTERACTION_FLAGS { type Output = Self; fn bitor(self, rhs: Self) -> Self { Self(self.0 | rhs.0) } } impl ::core::ops::BitAnd for INTERACTION_FLAGS { type Output = Self; fn bitand(self, rhs: Self) -> Self { Self(self.0 & rhs.0) } } impl ::core::ops::BitOrAssign for INTERACTION_FLAGS { fn bitor_assign(&mut self, rhs: Self) { self.0.bitor_assign(rhs.0) } } impl ::core::ops::BitAndAssign for INTERACTION_FLAGS { fn bitand_assign(&mut self, rhs: Self) { self.0.bitand_assign(rhs.0) } } impl ::core::ops::Not for INTERACTION_FLAGS { type Output = Self; fn not(self) -> Self { Self(self.0.not()) } } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INTERACTION_ID(pub i32); pub const INTERACTION_ID_NONE: INTERACTION_ID = INTERACTION_ID(0i32); pub const INTERACTION_ID_MANIPULATION: INTERACTION_ID = INTERACTION_ID(1i32); pub const INTERACTION_ID_TAP: INTERACTION_ID = INTERACTION_ID(2i32); pub const INTERACTION_ID_SECONDARY_TAP: INTERACTION_ID = INTERACTION_ID(3i32); pub const INTERACTION_ID_HOLD: INTERACTION_ID = INTERACTION_ID(4i32); pub const INTERACTION_ID_DRAG: INTERACTION_ID = INTERACTION_ID(5i32); pub const INTERACTION_ID_CROSS_SLIDE: INTERACTION_ID = INTERACTION_ID(6i32); pub const INTERACTION_ID_MAX: INTERACTION_ID = INTERACTION_ID(-1i32); impl ::core::convert::From<i32> for INTERACTION_ID { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INTERACTION_ID { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct INTERACTION_STATE(pub i32); pub const INTERACTION_STATE_IDLE: INTERACTION_STATE = INTERACTION_STATE(0i32); pub const INTERACTION_STATE_IN_INTERACTION: INTERACTION_STATE = INTERACTION_STATE(1i32); pub const INTERACTION_STATE_POSSIBLE_DOUBLE_TAP: INTERACTION_STATE = INTERACTION_STATE(2i32); pub const INTERACTION_STATE_MAX: INTERACTION_STATE = INTERACTION_STATE(-1i32); impl ::core::convert::From<i32> for INTERACTION_STATE { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for INTERACTION_STATE { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct MANIPULATION_RAILS_STATE(pub i32); pub const MANIPULATION_RAILS_STATE_UNDECIDED: MANIPULATION_RAILS_STATE = MANIPULATION_RAILS_STATE(0i32); pub const MANIPULATION_RAILS_STATE_FREE: MANIPULATION_RAILS_STATE = MANIPULATION_RAILS_STATE(1i32); pub const MANIPULATION_RAILS_STATE_RAILED: MANIPULATION_RAILS_STATE = MANIPULATION_RAILS_STATE(2i32); pub const MANIPULATION_RAILS_STATE_MAX: MANIPULATION_RAILS_STATE = MANIPULATION_RAILS_STATE(-1i32); impl ::core::convert::From<i32> for MANIPULATION_RAILS_STATE { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for MANIPULATION_RAILS_STATE { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct MANIPULATION_TRANSFORM { pub translationX: f32, pub translationY: f32, pub scale: f32, pub expansion: f32, pub rotation: f32, } impl MANIPULATION_TRANSFORM {} impl ::core::default::Default for MANIPULATION_TRANSFORM { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for MANIPULATION_TRANSFORM { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("MANIPULATION_TRANSFORM").field("translationX", &self.translationX).field("translationY", &self.translationY).field("scale", &self.scale).field("expansion", &self.expansion).field("rotation", &self.rotation).finish() } } impl ::core::cmp::PartialEq for MANIPULATION_TRANSFORM { fn eq(&self, other: &Self) -> bool { self.translationX == other.translationX && self.translationY == other.translationY && self.scale == other.scale && self.expansion == other.expansion && self.rotation == other.rotation } } impl ::core::cmp::Eq for MANIPULATION_TRANSFORM {} unsafe impl ::windows::core::Abi for MANIPULATION_TRANSFORM { type Abi = Self; } #[derive(:: core :: clone :: Clone, :: core :: marker :: Copy)] #[repr(C)] pub struct MANIPULATION_VELOCITY { pub velocityX: f32, pub velocityY: f32, pub velocityExpansion: f32, pub velocityAngular: f32, } impl MANIPULATION_VELOCITY {} impl ::core::default::Default for MANIPULATION_VELOCITY { fn default() -> Self { unsafe { ::core::mem::zeroed() } } } impl ::core::fmt::Debug for MANIPULATION_VELOCITY { fn fmt(&self, fmt: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { fmt.debug_struct("MANIPULATION_VELOCITY").field("velocityX", &self.velocityX).field("velocityY", &self.velocityY).field("velocityExpansion", &self.velocityExpansion).field("velocityAngular", &self.velocityAngular).finish() } } impl ::core::cmp::PartialEq for MANIPULATION_VELOCITY { fn eq(&self, other: &Self) -> bool { self.velocityX == other.velocityX && self.velocityY == other.velocityY && self.velocityExpansion == other.velocityExpansion && self.velocityAngular == other.velocityAngular } } impl ::core::cmp::Eq for MANIPULATION_VELOCITY {} unsafe impl ::windows::core::Abi for MANIPULATION_VELOCITY { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct MOUSE_WHEEL_PARAMETER(pub i32); pub const MOUSE_WHEEL_PARAMETER_CHAR_TRANSLATION_X: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(1i32); pub const MOUSE_WHEEL_PARAMETER_CHAR_TRANSLATION_Y: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(2i32); pub const MOUSE_WHEEL_PARAMETER_DELTA_SCALE: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(3i32); pub const MOUSE_WHEEL_PARAMETER_DELTA_ROTATION: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(4i32); pub const MOUSE_WHEEL_PARAMETER_PAGE_TRANSLATION_X: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(5i32); pub const MOUSE_WHEEL_PARAMETER_PAGE_TRANSLATION_Y: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(6i32); pub const MOUSE_WHEEL_PARAMETER_MAX: MOUSE_WHEEL_PARAMETER = MOUSE_WHEEL_PARAMETER(-1i32); impl ::core::convert::From<i32> for MOUSE_WHEEL_PARAMETER { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for MOUSE_WHEEL_PARAMETER { type Abi = Self; } #[inline] pub unsafe fn ProcessBufferedPacketsInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ProcessBufferedPacketsInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } ProcessBufferedPacketsInteractionContext(interactioncontext.into_param().abi()).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn ProcessInertiaInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ProcessInertiaInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } ProcessInertiaInteractionContext(interactioncontext.into_param().abi()).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(all(feature = "Win32_Foundation", feature = "Win32_UI_Input_Pointer", feature = "Win32_UI_WindowsAndMessaging"))] #[inline] pub unsafe fn ProcessPointerFramesInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, entriescount: u32, pointercount: u32, pointerinfo: *const super::Input::Pointer::POINTER_INFO) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ProcessPointerFramesInteractionContext(interactioncontext: HINTERACTIONCONTEXT, entriescount: u32, pointercount: u32, pointerinfo: *const super::Input::Pointer::POINTER_INFO) -> ::windows::core::HRESULT; } ProcessPointerFramesInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(entriescount), ::core::mem::transmute(pointercount), ::core::mem::transmute(pointerinfo)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] #[inline] pub unsafe fn RegisterOutputCallbackInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, outputcallback: ::core::option::Option<INTERACTION_CONTEXT_OUTPUT_CALLBACK>, clientdata: *const ::core::ffi::c_void) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterOutputCallbackInteractionContext(interactioncontext: HINTERACTIONCONTEXT, outputcallback: ::windows::core::RawPtr, clientdata: *const ::core::ffi::c_void) -> ::windows::core::HRESULT; } RegisterOutputCallbackInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(outputcallback), ::core::mem::transmute(clientdata)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[cfg(feature = "Win32_UI_WindowsAndMessaging")] #[inline] pub unsafe fn RegisterOutputCallbackInteractionContext2<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, outputcallback: ::core::option::Option<INTERACTION_CONTEXT_OUTPUT_CALLBACK2>, clientdata: *const ::core::ffi::c_void) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RegisterOutputCallbackInteractionContext2(interactioncontext: HINTERACTIONCONTEXT, outputcallback: ::windows::core::RawPtr, clientdata: *const ::core::ffi::c_void) -> ::windows::core::HRESULT; } RegisterOutputCallbackInteractionContext2(interactioncontext.into_param().abi(), ::core::mem::transmute(outputcallback), ::core::mem::transmute(clientdata)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn RemovePointerInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, pointerid: u32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn RemovePointerInteractionContext(interactioncontext: HINTERACTIONCONTEXT, pointerid: u32) -> ::windows::core::HRESULT; } RemovePointerInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(pointerid)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn ResetInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn ResetInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } ResetInteractionContext(interactioncontext.into_param().abi()).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetCrossSlideParametersInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parametercount: u32, crossslideparameters: *const CROSS_SLIDE_PARAMETER) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetCrossSlideParametersInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parametercount: u32, crossslideparameters: *const CROSS_SLIDE_PARAMETER) -> ::windows::core::HRESULT; } SetCrossSlideParametersInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parametercount), ::core::mem::transmute(crossslideparameters)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetHoldParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: HOLD_PARAMETER, value: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetHoldParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: HOLD_PARAMETER, value: f32) -> ::windows::core::HRESULT; } SetHoldParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetInertiaParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, inertiaparameter: INERTIA_PARAMETER, value: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetInertiaParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, inertiaparameter: INERTIA_PARAMETER, value: f32) -> ::windows::core::HRESULT; } SetInertiaParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(inertiaparameter), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetInteractionConfigurationInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, configurationcount: u32, configuration: *const INTERACTION_CONTEXT_CONFIGURATION) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetInteractionConfigurationInteractionContext(interactioncontext: HINTERACTIONCONTEXT, configurationcount: u32, configuration: *const INTERACTION_CONTEXT_CONFIGURATION) -> ::windows::core::HRESULT; } SetInteractionConfigurationInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(configurationcount), ::core::mem::transmute(configuration)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetMouseWheelParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: MOUSE_WHEEL_PARAMETER, value: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetMouseWheelParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: MOUSE_WHEEL_PARAMETER, value: f32) -> ::windows::core::HRESULT; } SetMouseWheelParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetPivotInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, x: f32, y: f32, radius: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetPivotInteractionContext(interactioncontext: HINTERACTIONCONTEXT, x: f32, y: f32, radius: f32) -> ::windows::core::HRESULT; } SetPivotInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(x), ::core::mem::transmute(y), ::core::mem::transmute(radius)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetPropertyInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, contextproperty: INTERACTION_CONTEXT_PROPERTY, value: u32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetPropertyInteractionContext(interactioncontext: HINTERACTIONCONTEXT, contextproperty: INTERACTION_CONTEXT_PROPERTY, value: u32) -> ::windows::core::HRESULT; } SetPropertyInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(contextproperty), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetTapParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: TAP_PARAMETER, value: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetTapParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: TAP_PARAMETER, value: f32) -> ::windows::core::HRESULT; } SetTapParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn SetTranslationParameterInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0, parameter: TRANSLATION_PARAMETER, value: f32) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn SetTranslationParameterInteractionContext(interactioncontext: HINTERACTIONCONTEXT, parameter: TRANSLATION_PARAMETER, value: f32) -> ::windows::core::HRESULT; } SetTranslationParameterInteractionContext(interactioncontext.into_param().abi(), ::core::mem::transmute(parameter), ::core::mem::transmute(value)).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[inline] pub unsafe fn StopInteractionContext<'a, Param0: ::windows::core::IntoParam<'a, HINTERACTIONCONTEXT>>(interactioncontext: Param0) -> ::windows::core::Result<()> { #[cfg(windows)] { #[link(name = "windows")] extern "system" { fn StopInteractionContext(interactioncontext: HINTERACTIONCONTEXT) -> ::windows::core::HRESULT; } StopInteractionContext(interactioncontext.into_param().abi()).ok() } #[cfg(not(windows))] unimplemented!("Unsupported target OS"); } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct TAP_PARAMETER(pub i32); pub const TAP_PARAMETER_MIN_CONTACT_COUNT: TAP_PARAMETER = TAP_PARAMETER(0i32); pub const TAP_PARAMETER_MAX_CONTACT_COUNT: TAP_PARAMETER = TAP_PARAMETER(1i32); pub const TAP_PARAMETER_MAX: TAP_PARAMETER = TAP_PARAMETER(-1i32); impl ::core::convert::From<i32> for TAP_PARAMETER { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for TAP_PARAMETER { type Abi = Self; } #[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)] #[repr(transparent)] pub struct TRANSLATION_PARAMETER(pub i32); pub const TRANSLATION_PARAMETER_MIN_CONTACT_COUNT: TRANSLATION_PARAMETER = TRANSLATION_PARAMETER(0i32); pub const TRANSLATION_PARAMETER_MAX_CONTACT_COUNT: TRANSLATION_PARAMETER = TRANSLATION_PARAMETER(1i32); pub const TRANSLATION_PARAMETER_MAX: TRANSLATION_PARAMETER = TRANSLATION_PARAMETER(-1i32); impl ::core::convert::From<i32> for TRANSLATION_PARAMETER { fn from(value: i32) -> Self { Self(value) } } unsafe impl ::windows::core::Abi for TRANSLATION_PARAMETER { type Abi = Self; }
extern crate url; use std::env; use url::Url; #[derive(Debug)] pub struct Args { pub remote: String, pub url: Url, } impl Args { pub fn from_env(mut argv: env::Args) -> Result<Self, String> { let remote = try!(argv.nth(1).ok_or("remote arg is required".to_owned())); let url = try!(argv.next() .ok_or("remote url arg is required".to_owned()) .and_then(|arg| Url::parse(&arg).map_err(|e| e.to_string()) )); return Ok(Args{remote: remote, url: url}) } }
use std::fmt::{self, Write}; use firefly_binary::Bitstring; use firefly_intern::Symbol; use crate::{Annotation, Lit, Literal}; pub fn print_literal(f: &mut fmt::Formatter, literal: &Literal) -> fmt::Result { print_lit(f, &literal.value) } pub fn print_lit(f: &mut fmt::Formatter, lit: &Lit) -> fmt::Result { match lit { Lit::Atom(a) => write!(f, "{}", a), Lit::Integer(i) => write!(f, "{}", i), Lit::Float(n) => write!(f, "{}", n), Lit::Nil => f.write_str("[]"), Lit::Cons(ref h, ref t) => { f.write_char('[')?; print_literal(f, h)?; f.write_str(" | ")?; print_literal(f, t)?; f.write_char(']') } Lit::Tuple(es) => { f.write_char('{')?; for (i, e) in es.iter().enumerate() { if i > 0 { f.write_str(", ")?; } print_literal(f, e)?; } f.write_char('}') } Lit::Map(map) => { f.write_str("#{")?; for (i, (k, v)) in map.iter().enumerate() { if i > 0 { f.write_str(", ")?; } print_literal(f, k)?; f.write_str(" := ")?; print_literal(f, v)?; } f.write_char('}') } Lit::Binary(bitvec) => write!(f, "{}", bitvec.display()), } } pub fn print_annotation(f: &mut fmt::Formatter, sym: &Symbol, value: &Annotation) -> fmt::Result { match value { Annotation::Unit => write!(f, "{}", sym), Annotation::Term(ref value) => { write!(f, "{{{}, ", sym)?; print_literal(f, value)?; f.write_str("}") } Annotation::Vars(vars) => { write!(f, "{{{}, [", sym)?; for (i, id) in vars.iter().enumerate() { if i > 0 { write!(f, ",{}", id)?; } else { write!(f, "{}", id)?; } } write!(f, "]}}") } Annotation::Type(ty) => write!(f, "{{type, {}}}", &ty), } }
extern crate gcd; use gcd = gcd::gcd; pub fn main() { println!("{}", gcd(121i64, 44)); }
use crate::chunk::{Chunk, op_codes::*, value::{Value,number}}; use crate::scanner::{Scanner, tokens::{*}}; #[macro_use] mod rules; use rules::*; struct Compiler { previous: Token, current: Token, scanner: Scanner, success: bool, panic: bool, chunk: Chunk } pub fn compile(source: String) -> Result<Chunk, ()> { let scanner = Scanner::new(source); let placeholder_token = Token { ttype: TokenType::EOF, start: 0, length: 0, line: 0 }; let mut compiler = Compiler { scanner, current: placeholder_token, previous: placeholder_token, chunk: Chunk::new(), panic: false, success: true }; return match compiler.start() { Ok(()) => Ok(compiler.chunk), Err(()) => Err(()) } } impl Compiler { pub fn start(&mut self) -> Result<(), ()> { self.advance(); while self.current.ttype != TokenType::EOF { self.decleration(); } self.push_byte(RETURN); if !self.success { return Err(()); } else { return Ok(()); } } fn expression(&mut self) { //Lowest self.parse_precedence(Precedence::Assignment); } fn decleration(&mut self) { self.statement() } fn statement(&mut self) { match self.current.ttype { TokenType::PRINT => self.print_statement(), _ => unreachable!() } } fn print_statement(&mut self) { self.advance(); self.expression(); self.consume(TokenType::SEMICOLON, "expected ';' after expression"); self.push_byte(PRINT); } fn parse_precedence(&mut self, prec: impl Into<u32>) { let prec = prec.into(); self.advance(); let rule = get_rule(self.previous.ttype); if let Some(prefix) = rule.prefix { prefix(self); while prec <= get_rule(self.current.ttype).precedence as u32 { self.advance(); let new_rule = get_rule(self.previous.ttype); if let Some(infix) = new_rule.infix { infix(self); } else { unreachable!(); } } } else { self.error_at(self.previous, "expected expression") } } fn unary(&mut self) { let op_type = self.previous.ttype; self.parse_precedence(Precedence::Unary); match op_type { TokenType::MINUS => self.push_byte(NEGATE), TokenType::BANG => self.push_byte(NOT), _ => unreachable!() } } fn grouping(&mut self) { self.expression(); self.consume(TokenType::RIGHT_PAREN, "expected ')' after expression"); } fn binary(&mut self) { //First operand is compiled let op_type = self.previous.ttype; let rule = get_rule(op_type); //Push the other operand self.parse_precedence(rule.precedence as u32+1); //Operator time match op_type { TokenType::PLUS => self.push_byte(ADD), TokenType::MINUS => self.push_byte(SUBTRACT), TokenType::ASTERISK => self.push_byte(MULTIPLY), TokenType::SLASH => self.push_byte(DIVIDE), TokenType::EQUAL_EQUAL => self.push_byte(EQUAL), TokenType::BANG_EQUAL => self.push_bytes(&[EQUAL, NOT]), TokenType::GREATER => self.push_byte(GREATER), TokenType::GREATER_EQUAL => self.push_bytes(&[LESS,NOT]), TokenType::LESS => self.push_byte(LESS), TokenType::LESS_EQUAL => self.push_bytes(&[GREATER, NOT]), _ => unreachable!() } } fn literal(&mut self) { match self.previous.ttype { TokenType::NIL => self.push_byte(NIL), TokenType::TRUE => self.push_byte(TRUE), TokenType::FALSE => self.push_byte(FALSE), _ => unreachable!() } } fn string(&mut self) { let lexeme = self.lexeme(self.previous); let value = Value::from(lexeme[1..lexeme.len() - 1].to_owned()); self.push_constant(value); } fn number(&mut self) { //I bet it's safe to just assume this will parse to an int, right? let value = Value::from(self.lexeme(self.previous).parse::<number>().unwrap()); self.push_constant(value); } fn push_constant(&mut self, value: Value) { if self.chunk.constants.len() >= 256^std::mem::size_of::<OpCode>() { self.error_at(self.previous, "reached constant limit"); } let index = self.chunk.push_constant(value) as OpCode; self.push_bytes(&[CONSTANT, index]); } fn lexeme(&self, token: Token) -> &str { &self.scanner.source[token.start..token.start+(token.length as usize)] } fn advance(&mut self) { self.previous = self.current; loop { match self.scanner.scan_token() { TokenResult::TOKEN(token) => { self.current = token; break; }, TokenResult::ERROR(error) => { self.error(error) } } } } fn push_byte(&mut self, op: OpCode) { self.chunk.push_op(op, self.previous.line); } fn push_bytes(&mut self, ops: &[OpCode]) { for op in ops { self.push_byte(*op); } } fn consume(&mut self, ttype: TokenType, errmsg: impl AsRef<str>) { if self.current.ttype == ttype { self.advance(); } else { self.error_at(self.current, errmsg); } } fn error_at(&mut self, token: Token, msg: impl AsRef<str>) { let msg = msg.as_ref(); if token.ttype == TokenType::EOF { self.print_error(format!("[ERR {}]: at EOF {}", token.line, msg)); } else { let lexeme = self.lexeme(token).to_owned(); self.print_error(format!("[ERR {}]: at '{}' {}", token.line, lexeme, msg)); } } fn error(&mut self, error: TokenError) { self.print_error(format!("[ERR {}]: {}", error.line, error.message)); } fn print_error(&mut self, msg: String) { if self.panic {return;} println!("{}",msg); self.success = false; self.panic = true; } }
mod error; use std::borrow::Cow; use aws_lambda_events::event::autoscaling::AutoScalingEvent as Event; use failure::Fail; use lambda_runtime::{error::HandlerError, lambda, Context}; use log::{error, info}; use rusoto_autoscaling::{Autoscaling, AutoscalingClient, CompleteLifecycleActionType}; use serde::{Deserialize, Serialize}; use nomad_drain::nomad::Client as NomadClient; use nomad_drain::vault::Client as VaultClient; use nomad_drain::Secret; use crate::error::Error; #[derive(Deserialize, Debug, Clone, Eq, PartialEq)] struct Config { /// Address of Nomad server /// Deserialized from `NOMAD_ADDR` #[serde(rename = "nomad_addr")] nomad_address: String, /// Use Nomad Token or not #[serde(default = "Config::default_use_nomad_token")] use_nomad_token: bool, /// Nomad token, if any nomad_token: Option<Secret>, #[serde(flatten)] vault_config: VaultConfig, // Implicitly: RUST_LOG via `env_logger. // See https://docs.rs/env_logger/0.6.0/env_logger/#enabling-logging } #[derive(Deserialize, Debug, Clone, Eq, PartialEq)] struct VaultConfig { vault_token: Option<Secret>, #[serde(rename = "vault_addr")] vault_address: Option<String>, auth_path: Option<String>, auth_role: Option<String>, auth_header_value: Option<String>, nomad_path: Option<String>, nomad_role: Option<String>, } #[derive(Deserialize, Debug, Clone, Eq, PartialEq)] #[serde(rename_all = "PascalCase")] struct AsgEventDetails { pub lifecycle_action_token: String, pub auto_scaling_group_name: String, #[serde(rename = "EC2InstanceId")] pub instance_id: String, pub lifecycle_transition: AsgLifecycleTransition, pub lifecycle_hook_name: String, } #[derive(Deserialize, Debug, Clone, Eq, PartialEq)] enum AsgLifecycleTransition { #[serde(rename = "autoscaling:EC2_INSTANCE_LAUNCHING")] InstanceLaunching, #[serde(rename = "autoscaling:EC2_INSTANCE_TERMINATING")] InstanceTerminating, } #[derive(Serialize, Debug, Clone, Eq, PartialEq)] struct HandlerResult { pub instance_id: String, pub node_id: String, pub timestamp: chrono::DateTime<chrono::Utc>, } impl Config { /// Deserialize from the environment pub fn from_environment() -> Result<Self, Error> { Ok(envy::from_env()?) } const fn default_use_nomad_token() -> bool { true } } #[derive(Debug)] struct Clients { pub nomad_client: NomadClient, pub vault_client: Option<VaultClient>, } impl Clients { pub fn new(config: &Config) -> Result<Self, Error> { let mut vault_client = None; info!("Building Nomad Client"); let nomad_token = if config.use_nomad_token { info!("Using Nomad token"); Some(match config.nomad_token { Some(ref token) => Cow::Borrowed(token.as_str()), None => { info!("No Nomad Token configured. Retrieving from Vault"); vault_client = Some(Self::get_vault_client(config)?); let nomad_path = config.vault_config.nomad_path.as_ref().ok_or_else(|| { Error::MissingConfiguration("nomad_path".to_string()) })?; let nomad_role = config.vault_config.nomad_role.as_ref().ok_or_else(|| { Error::MissingConfiguration("nomad_role".to_string()) })?; Cow::Owned( vault_client .as_ref() .unwrap_or_else(|| unreachable!("Should not be reachable!")) .get_nomad_token(nomad_path, nomad_role)? .0, ) } }) } else { info!("No Nomad token in use"); None }; let nomad_client = NomadClient::new(&config.nomad_address, nomad_token.as_ref(), None)?; Ok(Self { nomad_client, vault_client, }) } fn get_vault_client(config: &Config) -> Result<VaultClient, Error> { let vault_address = config .vault_config .vault_address .as_ref() .ok_or_else(|| Error::MissingConfiguration("vault_address".to_string()))?; match config.vault_config.vault_token { Some(ref token) => Ok(VaultClient::new(vault_address, token, false, None)?), None => { info!("No Vault Token configured. Using AWS Credentials to retrieve from Vault"); let vault_auth_path = config .vault_config .auth_path .as_ref() .ok_or_else(|| Error::MissingConfiguration("auth_path".to_string()))?; let vault_auth_role = config .vault_config .auth_role .as_ref() .ok_or_else(|| Error::MissingConfiguration("auth_role".to_string()))?; let aws_credentials = nomad_drain::get_aws_credentials()?; Ok(nomad_drain::login_to_vault( vault_address, vault_auth_path, vault_auth_role, &aws_credentials, config .vault_config .auth_header_value .as_ref() .map(|s| s.as_str()), None, )?) } } } } fn main() -> Result<(), Box<dyn std::error::Error>> { env_logger::init(); lambda!(lambda_wrapper); Ok(()) } #[allow(clippy::needless_pass_by_value)] fn lambda_wrapper(event: Event, context: Context) -> Result<HandlerResult, HandlerError> { match lambda_handler(&event, &context) { Ok(result) => Ok(result), Err(e) => { let mut error_output = vec![format!("{}", e)]; if let Some(backtrace) = e.backtrace() { error_output.push(format!("Backtrace: {}", backtrace)); } let error_output = error_output.join("\n"); error!("{}", error_output); Err(context.new_error(&error_output)) } } } fn lambda_handler(event: &Event, _context: &Context) -> Result<HandlerResult, Error> { let config = Config::from_environment()?; info!("Configuration loaded: {:#?}", config); let clients = Clients::new(&config)?; let asg_event: AsgEventDetails = serde_json::from_value(serde_json::to_value(&event.detail)?)?; info!("Event Details: {:#?}", asg_event); if asg_event.lifecycle_transition != AsgLifecycleTransition::InstanceTerminating { Err(Error::UnexpectedLifecycleTransition)?; } info!("Instance ID {} is being terminated", asg_event.instance_id); let node = clients .nomad_client .find_node_by_instance_id(&asg_event.instance_id)?; info!("Setting Node ID {} to be ineligible", node.data.id); clients.nomad_client.set_node_eligibility( &node.data.id, nomad_drain::nomad::NodeEligibility::Ineligible, )?; info!("Draining Nomad Node ID {}", node.data.id); // Lambda has a max runtime of 900s. Let's set a deadline for 600s clients.nomad_client.set_node_drain( &node.data.id, true, Some(nomad_drain::nomad::DrainSpec { deadline: 600, ignore_system_jobs: false, }), )?; info!("Node ID {} Drained", node.data.id); info!("Marking lifecycle action complete"); // Complete the lifecycle action let asg_client = AutoscalingClient::new(Default::default()); let _ = asg_client .complete_lifecycle_action(CompleteLifecycleActionType { auto_scaling_group_name: asg_event.auto_scaling_group_name.to_string(), instance_id: Some(asg_event.instance_id.to_string()), lifecycle_action_result: "CONTINUE".to_string(), lifecycle_action_token: Some(asg_event.lifecycle_action_token.to_string()), lifecycle_hook_name: asg_event.lifecycle_hook_name.to_string(), }) .sync()?; info!("Lifecycle action complete"); // Revoke self Ok(HandlerResult { instance_id: asg_event.instance_id.to_string(), node_id: node.data.id.to_string(), timestamp: chrono::Utc::now(), }) }
use crate::smb2::responses; /// Takes the little endian encoded create response from the server and populates the corresponding /// Create Response struct. pub fn decode_create_response_body(encoded_body: Vec<u8>) -> responses::create::Create { let mut create_response = responses::create::Create::default(); create_response.structure_size = encoded_body[0..2].to_vec(); create_response.op_lock_level = encoded_body[2..3].to_vec(); create_response.flags = encoded_body[3..4].to_vec(); create_response.create_action = encoded_body[4..8].to_vec(); create_response.creation_time = encoded_body[8..16].to_vec(); create_response.last_access_time = encoded_body[16..24].to_vec(); create_response.last_write_time = encoded_body[24..32].to_vec(); create_response.change_time = encoded_body[32..40].to_vec(); create_response.allocation_size = encoded_body[40..48].to_vec(); create_response.end_of_file = encoded_body[48..56].to_vec(); create_response.file_attributes = encoded_body[56..60].to_vec(); create_response.reserved = encoded_body[60..64].to_vec(); create_response.file_id = encoded_body[64..80].to_vec(); create_response.create_contexts_offset = encoded_body[80..84].to_vec(); create_response.create_contexts_length = encoded_body[84..88].to_vec(); create_response.buffer = encoded_body[88..].to_vec(); create_response } #[cfg(test)] mod tests { use super::*; #[test] fn test_decode_create_response_body() { let encoded_create_response = b"\x59\x00\x00\x00\x01\x00\x00\x00\xb4\x10\x04\xf4\x3e\x25\xd7\x01\ \xb4\x10\x04\xf4\x3e\x25\xd7\x01\xb4\x10\x04\xf4\x3e\x25\xd7\x01\ \xb4\x10\x04\xf4\x3e\x25\xd7\x01\x00\x00\x10\x00\x00\x00\x00\x00\ \x0e\x00\x00\x00\x00\x00\x00\x00\x80\x00\x00\x00\x00\x00\x00\x00\ \x25\x96\x72\xb3\x00\x00\x00\x00\x26\xb0\x76\xe9\x00\x00\x00\x00\ \x00\x00\x00\x00\x00\x00\x00\x00" .to_vec(); let mut expected_create_response_struct = responses::create::Create::default(); expected_create_response_struct.op_lock_level = vec![0]; expected_create_response_struct.create_action = b"\x01\x00\x00\x00".to_vec(); expected_create_response_struct.creation_time = b"\xb4\x10\x04\xf4\x3e\x25\xd7\x01".to_vec(); expected_create_response_struct.last_access_time = b"\xb4\x10\x04\xf4\x3e\x25\xd7\x01".to_vec(); expected_create_response_struct.last_write_time = b"\xb4\x10\x04\xf4\x3e\x25\xd7\x01".to_vec(); expected_create_response_struct.change_time = b"\xb4\x10\x04\xf4\x3e\x25\xd7\x01".to_vec(); expected_create_response_struct.allocation_size = b"\x00\x00\x10\x00\x00\x00\x00\x00".to_vec(); expected_create_response_struct.end_of_file = b"\x0e\x00\x00\x00\x00\x00\x00\x00".to_vec(); expected_create_response_struct.file_attributes = b"\x80\x00\x00\x00".to_vec(); expected_create_response_struct.file_id = b"\x25\x96\x72\xb3\x00\x00\x00\x00\x26\xb0\x76\xe9\x00\x00\x00\x00".to_vec(); expected_create_response_struct.create_contexts_offset = vec![0; 4]; expected_create_response_struct.create_contexts_length = vec![0; 4]; assert_eq!( expected_create_response_struct, decode_create_response_body(encoded_create_response) ); } }
use anyhow::*; use liblumen_alloc::erts::exception; use liblumen_alloc::erts::term::prelude::*; pub fn flag_is_not_a_supported_atom(flag: Term) -> exception::Result<Term> { Err(anyhow!("flag ({}) is not a supported atom (label, monotonic_timestamp, print, receive, send, serial, spawn, strict_monotonic_timestamp, or timestamp)", flag).into()) }
use cid::Cid; use ipfs_unixfs::file::{visit::IdleFileVisit, FileReadFailed}; use std::convert::TryFrom; use std::fmt; use std::io::{Error as IoError, Read, Write}; use std::path::PathBuf; fn main() { let cid = match std::env::args().nth(1).map(Cid::try_from) { Some(Ok(cid)) => cid, Some(Err(e)) => { eprintln!("Invalid cid given as argument: {}", e); std::process::exit(1); } None => { eprintln!("USAGE: {} CID\n", std::env::args().next().unwrap()); eprintln!( "Will walk the unixfs file pointed out by the CID from default go-ipfs 0.5 \ configuration flatfs blockstore and write all content to stdout." ); std::process::exit(0); } }; let ipfs_path = match std::env::var("IPFS_PATH") { Ok(s) => s, Err(e) => { eprintln!("IPFS_PATH is not set or could not be read: {}", e); std::process::exit(1); } }; let mut blocks = PathBuf::from(ipfs_path); blocks.push("blocks"); let blockstore = ShardedBlockStore { root: blocks }; match walk(blockstore, &cid) { Ok((read, content)) => { eprintln!("Content bytes: {}", content); eprintln!("Total bytes: {}", read); } Err(Error::OpeningFailed(e)) => { eprintln!("{}\n", e); eprintln!("This is likely caused by either:"); eprintln!(" - ipfs does not have the block"); eprintln!(" - ipfs is configured to use non-flatfs storage"); eprintln!(" - ipfs is configured to use flatfs with different sharding"); std::process::exit(1); } Err(e) => { eprintln!("Failed to walk the merkle tree: {}", e); std::process::exit(1); } } } fn walk(blocks: ShardedBlockStore, start: &Cid) -> Result<(u64, u64), Error> { let stdout = std::io::stdout(); let mut stdout = stdout.lock(); let mut read_bytes = 0; let mut content_bytes = 0; // The blockstore specific way of reading the block. Here we assume go-ipfs 0.5 default flatfs // configuration, which puts the files at sharded directories and names the blocks as base32 // upper and a suffix of "data". // // For the ipfs-unixfs it is important that the raw block data lives long enough that the // possible content gets to be processed, at minimum one step of the walk as shown in this // example. let mut buf = Vec::new(); read_bytes += blocks.as_file(&start.to_bytes())?.read_to_end(&mut buf)? as u64; // First step of the walk can give content or continued visitation but not both. let (content, _, _metadata, mut step) = IdleFileVisit::default().start(&buf)?; stdout.write_all(content)?; content_bytes += content.len() as u64; // Following steps repeat the same pattern: while let Some(visit) = step { // Read the next link. The `pending_links()` gives the next link and an iterator over the // following links. The iterator lists the known links in the order of traversal, with the // exception of possible new links appearing before the older. let (first, _) = visit.pending_links(); buf.clear(); read_bytes += blocks.as_file(&first.to_bytes())?.read_to_end(&mut buf)? as u64; // Similar to first step, except we no longer get the file metadata. It is still accessible // from the `visit` via `AsRef<ipfs_unixfs::file::Metadata>` but likely only needed in // the first step. let (content, next_step) = visit.continue_walk(&buf, &mut None)?; stdout.write_all(content)?; content_bytes += content.len() as u64; // Using a while loop combined with `let Some(visit) = step` allows for easy walking. step = next_step; } stdout.flush()?; Ok((read_bytes, content_bytes)) } enum Error { OpeningFailed(IoError), Other(IoError), Traversal(ipfs_unixfs::file::FileReadFailed), } impl From<IoError> for Error { fn from(e: IoError) -> Error { Error::Other(e) } } impl From<FileReadFailed> for Error { fn from(e: FileReadFailed) -> Error { Error::Traversal(e) } } impl fmt::Display for Error { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { use Error::*; match self { OpeningFailed(e) => write!(fmt, "File opening failed: {}", e), Other(e) => write!(fmt, "Other file related io error: {}", e), Traversal(e) => write!(fmt, "Traversal failed, please report this as a bug: {}", e), } } } struct ShardedBlockStore { root: PathBuf, } impl ShardedBlockStore { fn as_path(&self, key: &[u8]) -> PathBuf { // assume that we have a block store with second-to-last/2 sharding // files in Base32Upper let encoded = multibase::Base::Base32Upper.encode(key); let len = encoded.len(); // this is safe because base32 is ascii let dir = &encoded[(len - 3)..(len - 1)]; assert_eq!(dir.len(), 2); let mut path = self.root.clone(); path.push(dir); path.push(encoded); path.set_extension("data"); path } fn as_file(&self, key: &[u8]) -> Result<std::fs::File, Error> { let path = self.as_path(key); std::fs::OpenOptions::new() .read(true) .open(path) .map_err(Error::OpeningFailed) } }
use extension_trait::extension_trait; use rustc_hash::FxHasher; use std::hash::{Hash, Hasher}; #[extension_trait] pub impl AdjustCasingOfFirstLetter for str { fn lowercase_first_letter(&self) -> String { let mut c = self.chars(); match c.next() { None => String::new(), Some(f) => f.to_lowercase().collect::<String>() + c.as_str(), } } fn uppercase_first_letter(&self) -> String { let mut c = self.chars(); match c.next() { None => String::new(), Some(f) => f.to_uppercase().collect::<String>() + c.as_str(), } } } #[extension_trait] pub impl<T: Hash> DoHash for T { fn do_hash(&self) -> u64 { let mut hasher = FxHasher::default(); self.hash(&mut hasher); hasher.finish() } }
use acteur::{Actor, Assistant, Handle, System}; use async_trait::async_trait; #[derive(Debug)] struct Employee { salary: u32, } #[async_trait] impl Actor for Employee { type Id = u32; async fn activate(_: Self::Id) -> Self { Employee { salary: 0, //Load from DB or set a default, } } } #[derive(Debug)] struct SalaryChanged(u32); #[async_trait] impl Handle<SalaryChanged> for Employee { async fn handle(&mut self, message: SalaryChanged, _: Assistant) { self.salary = message.0; } } fn main() { let sys = System::new(); sys.send::<Employee, SalaryChanged>(42, SalaryChanged(55000)); sys.wait_until_stopped(); }
use std::os::unix; use std::io::prelude::*; use errors::*; use types::Client; use httpstream::{read_from_stream, HttpStream}; use utils::http; use utils::http::{Request, Response}; pub struct UnixStream { stream: unix::net::UnixStream, } impl HttpStream for UnixStream { fn connect(client: Client) -> Result<UnixStream> { let socket_path = client .socket_path .ok_or("No socket path defined with unix backend")?; let stream = unix::net::UnixStream::connect(socket_path) .chain_err(|| "Could not connect to unix socket")?; Ok(UnixStream { stream }) } fn request(&mut self, req: Request) -> Result<Response> { let req_str = http::gen_request_string(req); let mut stream = self.stream .try_clone() .chain_err(|| "Could not clone unix stream")?; stream .write_all(req_str.as_bytes()) .chain_err(|| "Could not write to unix stream")?; let response_str = read_from_stream(&mut stream).chain_err(|| "Could not read from unix stream")?; http::parse_response(&response_str).chain_err(|| "Could not parse HTTP response") } }
use nom::error::{ErrorKind, ParseError}; use thiserror::*; #[derive(Error, Debug)] #[error("A parser error has occured: {1}")] pub struct ParserError<'a>(pub &'a [u8], pub ParserErrorKind<'a>); #[derive(Error, Debug)] pub enum ParserErrorKind<'a> { #[error("Invalid slice offset, most likely corrupt archive")] InvalidOffset, #[error("Invalid magic expected farc, found {0:?}")] InvalidMagic(&'a str), #[error("Invalid mode, expected {expected} found {found}.\nMost likely corrupted archive or encrypted future tone archive")] InvalidMode { expected: u32, found: u32 }, #[error("Invalid version detected, expected {expected} found {found}.\nMost likely found future tone archive while expecting extended and vice versa")] InvalidVersion { expected: u32, found: u32 }, #[error("String overflew, couldn't find null byte")] StringOverflow, #[error("{0:?}")] Other(ErrorKind), } impl<'a> ParseError<&'a [u8]> for ParserError<'a> { fn from_error_kind(input: &'a [u8], kind: ErrorKind) -> Self { Self(input, ParserErrorKind::Other(kind)) } fn append(_: &[u8], _: ErrorKind, other: Self) -> Self { other } } impl<'a> From<(&'a [u8], ErrorKind)> for ParserError<'a> { fn from((i, err): (&'a [u8], ErrorKind)) -> Self { Self::from_error_kind(i, err) } } #[cfg(test)] mod tests { use super::*; #[test] fn convert() { let i: &[u8] = &[]; let err = (i, ErrorKind::IsNot); let _err2: ParserError = err.into(); } }
use tree_sitter::{Node, Parser, Query, QueryCursor}; use guarding_core::domain::code_file::CodeFile; use guarding_core::domain::code_class::CodeClass; use crate::code_ident::CodeIdent; const JS_QUERY: &'static str = " (import_specifier name: (identifier) @import-name) (namespace_import (identifier) @import-name) (import_statement source: (string) @source) (import_clause (identifier) @import-name) (class_declaration name: (identifier) @class-name body: (class_body (method_definition name: (property_identifier) @class-method-name parameters: (formal_parameters (identifier)? @parameter) ) ) ) (program (function_declaration name: * @function-name)) "; pub struct JsIdent { parser: Parser, query: Query, } impl JsIdent { fn new() -> JsIdent { let mut parser = Parser::new(); let language = tree_sitter_javascript::language(); parser.set_language(language).unwrap(); let query = Query::new(language, &JS_QUERY) .map_err(|e| println!("{}", format!("Query compilation failed: {:?}", e))).unwrap(); JsIdent { parser, query } } } impl JsIdent { fn do_parse(code: &str, ident: &mut JsIdent) -> CodeFile { let text_callback = |n: Node| &code[n.byte_range()]; let tree = ident.parser.parse(code, None).unwrap(); let mut query_cursor = QueryCursor::new(); let captures = query_cursor.captures(&ident.query, tree.root_node(), text_callback); let mut code_file = CodeFile::default(); let mut last_class_end_line = 0; let mut class = CodeClass::default(); for (mat, capture_index) in captures { let capture = mat.captures[capture_index]; let capture_name = &ident.query.capture_names()[capture.index as usize]; let text = capture.node.utf8_text((&code).as_ref()).unwrap_or(""); match capture_name.as_str() { "source" => { code_file.imports.push(text.to_string()); } "class-name" => { class.name = text.to_string(); let class_node = capture.node.parent().unwrap(); last_class_end_line = class_node.end_position().row; JsIdent::insert_location(&mut class, class_node); } "class-method-name" => { class.functions.push(JsIdent::create_function(capture, text)); } "function-name" => { code_file.functions.push(JsIdent::create_function(capture, text)); } "import-name" => {} "parameter" => {} &_ => { println!( " pattern: {}, capture: {}, row: {}, text: {:?}", mat.pattern_index, capture_name, capture.node.start_position().row, capture.node.utf8_text((&code).as_ref()).unwrap_or("") ); } } if capture.node.start_position().row >= last_class_end_line { if !class.name.is_empty() { code_file.classes.push(class.clone()); class = CodeClass::default(); } } } code_file } } impl CodeIdent for JsIdent { fn parse(code: &str) -> CodeFile { let mut ident = JsIdent::new(); JsIdent::do_parse(code, &mut ident) } } #[cfg(test)] mod tests { use crate::code_ident::CodeIdent; use crate::js_ident::JsIdent; #[test] fn should_parse_import() { let source_code = "import {sayHi} from './say.js' class Rectangle { constructor(height, width) { this.height = height; this.width = width; } } function abc() { } "; let file = JsIdent::parse(source_code); let funcs = &file.functions[0]; let class = &file.classes[0]; assert_eq!("Rectangle", class.name); assert_eq!(0, class.start.column); assert_eq!(2, class.start.row); assert_eq!(7, class.end.row); assert_eq!(1, class.end.column); assert_eq!("constructor", class.functions[0].name); assert_eq!("abc", funcs.name); } #[test] fn should_parse_func_location() { let source_code = "function abc() { } "; let file = JsIdent::parse(source_code); let funcs = &file.functions[0]; assert_eq!("abc", funcs.name); assert_eq!(0, funcs.start.row); assert_eq!(0, funcs.start.column); assert_eq!(2, funcs.end.row); assert_eq!(1, funcs.end.column); } }
/// Ownership/ Kepemilikan /// /// Ahad, 15 Desember 2019 18:00 /// Demo untuk membuktikan bahwa fungsi println! tidak mentransfer /// kepemilikan /// fn main() { // buat var name dengan default immutable/ tidak dapat diubah let name = String::from("Hello"); println!("1. {}", name); println!("2. {}", name); println!("3. {}", name); let msg1 = format!("Pesan 1: {}", name); let msg2 = format!("Pesan 2: {}", name); println!("{}", msg1); println!("{}", msg2); }
use serde::{Deserialize, Serialize}; use std::path::PathBuf; use crate::spotify; use rspotify::client::Spotify; pub type Result<T> = std::result::Result<T, Box<dyn std::error::Error>>; pub struct MusicLibrary { spotify: Option<Spotify>, dirs: Vec<LocalDir>, } #[derive(Debug, Clone)] pub struct LocalDir { name: String, path: PathBuf, } impl MusicLibrary { pub fn new() -> MusicLibrary { MusicLibrary { spotify: None, dirs: vec![], } } pub fn set_spotify(&mut self, spotify: Spotify) -> &mut MusicLibrary { self.spotify = Some(spotify); self } pub fn add_dir(&mut self, name: &str, path: &str) -> &mut MusicLibrary { let local_dir = LocalDir { name: name.to_string(), path: PathBuf::from(path), }; self.dirs.push(local_dir); self } pub fn sources(&self) -> Vec<Box<dyn MusicSource>> { let mut sources: Vec<Box<dyn MusicSource>> = vec![]; for spotify in self.spotify.clone() { sources.push(Box::new(spotify.clone())); } for dir in self.dirs.clone() { sources.push(Box::new(dir.clone())); } sources } } impl MusicLibrary { pub fn get_artists(&self) -> Result<Vec<Artist>> { let artists = self .sources() .iter() .flat_map(|source| match source.get_artists() { Ok(artists) => artists, Err(_error) => vec![], }) .collect::<Vec<_>>(); Ok(artists) } } pub trait MusicSource { fn get_artists(&self) -> Result<Vec<Artist>>; } impl MusicSource for LocalDir { fn get_artists(&self) -> Result<Vec<Artist>> { // TODO: Ok(vec![]) } } impl MusicSource for Spotify { fn get_artists(&self) -> Result<Vec<Artist>> { // TODO: limit and iterating let spotify_artists = self.current_user_followed_artists(1000, None)?; let artists = spotify_artists .artists .items .into_iter() .map(|a| a.into()) .collect::<Vec<Artist>>(); Ok(artists) } } #[derive(Debug, Serialize, Deserialize)] pub struct Artist { pub name: String, pub genres: Vec<String>, pub url: Option<String>, pub spotify_id: Option<String>, pub image_urls: Vec<String>, } impl From<rspotify::model::artist::FullArtist> for Artist { fn from(artist: rspotify::model::artist::FullArtist) -> Artist { Artist { name: artist.name, genres: artist.genres, url: artist .external_urls .values() .take(1) .map(|url| url.to_string()) .collect::<Vec<_>>() .pop(), spotify_id: Some(artist.id), image_urls: artist.images.into_iter().map(|image| image.url).collect(), } } }
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)] #[link(name = "windows")] extern "system" {} pub const ARRAY_SEP_CHAR: u32 = 9u32; pub const FACILITY_WPC: u32 = 2457u32; pub type IWPCGamesSettings = *mut ::core::ffi::c_void; pub type IWPCProviderConfig = *mut ::core::ffi::c_void; pub type IWPCProviderState = *mut ::core::ffi::c_void; pub type IWPCProviderSupport = *mut ::core::ffi::c_void; pub type IWPCSettings = *mut ::core::ffi::c_void; pub type IWPCWebSettings = *mut ::core::ffi::c_void; pub type IWindowsParentalControls = *mut ::core::ffi::c_void; pub type IWindowsParentalControlsCore = *mut ::core::ffi::c_void; pub const MSG_Event_AppBlocked: i32 = -1342177264i32; pub const MSG_Event_AppOverride: i32 = -1342177263i32; pub const MSG_Event_Application: i32 = -1342177260i32; pub const MSG_Event_ComputerUsage: i32 = -1342177259i32; pub const MSG_Event_ContentUsage: i32 = -1342177258i32; pub const MSG_Event_Custom: i32 = -1342177267i32; pub const MSG_Event_EmailContact: i32 = -1342177266i32; pub const MSG_Event_EmailReceived: i32 = -1342177276i32; pub const MSG_Event_EmailSent: i32 = -1342177275i32; pub const MSG_Event_FileDownload: i32 = -1342177270i32; pub const MSG_Event_GameStart: i32 = -1342177278i32; pub const MSG_Event_IMContact: i32 = -1342177265i32; pub const MSG_Event_IMFeature: i32 = -1342177269i32; pub const MSG_Event_IMInvitation: i32 = -1342177273i32; pub const MSG_Event_IMJoin: i32 = -1342177272i32; pub const MSG_Event_IMLeave: i32 = -1342177271i32; pub const MSG_Event_MediaPlayback: i32 = -1342177274i32; pub const MSG_Event_SettingChange: i32 = -1342177279i32; pub const MSG_Event_UrlVisit: i32 = -1342177277i32; pub const MSG_Event_WebOverride: i32 = -1342177262i32; pub const MSG_Event_WebsiteVisit: i32 = -1342177261i32; pub const MSG_Keyword_ThirdParty: i32 = 268435462i32; pub const MSG_Keyword_WPC: i32 = 268435461i32; pub const MSG_Opcode_Launch: i32 = 805306390i32; pub const MSG_Opcode_Locate: i32 = 805306388i32; pub const MSG_Opcode_Modify: i32 = 805306389i32; pub const MSG_Opcode_System: i32 = 805306391i32; pub const MSG_Opcode_Web: i32 = 805306392i32; pub const MSG_Publisher_Name: i32 = -1879048191i32; pub const MSG_Task_AppBlocked: i32 = 1879048208i32; pub const MSG_Task_AppOverride: i32 = 1879048209i32; pub const MSG_Task_Application: i32 = 1879048212i32; pub const MSG_Task_ComputerUsage: i32 = 1879048213i32; pub const MSG_Task_ContentUsage: i32 = 1879048214i32; pub const MSG_Task_Custom: i32 = 1879048205i32; pub const MSG_Task_EmailContact: i32 = 1879048206i32; pub const MSG_Task_EmailReceived: i32 = 1879048196i32; pub const MSG_Task_EmailSent: i32 = 1879048197i32; pub const MSG_Task_FileDownload: i32 = 1879048202i32; pub const MSG_Task_GameStart: i32 = 1879048194i32; pub const MSG_Task_IMContact: i32 = 1879048207i32; pub const MSG_Task_IMFeature: i32 = 1879048203i32; pub const MSG_Task_IMInvitation: i32 = 1879048199i32; pub const MSG_Task_IMJoin: i32 = 1879048200i32; pub const MSG_Task_IMLeave: i32 = 1879048201i32; pub const MSG_Task_MediaPlayback: i32 = 1879048198i32; pub const MSG_Task_SettingChange: i32 = 1879048193i32; pub const MSG_Task_UrlVisit: i32 = 1879048195i32; pub const MSG_Task_WebOverride: i32 = 1879048210i32; pub const MSG_Task_WebsiteVisit: i32 = 1879048211i32; pub const WPCCHANNEL: u32 = 16u32; pub const WPCEVENT_APPLICATION_value: u32 = 20u32; pub const WPCEVENT_APPOVERRIDE_value: u32 = 17u32; pub const WPCEVENT_COMPUTERUSAGE_value: u32 = 21u32; pub const WPCEVENT_CONTENTUSAGE_value: u32 = 22u32; pub const WPCEVENT_CUSTOM_value: u32 = 13u32; pub const WPCEVENT_EMAIL_CONTACT_value: u32 = 14u32; pub const WPCEVENT_EMAIL_RECEIVED_value: u32 = 4u32; pub const WPCEVENT_EMAIL_SENT_value: u32 = 5u32; pub const WPCEVENT_GAME_START_value: u32 = 2u32; pub const WPCEVENT_IM_CONTACT_value: u32 = 15u32; pub const WPCEVENT_IM_FEATURE_value: u32 = 11u32; pub const WPCEVENT_IM_INVITATION_value: u32 = 7u32; pub const WPCEVENT_IM_JOIN_value: u32 = 8u32; pub const WPCEVENT_IM_LEAVE_value: u32 = 9u32; pub const WPCEVENT_MEDIA_PLAYBACK_value: u32 = 6u32; pub const WPCEVENT_SYSTEM_APPBLOCKED_value: u32 = 16u32; pub const WPCEVENT_SYS_SETTINGCHANGE_value: u32 = 1u32; pub const WPCEVENT_WEBOVERRIDE_value: u32 = 18u32; pub const WPCEVENT_WEB_FILEDOWNLOAD_value: u32 = 10u32; pub const WPCEVENT_WEB_URLVISIT_value: u32 = 3u32; pub const WPCEVENT_WEB_WEBSITEVISIT_value: u32 = 19u32; pub type WPCFLAG_IM_FEATURE = i32; pub const WPCFLAG_IM_FEATURE_NONE: WPCFLAG_IM_FEATURE = 0i32; pub const WPCFLAG_IM_FEATURE_VIDEO: WPCFLAG_IM_FEATURE = 1i32; pub const WPCFLAG_IM_FEATURE_AUDIO: WPCFLAG_IM_FEATURE = 2i32; pub const WPCFLAG_IM_FEATURE_GAME: WPCFLAG_IM_FEATURE = 4i32; pub const WPCFLAG_IM_FEATURE_SMS: WPCFLAG_IM_FEATURE = 8i32; pub const WPCFLAG_IM_FEATURE_FILESWAP: WPCFLAG_IM_FEATURE = 16i32; pub const WPCFLAG_IM_FEATURE_URLSWAP: WPCFLAG_IM_FEATURE = 32i32; pub const WPCFLAG_IM_FEATURE_SENDING: WPCFLAG_IM_FEATURE = -2147483648i32; pub const WPCFLAG_IM_FEATURE_ALL: WPCFLAG_IM_FEATURE = -1i32; pub type WPCFLAG_IM_LEAVE = i32; pub const WPCFLAG_IM_LEAVE_NORMAL: WPCFLAG_IM_LEAVE = 0i32; pub const WPCFLAG_IM_LEAVE_FORCED: WPCFLAG_IM_LEAVE = 1i32; pub const WPCFLAG_IM_LEAVE_CONVERSATION_END: WPCFLAG_IM_LEAVE = 2i32; pub type WPCFLAG_ISBLOCKED = i32; pub const WPCFLAG_ISBLOCKED_NOTBLOCKED: WPCFLAG_ISBLOCKED = 0i32; pub const WPCFLAG_ISBLOCKED_IMBLOCKED: WPCFLAG_ISBLOCKED = 1i32; pub const WPCFLAG_ISBLOCKED_EMAILBLOCKED: WPCFLAG_ISBLOCKED = 2i32; pub const WPCFLAG_ISBLOCKED_MEDIAPLAYBACKBLOCKED: WPCFLAG_ISBLOCKED = 4i32; pub const WPCFLAG_ISBLOCKED_WEBBLOCKED: WPCFLAG_ISBLOCKED = 8i32; pub const WPCFLAG_ISBLOCKED_GAMESBLOCKED: WPCFLAG_ISBLOCKED = 16i32; pub const WPCFLAG_ISBLOCKED_CONTACTBLOCKED: WPCFLAG_ISBLOCKED = 32i32; pub const WPCFLAG_ISBLOCKED_FEATUREBLOCKED: WPCFLAG_ISBLOCKED = 64i32; pub const WPCFLAG_ISBLOCKED_DOWNLOADBLOCKED: WPCFLAG_ISBLOCKED = 128i32; pub const WPCFLAG_ISBLOCKED_RATINGBLOCKED: WPCFLAG_ISBLOCKED = 256i32; pub const WPCFLAG_ISBLOCKED_DESCRIPTORBLOCKED: WPCFLAG_ISBLOCKED = 512i32; pub const WPCFLAG_ISBLOCKED_EXPLICITBLOCK: WPCFLAG_ISBLOCKED = 1024i32; pub const WPCFLAG_ISBLOCKED_BADPASS: WPCFLAG_ISBLOCKED = 2048i32; pub const WPCFLAG_ISBLOCKED_MAXHOURS: WPCFLAG_ISBLOCKED = 4096i32; pub const WPCFLAG_ISBLOCKED_SPECHOURS: WPCFLAG_ISBLOCKED = 8192i32; pub const WPCFLAG_ISBLOCKED_SETTINGSCHANGEBLOCKED: WPCFLAG_ISBLOCKED = 16384i32; pub const WPCFLAG_ISBLOCKED_ATTACHMENTBLOCKED: WPCFLAG_ISBLOCKED = 32768i32; pub const WPCFLAG_ISBLOCKED_SENDERBLOCKED: WPCFLAG_ISBLOCKED = 65536i32; pub const WPCFLAG_ISBLOCKED_RECEIVERBLOCKED: WPCFLAG_ISBLOCKED = 131072i32; pub const WPCFLAG_ISBLOCKED_NOTEXPLICITLYALLOWED: WPCFLAG_ISBLOCKED = 262144i32; pub const WPCFLAG_ISBLOCKED_NOTINLIST: WPCFLAG_ISBLOCKED = 524288i32; pub const WPCFLAG_ISBLOCKED_CATEGORYBLOCKED: WPCFLAG_ISBLOCKED = 1048576i32; pub const WPCFLAG_ISBLOCKED_CATEGORYNOTINLIST: WPCFLAG_ISBLOCKED = 2097152i32; pub const WPCFLAG_ISBLOCKED_NOTKIDS: WPCFLAG_ISBLOCKED = 4194304i32; pub const WPCFLAG_ISBLOCKED_UNRATED: WPCFLAG_ISBLOCKED = 8388608i32; pub const WPCFLAG_ISBLOCKED_NOACCESS: WPCFLAG_ISBLOCKED = 16777216i32; pub const WPCFLAG_ISBLOCKED_INTERNALERROR: WPCFLAG_ISBLOCKED = -1i32; pub type WPCFLAG_LOGOFF_TYPE = i32; pub const WPCFLAG_LOGOFF_TYPE_LOGOUT: WPCFLAG_LOGOFF_TYPE = 0i32; pub const WPCFLAG_LOGOFF_TYPE_RESTART: WPCFLAG_LOGOFF_TYPE = 1i32; pub const WPCFLAG_LOGOFF_TYPE_SHUTDOWN: WPCFLAG_LOGOFF_TYPE = 2i32; pub const WPCFLAG_LOGOFF_TYPE_FUS: WPCFLAG_LOGOFF_TYPE = 4i32; pub const WPCFLAG_LOGOFF_TYPE_FORCEDFUS: WPCFLAG_LOGOFF_TYPE = 8i32; pub type WPCFLAG_OVERRIDE = i32; pub const WPCFLAG_APPLICATION: WPCFLAG_OVERRIDE = 1i32; pub type WPCFLAG_RESTRICTION = i32; pub const WPCFLAG_NO_RESTRICTION: WPCFLAG_RESTRICTION = 0i32; pub const WPCFLAG_LOGGING_REQUIRED: WPCFLAG_RESTRICTION = 1i32; pub const WPCFLAG_WEB_FILTERED: WPCFLAG_RESTRICTION = 2i32; pub const WPCFLAG_HOURS_RESTRICTED: WPCFLAG_RESTRICTION = 4i32; pub const WPCFLAG_GAMES_BLOCKED: WPCFLAG_RESTRICTION = 8i32; pub const WPCFLAG_APPS_RESTRICTED: WPCFLAG_RESTRICTION = 16i32; pub const WPCFLAG_TIME_ALLOWANCE_RESTRICTED: WPCFLAG_RESTRICTION = 32i32; pub const WPCFLAG_GAMES_RESTRICTED: WPCFLAG_RESTRICTION = 64i32; pub type WPCFLAG_VISIBILITY = i32; pub const WPCFLAG_WPC_VISIBLE: WPCFLAG_VISIBILITY = 0i32; pub const WPCFLAG_WPC_HIDDEN: WPCFLAG_VISIBILITY = 1i32; pub type WPCFLAG_WEB_SETTING = i32; pub const WPCFLAG_WEB_SETTING_NOTBLOCKED: WPCFLAG_WEB_SETTING = 0i32; pub const WPCFLAG_WEB_SETTING_DOWNLOADSBLOCKED: WPCFLAG_WEB_SETTING = 1i32; pub const WPCPROV: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 17367141, data2: 46183, data3: 17667, data4: [155, 40, 83, 55, 102, 118, 16, 135] }; pub const WPCPROV_KEYWORD_ThirdParty: u32 = 32u32; pub const WPCPROV_KEYWORD_WPC: u32 = 16u32; pub const WPCPROV_TASK_AppBlocked: u32 = 16u32; pub const WPCPROV_TASK_AppOverride: u32 = 17u32; pub const WPCPROV_TASK_Application: u32 = 20u32; pub const WPCPROV_TASK_ComputerUsage: u32 = 21u32; pub const WPCPROV_TASK_ContentUsage: u32 = 22u32; pub const WPCPROV_TASK_Custom: u32 = 13u32; pub const WPCPROV_TASK_EmailContact: u32 = 14u32; pub const WPCPROV_TASK_EmailReceived: u32 = 4u32; pub const WPCPROV_TASK_EmailSent: u32 = 5u32; pub const WPCPROV_TASK_FileDownload: u32 = 10u32; pub const WPCPROV_TASK_GameStart: u32 = 2u32; pub const WPCPROV_TASK_IMContact: u32 = 15u32; pub const WPCPROV_TASK_IMFeature: u32 = 11u32; pub const WPCPROV_TASK_IMInvitation: u32 = 7u32; pub const WPCPROV_TASK_IMJoin: u32 = 8u32; pub const WPCPROV_TASK_IMLeave: u32 = 9u32; pub const WPCPROV_TASK_MediaPlayback: u32 = 6u32; pub const WPCPROV_TASK_SettingChange: u32 = 1u32; pub const WPCPROV_TASK_UrlVisit: u32 = 3u32; pub const WPCPROV_TASK_WebOverride: u32 = 18u32; pub const WPCPROV_TASK_WebsiteVisit: u32 = 19u32; pub const WPC_APP_LAUNCH: u32 = 22u32; pub type WPC_ARGS_APPLICATIONEVENT = i32; pub const WPC_ARGS_APPLICATIONEVENT_SERIALIZEDAPPLICATION: WPC_ARGS_APPLICATIONEVENT = 0i32; pub const WPC_ARGS_APPLICATIONEVENT_DECISION: WPC_ARGS_APPLICATIONEVENT = 1i32; pub const WPC_ARGS_APPLICATIONEVENT_PROCESSID: WPC_ARGS_APPLICATIONEVENT = 2i32; pub const WPC_ARGS_APPLICATIONEVENT_CREATIONTIME: WPC_ARGS_APPLICATIONEVENT = 3i32; pub const WPC_ARGS_APPLICATIONEVENT_TIMEUSED: WPC_ARGS_APPLICATIONEVENT = 4i32; pub const WPC_ARGS_APPLICATIONEVENT_CARGS: WPC_ARGS_APPLICATIONEVENT = 5i32; pub type WPC_ARGS_APPOVERRIDEEVENT = i32; pub const WPC_ARGS_APPOVERRIDEEVENT_USERID: WPC_ARGS_APPOVERRIDEEVENT = 0i32; pub const WPC_ARGS_APPOVERRIDEEVENT_PATH: WPC_ARGS_APPOVERRIDEEVENT = 1i32; pub const WPC_ARGS_APPOVERRIDEEVENT_REASON: WPC_ARGS_APPOVERRIDEEVENT = 2i32; pub const WPC_ARGS_APPOVERRIDEEVENT_CARGS: WPC_ARGS_APPOVERRIDEEVENT = 3i32; pub type WPC_ARGS_COMPUTERUSAGEEVENT = i32; pub const WPC_ARGS_COMPUTERUSAGEEVENT_ID: WPC_ARGS_COMPUTERUSAGEEVENT = 0i32; pub const WPC_ARGS_COMPUTERUSAGEEVENT_TIMEUSED: WPC_ARGS_COMPUTERUSAGEEVENT = 1i32; pub const WPC_ARGS_COMPUTERUSAGEEVENT_CARGS: WPC_ARGS_COMPUTERUSAGEEVENT = 2i32; pub type WPC_ARGS_CONTENTUSAGEEVENT = i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_CONTENTPROVIDERID: WPC_ARGS_CONTENTUSAGEEVENT = 0i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_CONTENTPROVIDERTITLE: WPC_ARGS_CONTENTUSAGEEVENT = 1i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_ID: WPC_ARGS_CONTENTUSAGEEVENT = 2i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_TITLE: WPC_ARGS_CONTENTUSAGEEVENT = 3i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_CATEGORY: WPC_ARGS_CONTENTUSAGEEVENT = 4i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_RATINGS: WPC_ARGS_CONTENTUSAGEEVENT = 5i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_DECISION: WPC_ARGS_CONTENTUSAGEEVENT = 6i32; pub const WPC_ARGS_CONTENTUSAGEEVENT_CARGS: WPC_ARGS_CONTENTUSAGEEVENT = 7i32; pub type WPC_ARGS_CONVERSATIONINITEVENT = i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_APPNAME: WPC_ARGS_CONVERSATIONINITEVENT = 0i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_APPVERSION: WPC_ARGS_CONVERSATIONINITEVENT = 1i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_ACCOUNTNAME: WPC_ARGS_CONVERSATIONINITEVENT = 2i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_CONVID: WPC_ARGS_CONVERSATIONINITEVENT = 3i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_REQUESTINGIP: WPC_ARGS_CONVERSATIONINITEVENT = 4i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_SENDER: WPC_ARGS_CONVERSATIONINITEVENT = 5i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_REASON: WPC_ARGS_CONVERSATIONINITEVENT = 6i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_RECIPCOUNT: WPC_ARGS_CONVERSATIONINITEVENT = 7i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_RECIPIENT: WPC_ARGS_CONVERSATIONINITEVENT = 8i32; pub const WPC_ARGS_CONVERSATIONINITEVENT_CARGS: WPC_ARGS_CONVERSATIONINITEVENT = 9i32; pub type WPC_ARGS_CONVERSATIONJOINEVENT = i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_APPNAME: WPC_ARGS_CONVERSATIONJOINEVENT = 0i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_APPVERSION: WPC_ARGS_CONVERSATIONJOINEVENT = 1i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_ACCOUNTNAME: WPC_ARGS_CONVERSATIONJOINEVENT = 2i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_CONVID: WPC_ARGS_CONVERSATIONJOINEVENT = 3i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_JOININGIP: WPC_ARGS_CONVERSATIONJOINEVENT = 4i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_JOININGUSER: WPC_ARGS_CONVERSATIONJOINEVENT = 5i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_REASON: WPC_ARGS_CONVERSATIONJOINEVENT = 6i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_MEMBERCOUNT: WPC_ARGS_CONVERSATIONJOINEVENT = 7i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_MEMBER: WPC_ARGS_CONVERSATIONJOINEVENT = 8i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_SENDER: WPC_ARGS_CONVERSATIONJOINEVENT = 9i32; pub const WPC_ARGS_CONVERSATIONJOINEVENT_CARGS: WPC_ARGS_CONVERSATIONJOINEVENT = 10i32; pub type WPC_ARGS_CONVERSATIONLEAVEEVENT = i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_APPNAME: WPC_ARGS_CONVERSATIONLEAVEEVENT = 0i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_APPVERSION: WPC_ARGS_CONVERSATIONLEAVEEVENT = 1i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_ACCOUNTNAME: WPC_ARGS_CONVERSATIONLEAVEEVENT = 2i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_CONVID: WPC_ARGS_CONVERSATIONLEAVEEVENT = 3i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_LEAVINGIP: WPC_ARGS_CONVERSATIONLEAVEEVENT = 4i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_LEAVINGUSER: WPC_ARGS_CONVERSATIONLEAVEEVENT = 5i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_REASON: WPC_ARGS_CONVERSATIONLEAVEEVENT = 6i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_MEMBERCOUNT: WPC_ARGS_CONVERSATIONLEAVEEVENT = 7i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_MEMBER: WPC_ARGS_CONVERSATIONLEAVEEVENT = 8i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_FLAGS: WPC_ARGS_CONVERSATIONLEAVEEVENT = 9i32; pub const WPC_ARGS_CONVERSATIONLEAVEEVENT_CARGS: WPC_ARGS_CONVERSATIONLEAVEEVENT = 10i32; pub type WPC_ARGS_CUSTOMEVENT = i32; pub const WPC_ARGS_CUSTOMEVENT_PUBLISHER: WPC_ARGS_CUSTOMEVENT = 0i32; pub const WPC_ARGS_CUSTOMEVENT_APPNAME: WPC_ARGS_CUSTOMEVENT = 1i32; pub const WPC_ARGS_CUSTOMEVENT_APPVERSION: WPC_ARGS_CUSTOMEVENT = 2i32; pub const WPC_ARGS_CUSTOMEVENT_EVENT: WPC_ARGS_CUSTOMEVENT = 3i32; pub const WPC_ARGS_CUSTOMEVENT_VALUE1: WPC_ARGS_CUSTOMEVENT = 4i32; pub const WPC_ARGS_CUSTOMEVENT_VALUE2: WPC_ARGS_CUSTOMEVENT = 5i32; pub const WPC_ARGS_CUSTOMEVENT_VALUE3: WPC_ARGS_CUSTOMEVENT = 6i32; pub const WPC_ARGS_CUSTOMEVENT_BLOCKED: WPC_ARGS_CUSTOMEVENT = 7i32; pub const WPC_ARGS_CUSTOMEVENT_REASON: WPC_ARGS_CUSTOMEVENT = 8i32; pub const WPC_ARGS_CUSTOMEVENT_CARGS: WPC_ARGS_CUSTOMEVENT = 9i32; pub type WPC_ARGS_EMAILCONTACTEVENT = i32; pub const WPC_ARGS_EMAILCONTACTEVENT_APPNAME: WPC_ARGS_EMAILCONTACTEVENT = 0i32; pub const WPC_ARGS_EMAILCONTACTEVENT_APPVERSION: WPC_ARGS_EMAILCONTACTEVENT = 1i32; pub const WPC_ARGS_EMAILCONTACTEVENT_OLDNAME: WPC_ARGS_EMAILCONTACTEVENT = 2i32; pub const WPC_ARGS_EMAILCONTACTEVENT_OLDID: WPC_ARGS_EMAILCONTACTEVENT = 3i32; pub const WPC_ARGS_EMAILCONTACTEVENT_NEWNAME: WPC_ARGS_EMAILCONTACTEVENT = 4i32; pub const WPC_ARGS_EMAILCONTACTEVENT_NEWID: WPC_ARGS_EMAILCONTACTEVENT = 5i32; pub const WPC_ARGS_EMAILCONTACTEVENT_REASON: WPC_ARGS_EMAILCONTACTEVENT = 6i32; pub const WPC_ARGS_EMAILCONTACTEVENT_EMAILACCOUNT: WPC_ARGS_EMAILCONTACTEVENT = 7i32; pub const WPC_ARGS_EMAILCONTACTEVENT_CARGS: WPC_ARGS_EMAILCONTACTEVENT = 8i32; pub type WPC_ARGS_EMAILRECEIEVEDEVENT = i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_SENDER: WPC_ARGS_EMAILRECEIEVEDEVENT = 0i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_APPNAME: WPC_ARGS_EMAILRECEIEVEDEVENT = 1i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_APPVERSION: WPC_ARGS_EMAILRECEIEVEDEVENT = 2i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_SUBJECT: WPC_ARGS_EMAILRECEIEVEDEVENT = 3i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_REASON: WPC_ARGS_EMAILRECEIEVEDEVENT = 4i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_RECIPCOUNT: WPC_ARGS_EMAILRECEIEVEDEVENT = 5i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_RECIPIENT: WPC_ARGS_EMAILRECEIEVEDEVENT = 6i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_ATTACHCOUNT: WPC_ARGS_EMAILRECEIEVEDEVENT = 7i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_ATTACHMENTNAME: WPC_ARGS_EMAILRECEIEVEDEVENT = 8i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_RECEIVEDTIME: WPC_ARGS_EMAILRECEIEVEDEVENT = 9i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_EMAILACCOUNT: WPC_ARGS_EMAILRECEIEVEDEVENT = 10i32; pub const WPC_ARGS_EMAILRECEIEVEDEVENT_CARGS: WPC_ARGS_EMAILRECEIEVEDEVENT = 11i32; pub type WPC_ARGS_EMAILSENTEVENT = i32; pub const WPC_ARGS_EMAILSENTEVENT_SENDER: WPC_ARGS_EMAILSENTEVENT = 0i32; pub const WPC_ARGS_EMAILSENTEVENT_APPNAME: WPC_ARGS_EMAILSENTEVENT = 1i32; pub const WPC_ARGS_EMAILSENTEVENT_APPVERSION: WPC_ARGS_EMAILSENTEVENT = 2i32; pub const WPC_ARGS_EMAILSENTEVENT_SUBJECT: WPC_ARGS_EMAILSENTEVENT = 3i32; pub const WPC_ARGS_EMAILSENTEVENT_REASON: WPC_ARGS_EMAILSENTEVENT = 4i32; pub const WPC_ARGS_EMAILSENTEVENT_RECIPCOUNT: WPC_ARGS_EMAILSENTEVENT = 5i32; pub const WPC_ARGS_EMAILSENTEVENT_RECIPIENT: WPC_ARGS_EMAILSENTEVENT = 6i32; pub const WPC_ARGS_EMAILSENTEVENT_ATTACHCOUNT: WPC_ARGS_EMAILSENTEVENT = 7i32; pub const WPC_ARGS_EMAILSENTEVENT_ATTACHMENTNAME: WPC_ARGS_EMAILSENTEVENT = 8i32; pub const WPC_ARGS_EMAILSENTEVENT_EMAILACCOUNT: WPC_ARGS_EMAILSENTEVENT = 9i32; pub const WPC_ARGS_EMAILSENTEVENT_CARGS: WPC_ARGS_EMAILSENTEVENT = 10i32; pub type WPC_ARGS_FILEDOWNLOADEVENT = i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_URL: WPC_ARGS_FILEDOWNLOADEVENT = 0i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_APPNAME: WPC_ARGS_FILEDOWNLOADEVENT = 1i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_VERSION: WPC_ARGS_FILEDOWNLOADEVENT = 2i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_BLOCKED: WPC_ARGS_FILEDOWNLOADEVENT = 3i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_PATH: WPC_ARGS_FILEDOWNLOADEVENT = 4i32; pub const WPC_ARGS_FILEDOWNLOADEVENT_CARGS: WPC_ARGS_FILEDOWNLOADEVENT = 5i32; pub type WPC_ARGS_GAMESTARTEVENT = i32; pub const WPC_ARGS_GAMESTARTEVENT_APPID: WPC_ARGS_GAMESTARTEVENT = 0i32; pub const WPC_ARGS_GAMESTARTEVENT_INSTANCEID: WPC_ARGS_GAMESTARTEVENT = 1i32; pub const WPC_ARGS_GAMESTARTEVENT_APPVERSION: WPC_ARGS_GAMESTARTEVENT = 2i32; pub const WPC_ARGS_GAMESTARTEVENT_PATH: WPC_ARGS_GAMESTARTEVENT = 3i32; pub const WPC_ARGS_GAMESTARTEVENT_RATING: WPC_ARGS_GAMESTARTEVENT = 4i32; pub const WPC_ARGS_GAMESTARTEVENT_RATINGSYSTEM: WPC_ARGS_GAMESTARTEVENT = 5i32; pub const WPC_ARGS_GAMESTARTEVENT_REASON: WPC_ARGS_GAMESTARTEVENT = 6i32; pub const WPC_ARGS_GAMESTARTEVENT_DESCCOUNT: WPC_ARGS_GAMESTARTEVENT = 7i32; pub const WPC_ARGS_GAMESTARTEVENT_DESCRIPTOR: WPC_ARGS_GAMESTARTEVENT = 8i32; pub const WPC_ARGS_GAMESTARTEVENT_PID: WPC_ARGS_GAMESTARTEVENT = 9i32; pub const WPC_ARGS_GAMESTARTEVENT_CARGS: WPC_ARGS_GAMESTARTEVENT = 10i32; pub type WPC_ARGS_IMCONTACTEVENT = i32; pub const WPC_ARGS_IMCONTACTEVENT_APPNAME: WPC_ARGS_IMCONTACTEVENT = 0i32; pub const WPC_ARGS_IMCONTACTEVENT_APPVERSION: WPC_ARGS_IMCONTACTEVENT = 1i32; pub const WPC_ARGS_IMCONTACTEVENT_ACCOUNTNAME: WPC_ARGS_IMCONTACTEVENT = 2i32; pub const WPC_ARGS_IMCONTACTEVENT_OLDNAME: WPC_ARGS_IMCONTACTEVENT = 3i32; pub const WPC_ARGS_IMCONTACTEVENT_OLDID: WPC_ARGS_IMCONTACTEVENT = 4i32; pub const WPC_ARGS_IMCONTACTEVENT_NEWNAME: WPC_ARGS_IMCONTACTEVENT = 5i32; pub const WPC_ARGS_IMCONTACTEVENT_NEWID: WPC_ARGS_IMCONTACTEVENT = 6i32; pub const WPC_ARGS_IMCONTACTEVENT_REASON: WPC_ARGS_IMCONTACTEVENT = 7i32; pub const WPC_ARGS_IMCONTACTEVENT_CARGS: WPC_ARGS_IMCONTACTEVENT = 8i32; pub type WPC_ARGS_IMFEATUREEVENT = i32; pub const WPC_ARGS_IMFEATUREEVENT_APPNAME: WPC_ARGS_IMFEATUREEVENT = 0i32; pub const WPC_ARGS_IMFEATUREEVENT_APPVERSION: WPC_ARGS_IMFEATUREEVENT = 1i32; pub const WPC_ARGS_IMFEATUREEVENT_ACCOUNTNAME: WPC_ARGS_IMFEATUREEVENT = 2i32; pub const WPC_ARGS_IMFEATUREEVENT_CONVID: WPC_ARGS_IMFEATUREEVENT = 3i32; pub const WPC_ARGS_IMFEATUREEVENT_MEDIATYPE: WPC_ARGS_IMFEATUREEVENT = 4i32; pub const WPC_ARGS_IMFEATUREEVENT_REASON: WPC_ARGS_IMFEATUREEVENT = 5i32; pub const WPC_ARGS_IMFEATUREEVENT_RECIPCOUNT: WPC_ARGS_IMFEATUREEVENT = 6i32; pub const WPC_ARGS_IMFEATUREEVENT_RECIPIENT: WPC_ARGS_IMFEATUREEVENT = 7i32; pub const WPC_ARGS_IMFEATUREEVENT_SENDER: WPC_ARGS_IMFEATUREEVENT = 8i32; pub const WPC_ARGS_IMFEATUREEVENT_SENDERIP: WPC_ARGS_IMFEATUREEVENT = 9i32; pub const WPC_ARGS_IMFEATUREEVENT_DATA: WPC_ARGS_IMFEATUREEVENT = 10i32; pub const WPC_ARGS_IMFEATUREEVENT_CARGS: WPC_ARGS_IMFEATUREEVENT = 11i32; pub type WPC_ARGS_MEDIADOWNLOADEVENT = i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_APPNAME: WPC_ARGS_MEDIADOWNLOADEVENT = 0i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_APPVERSION: WPC_ARGS_MEDIADOWNLOADEVENT = 1i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_MEDIATYPE: WPC_ARGS_MEDIADOWNLOADEVENT = 2i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_PATH: WPC_ARGS_MEDIADOWNLOADEVENT = 3i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_TITLE: WPC_ARGS_MEDIADOWNLOADEVENT = 4i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_PML: WPC_ARGS_MEDIADOWNLOADEVENT = 5i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_ALBUM: WPC_ARGS_MEDIADOWNLOADEVENT = 6i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_EXPLICIT: WPC_ARGS_MEDIADOWNLOADEVENT = 7i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_REASON: WPC_ARGS_MEDIADOWNLOADEVENT = 8i32; pub const WPC_ARGS_MEDIADOWNLOADEVENT_CARGS: WPC_ARGS_MEDIADOWNLOADEVENT = 9i32; pub type WPC_ARGS_MEDIAPLAYBACKEVENT = i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_APPNAME: WPC_ARGS_MEDIAPLAYBACKEVENT = 0i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_APPVERSION: WPC_ARGS_MEDIAPLAYBACKEVENT = 1i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_MEDIATYPE: WPC_ARGS_MEDIAPLAYBACKEVENT = 2i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_PATH: WPC_ARGS_MEDIAPLAYBACKEVENT = 3i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_TITLE: WPC_ARGS_MEDIAPLAYBACKEVENT = 4i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_PML: WPC_ARGS_MEDIAPLAYBACKEVENT = 5i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_ALBUM: WPC_ARGS_MEDIAPLAYBACKEVENT = 6i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_EXPLICIT: WPC_ARGS_MEDIAPLAYBACKEVENT = 7i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_REASON: WPC_ARGS_MEDIAPLAYBACKEVENT = 8i32; pub const WPC_ARGS_MEDIAPLAYBACKEVENT_CARGS: WPC_ARGS_MEDIAPLAYBACKEVENT = 9i32; pub type WPC_ARGS_SAFERAPPBLOCKED = i32; pub const WPC_ARGS_SAFERAPPBLOCKED_TIMESTAMP: WPC_ARGS_SAFERAPPBLOCKED = 0i32; pub const WPC_ARGS_SAFERAPPBLOCKED_USERID: WPC_ARGS_SAFERAPPBLOCKED = 1i32; pub const WPC_ARGS_SAFERAPPBLOCKED_PATH: WPC_ARGS_SAFERAPPBLOCKED = 2i32; pub const WPC_ARGS_SAFERAPPBLOCKED_RULEID: WPC_ARGS_SAFERAPPBLOCKED = 3i32; pub const WPC_ARGS_SAFERAPPBLOCKED_CARGS: WPC_ARGS_SAFERAPPBLOCKED = 4i32; pub type WPC_ARGS_SETTINGSCHANGEEVENT = i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_CLASS: WPC_ARGS_SETTINGSCHANGEEVENT = 0i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_SETTING: WPC_ARGS_SETTINGSCHANGEEVENT = 1i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_OWNER: WPC_ARGS_SETTINGSCHANGEEVENT = 2i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_OLDVAL: WPC_ARGS_SETTINGSCHANGEEVENT = 3i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_NEWVAL: WPC_ARGS_SETTINGSCHANGEEVENT = 4i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_REASON: WPC_ARGS_SETTINGSCHANGEEVENT = 5i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_OPTIONAL: WPC_ARGS_SETTINGSCHANGEEVENT = 6i32; pub const WPC_ARGS_SETTINGSCHANGEEVENT_CARGS: WPC_ARGS_SETTINGSCHANGEEVENT = 7i32; pub type WPC_ARGS_URLVISITEVENT = i32; pub const WPC_ARGS_URLVISITEVENT_URL: WPC_ARGS_URLVISITEVENT = 0i32; pub const WPC_ARGS_URLVISITEVENT_APPNAME: WPC_ARGS_URLVISITEVENT = 1i32; pub const WPC_ARGS_URLVISITEVENT_VERSION: WPC_ARGS_URLVISITEVENT = 2i32; pub const WPC_ARGS_URLVISITEVENT_REASON: WPC_ARGS_URLVISITEVENT = 3i32; pub const WPC_ARGS_URLVISITEVENT_RATINGSYSTEMID: WPC_ARGS_URLVISITEVENT = 4i32; pub const WPC_ARGS_URLVISITEVENT_CATCOUNT: WPC_ARGS_URLVISITEVENT = 5i32; pub const WPC_ARGS_URLVISITEVENT_CATEGORY: WPC_ARGS_URLVISITEVENT = 6i32; pub const WPC_ARGS_URLVISITEVENT_CARGS: WPC_ARGS_URLVISITEVENT = 7i32; pub type WPC_ARGS_WEBOVERRIDEEVENT = i32; pub const WPC_ARGS_WEBOVERRIDEEVENT_USERID: WPC_ARGS_WEBOVERRIDEEVENT = 0i32; pub const WPC_ARGS_WEBOVERRIDEEVENT_URL: WPC_ARGS_WEBOVERRIDEEVENT = 1i32; pub const WPC_ARGS_WEBOVERRIDEEVENT_REASON: WPC_ARGS_WEBOVERRIDEEVENT = 2i32; pub const WPC_ARGS_WEBOVERRIDEEVENT_CARGS: WPC_ARGS_WEBOVERRIDEEVENT = 3i32; pub type WPC_ARGS_WEBSITEVISITEVENT = i32; pub const WPC_ARGS_WEBSITEVISITEVENT_URL: WPC_ARGS_WEBSITEVISITEVENT = 0i32; pub const WPC_ARGS_WEBSITEVISITEVENT_DECISION: WPC_ARGS_WEBSITEVISITEVENT = 1i32; pub const WPC_ARGS_WEBSITEVISITEVENT_CATEGORIES: WPC_ARGS_WEBSITEVISITEVENT = 2i32; pub const WPC_ARGS_WEBSITEVISITEVENT_BLOCKEDCATEGORIES: WPC_ARGS_WEBSITEVISITEVENT = 3i32; pub const WPC_ARGS_WEBSITEVISITEVENT_SERIALIZEDAPPLICATION: WPC_ARGS_WEBSITEVISITEVENT = 4i32; pub const WPC_ARGS_WEBSITEVISITEVENT_TITLE: WPC_ARGS_WEBSITEVISITEVENT = 5i32; pub const WPC_ARGS_WEBSITEVISITEVENT_CONTENTTYPE: WPC_ARGS_WEBSITEVISITEVENT = 6i32; pub const WPC_ARGS_WEBSITEVISITEVENT_REFERRER: WPC_ARGS_WEBSITEVISITEVENT = 7i32; pub const WPC_ARGS_WEBSITEVISITEVENT_TELEMETRY: WPC_ARGS_WEBSITEVISITEVENT = 8i32; pub const WPC_ARGS_WEBSITEVISITEVENT_CARGS: WPC_ARGS_WEBSITEVISITEVENT = 9i32; pub type WPC_MEDIA_EXPLICIT = i32; pub const WPC_MEDIA_EXPLICIT_FALSE: WPC_MEDIA_EXPLICIT = 0i32; pub const WPC_MEDIA_EXPLICIT_TRUE: WPC_MEDIA_EXPLICIT = 1i32; pub const WPC_MEDIA_EXPLICIT_UNKNOWN: WPC_MEDIA_EXPLICIT = 2i32; pub type WPC_MEDIA_TYPE = i32; pub const WPC_MEDIA_TYPE_OTHER: WPC_MEDIA_TYPE = 0i32; pub const WPC_MEDIA_TYPE_DVD: WPC_MEDIA_TYPE = 1i32; pub const WPC_MEDIA_TYPE_RECORDED_TV: WPC_MEDIA_TYPE = 2i32; pub const WPC_MEDIA_TYPE_AUDIO_FILE: WPC_MEDIA_TYPE = 3i32; pub const WPC_MEDIA_TYPE_CD_AUDIO: WPC_MEDIA_TYPE = 4i32; pub const WPC_MEDIA_TYPE_VIDEO_FILE: WPC_MEDIA_TYPE = 5i32; pub const WPC_MEDIA_TYPE_PICTURE_FILE: WPC_MEDIA_TYPE = 6i32; pub const WPC_MEDIA_TYPE_MAX: WPC_MEDIA_TYPE = 7i32; pub type WPC_SETTINGS = i32; pub const WPC_SETTINGS_WPC_EXTENSION_PATH: WPC_SETTINGS = 0i32; pub const WPC_SETTINGS_WPC_EXTENSION_SILO: WPC_SETTINGS = 1i32; pub const WPC_SETTINGS_WPC_EXTENSION_IMAGE_PATH: WPC_SETTINGS = 2i32; pub const WPC_SETTINGS_WPC_EXTENSION_DISABLEDIMAGE_PATH: WPC_SETTINGS = 3i32; pub const WPC_SETTINGS_WPC_EXTENSION_NAME: WPC_SETTINGS = 4i32; pub const WPC_SETTINGS_WPC_EXTENSION_SUB_TITLE: WPC_SETTINGS = 5i32; pub const WPC_SETTINGS_SYSTEM_CURRENT_RATING_SYSTEM: WPC_SETTINGS = 6i32; pub const WPC_SETTINGS_SYSTEM_LAST_LOG_VIEW: WPC_SETTINGS = 7i32; pub const WPC_SETTINGS_SYSTEM_LOG_VIEW_REMINDER_INTERVAL: WPC_SETTINGS = 8i32; pub const WPC_SETTINGS_SYSTEM_HTTP_EXEMPTION_LIST: WPC_SETTINGS = 9i32; pub const WPC_SETTINGS_SYSTEM_URL_EXEMPTION_LIST: WPC_SETTINGS = 10i32; pub const WPC_SETTINGS_SYSTEM_FILTER_ID: WPC_SETTINGS = 11i32; pub const WPC_SETTINGS_SYSTEM_FILTER_NAME: WPC_SETTINGS = 12i32; pub const WPC_SETTINGS_SYSTEM_LOCALE: WPC_SETTINGS = 13i32; pub const WPC_SETTINGS_ALLOW_BLOCK: WPC_SETTINGS = 14i32; pub const WPC_SETTINGS_GAME_BLOCKED: WPC_SETTINGS = 15i32; pub const WPC_SETTINGS_GAME_ALLOW_UNRATED: WPC_SETTINGS = 16i32; pub const WPC_SETTINGS_GAME_MAX_ALLOWED: WPC_SETTINGS = 17i32; pub const WPC_SETTINGS_GAME_DENIED_DESCRIPTORS: WPC_SETTINGS = 18i32; pub const WPC_SETTINGS_USER_WPC_ENABLED: WPC_SETTINGS = 19i32; pub const WPC_SETTINGS_USER_LOGGING_REQUIRED: WPC_SETTINGS = 20i32; pub const WPC_SETTINGS_USER_HOURLY_RESTRICTIONS: WPC_SETTINGS = 21i32; pub const WPC_SETTINGS_USER_OVERRRIDE_REQUESTS: WPC_SETTINGS = 22i32; pub const WPC_SETTINGS_USER_LOGON_HOURS: WPC_SETTINGS = 23i32; pub const WPC_SETTINGS_USER_APP_RESTRICTIONS: WPC_SETTINGS = 24i32; pub const WPC_SETTINGS_WEB_FILTER_ON: WPC_SETTINGS = 25i32; pub const WPC_SETTINGS_WEB_DOWNLOAD_BLOCKED: WPC_SETTINGS = 26i32; pub const WPC_SETTINGS_WEB_FILTER_LEVEL: WPC_SETTINGS = 27i32; pub const WPC_SETTINGS_WEB_BLOCKED_CATEGORY_LIST: WPC_SETTINGS = 28i32; pub const WPC_SETTINGS_WEB_BLOCK_UNRATED: WPC_SETTINGS = 29i32; pub const WPC_SETTINGS_WPC_ENABLED: WPC_SETTINGS = 30i32; pub const WPC_SETTINGS_WPC_LOGGING_REQUIRED: WPC_SETTINGS = 31i32; pub const WPC_SETTINGS_RATING_SYSTEM_PATH: WPC_SETTINGS = 32i32; pub const WPC_SETTINGS_WPC_PROVIDER_CURRENT: WPC_SETTINGS = 33i32; pub const WPC_SETTINGS_USER_TIME_ALLOWANCE: WPC_SETTINGS = 34i32; pub const WPC_SETTINGS_USER_TIME_ALLOWANCE_RESTRICTIONS: WPC_SETTINGS = 35i32; pub const WPC_SETTINGS_GAME_RESTRICTED: WPC_SETTINGS = 36i32; pub const WPC_SETTING_COUNT: WPC_SETTINGS = 37i32; pub const WPC_SETTINGS_LOCATE: u32 = 20u32; pub const WPC_SETTINGS_MODIFY: u32 = 21u32; pub const WPC_SYSTEM: u32 = 23u32; pub const WPC_WEB: u32 = 24u32; pub const WindowsParentalControls: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 3883714715, data2: 29697, data3: 19460, data4: [140, 237, 20, 157, 179, 90, 221, 4] }; pub const WpcProviderSupport: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 3138963360, data2: 8582, data3: 19424, data4: [151, 216, 4, 132, 123, 98, 142, 2] }; pub const WpcSettingsProvider: ::windows_sys::core::GUID = ::windows_sys::core::GUID { data1: 895352746, data2: 15263, data3: 17244, data4: [180, 40, 93, 68, 41, 11, 197, 242] };
//! A widget that may present a modal. use druid::kurbo::Vec2; use druid::widget::prelude::*; use druid::{Color, Command, Data, Rect, Selector, SingleUse, WidgetExt, WidgetPod}; /// A wrapper around a closure for constructing a widget. pub struct ModalBuilder<T>(Box<dyn FnOnce() -> Box<dyn Widget<T>>>); impl<T: Data> ModalBuilder<T> { /// Create a new `ModalBuilder fn new<W: Widget<T> + 'static>(f: impl FnOnce() -> W + 'static) -> Self { ModalBuilder(Box::new(|| f().boxed())) } fn build(self) -> Box<dyn Widget<T>> { (self.0)() } } /// A widget that has a child, and can optionally show a modal dialog /// that obscures the child. pub struct ModalHost<T> { child: WidgetPod<T, Box<dyn Widget<T>>>, modal: Option<WidgetPod<T, Box<dyn Widget<T>>>>, } // this impl block has () type so that you can use this const without knowing `T`. impl ModalHost<()> { /// Command to dismiss the modal. pub const DISMISS_MODAL: Selector = Selector::new("runebender.dismiss-modal-widget"); } impl<T: Data> ModalHost<T> { /// Command to display a modal in this host. /// /// The argument **must** be a `ModalBuilder`. pub const SHOW_MODAL: Selector<SingleUse<ModalBuilder<T>>> = Selector::new("runebender.show-modal-widget"); /// A convenience for creating a command to send to this widget. /// /// This mostly just requires the user to import fewer types. pub fn make_modal_command<W: Widget<T> + 'static>(f: impl FnOnce() -> W + 'static) -> Command { Self::SHOW_MODAL.with(SingleUse::new(ModalBuilder::new(f))) } pub fn new(widget: impl Widget<T> + 'static) -> Self { ModalHost { child: WidgetPod::new(widget.boxed()), modal: None, } } } impl<T: Data> Widget<T> for ModalHost<T> { fn event(&mut self, ctx: &mut EventCtx, event: &Event, data: &mut T, env: &Env) { match event { Event::Command(cmd) => { if let Some(payload) = cmd.get(Self::SHOW_MODAL) { if self.modal.is_none() { self.modal = Some(WidgetPod::new(payload.take().unwrap().build())); ctx.children_changed(); } else { log::warn!("cannot show modal; already showing modal"); } ctx.set_handled(); } else if cmd.is(ModalHost::DISMISS_MODAL) { if self.modal.is_some() { self.modal = None; ctx.children_changed(); } else { log::warn!("cannot dismiss modal; no modal shown"); } ctx.set_handled(); } } // user input only gets delivered to modal, if modal is present e if is_user_input(e) => match self.modal.as_mut() { Some(modal) => modal.event(ctx, event, data, env), None => self.child.event(ctx, event, data, env), }, // other events (timers, commands) are delivered to both widgets other => { if let Some(modal) = self.modal.as_mut() { modal.event(ctx, other, data, env); } self.child.event(ctx, other, data, env); } } } fn lifecycle(&mut self, ctx: &mut LifeCycleCtx, event: &LifeCycle, data: &T, env: &Env) { if let Some(modal) = self.modal.as_mut() { modal.lifecycle(ctx, event, data, env); } self.child.lifecycle(ctx, event, data, env); } fn update(&mut self, ctx: &mut UpdateCtx, _old_data: &T, data: &T, env: &Env) { if let Some(modal) = self.modal.as_mut() { modal.update(ctx, data, env); } self.child.update(ctx, data, env); } fn layout(&mut self, ctx: &mut LayoutCtx, bc: &BoxConstraints, data: &T, env: &Env) -> Size { let size = self.child.layout(ctx, bc, data, env); self.child.set_layout_rect(ctx, data, env, size.to_rect()); if let Some(modal) = self.modal.as_mut() { let modal_constraints = BoxConstraints::new(Size::ZERO, size); let modal_size = modal.layout(ctx, &modal_constraints, data, env); let modal_orig = (size.to_vec2() - modal_size.to_vec2()) / 2.0; let modal_frame = Rect::from_origin_size(modal_orig.to_point(), modal_size); modal.set_layout_rect(ctx, data, env, modal_frame); } size } fn paint(&mut self, ctx: &mut PaintCtx, data: &T, env: &Env) { self.child.paint(ctx, data, env); if let Some(modal) = self.modal.as_mut() { let frame = ctx.size().to_rect(); ctx.fill(frame, &Color::BLACK.with_alpha(0.35)); let modal_rect = modal.layout_rect() + Vec2::new(5.0, 5.0); let blur_color = Color::grey8(100); ctx.blurred_rect(modal_rect, 5.0, &blur_color); modal.paint(ctx, data, env); } } } fn is_user_input(event: &Event) -> bool { matches!( event, Event::MouseUp(_) | Event::MouseDown(_) | Event::MouseMove(_) | Event::KeyUp(_) | Event::KeyDown(_) | Event::Paste(_) | Event::Wheel(_) | Event::Zoom(_) ) }
#![feature( anonymous_lifetime_in_impl_trait, async_closure, box_patterns, let_chains, strict_provenance )] pub mod database; pub mod debug_adapter; pub mod features; pub mod features_candy; pub mod features_ir; mod semantic_tokens; pub mod server; pub mod utils;
use std::path::{Path, PathBuf}; macro_rules! out_ { ($path:expr) => { &[env!("CARGO_MANIFEST_DIR"), "/../target/", $path].concat() }; } macro_rules! in_ { ($path:expr) => { &[env!("CARGO_MANIFEST_DIR"), "/../resources/", $path].concat() }; } /// TODO{issue#128}: rework to provide flexibility and consistency, so all modules can use this; pub fn setup_test_image(test_image_path: &str) -> PathBuf { Path::new("").join(in_!(test_image_path)) } pub fn setup_output_path(test_output_path: &str) -> PathBuf { Path::new("").join(out_!(test_output_path)) } pub fn clean_up_output_path(test_output_path: &str) { std::fs::remove_file(setup_output_path(test_output_path)) .expect("Unable to remove file after test."); }
use libc::*; use sdl2_sys; use std::ffi::CString; #[inline] pub fn get_proc_address(name: &str) -> *const c_void { let cstring = CString::new(name).expect("could not convert name to a CString"); unsafe { sdl2_sys::SDL_GL_GetProcAddress(cstring.as_ptr()) as *const _ } }
extern crate plotlib; use plotlib::page::Page; use plotlib::repr::{Line, Scatter}; use plotlib::style::{PointMarker, PointStyle}; use plotlib::view::ContinuousView; fn main() { let K = |x: f64, s: f64| (x * x - s * s).exp(); let f = |x: f64| (x * x).exp(); let (start, end) = (0., 1f64); let num_points = 40.; let h = (end - start).abs() / num_points; let x = (0..num_points as u32) .map(|x| lerp(start, end, f64::from(x) / num_points)) .collect::<Vec<_>>(); let mut y = vec![0.; num_points as usize]; y[0] = f(x[0]) * (1. - h * K(x[0], x[0]) / 3.).powi(-1); let koeff = |i| if i % 2 == 0 { 4. * h / 3. } else { 2. * h / 3. }; for i in 1..num_points as usize { let mut sum = 0.; for j in 1..i { sum += koeff(j) * K(x[i], x[j]) * y[j]; } y[i] = ((1. - koeff(i) * K(x[i], x[i])).powi(-1)) * (f(x[i]) + (h / 3.) * K(x[i], x[0]) * y[0] + sum); } let func = |x: f64| (x * x + x).exp(); let yc = y.clone(); let arr = x.iter().cloned().zip(yc).collect::<Vec<_>>(); let orig = plotlib::repr::Function::new(func, 0., 1.) .style(plotlib::style::LineStyle::new().colour("#113355")); let s1: Scatter = Scatter::from_slice(&arr.as_slice()).style( PointStyle::new() .marker(PointMarker::Square) .colour("#DD3355"), ); let view = ContinuousView::new() .add(orig) .add(s1) .x_label("Йекс") .y_label("Уигрек"); Page::single(&view).save("compare.svg").unwrap(); let size = x.len(); let dev = (0..size).map(|i| 100. * ((y[i] - func(x[i])) / func(x[i]))); let data = x.iter().cloned().zip(dev).collect::<Vec<_>>(); let s2: Scatter = Scatter::from_slice(data.as_slice()).style( PointStyle::new() .marker(PointMarker::Square) .colour("#DD3355"), ); let l2: Line = Line::new(data).style(plotlib::style::LineStyle::new().colour("#DD3355")); let view = ContinuousView::new() .add(s2) .add(l2) .x_label("Йекс") .y_label("Уигрек"); Page::single(&view).save("scatter.svg").unwrap(); } fn lerp(a: f64, b: f64, t: f64) -> f64 { let t = t.max(0.).min(1.); a + (b - a).abs() * t }
use super::Symbol; use crate::account::AccountName; use crate::bytes::{NumBytes, Read, Write}; use core::fmt; use core::ops::Deref; pub use eosio_numstr::ParseSymbolError; /// Extended asset which stores the information of the owner of the symbol /// <https://github.com/EOSIO/eosio.cdt/blob/4985359a30da1f883418b7133593f835927b8046/libraries/eosiolib/core/eosio/symbol.hpp#L372-L450> #[derive(Debug, PartialEq, Clone, Copy, Default, Read, Write, NumBytes)] #[eosio(crate_path = "crate::bytes")] pub struct ExtendedSymbol { /// The symbol pub symbol: Symbol, /// The token contract hosting the symbol pub contract: AccountName, } impl fmt::Display for ExtendedSymbol { #[inline] fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}@{}", self.symbol, self.contract.deref()) } } #[cfg(test)] mod tests { use super::*; use crate::SymbolCode; use alloc::string::ToString; use core::str::FromStr; use proptest::prelude::*; proptest! { #[test] fn from_str_to_string( precision in 0_u8.., code in "[A-Z]{2,7}", contract in "[[1-5][a-z]]{1,12}" ) { let expected = format!("{},{}@{}", precision, code, contract); let code = SymbolCode::from_str(&code).unwrap(); let symbol = Symbol::new_with_code(precision, code); let contract = AccountName::from_str(&contract).unwrap(); let extended_symbol = ExtendedSymbol { symbol, contract }; let result = extended_symbol.to_string(); prop_assert_eq!(result, expected); } } } // #[cfg(test)] // mod extended_symbol_tests { // use super::*; // use alloc::string::ToString; // use eosio_macros::{n, s}; // macro_rules! test_to_string { // ($($name:ident, $symbol:expr, $contract:expr, $expected:expr)*) => ($( // #[test] // fn $name() { // let extended = ExtendedSymbol { // symbol: $symbol.into(), // contract: $contract.into(), // }; // assert_eq!(extended.to_string(), $expected); // } // )*) // } // test_to_string! { // to_string, // s!(4, "EOS"), // n!("eosio.token"), // "4,EOS@eosio.token" // to_string_zero_precision, // s!(0, "TST"), // n!("test"), // "0,TST@test" // to_string_one_precision, // s!(1, "TGFT"), // n!("greatfiltert"), // "1,TGFT@greatfiltert" // } // }
/* * @lc app=leetcode.cn id=232 lang=rust * * [232] 用栈实现队列 * * https://leetcode-cn.com/problems/implement-queue-using-stacks/description/ * * algorithms * Easy (61.83%) * Likes: 129 * Dislikes: 0 * Total Accepted: 30.7K * Total Submissions: 49.1K * Testcase Example: '["MyQueue","push","push","peek","pop","empty"]\n[[],[1],[2],[],[],[]]' * * 使用栈实现队列的下列操作: * * * push(x) -- 将一个元素放入队列的尾部。 * pop() -- 从队列首部移除元素。 * peek() -- 返回队列首部的元素。 * empty() -- 返回队列是否为空。 * * * 示例: * * MyQueue queue = new MyQueue(); * * queue.push(1); * queue.push(2); * queue.peek(); // 返回 1 * queue.pop(); // 返回 1 * queue.empty(); // 返回 false * * 说明: * * * 你只能使用标准的栈操作 -- 也就是只有 push to top, peek/pop from top, size, 和 is empty * 操作是合法的。 * 你所使用的语言也许不支持栈。你可以使用 list 或者 deque(双端队列)来模拟一个栈,只要是标准的栈操作即可。 * 假设所有操作都是有效的 (例如,一个空的队列不会调用 pop 或者 peek 操作)。 * * */ // @lc code=start #[derive(Default)] struct MyQueue { stack: Vec<i32>, queue: Vec<i32>, } /** * `&self` means the method takes an immutable reference. * If you need a mutable reference, change it to `&mut self` instead. */ impl MyQueue { /** Initialize your data structure here. */ fn new() -> Self { Default::default() } /** Push element x to the back of queue. */ fn push(&mut self, x: i32) { while let Some(q) = self.queue.pop() { self.stack.push(q); } self.stack.push(x); while let Some(s) = self.stack.pop() { self.queue.push(s); } } /** Removes the element from in front of queue and returns that element. */ fn pop(&mut self) -> i32 { self.queue.pop().unwrap() } /** Get the front element. */ fn peek(&self) -> i32 { *self.queue.last().unwrap() } /** Returns whether the queue is empty. */ fn empty(&self) -> bool { self.queue.is_empty() } } /** * Your MyQueue object will be instantiated and called as such: * let obj = MyQueue::new(); * obj.push(x); * let ret_2: i32 = obj.pop(); * let ret_3: i32 = obj.peek(); * let ret_4: bool = obj.empty(); */ // @lc code=end
#![no_std] extern crate alloc; use alloc::format; use alloc::string::String; use alloc::vec::Vec; use core::cmp::PartialEq; use core::default::Default; use core::fmt::Display; #[macro_use] extern crate cfg_if; use prost; use prost::Message; cfg_if! { if #[cfg(feature = "edition-2015")] { extern crate bytes; extern crate prost; extern crate prost_types; extern crate protobuf; #[cfg(test)] extern crate prost_build; #[cfg(test)] extern crate tempfile; #[cfg(test)] extern crate tests_infra; } } pub enum RoundtripResult { /// The roundtrip succeeded. Ok(Vec<u8>), /// The data could not be decoded. This could indicate a bug in prost, /// or it could indicate that the input was bogus. DecodeError(prost::DecodeError), /// Re-encoding or validating the data failed. This indicates a bug in `prost`. Error(String), } impl RoundtripResult { /// Unwrap the roundtrip result. pub fn unwrap(self) -> Vec<u8> { match self { RoundtripResult::Ok(buf) => buf, RoundtripResult::DecodeError(error) => { panic!("failed to decode the roundtrip data: {}", error) } RoundtripResult::Error(error) => panic!("failed roundtrip: {}", error), } } /// Unwrap the roundtrip result. Panics if the result was a validation or re-encoding error. pub fn unwrap_error(self) -> Result<Vec<u8>, prost::DecodeError> { match self { RoundtripResult::Ok(buf) => Ok(buf), RoundtripResult::DecodeError(error) => Err(error), RoundtripResult::Error(error) => panic!("failed roundtrip: {}", error), } } } /// Tests round-tripping a message type. The message should be compiled with `BTreeMap` fields, /// otherwise the comparison may fail due to inconsistent `HashMap` entry encoding ordering. pub fn roundtrip<M>(data: &[u8]) -> RoundtripResult where M: Message + Default, { // Try to decode a message from the data. If decoding fails, continue. let all_types = match M::decode(data) { Ok(all_types) => all_types, Err(error) => return RoundtripResult::DecodeError(error), }; let encoded_len = all_types.encoded_len(); // TODO: Reenable this once sign-extension in negative int32s is figured out. // assert!(encoded_len <= data.len(), "encoded_len: {}, len: {}, all_types: {:?}", // encoded_len, data.len(), all_types); let mut buf1 = Vec::new(); if let Err(error) = all_types.encode(&mut buf1) { return RoundtripResult::Error(to_string(&error)); } if encoded_len != buf1.len() { return RoundtripResult::Error( format!( "expected encoded len ({}) did not match actual encoded len ({})", encoded_len, buf1.len() ) .into(), ); } let roundtrip = match M::decode(&buf1[..]) { Ok(roundtrip) => roundtrip, Err(error) => return RoundtripResult::Error(to_string(&error)), }; let mut buf2 = Vec::new(); if let Err(error) = roundtrip.encode(&mut buf2) { return RoundtripResult::Error(to_string(&error)); } /* // Useful for debugging: eprintln!(" data: {:?}", data.iter().map(|x| format!("0x{:x}", x)).collect::<Vec<_>>()); eprintln!(" buf1: {:?}", buf1.iter().map(|x| format!("0x{:x}", x)).collect::<Vec<_>>()); eprintln!("a: {:?}\nb: {:?}", all_types, roundtrip); */ if buf1 != buf2 { return RoundtripResult::Error("roundtripped encoded buffers do not match".into()); } RoundtripResult::Ok(buf1) } /// Generic rountrip serialization check for messages. pub fn check_message<M>(msg: &M) where M: Message + Default + PartialEq, { let expected_len = msg.encoded_len(); let mut buf = Vec::with_capacity(18); msg.encode(&mut buf).unwrap(); assert_eq!(expected_len, buf.len()); use bytes::Buf; let buf = (&buf[..]).to_bytes(); let roundtrip = M::decode(buf).unwrap(); // FIXME(chris) // if buf.has_remaining() { // panic!("expected buffer to be empty: {}", buf.remaining()); // } assert_eq!(msg, &roundtrip); } /// Serialize from A should equal Serialize from B pub fn check_serialize_equivalent<M, N>(msg_a: &M, msg_b: &N) where M: Message + Default + PartialEq, N: Message + Default + PartialEq, { let mut buf_a = Vec::new(); msg_a.encode(&mut buf_a).unwrap(); let mut buf_b = Vec::new(); msg_b.encode(&mut buf_b).unwrap(); assert_eq!(buf_a, buf_b); } // helper fn to_string<T: Display>(obj: &T) -> String { format!("{}", obj) }
pub struct Solution; impl Solution { pub fn longest_palindrome(s: String) -> String { if s.is_empty() { return s; } let chars = s.chars().collect::<Vec<char>>(); let n = chars.len(); let mut max = 1; let mut max_i = 0; let mut max_j = 0; for i in 0..2 * n - 1 { let mut j = i / 2 + 1; while j <= i && j < n && chars[i - j] == chars[j] { j += 1; } j -= 1; if 2 * j + 1 > max + i { // j - (i - j) + 1 > max max = 2 * j + 1 - i; max_i = i; max_j = j; } } chars[max_i - max_j..=max_j].iter().collect() } } #[test] fn test0005() { assert_eq!( Solution::longest_palindrome("babad".to_string()), "bab".to_string() ); assert_eq!( Solution::longest_palindrome("cbbd".to_string()), "bb".to_string() ); }
mod util; pub use util::loadtxt; use util::{FloatMax, ToU64}; mod colormaps; use pdfpdf::{Alignment::*, Color, Matrix, Pdf, Point, Size}; pub struct Plot { pdf: Pdf, width: f64, height: f64, font_size: f64, tick_length: f64, x_tick_interval: Option<f64>, y_tick_interval: Option<f64>, xlim: Option<(f64, f64)>, ylim: Option<(f64, f64)>, xlabel: Option<String>, ylabel: Option<String>, marker: Option<Marker>, linestyle: Option<LineStyle>, } #[derive(Clone, Copy, Debug)] pub enum Marker { Dot, } #[derive(Clone, Copy, Debug)] pub enum LineStyle { Solid, } fn compute_tick_interval(range: f64) -> f64 { let range = range.abs(); let order_of_magnitude = (10.0f64).powi(range.log10().round() as i32); let possible_tick_intervals = [ order_of_magnitude / 10.0, order_of_magnitude / 5.0, order_of_magnitude / 2.0, order_of_magnitude, order_of_magnitude * 2.0, ]; let num_ticks = [ (range / possible_tick_intervals[0]).round() as i64, (range / possible_tick_intervals[1]).round() as i64, (range / possible_tick_intervals[2]).round() as i64, (range / possible_tick_intervals[3]).round() as i64, (range / possible_tick_intervals[4]).round() as i64, ]; // Try to get as close to 5 ticks as possible let chosen_index = num_ticks .iter() .enumerate() .min_by_key(|(_, num)| (**num - 5).abs()) .unwrap() .0; possible_tick_intervals[chosen_index] } struct Axis { limits: (f64, f64), tick_interval: f64, num_ticks: u64, tick_labels: Vec<String>, margin: f64, } impl Axis { fn tick_labels(&mut self) { let tick_precision = self.tick_interval.abs().log10(); let tick_max = self.limits.0.abs().max(self.limits.1.abs()).log10(); self.tick_labels = (0..self.num_ticks) .map(|i| i as f64 * self.tick_interval + self.limits.0) .map(|v| { if v == 0.0 { format!("{}", v) } else if tick_precision < 0.0 { // If we have small ticks, format so that the last sig fig is visible format!("{:.*}", tick_precision.abs().ceil() as usize, v) } else if tick_max < 4. { // For numbers close to +/- 1, use default formatting format!("{:.2}", v) } else { format!( "{:.*e}", ((tick_max - tick_precision).abs().ceil() - 1.).max(1.) as usize, v ) } }) .collect(); } } impl Plot { pub fn new() -> Self { let mut pdf = Pdf::new(); pdf.font(pdfpdf::Font::Helvetica, 20.0).precision(4); Self { pdf, font_size: 20.0, width: 810.0, height: 630.0, tick_length: 6.0, x_tick_interval: None, y_tick_interval: None, xlim: None, ylim: None, xlabel: None, ylabel: None, marker: None, linestyle: Some(LineStyle::Solid), } } pub fn ylim(&mut self, min: f64, max: f64) -> &mut Self { self.ylim = Some((min, max)); self } pub fn xlim(&mut self, min: f64, max: f64) -> &mut Self { self.xlim = Some((min, max)); self } pub fn xlabel(&mut self, text: &str) -> &mut Self { self.xlabel = Some(text.to_string()); self } pub fn ylabel(&mut self, text: &str) -> &mut Self { self.ylabel = Some(text.to_string()); self } pub fn tick_length(&mut self, length: f64) -> &mut Self { self.tick_length = length; self } pub fn x_tick_interval(&mut self, interval: f64) -> &mut Self { self.x_tick_interval = Some(interval); self } pub fn y_tick_interval(&mut self, interval: f64) -> &mut Self { self.y_tick_interval = Some(interval); self } pub fn marker(&mut self, marker: Option<Marker>) -> &mut Self { self.marker = marker; self } pub fn linestyle(&mut self, style: Option<LineStyle>) -> &mut Self { self.linestyle = style; self } fn digest_tick_settings(&self, x_values: &[f64], y_values: &[f64]) -> (Axis, Axis) { // Pick the axes limits let (min, max) = { use std::f64; let mut max = Point { x: f64::NEG_INFINITY, y: f64::NEG_INFINITY, }; let mut min = Point { x: f64::INFINITY, y: f64::INFINITY, }; for (&x, &y) in x_values.iter().zip(y_values.iter()) { max.x = max.x.max(x); max.y = max.y.max(y); min.x = min.x.min(x); min.y = min.y.min(y); } (min, max) }; // Must either provide data or configure assert!((min.x.is_finite() && max.x.is_finite()) || self.xlim.is_some()); assert!((min.y.is_finite() && max.y.is_finite()) || self.ylim.is_some()); // Compute the tick interval from maxes first so we can choose limits that are a multiple // of the tick interval let x_tick_interval = self .x_tick_interval .unwrap_or_else(|| compute_tick_interval(max.x - min.x)); let y_tick_interval = self .y_tick_interval .unwrap_or_else(|| compute_tick_interval(max.y - min.y)); let xlim = self.xlim.unwrap_or_else(|| { let min_in_ticks = (min.x / x_tick_interval).floor(); let xmin = min_in_ticks * x_tick_interval; let max_in_ticks = (max.x / x_tick_interval).ceil(); let xmax = max_in_ticks * x_tick_interval; (xmin, xmax) }); let ylim = self.ylim.unwrap_or_else(|| { let min_in_ticks = (min.y / y_tick_interval).floor(); let ymin = min_in_ticks * y_tick_interval; let max_in_ticks = (max.y / y_tick_interval).ceil(); let ymax = max_in_ticks * y_tick_interval; (ymin, ymax) }); // Compute the tick interval again but this time based on the now-known axes limits // This fixes our selection of tick interval in situations where we were told odd axes // limits let x_tick_interval = self .x_tick_interval .unwrap_or_else(|| compute_tick_interval(xlim.1 - xlim.0)); let y_tick_interval = self .y_tick_interval .unwrap_or_else(|| compute_tick_interval(ylim.1 - ylim.0)); let x_num_ticks = ((xlim.1 - xlim.0).abs() / x_tick_interval).to_u64() + 1; let y_num_ticks = ((ylim.1 - ylim.0).abs() / y_tick_interval).to_u64() + 1; // Quantize the tick interval so that it fits nicely let x_tick_interval = x_tick_interval * (xlim.1 - xlim.0).signum(); let y_tick_interval = y_tick_interval * (ylim.1 - ylim.0).signum(); let mut xaxis = Axis { limits: xlim, num_ticks: x_num_ticks, tick_interval: x_tick_interval, margin: 0.0, tick_labels: Vec::new(), }; xaxis.tick_labels(); // X border size is 1.5 * height of the axis label label, height of the tick labels, and the tick length xaxis.margin = (self.font_size * 1.5) + self.font_size + self.tick_length + self.font_size; let mut yaxis = Axis { limits: ylim, num_ticks: y_num_ticks, tick_interval: y_tick_interval, margin: 0.0, tick_labels: Vec::new(), }; yaxis.tick_labels(); // Y Border size is height of the font, max width of a label, and the tick length yaxis.margin = self.font_size * 2. + yaxis .tick_labels .iter() .map(|label| self.pdf.width_of(&label)) .float_max() + self.tick_length + self.font_size; (xaxis, yaxis) } fn draw_axes( &mut self, xaxis: &Axis, yaxis: &Axis, to_canvas_x: impl Fn(f64) -> f64, to_canvas_y: impl Fn(f64) -> f64, ) { // Draw the plot's border at the margins self.pdf .add_page(Size { width: self.width, height: self.height, }) .set_color(Color::gray(0)) .set_line_width(1.0) .draw_rectangle( Point { x: to_canvas_x(xaxis.limits.0), y: to_canvas_y(yaxis.limits.0), }, Size { width: to_canvas_x(xaxis.limits.1) - to_canvas_x(xaxis.limits.0), height: to_canvas_y(yaxis.limits.1) - to_canvas_y(yaxis.limits.0), }, ); // Draw the x tick marks for (i, label) in (0..xaxis.num_ticks).zip(&xaxis.tick_labels) { let x = i as f64 * xaxis.tick_interval + xaxis.limits.0; self.pdf .move_to(Point { x: to_canvas_x(x), y: to_canvas_y(yaxis.limits.0), }) .line_to(Point { x: to_canvas_x(x), y: to_canvas_y(yaxis.limits.0) - self.tick_length, }) .end_line(); self.pdf.draw_text( Point { x: to_canvas_x(x), y: to_canvas_y(yaxis.limits.0) - self.tick_length, }, TopCenter, label, ); } // Draw the y tick marks for (i, label) in (0..yaxis.num_ticks).zip(&yaxis.tick_labels) { let y = i as f64 * yaxis.tick_interval + yaxis.limits.0; self.pdf .move_to(Point { x: to_canvas_x(xaxis.limits.0), y: to_canvas_y(y), }) .line_to(Point { x: to_canvas_x(xaxis.limits.0) - self.tick_length, y: to_canvas_y(y), }) .end_line(); self.pdf.draw_text( Point { x: to_canvas_x(xaxis.limits.0) - self.tick_length - 2.0, y: to_canvas_y(y), }, CenterRight, label, ); } // Draw the x label if let Some(ref xlabel) = self.xlabel { self.pdf.draw_text( Point { x: to_canvas_x(xaxis.limits.0 + (xaxis.limits.1 - xaxis.limits.0) / 2.0), y: 4.0 + self.font_size / 2.0, }, BottomCenter, xlabel, ); } // Draw the y label if let Some(ref ylabel) = self.ylabel { self.pdf.transform(Matrix::rotate_deg(90)).draw_text( Point { x: to_canvas_y(yaxis.limits.0 + (yaxis.limits.1 - yaxis.limits.0) / 2.0), y: -6.0, }, TopCenter, ylabel, ); self.pdf.transform(Matrix::rotate_deg(-90)); } } pub fn plot(&mut self, x_values: &[f64], y_values: &[f64]) -> &mut Self { let (xaxis, yaxis) = self.digest_tick_settings(x_values, y_values); let width = self.width; let height = self.height; let plot_width = width - yaxis.margin - self.pdf.width_of(xaxis.tick_labels.last().unwrap()); let plot_height = height - xaxis.margin - self.font_size; // Function to convert from plot pixels to canvas pixels let to_canvas_x = |x| { let x_scale = plot_width / (xaxis.limits.1 - xaxis.limits.0); ((x - xaxis.limits.0) * x_scale) + yaxis.margin }; let to_canvas_y = |y| { let y_scale = plot_height / (yaxis.limits.1 - yaxis.limits.0); ((y - yaxis.limits.0) * y_scale) + xaxis.margin }; self.draw_axes(&xaxis, &yaxis, to_canvas_x, to_canvas_y); // Draw the data series if !x_values.is_empty() { self.pdf .set_clipping_box( Point { x: to_canvas_x(xaxis.limits.0) - 2.0, y: to_canvas_y(yaxis.limits.0) - 2.0, }, Size { width: to_canvas_x(xaxis.limits.1) - to_canvas_x(xaxis.limits.0) + 4.0, height: to_canvas_y(yaxis.limits.1) - to_canvas_y(yaxis.limits.0) + 4.0, }, ) .set_line_width(1.5) .set_color(Color { red: 31, green: 119, blue: 180, }) .draw_line( x_values.iter().map(|&v| to_canvas_x(v)), y_values.iter().map(|&v| to_canvas_y(v)), ) .set_color(Color::gray(0)); } self } pub fn image( &mut self, image_data: &[f64], image_width: usize, image_height: usize, ) -> &mut Self { // Convert the image to u8 and apply a color map assert!(image_width * image_height == image_data.len()); let mut png_bytes = Vec::with_capacity(image_data.len() * 3); let mut max = std::f64::MIN; let mut min = std::f64::MAX; for i in image_data .iter() .filter(|i| !i.is_nan() && !i.is_infinite()) { if *i < min { min = *i; } if *i > max { max = *i; } } let map = colormaps::VIRIDIS; for i in image_data { if i.is_nan() || i.is_infinite() { png_bytes.extend(&[255, 255, 255]); } else { let i = i.max(min); // upper-end clipping is applied by the line below let index = ((i - min) / (max - min) * 255.0) as usize; png_bytes.push((map[index][0] * 255.0) as u8); png_bytes.push((map[index][1] * 255.0) as u8); png_bytes.push((map[index][2] * 255.0) as u8); } } let (xaxis, yaxis) = self.digest_tick_settings(&[], &[]); let width = self.width; let height = self.height; let plot_width = width - yaxis.margin - self.pdf.width_of(xaxis.tick_labels.last().unwrap()); let plot_height = height - xaxis.margin - self.font_size; let plot_size = plot_width.min(plot_height); // This is a hack; we adjust the height and width so that the generated PDF file has its // dimensions adjusted // TODO: This change should be ephemeral self.height = plot_size + xaxis.margin + self.font_size; self.width = plot_size + yaxis.margin + self.font_size; // Function to convert from plot pixels to canvas pixels let to_canvas_x = |x| { let x_scale = plot_size / (xaxis.limits.1 - xaxis.limits.0); ((x - xaxis.limits.0) * x_scale) + yaxis.margin }; let to_canvas_y = |y| { let y_scale = plot_size / (yaxis.limits.1 - yaxis.limits.0); ((y - yaxis.limits.0) * y_scale) + xaxis.margin }; self.draw_axes(&xaxis, &yaxis, to_canvas_x, to_canvas_y); let x_extent = to_canvas_x(xaxis.limits.1) - to_canvas_x(xaxis.limits.0) - 1.0; let y_extent = to_canvas_y(yaxis.limits.1) - to_canvas_y(yaxis.limits.0) - 1.0; self.pdf.transform( Matrix::scale( x_extent / (image_width as f64), y_extent / (image_width as f64), ) * Matrix::translate( to_canvas_x(xaxis.limits.0) + 0.5, to_canvas_y(yaxis.limits.0) + 0.5, ), ); self.pdf.add_image_at( pdfpdf::Image::new(&png_bytes, image_width as u64, image_height as u64), pdfpdf::Point { x: 0, y: 0 }, ); self } pub fn write_to<F>(&mut self, filename: F) -> std::io::Result<()> where F: AsRef<std::path::Path>, { self.pdf.write_to(filename) } }