text stringlengths 8 4.13M |
|---|
#![feature(test)]
extern crate test;
use morgan_runtime::message_processor::*;
use test::Bencher;
#[bench]
fn bench_has_duplicates(bencher: &mut Bencher) {
bencher.iter(|| {
let data = test::black_box([1, 2, 3]);
assert!(!has_duplicates(&data));
})
}
|
use abi_stable::StableAbi;
#[repr(u8)]
#[derive(StableAbi)]
#[sabi(kind(WithNonExhaustive(
size = 2,
)))]
#[sabi(with_constructor)]
pub enum OkSize {
Foo,
Bar,
Baz(u8),
}
// The size of the storage is actually `align_of::<usize>()`,
// because the alignment defaults to that of a usize
#[repr(u8)]
#[derive(StableAbi)]
#[sabi(kind(WithNonExhaustive(
size = 1,
assert_nonexhaustive = OkSizeBecauseAlignIsUsize,
)))]
#[sabi(with_constructor)]
pub enum OkSizeBecauseAlignIsUsize {
Foo,
Bar,
Baz(u8),
}
fn main(){} |
// Based on https://github.com/Bombfuse/emerald/blob/master/src/core/engine.rs
use crate::mq;
use multiqueue2::{broadcast_queue, BroadcastReceiver, BroadcastSender};
use ringbuffer::{AllocRingBuffer, RingBuffer, RingBufferExt, RingBufferWrite};
pub mod events;
mod frame_timer;
pub mod input;
mod logger;
mod miniquad;
mod script;
pub mod world;
pub use events::Event;
use input::{Direction, InputEngine, KeyBind, KeyMods};
pub use logger::Logger;
use script::ScriptEngine;
use frame_timer::DESIRED_FRAMETIME;
const TIME_HISTORY_COUNT: usize = 4;
pub struct Engine<'a> {
pub now: f64,
pub delta: f64,
pub fps: usize,
pub overstep_percentage: f32,
pub quad_ctx: &'a mut mq::Context,
pub egui_ctx: &'a egui::CtxRef,
pub mouse_over_ui: bool,
pub input: &'a mut InputEngine,
pub script: &'a mut ScriptEngine,
pub event_sender: &'a BroadcastSender<Event>,
}
pub trait Game {
fn initialize(&mut self, _eng: Engine<'_>) {}
fn update(&mut self, _eng: Engine<'_>) {}
fn draw(&mut self, _eng: Engine<'_>) {}
}
pub struct Runner<G: Game> {
game: G,
// frame_timer
resync: bool,
frame_time: f64,
time_averager: AllocRingBuffer<f64>,
frame_accumulator: f64,
// renderer
overstep_percentage: f32,
render_time: f64,
fps_second: f64,
fps_count: usize,
fps: AllocRingBuffer<usize>,
// engines
pub(crate) input: InputEngine,
pub(crate) script: ScriptEngine,
// events queue
event_sender: BroadcastSender<Event>,
// dependencies
egui_mq: egui_miniquad::EguiMq,
mouse_over_ui: bool,
}
impl<G: Game> Runner<G> {
pub fn new(ctx: &mut mq::Context, mut game: G) -> Self {
let mut time_averager = AllocRingBuffer::with_capacity(TIME_HISTORY_COUNT);
time_averager.fill(DESIRED_FRAMETIME);
let (event_sender, event_recv) = broadcast_queue(64);
let egui_mq = egui_miniquad::EguiMq::new(ctx);
let mut input = InputEngine::new();
let mut script = ScriptEngine::new(event_sender.clone(), event_recv);
let now = mq::date::now();
let eng = Engine {
now,
delta: 0.,
fps: 0,
overstep_percentage: 0.,
quad_ctx: ctx,
egui_ctx: egui_mq.egui_ctx(),
mouse_over_ui: false,
input: &mut input,
script: &mut script,
event_sender: &event_sender,
};
game.initialize(eng);
Runner {
game,
// frame_timer
resync: true,
frame_time: now,
time_averager,
frame_accumulator: 0.0,
overstep_percentage: 1.0,
render_time: now,
fps_second: now.round(),
fps_count: 0,
fps: AllocRingBuffer::with_capacity(64),
input,
script,
event_sender,
egui_mq,
mouse_over_ui: false,
}
}
pub fn fps(&self) -> usize {
*self.fps.get(-1).unwrap_or(&0)
}
}
|
extern crate regex;
extern crate time;
use std::env;
use std::io;
use std::io::prelude::*;
use std::io::BufReader;
use std::fs::File;
use regex::Regex;
use std::collections::HashSet;
use time::PreciseTime;
#[derive(Copy, Clone, Debug)]
enum Tile {
Island(i32, i32),
Water,
Bridge,
}
#[derive(Clone)]
struct Map {
data: Vec<Tile>,
bridges: Vec<(i32, i32, i32)>,
height: i32,
i_counter: i32,
width: i32,
}
impl Map {
fn new(width: i32, height: i32) -> Map {
Map{width: width, height: height, data: vec![Tile::Water; (width * height) as usize],
bridges: Vec::new(), i_counter: 0}
}
fn get(&self, y: i32, x: i32) -> Tile {
self.data[(y * self.width + x) as usize]
}
fn set(&mut self, y: i32, x: i32, tile: Tile) {
self.data[(y * self.width + x) as usize] = tile;
}
fn add_island(&mut self, y: i32, x: i32, n: i32) {
let i = self.i_counter;
self.set(y, x, Tile::Island(i, n));
self.i_counter += 1;
}
fn iter_islands(&self) -> IterIslands {
IterIslands(&self, 0)
}
fn build_bridge(&mut self, y: i32, x: i32, ny: i32, nx: i32, weight: i32) {
for iy in (y+1)..ny {
self.set(iy, x, Tile::Bridge);
}
for ix in (x+1)..nx {
self.set(y, ix, Tile::Bridge);
}
if let Tile::Island(id, w) = self.get(y, x) {
self.set(y, x, Tile::Island(id, w - weight));
}
if let Tile::Island(id, w) = self.get(ny, nx) {
self.set(ny, nx, Tile::Island(id, w - weight));
}
}
}
struct IterIslands<'a>(&'a Map, i32);
impl<'a> Iterator for IterIslands<'a> {
type Item = ((i32, i32), (i32, i32));
fn next(&mut self) -> Option<Self::Item> {
while self.1 < (self.0.width * self.0.height) {
let y = self.1 / self.0.width;
let x = self.1 % self.0.width;
self.1 += 1;
if let Tile::Island(id, w) = self.0.get(y, x) {
return Some(((y, x), (id, w)));
}
}
None
}
}
fn parse_maps(path: &str) -> Result<Vec<Map>, io::Error> {
let size_re = Regex::new(r"(\d+)x(\d+)").unwrap();
let island_re = Regex::new(r"island\((\d+), *(\d+), *(\d+)\)\.").unwrap();
let f = try!(File::open(path));
let reader = BufReader::new(f);
let mut current_map: Option<Map> = None;
let mut maps: Vec<Map> = Vec::new();
for line in reader.lines() {
let line = try!(line);
if let Some(cap) = size_re.captures(line.as_str()) {
if let Some(map) = current_map {
maps.push(map);
}
let width = cap.at(1).unwrap().parse::<i32>().unwrap();
let height = cap.at(1).unwrap().parse::<i32>().unwrap();
current_map = Some(Map::new(width, height));
continue;
}
if let Some(ref mut map) = current_map {
for cap in island_re.captures_iter(line.as_str()) {
let x = cap.at(1).unwrap().parse::<i32>().unwrap();
let y = map.height - 1 - cap.at(2).unwrap().parse::<i32>().unwrap();
let n = cap.at(3).unwrap().parse::<i32>().unwrap();
map.add_island(y, x, n);
}
}
}
if let Some(map) = current_map {
maps.push(map);
}
Ok(maps)
}
fn find_bridges(m: &Map, y: i32, x: i32) -> Vec<(i32, i32, i32, i32)> {
let mut cx;
let mut cy;
let mut bridges = Vec::new();
let (_, w) = match m.get(y, x) {
Tile::Island(id, w) => (id, w),
_ => return bridges,
};
for &(dy, dx) in &[(1, 0), (0, 1)] {
cy = y + dy;
cx = x + dx;
while cy >= 0 && cy < m.height && cx >= 0 && cx < m.width {
match m.get(cy, cx) {
Tile::Water => { cy += dy; cx += dx },
Tile::Bridge => { break },
Tile::Island(n_id, n_w) => {
if w >= 1 && n_w >= 1 {
bridges.push((cy, cx, 1, n_id));
}
if w >= 2 && n_w >= 2 {
bridges.push((cy, cx, 2, n_id));
}
break;
}
};
}
}
bridges
}
fn solved(map: &Map) -> bool {
for (_, (_, w)) in map.iter_islands() {
if w != 0 {
return false;
}
}
true
}
fn subsets<T>(v: &[T]) -> Vec<Vec<T>>
where T: Copy + Clone
{
let mut res = Vec::new();
if v.len() == 0 {
res.push(Vec::new());
return res;
}
for sub in subsets(&v[1..]) {
let mut new = sub.clone();
res.push(sub);
new.push(v[0]);
res.push(new);
}
res
}
fn find_solution(map: &Map) -> Option<Vec<(i32, i32, i32)>> {
if solved(map) {
return Some(map.bridges.clone())
}
for ((y, x), (id, w)) in map.iter_islands() {
let bridges = find_bridges(&map, y, x);
if bridges.is_empty() {
continue;
}
let mut found_valid = false;
for bridge_set in subsets(bridges.as_slice()) {
let mut island_set = HashSet::new();
let mut n_map = map.clone();
let mut sum = 0;
for &(by, bx, bw, bid) in &bridge_set {
if island_set.contains(&(by, bx)) {
break;
} else {
island_set.insert((by, bx));
}
n_map.build_bridge(y, x, by, bx, bw);
n_map.bridges.push((id, bid, bw));
sum += bw;
}
if sum == w {
found_valid = true;
if let Some(bridges) = find_solution(&n_map) {
return Some(bridges);
}
}
}
if !found_valid {
break
}
}
None
}
fn main() {
let path = env::args().nth(1).expect("Missing arg");
let maps = parse_maps(path.as_str()).expect("File not readable");
for (n, map) in maps.iter().enumerate() {
println!("Solving map {} ({}x{}):", n+1, map.width, map.height);
let start_time = PreciseTime::now();
if let Some(bridges) = find_solution(map){
println!("Total bridges {}:", bridges.len());
for (id1, id2, w) in bridges {
println!("> bridge from {} to {}, width {}", id1, id2, w);
}
println!("Elapsed time {}\n", start_time.to(PreciseTime::now()));
} else {
println!("No solution found");
}
}
}
|
use crate::logic::models::ground::Ground;
use actix_web::{Error, HttpRequest, HttpResponse, Responder};
use futures::future::{ready, Ready};
use serde::Serialize;
#[derive(Serialize)]
pub struct Data {
pub items: Vec<Ground>,
}
impl Responder for Data {
type Error = Error;
type Future = Ready<Result<HttpResponse, Error>>;
fn respond_to(self, _req: &HttpRequest) -> Self::Future {
let body = serde_json::to_string(&self).unwrap();
ready(Ok(HttpResponse::Ok()
.content_type("application/json")
.header("Access-Control-Allow-Origin", "*")
.body(body)))
}
}
|
#[doc = "Reader of register PC"]
pub type R = crate::R<u32, super::PC>;
#[doc = "Writer for register PC"]
pub type W = crate::W<u32, super::PC>;
#[doc = "Register PC `reset()`'s with value 0"]
impl crate::ResetValue for super::PC {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Extended Drive Mode Bit 0\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
#[repr(u8)]
pub enum EDM0_A {
#[doc = "0: Drive values of 2, 4 and 8 mA are maintained. GPIO n Drive Select (GPIODRnR) registers function as normal"]
DISABLE = 0,
#[doc = "1: An additional 6 mA option is provided"]
_6MA = 1,
#[doc = "3: A 2 mA driver is always enabled; setting the corresponding GPIODR4R register bit adds 2 mA and setting the corresponding GPIODR8R of GPIODR12R register bit adds an additional 4 mA"]
PLUS2MA = 3,
}
impl From<EDM0_A> for u8 {
#[inline(always)]
fn from(variant: EDM0_A) -> Self {
variant as _
}
}
#[doc = "Reader of field `EDM0`"]
pub type EDM0_R = crate::R<u8, EDM0_A>;
impl EDM0_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<u8, EDM0_A> {
use crate::Variant::*;
match self.bits {
0 => Val(EDM0_A::DISABLE),
1 => Val(EDM0_A::_6MA),
3 => Val(EDM0_A::PLUS2MA),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `DISABLE`"]
#[inline(always)]
pub fn is_disable(&self) -> bool {
*self == EDM0_A::DISABLE
}
#[doc = "Checks if the value of the field is `_6MA`"]
#[inline(always)]
pub fn is_6ma(&self) -> bool {
*self == EDM0_A::_6MA
}
#[doc = "Checks if the value of the field is `PLUS2MA`"]
#[inline(always)]
pub fn is_plus2ma(&self) -> bool {
*self == EDM0_A::PLUS2MA
}
}
#[doc = "Write proxy for field `EDM0`"]
pub struct EDM0_W<'a> {
w: &'a mut W,
}
impl<'a> EDM0_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: EDM0_A) -> &'a mut W {
unsafe { self.bits(variant.into()) }
}
#[doc = "Drive values of 2, 4 and 8 mA are maintained. GPIO n Drive Select (GPIODRnR) registers function as normal"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(EDM0_A::DISABLE)
}
#[doc = "An additional 6 mA option is provided"]
#[inline(always)]
pub fn _6ma(self) -> &'a mut W {
self.variant(EDM0_A::_6MA)
}
#[doc = "A 2 mA driver is always enabled; setting the corresponding GPIODR4R register bit adds 2 mA and setting the corresponding GPIODR8R of GPIODR12R register bit adds an additional 4 mA"]
#[inline(always)]
pub fn plus2ma(self) -> &'a mut W {
self.variant(EDM0_A::PLUS2MA)
}
#[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 & !0x03) | ((value as u32) & 0x03);
self.w
}
}
#[doc = "Reader of field `EDM1`"]
pub type EDM1_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM1`"]
pub struct EDM1_W<'a> {
w: &'a mut W,
}
impl<'a> EDM1_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 2)) | (((value as u32) & 0x03) << 2);
self.w
}
}
#[doc = "Reader of field `EDM2`"]
pub type EDM2_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM2`"]
pub struct EDM2_W<'a> {
w: &'a mut W,
}
impl<'a> EDM2_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 4)) | (((value as u32) & 0x03) << 4);
self.w
}
}
#[doc = "Reader of field `EDM3`"]
pub type EDM3_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM3`"]
pub struct EDM3_W<'a> {
w: &'a mut W,
}
impl<'a> EDM3_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u32) & 0x03) << 6);
self.w
}
}
#[doc = "Reader of field `EDM4`"]
pub type EDM4_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM4`"]
pub struct EDM4_W<'a> {
w: &'a mut W,
}
impl<'a> EDM4_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 8)) | (((value as u32) & 0x03) << 8);
self.w
}
}
#[doc = "Reader of field `EDM5`"]
pub type EDM5_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM5`"]
pub struct EDM5_W<'a> {
w: &'a mut W,
}
impl<'a> EDM5_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 10)) | (((value as u32) & 0x03) << 10);
self.w
}
}
#[doc = "Reader of field `EDM6`"]
pub type EDM6_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM6`"]
pub struct EDM6_W<'a> {
w: &'a mut W,
}
impl<'a> EDM6_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 12)) | (((value as u32) & 0x03) << 12);
self.w
}
}
#[doc = "Reader of field `EDM7`"]
pub type EDM7_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `EDM7`"]
pub struct EDM7_W<'a> {
w: &'a mut W,
}
impl<'a> EDM7_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 14)) | (((value as u32) & 0x03) << 14);
self.w
}
}
impl R {
#[doc = "Bits 0:1 - Extended Drive Mode Bit 0"]
#[inline(always)]
pub fn edm0(&self) -> EDM0_R {
EDM0_R::new((self.bits & 0x03) as u8)
}
#[doc = "Bits 2:3 - Extended Drive Mode Bit 1"]
#[inline(always)]
pub fn edm1(&self) -> EDM1_R {
EDM1_R::new(((self.bits >> 2) & 0x03) as u8)
}
#[doc = "Bits 4:5 - Extended Drive Mode Bit 2"]
#[inline(always)]
pub fn edm2(&self) -> EDM2_R {
EDM2_R::new(((self.bits >> 4) & 0x03) as u8)
}
#[doc = "Bits 6:7 - Extended Drive Mode Bit 3"]
#[inline(always)]
pub fn edm3(&self) -> EDM3_R {
EDM3_R::new(((self.bits >> 6) & 0x03) as u8)
}
#[doc = "Bits 8:9 - Extended Drive Mode Bit 4"]
#[inline(always)]
pub fn edm4(&self) -> EDM4_R {
EDM4_R::new(((self.bits >> 8) & 0x03) as u8)
}
#[doc = "Bits 10:11 - Extended Drive Mode Bit 5"]
#[inline(always)]
pub fn edm5(&self) -> EDM5_R {
EDM5_R::new(((self.bits >> 10) & 0x03) as u8)
}
#[doc = "Bits 12:13 - Extended Drive Mode Bit 6"]
#[inline(always)]
pub fn edm6(&self) -> EDM6_R {
EDM6_R::new(((self.bits >> 12) & 0x03) as u8)
}
#[doc = "Bits 14:15 - Extended Drive Mode Bit 7"]
#[inline(always)]
pub fn edm7(&self) -> EDM7_R {
EDM7_R::new(((self.bits >> 14) & 0x03) as u8)
}
}
impl W {
#[doc = "Bits 0:1 - Extended Drive Mode Bit 0"]
#[inline(always)]
pub fn edm0(&mut self) -> EDM0_W {
EDM0_W { w: self }
}
#[doc = "Bits 2:3 - Extended Drive Mode Bit 1"]
#[inline(always)]
pub fn edm1(&mut self) -> EDM1_W {
EDM1_W { w: self }
}
#[doc = "Bits 4:5 - Extended Drive Mode Bit 2"]
#[inline(always)]
pub fn edm2(&mut self) -> EDM2_W {
EDM2_W { w: self }
}
#[doc = "Bits 6:7 - Extended Drive Mode Bit 3"]
#[inline(always)]
pub fn edm3(&mut self) -> EDM3_W {
EDM3_W { w: self }
}
#[doc = "Bits 8:9 - Extended Drive Mode Bit 4"]
#[inline(always)]
pub fn edm4(&mut self) -> EDM4_W {
EDM4_W { w: self }
}
#[doc = "Bits 10:11 - Extended Drive Mode Bit 5"]
#[inline(always)]
pub fn edm5(&mut self) -> EDM5_W {
EDM5_W { w: self }
}
#[doc = "Bits 12:13 - Extended Drive Mode Bit 6"]
#[inline(always)]
pub fn edm6(&mut self) -> EDM6_W {
EDM6_W { w: self }
}
#[doc = "Bits 14:15 - Extended Drive Mode Bit 7"]
#[inline(always)]
pub fn edm7(&mut self) -> EDM7_W {
EDM7_W { w: self }
}
}
|
use std::process::{Command, Output};
use std::fs;
use std::io::Error;
use std::path::Path;
pub fn decompress(archive_path: &String, destination_folder: &String, version_str: &String) -> Result<Output, Error> {
Command::new("tar")
.arg("-zxf")
.arg(archive_path)
.arg("-C")
.arg(version_str)
.arg("--strip")
.arg("1")
.current_dir(Path::new(&destination_folder))
.output()
}
pub fn remove_archive_file(archive_file: &String) -> Result<(), Error> {
fs::remove_file(archive_file)
}
|
use std::fmt;
#[derive(Clone, Debug, PartialEq)]
pub enum Token {
Identifier(String),
IntegerConstant(String),
StringValue(String),
Plus,
Minus,
Multiplication,
Division,
Equals,
LessThan,
GreaterThan,
Assign,
Var,
Print,
Colon,
True,
False,
Read,
And,
Not,
For,
In,
Do,
End,
Range,
Assert,
LeftBracket,
RightBracket,
SemiColon,
IntegerType,
StringType,
BooleanType,
EOF,
Illegal,
}
impl fmt::Display for Token {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let output = match self {
Token::Identifier(name) => name,
Token::IntegerConstant(constant) => constant,
Token::StringValue(s) => s,
Token::Plus => "+",
Token::Minus => "-",
Token::Multiplication => "*",
Token::Division => "/",
Token::And => "&",
Token::Not => "!",
Token::LeftBracket => "(",
Token::RightBracket => ")",
Token::Colon => ":",
Token::SemiColon => ";",
Token::Equals => "=",
Token::LessThan => "<",
Token::GreaterThan => ">",
Token::Assign => ":=",
Token::Var => "var",
Token::Print => "print",
Token::For => "for",
Token::In => "in",
Token::Do => "do",
Token::End => "end",
Token::Range => "..",
Token::Assert => "assert",
Token::Read => "read",
Token::True => "true",
Token::False => "false",
Token::BooleanType => "bool",
Token::StringType => "string",
Token::IntegerType => "int",
Token::EOF => "EOF",
Token::Illegal => "Illegal Token!",
};
write!(f, "{}", output)
}
}
pub fn get_id_or_key_token(lexeme: &str) -> Token {
match lexeme {
"for" => Token::For,
"in" => Token::In,
"do" => Token::Do,
"end" => Token::End,
"true" => Token::True,
"false" => Token::False,
"var" => Token::Var,
"print" => Token::Print,
"bool" => Token::BooleanType,
"string" => Token::StringType,
"int" => Token::IntegerType,
"assert" => Token::Assert,
"read" => Token::Read,
id => Token::Identifier(String::from(id)),
}
}
|
use std::path::Path;
use crate::casc::CascStorage;
use crate::sprite_config::{SpriteGroup, SpriteFormat};
use std::error::Error;
use crate::anim::Anim;
use std::fs::{create_dir_all, File, read_dir};
use crate::sprite_maker::{makeSprites, Preset, makeSpritesSd, FactorioSprites};
use crate::lua;
use crate::lua::LuaSyntax;
use std::io::Write;
const modname: &str = "sc-redux";
enum Resolution {
HD,
SD,
}
fn writeAnimation(
group: &String,
format: &SpriteFormat,
sprites: &FactorioSprites,
preset: &Preset,
resolution: &Resolution,
output_dir: &String,
) -> Result<lua::Exp, Box<dyn Error>> {
let sprite_dir = Path::new(&format!("{}/graphics", output_dir))
.join(match resolution {
Resolution::HD => "hd",
Resolution::SD => "sd"
})
.join(group);
create_dir_all(&sprite_dir)?;
let filename_field = if sprites.images.len() > 1 {
(
String::from("filenames"),
lua::Exp::Array {
member_list: (0..sprites.images.len())
.map(|i| {
let filename = match preset {
Preset::normal => format!("{}-{:02}.png", &format.name, i + 1),
Preset::mask => format!("{}-mask-{:02}.png", &format.name, i + 1),
Preset::light => format!("{}-light-{:02}.png", &format.name, i + 1),
};
sprites.images[i].save(sprite_dir.join(&filename)).unwrap();
lua::Exp::String(
match resolution {
Resolution::HD => format!("__{}__/graphics/hd/{}/{}", modname, group, &filename),
Resolution::SD => format!("__{}__/graphics/sd/{}/{}", modname, group, &filename),
}
)
})
.collect()
}
)
} else {
(
String::from("filename"),
{
let filename = match preset {
Preset::normal => format!("{}.png", &format.name),
Preset::mask => format!("{}-mask.png", &format.name),
Preset::light => format!("{}-light.png", &format.name),
};
sprites.images[0].save(sprite_dir.join(&filename)).unwrap();
lua::Exp::String(
match resolution {
Resolution::HD => format!("__{}__/graphics/hd/{}/{}", modname, group, &filename),
Resolution::SD => format!("__{}__/graphics/sd/{}/{}", modname, group, &filename),
}
)
}
)
};
let mut result = lua::Exp::Table {
field_list: vec![
filename_field,
(
String::from("slice"),
lua::Exp::Number(sprites.slice as f32)
),
(
String::from("line_length"),
lua::Exp::Number(sprites.slice as f32)
),
(
String::from("lines_per_file"),
lua::Exp::Number(sprites.lines_per_file as f32)
),
(
String::from("width"),
lua::Exp::Number(sprites.width as f32)
),
(
String::from("height"),
lua::Exp::Number(sprites.height as f32)
),
(
String::from("frame_count"),
lua::Exp::Number(format.animation_length as f32)
),
(
String::from("direction_count"),
lua::Exp::Number(format.direction_count as f32)
),
(
String::from("shift"),
lua::Exp::Array {
member_list: vec![
lua::Exp::Number(format.final_offset.0),
lua::Exp::Number(format.final_offset.1),
]
}
),
(
String::from("animation_speed"),
lua::Exp::Number(0.4)
),
(
String::from("draw_as_shadow"),
lua::Exp::Bool(format.draw_as_shadow),
),
(
String::from("run_mode"),
lua::Exp::String(format.run_mode.clone()),
),
(
String::from("scale"),
if format.scalable {
match resolution {
Resolution::HD => lua::Exp::Var(String::from("0.5 * scale")),
Resolution::SD => lua::Exp::Var(String::from("scale")),
}
} else {
match resolution {
Resolution::HD => lua::Exp::Var(String::from("0.5")),
Resolution::SD => lua::Exp::Var(String::from("1")),
}
}
),
]
};
if let lua::Exp::Table { field_list } = &mut result {
if let Some(frame_sequence) = &format.frame_sequence {
field_list.push(
(
String::from("frame_sequence"),
lua::Exp::Array {
member_list: frame_sequence
.into_iter()
.map(|x| lua::Exp::Number(*x as f32))
.collect()
}
)
)
}
}
if let lua::Exp::Table { field_list } = &mut result {
match preset {
Preset::normal => {
field_list.push(
(
String::from("draw_as_glow"),
lua::Exp::Bool(format.draw_as_glow),
)
);
}
Preset::mask => {
field_list.push(
(
String::from("flags"),
lua::Exp::Array {
member_list: vec![lua::Exp::String(String::from("mask"))]
},
)
);
field_list.push(
(
String::from("tint"),
lua::Exp::Var(String::from("tint")),
)
);
}
Preset::light => {
field_list.push(
(
String::from("draw_as_glow"),
lua::Exp::Bool(true),
)
);
field_list.push(
(
String::from("flags"),
lua::Exp::Array {
member_list: vec![lua::Exp::String(String::from("light"))]
},
)
);
}
}
}
Ok(result)
}
pub fn writeAnimations(
storage: &mut CascStorage,
metadata: &Vec<SpriteGroup>,
output_dir: &String,
) -> Result<(), Box<dyn Error>> {
let mut return_table = Vec::new();
for sprite_group in metadata {
println!("Processing: {} ({})", sprite_group.source, sprite_group.category);
if cfg!(debug_assertions) {
let folder_name = format!("{}/graphics/hd/{}", output_dir, sprite_group.category);
if !Path::new(&folder_name).exists() {
create_dir_all(&folder_name)?;
}
if sprite_group.sprites.iter()
.all(|sprite| read_dir(&folder_name)
.unwrap()
.any(|file| file.as_ref()
.unwrap()
.path()
.file_name()
.unwrap()
.to_string_lossy()
.starts_with(&sprite.name)
)
) {
continue;
}
}
let anim = Anim::fromFile(
storage.openFile(&sprite_group.source)?
)?;
let presets = vec![Preset::normal, Preset::mask, Preset::light];
for format in &sprite_group.sprites {
for preset in &presets {
let tmp = makeSprites(&anim, format, sprite_group.base_offset_x2, preset.clone())?;
let hd_sprites;
match tmp {
Some(sprites) => hd_sprites = sprites,
None => { continue; }
}
let lua_sprites = if format.split_anim {
lua::Exp::Array {
member_list: (0..format.direction_count)
.map(|i| {
let split_format = SpriteFormat {
direction_count: 1,
name: format!("{}-{:02}", format.name, i + 1),
..format.clone()
};
let split_hd_sprites = FactorioSprites {
images: vec![hd_sprites.images[i as usize].clone()],
..hd_sprites.clone()
};
let lua_hr_sprites = writeAnimation(
&sprite_group.category,
&split_format,
&split_hd_sprites,
preset,
&Resolution::HD,
&output_dir,
).unwrap();
let sd_sprites = makeSpritesSd(&split_hd_sprites, &split_format);
let mut lua_sprites = writeAnimation(
&sprite_group.category,
&split_format,
&sd_sprites,
preset,
&Resolution::SD,
&output_dir,
).unwrap();
if let lua::Exp::Table { field_list } = &mut lua_sprites {
field_list.push(
(
String::from("hr_version"),
lua_hr_sprites
)
);
}
lua_sprites
})
.collect()
}
} else {
let lua_hr_sprites = writeAnimation(
&sprite_group.category,
&format,
&hd_sprites,
preset,
&Resolution::HD,
&output_dir,
)?;
let sd_sprites = makeSpritesSd(&hd_sprites, format);
let mut lua_sprites = writeAnimation(
&sprite_group.category,
&format,
&sd_sprites,
preset,
&Resolution::SD,
&output_dir,
)?;
if let lua::Exp::Table { field_list } = &mut lua_sprites {
field_list.push(
(
String::from("hr_version"),
lua_hr_sprites
)
);
}
lua_sprites
};
let anim_name = match preset {
Preset::normal => format!("{}_{}", &sprite_group.category, format.name),
Preset::mask => format!("{}_{}_mask", &sprite_group.category, format.name),
Preset::light => format!("{}_{}_light", &sprite_group.category, format.name),
};
let anim_name = anim_name.replace("-", "_");
let mut params = Vec::new();
if format.scalable { params.push(String::from("scale")); }
if let Preset::mask = preset { params.push(String::from("tint")); }
return_table.push(
(
anim_name,
lua::Exp::Function {
par_list: params,
body: lua::Block {
stats: Vec::new(),
last_stat: Some(lua::LastStat::Return { exp_list: vec![lua_sprites] }),
},
}
)
)
}
}
}
let mut file = File::create(format!("{}/anim.lua", output_dir))?;
file.write_all(
lua::LastStat::Return {
exp_list: vec![
lua::Exp::Table {
field_list: return_table
}
]
}.prettyPrint().as_ref()
)?;
Ok(())
}
|
//! Request all local ip addresses via `hostname`, useful to find out which IP address can be used
//! in a server
use std::io;
use std::net::{IpAddr, Ipv4Addr, Ipv6Addr};
use std::process::Command;
/// Execute `hostname` and parses the output as either Ipv4 or Ipv6 address
///
/// ## Example
/// ```rust
/// use hex_gossip::local_ip;
///
/// for addr in local_ip::get().expect("Could not execute 'hostname', perhaps missing?") {
/// println!(" => {:?}", addr);
/// }
/// ```
pub fn get() -> Result<Vec<IpAddr>, io::Error> {
let output = Command::new("hostname").args(&["-i"]).output()?;
let stdout = String::from_utf8(output.stdout).unwrap();
let res = stdout.trim().split(" ")
.filter_map(|x|
x.parse::<Ipv4Addr>().map(|x| IpAddr::from(x))
.or_else(|_| x.parse::<Ipv6Addr>().map(|x| IpAddr::from(x)))
.ok()
)
.collect::<Vec<IpAddr>>();
Ok(res)
}
|
use escapi;
use super::CameraProvider;
use image;
use std::option::Option;
use image::ImageFormat;
use std::sync::Arc;
pub struct WindowsCamera {
width: usize,
height: usize,
frame_rate: usize,
device : escapi::Device,
last_frame : Option<Vec<u8>>,
counter: usize
}
unsafe impl Send for WindowsCamera{}
unsafe impl Sync for WindowsCamera{}
impl WindowsCamera{
pub fn new(width: usize, height: usize, frame_rate: usize) -> Self {
let w=width as u32;
let h=height as u32;
let device=escapi::init(0, w, h, frame_rate as u64).unwrap();
println!("WindowsCamera initialized. device name: {}", device.name());
WindowsCamera{width, height, frame_rate, device, last_frame: None, counter: 0}
}
}
impl CameraProvider for WindowsCamera {
// Simulating 60fps using 30fps.
fn capture(&mut self) -> Option<Vec<u8>> {
match &self.last_frame{
None=>{
let mut camera=&mut self.device;
let (width, height) = (camera.capture_width(), camera.capture_height());
//println!("capture1");
let pixels = camera.capture().unwrap();
//println!("capture2");
let mut buffer = vec![0; width as usize * height as usize * 3];
for i in 0..pixels.len() / 4 {
buffer[i * 3] = pixels[i * 4 + 2];
buffer[i * 3 + 1] = pixels[i * 4 + 1];
buffer[i * 3 + 2] = pixels[i * 4];
}
//println!("capture3");
let mut buf=Vec::new();
image::jpeg::JPEGEncoder::new(&mut buf).encode(&buffer, width, height, image::ColorType::RGB(8)).unwrap();
self.last_frame=Some(buf.clone());
self.counter=3;
Some(buf)
}
Some(vec)=>{
let buf=self.last_frame.as_ref().unwrap().clone();
self.counter-=1;
if self.counter==0{
self.last_frame=None;
}
Some(buf)
}
}
}
fn h264_header(&self) -> Arc<Vec<u8>> {
Arc::new(Vec::new())
}
} |
#[doc = r"Value read from the register"]
pub struct R {
bits: u32,
}
#[doc = r"Value to write to the register"]
pub struct W {
bits: u32,
}
impl super::BIT {
#[doc = r"Modifies the contents of the register"]
#[inline(always)]
pub fn modify<F>(&self, f: F)
where
for<'w> F: FnOnce(&R, &'w mut W) -> &'w mut W,
{
let bits = self.register.get();
self.register.set(f(&R { bits }, &mut W { bits }).bits);
}
#[doc = r"Reads the contents of the register"]
#[inline(always)]
pub fn read(&self) -> R {
R {
bits: self.register.get(),
}
}
#[doc = r"Writes to the register"]
#[inline(always)]
pub fn write<F>(&self, f: F)
where
F: FnOnce(&mut W) -> &mut W,
{
self.register.set(
f(&mut W {
bits: Self::reset_value(),
})
.bits,
);
}
#[doc = r"Reset value of the register"]
#[inline(always)]
pub const fn reset_value() -> u32 {
0
}
#[doc = r"Writes the reset value to the register"]
#[inline(always)]
pub fn reset(&self) {
self.register.set(Self::reset_value())
}
}
#[doc = r"Value of the field"]
pub struct CAN_BIT_BRPR {
bits: u8,
}
impl CAN_BIT_BRPR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _CAN_BIT_BRPW<'a> {
w: &'a mut W,
}
impl<'a> _CAN_BIT_BRPW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(63 << 0);
self.w.bits |= ((value as u32) & 63) << 0;
self.w
}
}
#[doc = r"Value of the field"]
pub struct CAN_BIT_SJWR {
bits: u8,
}
impl CAN_BIT_SJWR {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _CAN_BIT_SJWW<'a> {
w: &'a mut W,
}
impl<'a> _CAN_BIT_SJWW<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(3 << 6);
self.w.bits |= ((value as u32) & 3) << 6;
self.w
}
}
#[doc = r"Value of the field"]
pub struct CAN_BIT_TSEG1R {
bits: u8,
}
impl CAN_BIT_TSEG1R {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _CAN_BIT_TSEG1W<'a> {
w: &'a mut W,
}
impl<'a> _CAN_BIT_TSEG1W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(15 << 8);
self.w.bits |= ((value as u32) & 15) << 8;
self.w
}
}
#[doc = r"Value of the field"]
pub struct CAN_BIT_TSEG2R {
bits: u8,
}
impl CAN_BIT_TSEG2R {
#[doc = r"Value of the field as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u8 {
self.bits
}
}
#[doc = r"Proxy"]
pub struct _CAN_BIT_TSEG2W<'a> {
w: &'a mut W,
}
impl<'a> _CAN_BIT_TSEG2W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits &= !(7 << 12);
self.w.bits |= ((value as u32) & 7) << 12;
self.w
}
}
impl R {
#[doc = r"Value of the register as raw bits"]
#[inline(always)]
pub fn bits(&self) -> u32 {
self.bits
}
#[doc = "Bits 0:5 - Baud Rate Prescaler"]
#[inline(always)]
pub fn can_bit_brp(&self) -> CAN_BIT_BRPR {
let bits = ((self.bits >> 0) & 63) as u8;
CAN_BIT_BRPR { bits }
}
#[doc = "Bits 6:7 - (Re)Synchronization Jump Width"]
#[inline(always)]
pub fn can_bit_sjw(&self) -> CAN_BIT_SJWR {
let bits = ((self.bits >> 6) & 3) as u8;
CAN_BIT_SJWR { bits }
}
#[doc = "Bits 8:11 - Time Segment Before Sample Point"]
#[inline(always)]
pub fn can_bit_tseg1(&self) -> CAN_BIT_TSEG1R {
let bits = ((self.bits >> 8) & 15) as u8;
CAN_BIT_TSEG1R { bits }
}
#[doc = "Bits 12:14 - Time Segment after Sample Point"]
#[inline(always)]
pub fn can_bit_tseg2(&self) -> CAN_BIT_TSEG2R {
let bits = ((self.bits >> 12) & 7) as u8;
CAN_BIT_TSEG2R { bits }
}
}
impl W {
#[doc = r"Writes raw bits to the register"]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
#[doc = "Bits 0:5 - Baud Rate Prescaler"]
#[inline(always)]
pub fn can_bit_brp(&mut self) -> _CAN_BIT_BRPW {
_CAN_BIT_BRPW { w: self }
}
#[doc = "Bits 6:7 - (Re)Synchronization Jump Width"]
#[inline(always)]
pub fn can_bit_sjw(&mut self) -> _CAN_BIT_SJWW {
_CAN_BIT_SJWW { w: self }
}
#[doc = "Bits 8:11 - Time Segment Before Sample Point"]
#[inline(always)]
pub fn can_bit_tseg1(&mut self) -> _CAN_BIT_TSEG1W {
_CAN_BIT_TSEG1W { w: self }
}
#[doc = "Bits 12:14 - Time Segment after Sample Point"]
#[inline(always)]
pub fn can_bit_tseg2(&mut self) -> _CAN_BIT_TSEG2W {
_CAN_BIT_TSEG2W { w: self }
}
}
|
// This file is part of ICU4X. For terms of use, please see the file
// called LICENSE at the top level of the ICU4X source tree
// (online at: https://github.com/unicode-org/icu4x/blob/main/LICENSE ).
mod calendar;
mod date;
mod duration;
mod error;
pub mod iso;
pub use calendar::Calendar;
pub use date::{AsCalendar, Date};
pub use duration::{DateDuration, DurationUnit};
pub use error::Error;
pub use iso::Iso;
|
// Copyright 2019, The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use futures::{channel::mpsc, StreamExt};
use rand::rngs::OsRng;
use std::{sync::Arc, time::Duration};
use tari_comms::{
backoff::ConstantBackoff,
message::MessageExt,
peer_manager::{NodeId, NodeIdentity, Peer, PeerFeatures, PeerStorage},
pipeline,
pipeline::SinkService,
protocol::messaging::MessagingEvent,
transports::MemoryTransport,
types::CommsDatabase,
wrap_in_envelope_body,
CommsBuilder,
CommsNode,
};
use tari_comms_dht::{
domain_message::OutboundDomainMessage,
envelope::NodeDestination,
inbound::DecryptedDhtMessage,
outbound::{OutboundEncryption, SendMessageParams},
DbConnectionUrl,
Dht,
DhtBuilder,
};
use tari_storage::{lmdb_store::LMDBBuilder, LMDBWrapper};
use tari_test_utils::{
async_assert_eventually,
collect_stream,
paths::create_temporary_data_path,
random,
unpack_enum,
};
use tokio::time;
use tower::ServiceBuilder;
struct TestNode {
comms: CommsNode,
dht: Dht,
ims_rx: mpsc::Receiver<DecryptedDhtMessage>,
}
impl TestNode {
pub fn node_identity(&self) -> Arc<NodeIdentity> {
self.comms.node_identity()
}
pub fn to_peer(&self) -> Peer {
self.comms.node_identity().to_peer()
}
pub async fn next_inbound_message(&mut self, timeout: Duration) -> Option<DecryptedDhtMessage> {
time::timeout(timeout, self.ims_rx.next()).await.ok()?
}
}
fn make_node_identity(features: PeerFeatures) -> Arc<NodeIdentity> {
let port = MemoryTransport::acquire_next_memsocket_port();
Arc::new(NodeIdentity::random(&mut OsRng, format!("/memory/{}", port).parse().unwrap(), features).unwrap())
}
fn create_peer_storage(peers: Vec<Peer>) -> CommsDatabase {
let database_name = random::string(8);
let datastore = LMDBBuilder::new()
.set_path(create_temporary_data_path().to_str().unwrap())
.set_environment_size(50)
.set_max_number_of_databases(1)
.add_database(&database_name, lmdb_zero::db::CREATE)
.build()
.unwrap();
let peer_database = datastore.get_handle(&database_name).unwrap();
let peer_database = LMDBWrapper::new(Arc::new(peer_database));
let mut storage = PeerStorage::new_indexed(peer_database).unwrap();
for peer in peers {
storage.add_peer(peer).unwrap();
}
storage.into()
}
async fn make_node(features: PeerFeatures, seed_peer: Option<Peer>) -> TestNode {
let node_identity = make_node_identity(features);
make_node_with_node_identity(node_identity, seed_peer).await
}
async fn make_node_with_node_identity(node_identity: Arc<NodeIdentity>, seed_peer: Option<Peer>) -> TestNode {
let (tx, ims_rx) = mpsc::channel(10);
let (comms, dht) = setup_comms_dht(node_identity, create_peer_storage(seed_peer.into_iter().collect()), tx).await;
TestNode { comms, dht, ims_rx }
}
async fn setup_comms_dht(
node_identity: Arc<NodeIdentity>,
storage: CommsDatabase,
inbound_tx: mpsc::Sender<DecryptedDhtMessage>,
) -> (CommsNode, Dht)
{
// Create inbound and outbound channels
let (outbound_tx, outbound_rx) = mpsc::channel(10);
let comms = CommsBuilder::new()
.allow_test_addresses()
// In this case the listener address and the public address are the same (/memory/...)
.with_listener_address(node_identity.public_address())
.with_transport(MemoryTransport)
.with_node_identity(node_identity)
.with_peer_storage(storage)
.with_dial_backoff(ConstantBackoff::new(Duration::from_millis(100)))
.build()
.unwrap();
let dht = DhtBuilder::new(
comms.node_identity(),
comms.peer_manager(),
outbound_tx,
comms.connection_manager_requester(),
comms.shutdown_signal(),
)
.local_test()
.disable_auto_store_and_forward_requests()
.with_database_url(DbConnectionUrl::MemoryShared(random::string(8)))
.with_discovery_timeout(Duration::from_secs(60))
.with_num_neighbouring_nodes(8)
.finish()
.await
.unwrap();
let dht_outbound_layer = dht.outbound_middleware_layer();
let comms = comms
.with_messaging_pipeline(
pipeline::Builder::new()
.outbound_buffer_size(10)
.with_outbound_pipeline(outbound_rx, |sink| {
ServiceBuilder::new().layer(dht_outbound_layer).service(sink)
})
.max_concurrent_inbound_tasks(10)
.with_inbound_pipeline(
ServiceBuilder::new()
.layer(dht.inbound_middleware_layer())
.service(SinkService::new(inbound_tx)),
)
.finish(),
)
.spawn()
.await
.unwrap();
(comms, dht)
}
#[tokio_macros::test]
#[allow(non_snake_case)]
async fn dht_join_propagation() {
// Create 3 nodes where only Node B knows A and C, but A and C want to talk to each other
// Node C knows no one
let node_C = make_node(PeerFeatures::COMMUNICATION_NODE, None).await;
// Node B knows about Node C
let node_B = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_C.to_peer())).await;
// Node A knows about Node B
let node_A = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_B.to_peer())).await;
// Send a join request from Node A, through B to C. As all Nodes are in the same network region, once
// Node C receives the join request from Node A, it will send a direct join request back
// to A.
node_A.dht.dht_requester().send_join().await.unwrap();
let node_A_peer_manager = node_A.comms.peer_manager();
let node_C_peer_manager = node_C.comms.peer_manager();
// Check that Node A knows about Node C and vice versa
async_assert_eventually!(
node_A_peer_manager.exists(node_C.node_identity().public_key()).await,
expect = true,
max_attempts = 10,
interval = Duration::from_millis(1000)
);
async_assert_eventually!(
node_C_peer_manager.exists(node_A.node_identity().public_key()).await,
expect = true,
max_attempts = 10,
interval = Duration::from_millis(500)
);
let node_C_peer = node_A_peer_manager
.find_by_public_key(node_C.node_identity().public_key())
.await
.unwrap();
assert_eq!(node_C_peer.features, node_C.comms.node_identity().features());
node_A.comms.shutdown().await;
node_B.comms.shutdown().await;
node_C.comms.shutdown().await;
}
#[tokio_macros::test]
#[allow(non_snake_case)]
async fn dht_discover_propagation() {
// Create 4 nodes where A knows B, B knows A and C, C knows B and D, and D knows C
// Node D knows no one
let node_D = make_node(PeerFeatures::COMMUNICATION_CLIENT, None).await;
// Node C knows about Node D
let node_C = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_D.to_peer())).await;
// Node B knows about Node C
let node_B = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_C.to_peer())).await;
// Node A knows about Node B
let node_A = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_B.to_peer())).await;
// Send a discover request from Node A, through B and C, to D. Once Node D
// receives the discover request from Node A, it should send a discovery response
// request back to A at which time this call will resolve (or timeout).
node_A
.dht
.discovery_service_requester()
.discover_peer(
Box::new(node_D.node_identity().public_key().clone()),
NodeDestination::Unknown,
)
.await
.unwrap();
let node_A_peer_manager = node_A.comms.peer_manager();
let node_B_peer_manager = node_B.comms.peer_manager();
let node_C_peer_manager = node_C.comms.peer_manager();
let node_D_peer_manager = node_D.comms.peer_manager();
// Check that all the nodes know about each other in the chain and the discovery worked
assert!(node_A_peer_manager.exists(node_D.node_identity().public_key()).await);
assert!(node_B_peer_manager.exists(node_A.node_identity().public_key()).await);
assert!(node_C_peer_manager.exists(node_B.node_identity().public_key()).await);
assert!(node_D_peer_manager.exists(node_C.node_identity().public_key()).await);
assert!(node_D_peer_manager.exists(node_A.node_identity().public_key()).await);
node_A.comms.shutdown().await;
node_B.comms.shutdown().await;
node_C.comms.shutdown().await;
node_D.comms.shutdown().await;
}
#[tokio_macros::test]
#[allow(non_snake_case)]
async fn dht_store_forward() {
let node_C_node_identity = make_node_identity(PeerFeatures::COMMUNICATION_NODE);
// Node B knows about Node C
let node_B = make_node(PeerFeatures::COMMUNICATION_NODE, None).await;
// Node A knows about Node B
let node_A = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_B.to_peer())).await;
log::info!(
"NodeA = {}, NodeB = {}, Node C = {}",
node_A.node_identity().node_id().short_str(),
node_B.node_identity().node_id().short_str(),
node_C_node_identity.node_id().short_str(),
);
let dest_public_key = Box::new(node_C_node_identity.public_key().clone());
let params = SendMessageParams::new()
.neighbours(vec![])
.with_encryption(OutboundEncryption::EncryptFor(dest_public_key))
.with_destination(NodeDestination::NodeId(Box::new(
node_C_node_identity.node_id().clone(),
)))
.finish();
let secret_msg1 = b"NCZW VUSX PNYM INHZ XMQX SFWX WLKJ AHSH";
let secret_msg2 = b"NMCO CCAK UQPM KCSM HKSE INJU SBLK";
let node_B_msg_events = node_B.comms.subscribe_messaging_events();
node_A
.dht
.outbound_requester()
.send_raw(
params.clone(),
wrap_in_envelope_body!(secret_msg1.to_vec()).to_encoded_bytes(),
)
.await
.unwrap();
node_A
.dht
.outbound_requester()
.send_raw(params, wrap_in_envelope_body!(secret_msg2.to_vec()).to_encoded_bytes())
.await
.unwrap();
// Wait for node B to receive 2 propagation messages
collect_stream!(node_B_msg_events, take = 2, timeout = Duration::from_secs(20));
let mut node_C = make_node_with_node_identity(node_C_node_identity, Some(node_B.to_peer())).await;
let node_C_msg_events = node_C.comms.subscribe_messaging_events();
// Ask node B for messages
node_C
.dht
.store_and_forward_requester()
.request_saf_messages_from_peer(node_B.node_identity().node_id().clone())
.await
.unwrap();
// Wait for node C to send 1 SAF request, and receive a response
collect_stream!(node_C_msg_events, take = 2, timeout = Duration::from_secs(20));
let msg = node_C.next_inbound_message(Duration::from_secs(5)).await.unwrap();
assert_eq!(
msg.authenticated_origin.as_ref().unwrap(),
node_A.comms.node_identity().public_key()
);
let secret = msg.success().unwrap().decode_part::<Vec<u8>>(0).unwrap().unwrap();
assert_eq!(secret, secret_msg1.to_vec());
let msg = node_C.next_inbound_message(Duration::from_secs(5)).await.unwrap();
assert_eq!(
msg.authenticated_origin.as_ref().unwrap(),
node_A.comms.node_identity().public_key()
);
let secret = msg.success().unwrap().decode_part::<Vec<u8>>(0).unwrap().unwrap();
assert_eq!(secret, secret_msg2.to_vec());
node_A.comms.shutdown().await;
node_B.comms.shutdown().await;
node_C.comms.shutdown().await;
}
#[tokio_macros::test]
#[allow(non_snake_case)]
async fn dht_propagate_dedup() {
env_logger::init();
// Node D knows no one
let mut node_D = make_node(PeerFeatures::COMMUNICATION_NODE, None).await;
// Node C knows about Node D
let mut node_C = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_D.to_peer())).await;
// Node B knows about Node C
let mut node_B = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_C.to_peer())).await;
// Node A knows about Node B and C
let mut node_A = make_node(PeerFeatures::COMMUNICATION_NODE, Some(node_B.to_peer())).await;
node_A.comms.peer_manager().add_peer(node_C.to_peer()).await.unwrap();
log::info!(
"NodeA = {}, NodeB = {}, Node C = {}, Node D = {}",
node_A.node_identity().node_id().short_str(),
node_B.node_identity().node_id().short_str(),
node_C.node_identity().node_id().short_str(),
node_D.node_identity().node_id().short_str(),
);
// Connect the peers that should be connected
async fn connect_nodes(node1: &mut TestNode, node2: &mut TestNode) {
node1
.comms
.connection_manager()
.dial_peer(node2.node_identity().node_id().clone())
.await
.unwrap();
}
// Pre-connect nodes, this helps message passing be more deterministic
connect_nodes(&mut node_A, &mut node_B).await;
connect_nodes(&mut node_A, &mut node_C).await;
connect_nodes(&mut node_B, &mut node_C).await;
connect_nodes(&mut node_C, &mut node_D).await;
let mut node_A_messaging = node_A.comms.subscribe_messaging_events();
let mut node_B_messaging = node_B.comms.subscribe_messaging_events();
let mut node_C_messaging = node_C.comms.subscribe_messaging_events();
let mut node_D_messaging = node_D.comms.subscribe_messaging_events();
#[derive(Clone, PartialEq, ::prost::Message)]
struct Person {
#[prost(string, tag = "1")]
name: String,
#[prost(uint32, tag = "2")]
age: u32,
}
let out_msg = OutboundDomainMessage::new(123, Person {
name: "John Conway".into(),
age: 82,
});
node_A
.dht
.outbound_requester()
.propagate(
// Node D is a client node, so an destination is required for domain messages
NodeDestination::Unknown, // NodeId(Box::new(node_D.node_identity().node_id().clone())),
OutboundEncryption::EncryptFor(Box::new(node_D.node_identity().public_key().clone())),
vec![],
out_msg,
)
.await
.unwrap();
let msg = node_D
.next_inbound_message(Duration::from_secs(10))
.await
.expect("Node D expected an inbound message but it never arrived");
assert!(msg.decryption_succeeded());
let person = msg
.decryption_result
.unwrap()
.decode_part::<Person>(1)
.unwrap()
.unwrap();
assert_eq!(person.name, "John Conway");
let node_A_id = node_A.node_identity().node_id().clone();
let node_B_id = node_B.node_identity().node_id().clone();
let node_C_id = node_C.node_identity().node_id().clone();
let node_D_id = node_D.node_identity().node_id().clone();
node_A.comms.shutdown().await;
node_B.comms.shutdown().await;
node_C.comms.shutdown().await;
node_D.comms.shutdown().await;
// Check the message flow BEFORE deduping
let (sent, received) = partition_events(collect_stream!(node_A_messaging, timeout = Duration::from_secs(20)));
assert_eq!(sent.len(), 2);
// Expected race condition: If A->(B|C)->(C|B) before A->(C|B) then (C|B)->A
if received.len() > 0 {
assert_eq!(count_messages_received(&received, &[&node_B_id, &node_C_id]), 1);
}
let (sent, received) = partition_events(collect_stream!(node_B_messaging, timeout = Duration::from_secs(20)));
assert_eq!(sent.len(), 1);
let recv_count = count_messages_received(&received, &[&node_A_id, &node_C_id]);
// Expected race condition: If A->B->C before A->C then C->B does not happen
assert!(recv_count >= 1 && recv_count <= 2);
let (sent, received) = partition_events(collect_stream!(node_C_messaging, timeout = Duration::from_secs(20)));
let recv_count = count_messages_received(&received, &[&node_A_id, &node_B_id]);
assert_eq!(recv_count, 2);
assert_eq!(sent.len(), 2);
assert_eq!(count_messages_received(&received, &[&node_D_id]), 0);
let (sent, received) = partition_events(collect_stream!(node_D_messaging, timeout = Duration::from_secs(20)));
assert_eq!(sent.len(), 0);
assert_eq!(received.len(), 1);
assert_eq!(count_messages_received(&received, &[&node_C_id]), 1);
}
fn partition_events(
events: Vec<Result<Arc<MessagingEvent>, tokio::sync::broadcast::RecvError>>,
) -> (Vec<Arc<MessagingEvent>>, Vec<Arc<MessagingEvent>>) {
events.into_iter().map(Result::unwrap).partition(|e| match &**e {
MessagingEvent::MessageReceived(_, _) => false,
MessagingEvent::MessageSent(_) => true,
_ => unreachable!(),
})
}
fn count_messages_received(events: &[Arc<MessagingEvent>], node_ids: &[&NodeId]) -> usize {
events
.into_iter()
.filter(|event| {
unpack_enum!(MessagingEvent::MessageReceived(recv_node_id, _tag) = &***event);
node_ids.into_iter().any(|n| &**recv_node_id == *n)
})
.count()
}
|
//! WPPR
// Copyright 2018 Otto Rask
//
// 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.
extern crate wppr;
use std::process::exit;
use wppr::run;
fn main() {
let status: i32 = run();
exit(status);
}
|
extern crate fixedbitset;
extern crate slab;
extern crate smallvec;
extern crate vec_drain_where;
#[macro_use]
extern crate log;
use std::fmt::Debug;
pub trait ActionConfiguration: 'static {
type Target: Clone + PartialEq + Debug;
type KeyKind: Clone + PartialEq + Ord + Debug;
type CursorPos: Clone + PartialEq;
type Command: Clone;
}
mod context;
mod execution;
mod recipe;
pub use context::*;
pub use recipe::*;
/*
enum TargetOrFilter<T> {
Target(T),
TargetFilter(Box<Fn(T) -> bool>),
}
pub struct ActionRecipeBuilder<'a, T: ActionConfiguration> {
context: &'a mut ActionContext<T>,
conditions: Vec<ActionRecipeCondition<T>>,
}
pub impl ActionContext<C> where C: ActionConfiguration {
pub fn add_action_recipe(&mut self) -> ActionRecipeBuilder<T> {
ActionRecipeBuilder {
context: self,
conditions: vec![],
}
}
impl<'a> ActionRecipeBuilder<'a, T> {
pub fn add_condition(&mut self, condition: ActionRecipeCondition<T>) {
self.conditions.push(condition);
}
pub fn with_target(&mut self, target: T) -> &mut Self
where T: PartialEq
{
self.target = Some(TargetOrFilter::Target(target));
self
}
pub fn with_target_filter<F>(target_filter: F) -> &mut Self
where F: Fn(T) -> bool
{
self.target = Some(TargetOrFilter::TargetFilter(Box::new(target_filter) as _));
self
}
}
impl<'a> ActionRecipeBuilder<'a, T> where T: KeyStrokeActionConfiguration + CursorActionConfiguration{
pub fn trigger_by_left_button_click(&mut self) -> &mut Self {
}
pub fn trigger_by_right_button_down(&mut self) -> &mut Self {
}
pub fn trigger_by_left_and_right_button_click(&mut self) -> &mut Self {
}
}
pub trait TargetResolver {
type Target;
fn resolve_target(&self, point: Point) -> Self::Target;
}
*/
|
// 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 {
bitflags::bitflags,
byteorder::NativeEndian,
fuchsia_async as fasync,
fuchsia_syslog::fx_log_info,
fuchsia_zircon::{self as zx, sys},
num_derive::FromPrimitive,
num_traits::FromPrimitive,
std::{convert::TryFrom, mem, sync::Arc},
zerocopy::{
byteorder::{U16, U32},
AsBytes, FromBytes, LayoutVerified, Unaligned,
},
};
use crate::types::{
AudioCommandHeader, AudioSampleFormat, AudioStreamFormatRange, ChannelResponder, Decodable,
Error, ResponseDirectable, Result,
};
const AUDIO_CMD_HEADER_LEN: usize = mem::size_of::<AudioCommandHeader>();
const GET_FORMATS_MAX_RANGES_PER_RESPONSE: usize = 15;
#[repr(C)]
#[derive(Default, AsBytes)]
struct GetFormatsResponse {
pad: u32,
format_range_count: u16,
first_format_range_index: u16,
format_ranges: [AudioStreamFormatRange; GET_FORMATS_MAX_RANGES_PER_RESPONSE],
}
#[repr(C)]
#[derive(FromBytes, Unaligned)]
struct SetFormatRequest {
frames_per_second: U32<NativeEndian>,
sample_format: U32<NativeEndian>,
channels: U16<NativeEndian>,
}
#[repr(C)]
#[derive(AsBytes)]
struct SetFormatResponse {
status: sys::zx_status_t,
pad: u32,
external_delay_nsec: u64,
}
#[repr(C)]
#[derive(AsBytes)]
struct GetGainResponse {
cur_mute: bool,
cur_agc: bool,
pad1: u16,
cur_gain: f32,
can_mute: bool,
can_agc: bool,
pad2: u16,
min_gain: f32,
max_gain: f32,
gain_step: f32,
}
bitflags! {
#[repr(transparent)]
#[derive(FromBytes)]
struct SetGainFlags: u32 {
const MUTE_VALID = 0x0000_0001;
const AGC_VALID = 0x0000_0002;
const GAIN_VALID = 0x0000_0004;
const MUTE = 0x4000_0000;
const AGC = 0x8000_0000;
}
}
#[repr(C)]
#[derive(FromBytes)]
struct SetGainRequest {
flags: SetGainFlags,
gain: f32,
}
#[repr(C)]
#[derive(AsBytes)]
struct SetGainResponse {
result: sys::zx_status_t,
cur_mute: bool,
cur_agc: bool,
pad: u16,
cur_gain: f32,
}
bitflags! {
#[repr(transparent)]
struct PlugDetectFlags: u32 {
const ENABLE_NOTIFICATIONS = 0x4000_0000;
const DISABLE_NOTIFICATIONS = 0x8000_0000;
}
}
bitflags! {
#[repr(transparent)]
#[derive(AsBytes)]
struct PlugDetectNotifyFlags: u32 {
const HARDWIRED = 0x0000_0001;
const CAN_NOTIFY = 0x0000_0002;
const PLUGGED = 0x8000_0000;
}
}
#[repr(C)]
#[derive(AsBytes)]
struct PlugDetectResponse {
flags: PlugDetectNotifyFlags,
pad: u32,
plug_state_time: sys::zx_time_t,
}
#[allow(dead_code)]
type GetUniqueIdResponse = [u8; 16];
type GetStringRequest = U32<NativeEndian>;
#[repr(C)]
#[derive(AsBytes)]
struct GetStringResponse {
status: sys::zx_status_t,
id: u32,
string_len: u32,
string: [u8; 256 - AUDIO_CMD_HEADER_LEN - mem::size_of::<u32>() * 3],
}
impl GetStringResponse {
fn build(id: StringId, s: &String) -> GetStringResponse {
const MAX_STRING_LEN: usize = 256 - AUDIO_CMD_HEADER_LEN - mem::size_of::<u32>() * 3;
let mut r = GetStringResponse {
status: sys::ZX_OK,
id: id as u32,
string_len: s.len() as u32,
string: [0; MAX_STRING_LEN],
};
let bytes = s.clone().into_bytes();
if bytes.len() > MAX_STRING_LEN {
r.string.copy_from_slice(&bytes[0..MAX_STRING_LEN]);
r.string_len = MAX_STRING_LEN as u32;
} else {
r.string[0..bytes.len()].copy_from_slice(&bytes);
}
r
}
}
#[derive(Clone, PartialEq, FromPrimitive, Debug)]
pub(crate) enum StringId {
Manufacturer = 0x8000_0000,
Product = 0x8000_0001,
}
impl TryFrom<u32> for StringId {
type Error = Error;
fn try_from(value: u32) -> Result<Self> {
StringId::from_u32(value).ok_or(Error::OutOfRange)
}
}
#[derive(Clone, FromPrimitive, Debug)]
pub(crate) enum CommandType {
GetFormats = 0x1000,
SetFormat = 0x1001,
GetGain = 0x1002,
SetGain = 0x1003,
PlugDetect = 0x1004,
GetUniqueId = 0x1005,
GetString = 0x1006,
}
const COMMAND_NO_ACK: &u32 = &0x8000_0000;
impl TryFrom<u32> for CommandType {
type Error = Error;
fn try_from(value: u32) -> Result<Self> {
CommandType::from_u32(value).ok_or(Error::OutOfRange)
}
}
impl From<CommandType> for u32 {
fn from(v: CommandType) -> u32 {
v as u32
}
}
#[derive(Debug)]
pub(crate) enum Request {
GetFormats {
responder: GetFormatsResponder,
},
SetFormat {
frames_per_second: u32,
sample_format: AudioSampleFormat,
channels: u16,
responder: SetFormatResponder,
},
GetGain {
responder: GetGainResponder,
},
SetGain {
mute: Option<bool>,
agc: Option<bool>,
gain: Option<f32>,
responder: SetGainResponder,
},
PlugDetect {
notifications: bool,
responder: PlugDetectResponder,
},
GetUniqueId {
responder: GetUniqueIdResponder,
},
GetString {
id: StringId,
responder: GetStringResponder,
},
}
impl Decodable for Request {
fn decode(bytes: &[u8]) -> Result<Request> {
let (header, rest) =
LayoutVerified::<_, AudioCommandHeader>::new_unaligned_from_prefix(bytes)
.ok_or(Error::Encoding)?;
let ack = (header.command_type.get() & COMMAND_NO_ACK) == 0;
let cmd_type = CommandType::try_from(header.command_type.get() & !COMMAND_NO_ACK)?;
let chan_responder = ChannelResponder::build(header.transaction_id.get(), &cmd_type);
let res = match cmd_type {
CommandType::GetFormats => {
Request::GetFormats { responder: GetFormatsResponder(chan_responder) }
}
CommandType::SetFormat => {
let (request, rest) =
LayoutVerified::<_, SetFormatRequest>::new_unaligned_from_prefix(rest)
.ok_or(Error::Encoding)?;
if rest.len() > 0 {
fx_log_info!("{} extra bytes decoding SetFormatRequest, ignoring", rest.len());
}
Request::SetFormat {
responder: SetFormatResponder(chan_responder),
frames_per_second: request.frames_per_second.get(),
sample_format: AudioSampleFormat::try_from(request.sample_format.get())?,
channels: request.channels.get(),
}
}
CommandType::GetGain => {
Request::GetGain { responder: GetGainResponder(chan_responder) }
}
CommandType::SetGain => {
let request =
LayoutVerified::<_, SetGainRequest>::new(rest).ok_or(Error::Encoding)?;
Request::SetGain {
mute: if request.flags.contains(SetGainFlags::MUTE_VALID) {
Some(request.flags.contains(SetGainFlags::MUTE))
} else {
None
},
agc: if request.flags.contains(SetGainFlags::AGC_VALID) {
Some(request.flags.contains(SetGainFlags::AGC))
} else {
None
},
gain: if request.flags.contains(SetGainFlags::GAIN_VALID) {
Some(request.gain)
} else {
None
},
responder: SetGainResponder { inner: chan_responder, ack },
}
}
CommandType::PlugDetect => {
let flags_u32 =
LayoutVerified::<_, U32<NativeEndian>>::new(rest).ok_or(Error::Encoding)?;
let request =
PlugDetectFlags::from_bits(flags_u32.get()).ok_or(Error::OutOfRange)?;
Request::PlugDetect {
notifications: request.contains(PlugDetectFlags::ENABLE_NOTIFICATIONS),
responder: PlugDetectResponder { inner: chan_responder, ack },
}
}
CommandType::GetUniqueId => {
Request::GetUniqueId { responder: GetUniqueIdResponder(chan_responder) }
}
CommandType::GetString => {
let request =
LayoutVerified::<_, GetStringRequest>::new(rest).ok_or(Error::Encoding)?;
let id = StringId::try_from(request.get())?;
Request::GetString {
id: id.clone(),
responder: GetStringResponder { inner: chan_responder, id },
}
}
};
Ok(res)
}
}
impl ResponseDirectable for Request {
fn set_response_channel(&mut self, channel: Arc<fasync::Channel>) {
match self {
Request::GetFormats { responder } => responder.0.set_channel(channel),
Request::SetFormat { responder, .. } => responder.0.set_channel(channel),
Request::GetGain { responder } => responder.0.set_channel(channel),
Request::SetGain { responder, .. } => responder.inner.set_channel(channel),
Request::PlugDetect { responder, .. } => responder.inner.set_channel(channel),
Request::GetUniqueId { responder } => responder.0.set_channel(channel),
Request::GetString { responder, .. } => responder.inner.set_channel(channel),
}
}
}
#[derive(Debug)]
pub(crate) struct GetFormatsResponder(ChannelResponder);
impl GetFormatsResponder {
pub fn reply(self, supported_formats: &[AudioStreamFormatRange]) -> Result<()> {
// TODO: Merge any format ranges that are compatible?
let total_formats = supported_formats.len();
for (chunk_idx, ranges) in
supported_formats.chunks(GET_FORMATS_MAX_RANGES_PER_RESPONSE).enumerate()
{
let first_index = chunk_idx * GET_FORMATS_MAX_RANGES_PER_RESPONSE;
let mut resp = GetFormatsResponse {
format_range_count: total_formats as u16,
first_format_range_index: first_index as u16,
..Default::default()
};
resp.format_ranges[0..ranges.len()].clone_from_slice(ranges);
self.0.send(&resp.as_bytes())?;
}
Ok(())
}
}
#[derive(Debug)]
pub(crate) struct SetFormatResponder(ChannelResponder);
impl SetFormatResponder {
pub fn reply(
self,
status: zx::Status,
external_delay_nsec: u64,
rb_channel: Option<zx::Channel>,
) -> Result<()> {
let resp = SetFormatResponse { status: status.into_raw(), external_delay_nsec, pad: 0 };
let handles: Vec<zx::Handle> = rb_channel.into_iter().map(Into::into).collect();
self.0.send_with_handles(&resp.as_bytes(), handles)
}
}
#[derive(Debug)]
pub(crate) struct GetGainResponder(ChannelResponder);
impl GetGainResponder {
pub fn reply(
self,
mute: Option<bool>,
agc: Option<bool>,
gain: f32,
gain_range: [f32; 2],
gain_step: f32,
) -> Result<()> {
let resp = GetGainResponse {
can_mute: mute.is_some(),
cur_mute: mute.unwrap_or(false),
can_agc: agc.is_some(),
cur_agc: agc.unwrap_or(false),
cur_gain: gain,
min_gain: gain_range[0],
max_gain: gain_range[1],
gain_step,
pad1: 0,
pad2: 0,
};
self.0.send(&resp.as_bytes())
}
}
#[derive(Debug)]
pub(crate) struct SetGainResponder {
inner: ChannelResponder,
ack: bool,
}
impl SetGainResponder {
#[allow(dead_code)]
pub fn reply(
self,
result: zx::Status,
cur_mute: bool,
cur_agc: bool,
cur_gain: f32,
) -> Result<()> {
if !self.ack {
return Ok(());
}
let resp =
SetGainResponse { result: result.into_raw(), cur_mute, cur_agc, cur_gain, pad: 0 };
self.inner.send(&resp.as_bytes())
}
}
#[derive(Debug)]
pub(crate) struct PlugDetectResponder {
inner: ChannelResponder,
ack: bool,
}
pub enum PlugState {
/// Hard wired output
Hardwired,
/// A Pluggable output:
/// - `can_notify` indicates if notificaitons can be sent
/// - `plugged` indicates whether the output is currently plugged in
#[allow(dead_code)] // TODO: implement a way to notify and indicate plugged state
Pluggable { can_notify: bool, plugged: bool },
}
impl From<PlugState> for PlugDetectNotifyFlags {
fn from(state: PlugState) -> Self {
match state {
PlugState::Hardwired => PlugDetectNotifyFlags::PLUGGED,
PlugState::Pluggable { can_notify, plugged } => {
let mut flags = PlugDetectNotifyFlags::empty();
if plugged {
flags.insert(PlugDetectNotifyFlags::PLUGGED)
}
if can_notify {
flags.insert(PlugDetectNotifyFlags::CAN_NOTIFY)
}
flags
}
}
}
}
impl PlugDetectResponder {
pub fn reply(self, plug_state: PlugState, time: zx::Time) -> Result<()> {
if !self.ack {
return Ok(());
}
let resp = PlugDetectResponse {
flags: plug_state.into(),
plug_state_time: time.into_nanos(),
pad: 0,
};
self.inner.send(&resp.as_bytes())
}
}
#[derive(Debug)]
pub(crate) struct GetUniqueIdResponder(ChannelResponder);
impl GetUniqueIdResponder {
pub fn reply(self, id: &[u8; 16]) -> Result<()> {
self.0.send(id)
}
}
#[derive(Debug)]
pub(crate) struct GetStringResponder {
id: StringId,
inner: ChannelResponder,
}
impl GetStringResponder {
pub fn reply(self, string: &String) -> Result<()> {
let resp = GetStringResponse::build(self.id, string);
self.inner.send(&resp.as_bytes())
}
}
#[cfg(test)]
mod tests {
use super::*;
use fidl_fuchsia_media::{AudioChannelId, AudioPcmMode, PcmFormat};
use fuchsia_async as fasync;
use fuchsia_zircon::{self as zx, AsHandleRef};
use std::convert::TryInto;
fn make_pcmformat(frames_per_second: u32) -> PcmFormat {
PcmFormat {
pcm_mode: AudioPcmMode::Linear,
bits_per_sample: 16,
frames_per_second,
channel_map: vec![AudioChannelId::Lf, AudioChannelId::Rf],
}
}
// Expects `len` bytes to be received on `channel`, with the first byte equaling `matching`
fn expect_channel_recv(channel: &zx::Channel, len: usize, matching: &[u8]) -> zx::MessageBuf {
let mut buf = zx::MessageBuf::new();
assert!(channel.read(&mut buf).is_ok());
let sent = buf.bytes();
assert_eq!(len, sent.len());
assert_eq!(matching, &sent[0..matching.len()]);
buf
}
fn setup_request_test() -> (fasync::Executor, zx::Channel, Arc<fasync::Channel>) {
let exec = fasync::Executor::new().expect("failed to create an executor");
let (remote, local) = zx::Channel::create().expect("can't make channels");
let chan = Arc::new(fasync::Channel::from_channel(local).unwrap());
(exec, remote, chan)
}
#[test]
fn get_formats() {
let (_, remote, chan) = setup_request_test();
// 16 formats for testing multiple result messages.
let ranges: Vec<AudioStreamFormatRange> = vec![
make_pcmformat(44100),
make_pcmformat(88200),
make_pcmformat(22050),
make_pcmformat(11025),
make_pcmformat(48000),
make_pcmformat(24000),
make_pcmformat(12000),
make_pcmformat(32000),
make_pcmformat(16000),
make_pcmformat(8000),
make_pcmformat(37800),
make_pcmformat(64000),
make_pcmformat(96000),
make_pcmformat(192000),
make_pcmformat(4000),
make_pcmformat(2000),
]
.into_iter()
.map(|x| x.try_into().unwrap())
.collect();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x00, 0x10, 0x00, 0x00, // get_formats
];
let response_size = mem::size_of::<(AudioCommandHeader, GetFormatsResponse)>();
let r = Request::decode(request);
if let Ok(Request::GetFormats { mut responder }) = r {
responder.0.set_channel(chan.clone());
assert!(responder.reply(&ranges[0..1]).is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x00, 0x10, 0x00, 0x00, // get_formats
0x00, 0x00, 0x00, 0x00, // pad
0x01, 0x00, // format_range_count
0x00, 0x00, // first_format_range_index
0x04, 0x00, 0x00, 0x00, // 0: sample_formats (16-bit PCM)
0x44, 0xAC, 0x00, 0x00, // 0: min_frames_per_second (44100)
0x44, 0xAC, 0x00, 0x00, // 0: max_frames_per_second (44100)
0x02, 0x02, // 0: min_channels, max_channels (2)
0x01, 0x00, // 0: flags (FPS_CONTINUOUS)
]; // rest of bytes are not mattering
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("expected GetFormats got {:?}", r);
}
let request: &[u8] = &[
0xFE, 0xED, 0x00, 0x00, // transaction id
0x00, 0x10, 0x00, 0x00, // get_formats
];
let r = Request::decode(request);
assert!(r.is_ok());
if let Request::GetFormats { mut responder } = r.unwrap() {
responder.0.set_channel(chan.clone());
assert!(responder.reply(&ranges).is_ok());
let expected_preamble: &[u8] = &[
0xFE, 0xED, 0x00, 0x00, // transaction_id
0x00, 0x10, 0x00, 0x00, // get_formats
0x00, 0x00, 0x00, 0x00, // pad
0x10, 0x00, // format_range_count - 16
0x00, 0x00, // first_format_range_index
]; // Rest is 15 of the formats
expect_channel_recv(&remote, response_size, expected_preamble);
let expected_preamble: &[u8] = &[
0xFE, 0xED, 0x00, 0x00, // transaction_id
0x00, 0x10, 0x00, 0x00, // get_formats
0x00, 0x00, 0x00, 0x00, // pad
0x10, 0x00, // format_range_count - 16
0x0F, 0x00, // first_format_range_index - 15
0x04, 0x00, 0x00, 0x00, // 15: sample_formats (16-bit PCM)
0xD0, 0x07, 0x00, 0x00, // 15: min_frames_per_second (2000)
0xD0, 0x07, 0x00, 0x00, // 15: max_frames_per_second (2000)
0x02, 0x02, // 15: min_channels, max_channels (2)
0x01, 0x00, // 15: flags (FPS_CONTINUOUS)
]; // Rest doesn't matter
expect_channel_recv(&remote, response_size, expected_preamble);
} else {
panic!("expected to decode to GetFormats");
}
}
#[test]
fn set_format() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x01, 0x10, 0x00, 0x00, // set_format
0x44, 0xAC, 0x00, 0x00, // frames_per_second (44100)
0x04, 0x00, 0x00, 0x00, // 16 bit PCM
0x02, 0x00, // channels: 2
];
let response_size = mem::size_of::<(AudioCommandHeader, SetFormatResponse)>();
let r = Request::decode(request);
assert!(r.is_ok(), "request didn't parse: {:?}", r);
if let Ok(Request::SetFormat {
frames_per_second,
sample_format,
channels,
mut responder,
}) = r
{
assert_eq!(44100, frames_per_second);
assert_eq!(
AudioSampleFormat::Sixteen { unsigned: false, invert_endian: false },
sample_format
);
assert_eq!(2, channels);
responder.0.set_channel(chan);
let (there, _) = zx::Channel::create().expect("can't make channels");
let handleid = &there.raw_handle();
// 27 is a random test value.
assert!(responder.reply(zx::Status::OK, 27, Some(there)).is_ok());
let expected_bytes: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x01, 0x10, 0x00, 0x00, // set_format
0x00, 0x00, 0x00, 0x00, // zx::status::ok
0x00, 0x00, 0x00, 0x00, // padding
27, 0x00, 0x00, 0x00, // 27 ns external delay
0x00, 0x00, 0x00, 0x00,
];
let mut mb = expect_channel_recv(&remote, response_size, expected_bytes);
assert_eq!(1, mb.n_handles());
assert_eq!(handleid, &(mb.take_handle(0).unwrap()).raw_handle());
} else {
panic!("expected to decode to SetFormat: {:?}", r);
}
}
#[test]
fn get_gain() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x02, 0x10, 0x00, 0x00, // get_gain
];
let response_size =
mem::size_of::<AudioCommandHeader>() + mem::size_of::<GetGainResponse>();
let r = Request::decode(request);
if let Ok(Request::GetGain { mut responder }) = r {
responder.0.set_channel(chan);
assert!(responder.reply(None, Some(false), -6.0, [-10.0, 0.0], 0.5).is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x02, 0x10, 0x00, 0x00, // get_gain
0x00, // cur_mute: false
0x00, // cur_agc: false
0x00, 0x00, // 2x padding bytes that I don't care about
0x00, 0x00, 0xc0, 0xc0, // -6.0 db current gain (in float 32-bit)
0x00, // can_mute: false
0x01, // can_agc: true
0x00, 0x00, // 2x padding bytes that I don't care about
0x00, 0x00, 0x20, 0xc1, // -10.00 min_gain
0x00, 0x00, 0x00, 0x00, // 0.0 max_gain
0x00, 0x00, 0x00, 0x3f, // 0.5 gain_step
];
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("decoding GetGain failed: {:?}", r);
}
}
#[test]
fn set_gain() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x03, 0x10, 0x00, 0x00, // set_gain
0x05, 0x00, 0x00, 0x00, // flags: mute valid + gain valid + no mute
0x00, 0x00, 0x20, 0xc1, // gain: -10.0
];
let response_size =
mem::size_of::<AudioCommandHeader>() + mem::size_of::<SetGainResponse>();
let r = Request::decode(request);
if let Ok(Request::SetGain { mute, agc, gain, mut responder }) = r {
assert_eq!(None, agc);
assert_eq!(Some(false), mute);
assert_eq!(Some(-10.0), gain);
responder.inner.set_channel(chan);
assert!(responder.reply(zx::Status::OK, false, false, -10.0).is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x03, 0x10, 0x00, 0x00, // set_gain
0x00, 0x00, 0x00, 0x00, // status::OK
0x00, // mute: false
0x00, // agc: false
0x00, 0x00, // padding bytes
0x00, 0x00, 0x20, 0xc1, // -10.0 db current gain (in float 32-bit)
];
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("decoding SetGain failed: {:?}", r);
}
}
#[test]
fn plug_detect() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x04, 0x10, 0x00, 0x00, // plug_detect
0x00, 0x00, 0x00, 0x40, // flags: enable notifications
];
let response_size =
mem::size_of::<AudioCommandHeader>() + mem::size_of::<PlugDetectResponse>();
let r = Request::decode(request);
if let Ok(Request::PlugDetect { notifications, mut responder }) = r {
assert_eq!(true, notifications);
responder.inner.set_channel(chan);
let state = PlugState::Pluggable { can_notify: false, plugged: true };
assert!(responder.reply(state, zx::Time::from_nanos(27)).is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x04, 0x10, 0x00, 0x00, // plug_detect
0x00, 0x00, 0x00, 0x80, // flags: can't notify + plugged
0x00, 0x00, 0x00, 0x00, // pad to align
27, 0x00, 0x00, 0x00, // plugged at 27 nanos
0x00, 0x00, 0x00, 0x00,
];
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("decoding PlugDetect failed: {:?}", r);
}
}
#[test]
fn get_unique_id() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x05, 0x10, 0x00, 0x00, // get_unique_id
];
let response_size = mem::size_of::<(AudioCommandHeader, GetUniqueIdResponse)>();
let r = Request::decode(request);
if let Ok(Request::GetUniqueId { mut responder }) = r {
responder.0.set_channel(chan);
assert!(responder
.reply(&[
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C,
0x0D, 0x0E, 0x0F
])
.is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x05, 0x10, 0x00, 0x00, // get_unique_id
0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D,
0x0E, 0x0F, // (same id as above)
];
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("decoding GetUniqueId failed: {:?}", r);
}
}
#[test]
fn get_string() {
let (_, remote, chan) = setup_request_test();
let request: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction id
0x06, 0x10, 0x00, 0x00, // get_string
0x01, 0x00, 0x00, 0x80, // string_id: product
];
let response_size = mem::size_of::<(AudioCommandHeader, GetStringResponse)>();
let r = Request::decode(request);
if let Ok(Request::GetString { id, mut responder }) = r {
assert_eq!(StringId::Product, id);
responder.inner.set_channel(chan);
assert!(responder.reply(&"Fuchsia💖".to_string()).is_ok());
let expected_response: &[u8] = &[
0xF0, 0x0D, 0x00, 0x00, // transaction_id
0x06, 0x10, 0x00, 0x00, // get_string_id
0x00, 0x00, 0x00, 0x00, // status: OK
0x01, 0x00, 0x00, 0x80, // string_id: product
0x0B, 0x00, 0x00, 0x00, // string_len: 11
0x46, 0x75, 0x63, 0x68, 0x73, 0x69, 0x61, 0xF0, 0x9F, 0x92,
0x96, // String: Fuchsia💖
];
expect_channel_recv(&remote, response_size, expected_response);
} else {
panic!("decoding GetString failed: {:?}", r);
}
}
}
|
use std::char;
use std::collections::BTreeMap;
use std::fs::{create_dir_all, File};
use std::io::{BufRead, BufWriter, Cursor, Write};
use std::path::Path;
#[cfg(test)]
use std::collections::BTreeSet;
#[cfg(test)]
use std::iter::FromIterator;
use crate::fst_generator;
use anyhow::{anyhow, bail, Context, Result};
use fst::MapBuilder;
#[derive(PartialEq, Debug)]
enum LineType {
None,
Simple,
BlockStart(u32),
BlockEnd(u32),
}
const NAME_ALIASES: &[u8] = include_bytes!("../data/unicode/NameAliases.txt");
const UNICODE_DATA: &[u8] = include_bytes!("../data/unicode/UnicodeData.txt");
pub(crate) fn name_aliases() -> Cursor<&'static [u8]> {
Cursor::new(NAME_ALIASES)
}
pub(crate) fn unicode_data() -> Cursor<&'static [u8]> {
Cursor::new(UNICODE_DATA)
}
fn process_line(names: &mut fst_generator::Names, line: &str) -> Result<LineType> {
if line.starts_with('#') || line.trim_start() == "" {
return Ok(LineType::None);
}
let fields: Vec<&str> = line.splitn(15, ';').collect();
let cp = u32::from_str_radix(fields[0], 16)
.with_context(|| format!("Could not parse {} as base-16 integer", fields[0]))?;
if let Some(ch) = char::from_u32(cp) {
let query = fields[1].to_owned();
if query.ends_with(", First>") {
return Ok(LineType::BlockStart(ch as u32));
} else if query.ends_with(", Last>") {
return Ok(LineType::BlockEnd(ch as u32));
}
names.insert(vec![query], ch);
match fields.get(10) {
Some(&"") | None => {}
Some(&name) => names.insert(vec![name.to_string()], ch),
}
Ok(LineType::Simple)
} else {
Ok(LineType::None)
}
}
#[test]
fn test_processing() {
{
let mut sorted_names = fst_generator::Names::new();
// Non-data gets skipped:
assert_eq!(
LineType::None,
process_line(&mut sorted_names, "# this is a comment").unwrap()
);
assert_eq!(LineType::None, process_line(&mut sorted_names, "").unwrap());
assert_eq!(
LineType::None,
process_line(&mut sorted_names, " ").unwrap()
);
}
{
let mut sorted_names = fst_generator::Names::new();
assert_eq!(
LineType::Simple,
process_line(
&mut sorted_names,
"03BB;GREEK SMALL LETTER LAMDA;Ll;0;L;;;;;N;GREEK SMALL LETTER LAMBDA;;039B;;039B"
)
.unwrap()
);
let have = BTreeSet::from_iter(sorted_names.iter().map(|(name, chs)| {
let v: Vec<char> = chs.iter().map(|ch| ch.to_owned()).collect();
(name.as_str(), v)
}));
let want = BTreeSet::from_iter(vec![
// Current unicode spelling:
("greek", vec!['\u{03bb}']),
("greek small letter lamda", vec!['\u{03bb}']),
("lamda", vec!['\u{03bb}']),
// Unicode 1.0 spelling:
("greek small letter lambda", vec!['\u{03bb}']),
("lambda", vec!['\u{03bb}']),
]);
assert_eq!(have, want);
}
{
let mut sorted_names = fst_generator::Names::new();
// Some from NameAliases.txt:
assert_eq!(
LineType::Simple,
process_line(&mut sorted_names, "0091;PRIVATE USE ONE;control").unwrap()
);
assert_eq!(
LineType::Simple,
process_line(&mut sorted_names, "0092;PRIVATE USE TWO;control").unwrap()
);
assert_eq!(
LineType::Simple,
process_line(&mut sorted_names, "0005;ENQUIRY;control").unwrap()
);
assert_eq!(
LineType::Simple,
process_line(&mut sorted_names, "200D;ZWJ;abbreviation").unwrap()
);
// And some from UnicodeData.txt:
assert_eq!(
LineType::Simple,
process_line(
&mut sorted_names,
"00AE;REGISTERED SIGN;So;0;ON;;;;;N;REGISTERED TRADE MARK SIGN;;;;"
)
.unwrap()
);
assert_eq!(
LineType::Simple,
process_line(
&mut sorted_names,
"0214;LATIN CAPITAL LETTER U WITH DOUBLE GRAVE;Lu;0;L;0055 \
030F;;;;N;;;;0215;e"
)
.unwrap()
);
// CJK blocks:
assert_eq!(
LineType::BlockStart(0x3400),
process_line(
&mut sorted_names,
"3400;<CJK Ideograph Extension A, First>;Lo;0;L;;;;;N;;;;;"
)
.unwrap()
);
assert_eq!(
LineType::BlockEnd(0x4DB5),
process_line(
&mut sorted_names,
"4DB5;<CJK Ideograph Extension A, Last>;Lo;0;L;;;;;N;;;;;"
)
.unwrap()
);
let have = BTreeSet::from_iter(sorted_names.iter().map(|(name, chs)| {
let v: Vec<char> = chs.iter().map(|ch| ch.to_owned()).collect();
(name.as_str(), v)
}));
let want = BTreeSet::from_iter(vec![
("capital", vec!['\u{0214}']),
("double", vec!['\u{0214}']),
("enquiry", vec!['\u{0005}']),
("grave", vec!['\u{0214}']),
("latin", vec!['\u{0214}']),
("latin capital letter u with double grave", vec!['\u{0214}']),
("one", vec!['\u{91}']),
("two", vec!['\u{92}']),
("private", vec!['\u{91}', '\u{92}']),
("use", vec!['\u{91}', '\u{92}']),
("private use one", vec!['\u{91}']),
("private use two", vec!['\u{92}']),
("registered", vec!['\u{AE}']),
("trade", vec!['\u{AE}']),
("mark", vec!['\u{AE}']),
("registered sign", vec!['\u{AE}']),
("registered trade mark sign", vec!['\u{AE}']),
// Skip the "U": it's too short to be meaningful
("zwj", vec!['\u{200D}']),
]);
assert_eq!(have, want);
}
}
#[test]
fn test_old_names() {}
pub fn read_names(names: &mut fst_generator::Names, reader: impl BufRead) -> Result<()> {
let mut lines = reader.lines();
while let Some(line) = lines.next() {
match process_line(names, line?.as_str())? {
LineType::Simple | LineType::None => {}
LineType::BlockStart(start) => {
let line = lines
.next()
.ok_or_else(|| anyhow!("Premature end of block from {:?}", start))?
.with_context(|| {
format!(
"Could not read the next line after block started at {:?}",
start
)
})?;
match process_line(names, &line)? {
LineType::BlockEnd(end) => {
for i in start..=end {
if let Some(ch) = char::from_u32(i as u32) {
if let Some(name) = unicode_names2::name(ch) {
names.insert(vec![name.to_string()], ch);
}
}
}
}
line => {
bail!(
"Encountered a weird line after block start from {:?}: {:?}",
start,
line
);
}
}
}
LineType::BlockEnd(end) => {
bail!("Encountered a block end without a start: {:?}", end);
}
}
}
Ok(())
}
pub fn write_name_data(names: &fst_generator::Names, output: &Path) -> Result<()> {
create_dir_all(output)?;
let fst_byte_filename = output.join("name_fst.bin");
let out = BufWriter::new(File::create(fst_byte_filename)?);
let mut map_builder = MapBuilder::new(out)?;
let mut counter: u64 = 0;
let mut results: BTreeMap<String, u64> = BTreeMap::new();
for (name, chs) in names.iter() {
if chs.len() > 1 {
let mut key = String::new();
for c in chs {
key.push(*c)
}
let num: u64 = (0xff << 32)
| *results.entry(key).or_insert_with(|| {
counter += 1;
counter - 1
});
map_builder
.insert(name, num)
.with_context(|| format!("Inserting character num {:?} under {:?}", num, name))?;
} else {
map_builder
.insert(name, *chs.iter().next().unwrap() as u64)
.with_context(|| format!("Inserting {:?} as {:?}", chs, name))?;
}
}
map_builder.finish()?;
// Now generate the multi-results file:
let multi_result_filename = output.join("names.rs");
let mut rust_out = BufWriter::new(
File::create(&multi_result_filename)
.context(format!("Creating {:?}", &multi_result_filename))?,
);
let mut ambiguous_chars: Vec<String> = vec![String::new(); counter as usize];
for (chars, i) in results {
ambiguous_chars[i as usize] = chars;
}
writeln!(&mut rust_out, "/// Generated with `make names`")?;
writeln!(&mut rust_out, "#[rustfmt::skip]")?;
writeln!(
&mut rust_out,
"pub static AMBIGUOUS_CHARS: &[&str; {}] = &[",
ambiguous_chars.len()
)?;
for chars in ambiguous_chars {
writeln!(&mut rust_out, " {:?},", chars)?;
}
writeln!(&mut rust_out, "];")?;
Ok(())
}
|
// Copyright (c) 2021 Quark Container Authors / 2018 The gVisor Authors.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use alloc::sync::Arc;
use alloc::vec::Vec;
use spin::Mutex;
use super::super::super::super::qlib::common::*;
use super::super::super::super::qlib::linux_def::*;
use super::super::super::super::qlib::addr::*;
use super::super::super::super::qlib::auth::*;
use super::super::super::fsutil::file::readonly_file::*;
use super::super::super::super::task::*;
use super::super::super::file::*;
use super::super::super::attr::*;
use super::super::super::super::threadmgr::thread::*;
use super::super::super::flags::*;
use super::super::super::dirent::*;
use super::super::super::mount::*;
use super::super::super::inode::*;
use super::super::super::fsutil::inode::simple_file_inode::*;
use super::super::inode::*;
#[derive(PartialEq, Eq, Copy, Clone)]
pub enum ExecArgType {
CmdlineExecArg,
EnvironExecArg,
}
pub fn NewExecArg(task: &Task, thread: &Thread, msrc: &Arc<Mutex<MountSource>>, typ: ExecArgType) -> Inode {
let v = NewExecArgSimpleFileInode(task, thread, &ROOT_OWNER, &FilePermissions::FromMode(FileMode(0o400)), FSMagic::PROC_SUPER_MAGIC, typ);
return NewProcInode(&Arc::new(v), msrc, InodeType::SpecialFile, Some(thread.clone()))
}
pub fn NewExecArgSimpleFileInode(task: &Task,
thread: &Thread,
owner: &FileOwner,
perms: &FilePermissions,
typ: u64,
execArgType: ExecArgType)
-> SimpleFileInode<ExecArgSimpleFileTrait> {
return SimpleFileInode::New(task, owner, perms, typ, false, ExecArgSimpleFileTrait{
typ: execArgType,
thread: thread.clone(),
})
}
pub struct ExecArgSimpleFileTrait {
pub typ: ExecArgType,
pub thread: Thread,
}
impl SimpleFileTrait for ExecArgSimpleFileTrait {
fn GetFile(&self, _task: &Task, _dir: &Inode, dirent: &Dirent, flags: FileFlags) -> Result<File> {
let fops = NewExecArgReadonlyFileNodeFileOperations(self.typ, &self.thread);
let file = File::New(dirent, &flags, fops);
return Ok(file);
}
}
pub fn NewExecArgReadonlyFileNodeFileOperations(typ: ExecArgType, thread: &Thread) -> ReadonlyFileOperations<ExecArgReadonlyFileNode> {
return ReadonlyFileOperations {
node: ExecArgReadonlyFileNode {
thread: thread.clone(),
typ: typ,
}
}
}
pub struct ExecArgReadonlyFileNode {
pub typ: ExecArgType,
pub thread: Thread,
}
impl ReadonlyFileNode for ExecArgReadonlyFileNode {
fn ReadAt(&self, task: &Task, _f: &File, dsts: &mut [IoVec], offset: i64, _blocking: bool) -> Result<i64> {
if offset < 0 {
return Err(Error::SysError(SysErr::EINVAL))
}
let mm = self.thread.lock().memoryMgr.clone();
let range = match self.typ {
ExecArgType::CmdlineExecArg => {
mm.metadata.lock().argv
}
ExecArgType::EnvironExecArg => {
mm.metadata.lock().envv
}
};
info!("ExecArgReadonlyFileNode range is {:x?}", &range);
if range.Start() == 0 || range.End() == 0 {
return Err(Error::SysError(SysErr::EINVAL))
}
let start = match Addr(range.Start()).AddLen(offset as u64) {
Err(_) => return Ok(0),
Ok(v) => v.0,
};
let end = range.End();
if start >= end {
return Ok(0)
}
let mut length = end - start;
if length > IoVec::NumBytes(dsts) as u64{
length = IoVec::NumBytes(dsts) as u64;
}
let data : Vec<u8> = task.CopyInVec(start, length as usize)?;
let mut buf = &data[..];
// On Linux, if the NUL byte at the end of the argument vector has been
// overwritten, it continues reading the environment vector as part of
// the argument vector.
if self.typ == ExecArgType::CmdlineExecArg && buf[buf.len() - 1] != 0 {
let mut copyN = buf.len();
for i in 0..buf.len() {
if buf[i] == 0 {
copyN = i;
break;
}
}
if copyN < buf.len() {
buf = &buf[..copyN]
} else {
let envv = mm.metadata.lock().envv;
let mut lengthEnvv = envv.Len() as usize;
if lengthEnvv > MemoryDef::PAGE_SIZE as usize - buf.len() {
lengthEnvv = MemoryDef::PAGE_SIZE as usize - buf.len();
}
let envvData = task.CopyInVec(envv.Start(), lengthEnvv as usize)?;
let mut copyNE = envvData.len();
for i in 0..envvData.len() {
if envvData[i] == 0{
copyNE = i;
break;
}
}
let mut ret = Vec::with_capacity(buf.len() + copyNE);
for b in buf {
ret.push(*b)
}
for b in &envvData[..copyNE] {
ret.push(*b)
}
buf = &ret[..];
let n = task.CopyDataOutToIovs(buf, dsts)?;
return Ok(n as i64)
}
}
let n = task.CopyDataOutToIovs(buf, dsts)?;
return Ok(n as i64)
}
}
|
#[doc = "Reader of register MISR"]
pub type R = crate::R<u32, super::MISR>;
#[doc = "Reader of field `ALRAMF`"]
pub type ALRAMF_R = crate::R<bool, bool>;
#[doc = "Reader of field `ALRBMF`"]
pub type ALRBMF_R = crate::R<bool, bool>;
#[doc = "Reader of field `WUTMF`"]
pub type WUTMF_R = crate::R<bool, bool>;
#[doc = "Reader of field `TSMF`"]
pub type TSMF_R = crate::R<bool, bool>;
#[doc = "Reader of field `TSOVMF`"]
pub type TSOVMF_R = crate::R<bool, bool>;
#[doc = "Reader of field `ITSMF`"]
pub type ITSMF_R = crate::R<bool, bool>;
impl R {
#[doc = "Bit 0 - ALRAMF"]
#[inline(always)]
pub fn alramf(&self) -> ALRAMF_R {
ALRAMF_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - ALRBMF"]
#[inline(always)]
pub fn alrbmf(&self) -> ALRBMF_R {
ALRBMF_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - WUTMF"]
#[inline(always)]
pub fn wutmf(&self) -> WUTMF_R {
WUTMF_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 3 - TSMF"]
#[inline(always)]
pub fn tsmf(&self) -> TSMF_R {
TSMF_R::new(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 4 - TSOVMF"]
#[inline(always)]
pub fn tsovmf(&self) -> TSOVMF_R {
TSOVMF_R::new(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 5 - ITSMF"]
#[inline(always)]
pub fn itsmf(&self) -> ITSMF_R {
ITSMF_R::new(((self.bits >> 5) & 0x01) != 0)
}
}
|
// Copyright (c) Calibra Research
// SPDX-License-Identifier: Apache-2.0
use super::*;
use simulated_context::SimulatedContext;
use smr_context::*;
struct SharedRecordStore {
store: RecordStoreState,
contexts: HashMap<Author, SimulatedContext>,
}
impl SharedRecordStore {
fn new(num_nodes: usize, epoch_ttl: usize) -> Self {
let epoch_id = EpochId(0);
let initial_hash = QuorumCertificateHash(0);
let mut contexts = HashMap::new();
for i in 0..num_nodes {
contexts.insert(
Author(i),
SimulatedContext::new(Author(i), num_nodes, epoch_ttl),
);
}
let state = contexts
.get(&Author(0))
.unwrap()
.last_committed_state()
.clone();
SharedRecordStore {
store: RecordStoreState::new(
initial_hash,
state.clone(),
epoch_id,
contexts.get(&Author(0)).unwrap().configuration(&state),
),
contexts,
}
}
fn create_timeout(&mut self, author_id: usize, round: Round) {
let author = Author(author_id);
self.store
.create_timeout(author, round, self.contexts.get_mut(&author).unwrap())
}
fn propose_block(
&mut self,
author_id: usize,
previous_qc_hash: QuorumCertificateHash,
clock: NodeTime,
) {
let author = Author(author_id);
self.store.propose_block(
author,
previous_qc_hash,
clock,
self.contexts.get_mut(&author).unwrap(),
);
}
fn create_vote(&mut self, author_id: usize, block_hash: BlockHash) -> bool {
let author = Author(author_id);
self.store
.create_vote(author, block_hash, self.contexts.get_mut(&author).unwrap())
}
fn check_for_new_quorum_certificate(&mut self) -> bool {
let author = self.leader(self.store.current_round());
self.store
.check_for_new_quorum_certificate(author, self.contexts.get_mut(&author).unwrap())
}
fn leader(&self, round: Round) -> Author {
PacemakerState::leader(&self.store, round)
}
fn make_round(&mut self, clock: NodeTime) {
let author = self.leader(self.store.current_round());
let previous_qc_hash = self.store.highest_quorum_certificate_hash();
self.store.propose_block(
author,
previous_qc_hash,
clock,
self.contexts.get_mut(&author).unwrap(),
);
let proposed_hash = self.store.current_proposed_block.unwrap();
let threshold = self
.contexts
.get(&Author(0))
.unwrap()
.configuration(&self.store.initial_state)
.quorum_threshold();
for i in 0..threshold {
assert!(self.create_vote(i, proposed_hash));
}
assert!(self.check_for_new_quorum_certificate());
}
fn make_tc(&mut self) {
let threshold = self
.contexts
.get(&Author(0))
.unwrap()
.configuration(&self.store.initial_state)
.quorum_threshold();
let round = self.store.current_round();
for i in 0..threshold {
self.create_timeout(i, round);
}
}
}
#[test]
fn test_initial_store() {
let shared_store = SharedRecordStore::new(2, 20);
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 0);
assert_eq!(store.quorum_certificates.len(), 0);
assert_eq!(
store.highest_quorum_certificate_hash(),
QuorumCertificateHash(0)
);
assert_eq!(store.highest_quorum_certificate_round(), Round(0));
assert_eq!(store.highest_timeout_certificate_round(), Round(0));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(1));
assert_eq!(store.current_timeouts.len(), 0);
}
#[test]
fn test_propose_and_vote_no_qc() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.propose_block(0, QuorumCertificateHash(0), NodeTime(1));
shared_store.propose_block(1, QuorumCertificateHash(0), NodeTime(2));
let block_hashes: Vec<_> = shared_store.store.blocks.keys().cloned().collect();
assert!(shared_store.create_vote(0, block_hashes[0]));
assert!(shared_store.create_vote(0, block_hashes[0]));
assert!(shared_store.create_vote(1, block_hashes[1]));
assert!(!shared_store.check_for_new_quorum_certificate());
// We should count only one vote per author, hence no QC.
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 2);
assert_eq!(store.quorum_certificates.len(), 0);
assert_eq!(
store.highest_quorum_certificate_hash(),
QuorumCertificateHash(0)
);
assert_eq!(store.highest_quorum_certificate_round(), Round(0));
assert_eq!(store.highest_timeout_certificate_round(), Round(0));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(1));
assert_eq!(store.current_timeouts.len(), 0);
}
#[test]
fn test_vote_with_quorum() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.propose_block(0, QuorumCertificateHash(0), NodeTime(1));
shared_store.propose_block(1, QuorumCertificateHash(0), NodeTime(2));
let proposed_hash = shared_store.store.current_proposed_block.unwrap();
assert!(shared_store.create_vote(0, proposed_hash));
assert!(shared_store.create_vote(1, proposed_hash));
assert!(shared_store.check_for_new_quorum_certificate());
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 2);
assert_eq!(store.quorum_certificates.len(), 1);
assert_eq!(store.highest_quorum_certificate_round(), Round(1));
assert_eq!(store.highest_timeout_certificate_round(), Round(0));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(2));
assert_eq!(store.current_timeouts.len(), 0);
}
#[test]
fn test_timeouts_no_tc() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.propose_block(1, QuorumCertificateHash(0), NodeTime(2));
shared_store.create_timeout(0, Round(1));
shared_store.create_timeout(0, Round(1));
shared_store.create_timeout(1, Round(0));
// We should count only one timeout per author, at the current round, hence no TC.
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 1);
assert_eq!(store.quorum_certificates.len(), 0);
assert_eq!(
store.highest_quorum_certificate_hash(),
QuorumCertificateHash(0)
);
assert_eq!(store.highest_quorum_certificate_round(), Round(0));
assert_eq!(store.highest_timeout_certificate_round(), Round(0));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(1));
assert_eq!(store.current_timeouts.len(), 1);
}
#[test]
fn test_timeouts_with_tc() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.propose_block(1, QuorumCertificateHash(0), NodeTime(2));
shared_store.create_timeout(1, Round(0)); // should be ignored
shared_store.create_timeout(0, Round(1));
shared_store.create_timeout(1, Round(1)); // complete TC
shared_store.create_timeout(1, Round(2)); // single timeout
{
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 1);
assert_eq!(store.quorum_certificates.len(), 0);
assert_eq!(
store.highest_quorum_certificate_hash(),
QuorumCertificateHash(0)
);
assert_eq!(store.highest_quorum_certificate_round(), Round(0));
assert_eq!(store.highest_timeout_certificate_round(), Round(1));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(2));
assert_eq!(store.current_timeouts.len(), 1);
}
shared_store.create_timeout(0, Round(2)); // complete TC
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 1);
assert_eq!(store.highest_timeout_certificate_round(), Round(2));
assert_eq!(store.current_round(), Round(3));
assert_eq!(store.current_timeouts.len(), 0);
}
#[test]
fn test_non_contiguous_qcs() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.make_round(NodeTime(10));
shared_store.make_round(NodeTime(20));
shared_store.make_tc();
shared_store.make_round(NodeTime(40));
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 3);
assert_eq!(store.quorum_certificates.len(), 3);
assert_eq!(store.highest_quorum_certificate_round(), Round(4));
assert_eq!(store.highest_timeout_certificate_round(), Round(3));
assert_eq!(store.highest_committed_round(), Round(0));
assert_eq!(store.current_round(), Round(5));
assert_eq!(store.current_timeouts.len(), 0);
}
#[test]
fn test_commit() {
let mut shared_store = SharedRecordStore::new(2, 20);
shared_store.make_round(NodeTime(10));
shared_store.make_tc();
shared_store.make_round(NodeTime(30));
shared_store.make_round(NodeTime(40));
shared_store.make_round(NodeTime(50));
shared_store.make_tc();
let store = &shared_store.store;
assert_eq!(store.blocks.len(), 4);
assert_eq!(store.quorum_certificates.len(), 4);
assert_eq!(store.highest_quorum_certificate_round(), Round(5));
assert_eq!(store.highest_timeout_certificate_round(), Round(6));
assert_eq!(store.highest_committed_round(), Round(3));
assert_eq!(store.current_round(), Round(7));
assert_eq!(store.current_timeouts.len(), 0);
assert_eq!(store.highest_commit_certificate().unwrap().round, Round(5));
assert_eq!(
store.previous_round(
store
.highest_commit_certificate()
.unwrap()
.certified_block_hash
),
Round(4)
);
assert_eq!(
store.second_previous_round(
store
.highest_commit_certificate()
.unwrap()
.certified_block_hash
),
Round(3)
);
let commits = store.committed_states_after(Round(0));
assert_eq!(commits.len(), 2);
assert_eq!(commits[0].0, Round(1));
assert_eq!(commits[1].0, Round(3));
assert_eq!(
Some(&commits[1].1),
store
.highest_commit_certificate()
.unwrap()
.committed_state
.as_ref()
);
}
|
// Copyright 2021 Datafuse Labs.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use common_base::base::tokio::io::AsyncWrite;
use common_exception::ErrorCode;
use common_exception::Result;
use opensrv_mysql::*;
use tracing::error;
pub struct DFInitResultWriter<'a, W: AsyncWrite + Send + Unpin> {
inner: Option<InitWriter<'a, W>>,
}
impl<'a, W: AsyncWrite + Send + Unpin> DFInitResultWriter<'a, W> {
pub fn create(inner: InitWriter<'a, W>) -> DFInitResultWriter<'a, W> {
DFInitResultWriter::<'a, W> { inner: Some(inner) }
}
pub async fn write(&mut self, query_result: Result<()>) -> Result<()> {
if let Some(writer) = self.inner.take() {
match query_result {
Ok(_) => Self::ok(writer).await?,
Err(error) => Self::err(&error, writer).await?,
}
}
Ok(())
}
async fn ok(writer: InitWriter<'a, W>) -> Result<()> {
writer.ok().await?;
Ok(())
}
async fn err(error: &ErrorCode, writer: InitWriter<'a, W>) -> Result<()> {
error!("OnInit Error: {:?}", error);
writer
.error(ErrorKind::ER_UNKNOWN_ERROR, error.to_string().as_bytes())
.await?;
Ok(())
}
}
|
use cow::Move;
pub trait Mover {
fn new(loc: usize, id: usize) -> Self;
fn compute_move(&mut self, neighborhood: ([bool; 8], [bool; 8]));
fn get_move(&self) -> Move;
fn loc(&self) -> usize;
fn set_loc(&mut self, loc: usize);
fn score(&self) -> usize;
fn inc_score(&mut self);
fn reset_score(&mut self);
fn id(&self) -> usize;
}
|
#[macro_use]
extern crate conrod;
extern crate glutin;
#[macro_use]
extern crate gfx;
extern crate gfx_core;
extern crate gfx_window_glutin;
extern crate genmesh;
extern crate noise;
extern crate rand;
extern crate obj;
#[macro_use]
extern crate lazy_static;
extern crate find_folder;
#[macro_use]
extern crate log;
extern crate approx; // relative_eq!
extern crate nalgebra as na;
extern crate alewife;
extern crate image;
mod core;
// mod input;
mod rendering;
mod support;
mod ui;
fn main() {
use core::core::core::init;
init();
}
|
//! Imports from `std` that would be polyfilled for `no_std` builds (see `src/polyfill/no_std`).
//!
//! This implementation is used when `std` is available and just imports the necessary items from
//! `std`. For `no_std` builds, the file `src/polyfill/no_std` is used instead, which doesn't
//! depend on the standard library.
#[cfg(not(windows))]
pub mod io {
pub use std::io::{IoSlice, IoSliceMut};
}
#[cfg(not(any(target_os = "redox", target_os = "wasi")))]
#[cfg(feature = "net")]
pub mod net {
pub use std::net::{IpAddr, Ipv4Addr, Ipv6Addr, SocketAddr, SocketAddrV4, SocketAddrV6};
}
pub mod os {
pub mod fd {
// Change to use `std::os::fd` when MSRV becomes 1.66 or higher.
#[cfg(unix)]
pub use std::os::unix::io::{
AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd,
};
#[cfg(target_os = "wasi")]
pub use std::os::wasi::io::{
AsFd, AsRawFd, BorrowedFd, FromRawFd, IntoRawFd, OwnedFd, RawFd,
};
}
#[cfg(windows)]
pub mod windows {
pub mod io {
pub use std::os::windows::io::{
AsRawSocket, AsSocket, BorrowedSocket, FromRawSocket, IntoRawSocket, OwnedSocket,
RawSocket,
};
}
}
}
|
use std::collections::HashMap;
use std::io;
use std::io::BufRead;
use std::path::{Path, PathBuf};
struct HeaderExtractor<R: BufRead> {
reader: std::iter::Filter<std::iter::Map<io::Split<R>, fn(io::Result<Vec<u8>>) -> io::Result<Vec<u8>>>, fn(&io::Result<Vec<u8>>) -> bool>,
}
fn drop_lf(item: io::Result<Vec<u8>>) -> io::Result<Vec<u8>> {
item.map(|mut item| { if item.last() == Some(&b'\n') { item.pop(); } item })
}
fn filter_headers(item: &io::Result<Vec<u8>>) -> bool {
match *item {
Ok(ref item) => item.ends_with(b".h") || item.ends_with(b".hpp"),
Err(_) => true,
}
}
impl<R: BufRead> HeaderExtractor<R> {
pub fn new(reader: R) -> Self {
HeaderExtractor {
reader: reader
.split(b' ')
.map(drop_lf as fn(io::Result<Vec<u8>>) -> io::Result<Vec<u8>>)
.filter(filter_headers as fn(&io::Result<Vec<u8>>) -> bool)
}
}
}
impl<R: BufRead> Iterator for HeaderExtractor<R> {
type Item = io::Result<PathBuf>;
fn next(&mut self) -> Option<Self::Item> {
use std::os::unix::ffi::OsStringExt;
self.reader.next().map(|item| item.map(std::ffi::OsString::from_vec).map(Into::into))
}
}
fn header_to_unit<P: AsRef<Path> + Into<PathBuf>>(path: P) -> Option<PathBuf> {
path.as_ref().extension()?;
let mut path = path.into();
path.set_extension("c");
Some(if path.exists() {
path
} else {
path.set_extension("cpp");
path
})
}
/// Convert path to a .c(pp) file to a path to .o file.
pub fn unit_to_obj<P: AsRef<Path> + Into<PathBuf>>(path: P) -> Option<PathBuf> {
path.as_ref().extension()?;
let mut path = path.into();
path.set_extension("o");
Some(path)
}
fn get_headers<P: AsRef<Path>>(file: P) -> io::Result<Vec<PathBuf>> {
let mut cpp = std::process::Command::new("c++")
.arg("-MM")
.arg(file.as_ref())
.stdout(std::process::Stdio::piped())
.spawn()?;
let headers = HeaderExtractor::new(io::BufReader::new(cpp.stdout.take().expect("Stdout not set")));
headers.collect()
}
/// Scans files in the project
pub fn scan_c_files<P: AsRef<Path>>(root_file: P) -> io::Result<HashMap<PathBuf, Vec<PathBuf>>> {
let mut scanned_files = HashMap::new();
let headers = get_headers(&root_file)?;
scanned_files.insert(PathBuf::from(root_file.as_ref()), headers);
let mut prev_file_count = 0;
while prev_file_count != scanned_files.len() {
prev_file_count = scanned_files.len();
let candidates = scanned_files
.iter()
.flat_map(|(_, headers)| headers.iter())
.map(header_to_unit)
.map(Option::unwrap)
.filter(|file| !scanned_files.contains_key(file))
.collect::<Vec<_>>();
for (file, headers) in candidates.into_iter().map(|file| { let headers = get_headers(&file); (file, headers) }) {
let headers = headers?;
scanned_files.insert(file, headers);
}
}
Ok(scanned_files)
}
fn is_older<P: AsRef<Path>, I: Iterator<Item=P>>(time: std::time::SystemTime, files: I) -> io::Result<bool> {
for file in files {
if std::fs::metadata(&file)?.modified()? > time {
return Ok(true);
}
}
Ok(false)
}
/// Iterator over modified sources
pub struct ModifiedSources<'a> {
target_time: Option<std::time::SystemTime>,
sources: std::collections::hash_map::Iter<'a, PathBuf, Vec<PathBuf>>,
}
impl<'a> ModifiedSources<'a> {
pub fn scan<P: AsRef<Path>>(target: P, sources: &'a HashMap<PathBuf, Vec<PathBuf>>) -> io::Result<Self> {
let target_time = match std::fs::metadata(target) {
Ok(metadata) => Some(metadata.modified()?),
Err(err) => if err.kind() == io::ErrorKind::NotFound {
None
} else {
return Err(err);
},
};
Ok(ModifiedSources {
target_time,
sources: sources.iter(),
})
}
}
impl<'a> Iterator for ModifiedSources<'a> {
type Item = io::Result<&'a Path>;
fn next(&mut self) -> Option<Self::Item> {
loop {
let (source, headers) = self.sources.next()?;
if let Some(target_time) = self.target_time {
match is_older(target_time, Some(source).into_iter().chain(headers)) {
Ok(true) => return Some(Ok(source)),
Ok(false) => (),
Err(err) => return Some(Err(err)),
}
} else {
return Some(Ok(source))
}
}
}
}
|
use crate::common::writer_properties::{Compression, Encoding, WriterVersion};
use parquet::basic::{BrotliLevel, GzipLevel, ZstdLevel};
use wasm_bindgen::prelude::*;
impl From<Encoding> for parquet::basic::Encoding {
fn from(x: Encoding) -> parquet::basic::Encoding {
match x {
Encoding::PLAIN => parquet::basic::Encoding::PLAIN,
Encoding::PLAIN_DICTIONARY => parquet::basic::Encoding::PLAIN_DICTIONARY,
Encoding::RLE => parquet::basic::Encoding::RLE,
Encoding::BIT_PACKED => parquet::basic::Encoding::BIT_PACKED,
Encoding::DELTA_BINARY_PACKED => parquet::basic::Encoding::DELTA_BINARY_PACKED,
Encoding::DELTA_LENGTH_BYTE_ARRAY => parquet::basic::Encoding::DELTA_LENGTH_BYTE_ARRAY,
Encoding::DELTA_BYTE_ARRAY => parquet::basic::Encoding::DELTA_BYTE_ARRAY,
Encoding::RLE_DICTIONARY => parquet::basic::Encoding::RLE_DICTIONARY,
Encoding::BYTE_STREAM_SPLIT => parquet::basic::Encoding::BYTE_STREAM_SPLIT,
}
}
}
impl From<Compression> for parquet::basic::Compression {
fn from(x: Compression) -> parquet::basic::Compression {
match x {
Compression::UNCOMPRESSED => parquet::basic::Compression::UNCOMPRESSED,
Compression::SNAPPY => parquet::basic::Compression::SNAPPY,
Compression::GZIP => parquet::basic::Compression::GZIP(GzipLevel::default()),
Compression::BROTLI => parquet::basic::Compression::BROTLI(BrotliLevel::default()),
Compression::LZ4 => parquet::basic::Compression::LZ4,
Compression::ZSTD => parquet::basic::Compression::ZSTD(ZstdLevel::default()),
// TODO: fix this. Though LZ4 isn't supported in arrow1 for wasm anyways
Compression::LZ4_RAW => parquet::basic::Compression::LZ4,
}
}
}
impl From<WriterVersion> for parquet::file::properties::WriterVersion {
fn from(x: WriterVersion) -> parquet::file::properties::WriterVersion {
match x {
WriterVersion::V1 => parquet::file::properties::WriterVersion::PARQUET_1_0,
WriterVersion::V2 => parquet::file::properties::WriterVersion::PARQUET_2_0,
}
}
}
/// Controls the level of statistics to be computed by the writer
#[derive(Debug, Clone, Copy, Eq, PartialEq)]
#[wasm_bindgen]
pub enum EnabledStatistics {
/// Compute no statistics
None,
/// Compute chunk-level statistics but not page-level
Chunk,
/// Compute page-level and chunk-level statistics
Page,
}
impl From<EnabledStatistics> for parquet::file::properties::EnabledStatistics {
fn from(statistics: EnabledStatistics) -> Self {
match statistics {
EnabledStatistics::None => parquet::file::properties::EnabledStatistics::None,
EnabledStatistics::Chunk => parquet::file::properties::EnabledStatistics::Chunk,
EnabledStatistics::Page => parquet::file::properties::EnabledStatistics::Page,
}
}
}
/// Immutable struct to hold writing configuration for `writeParquet`.
///
/// Use {@linkcode WriterPropertiesBuilder} to create a configuration, then call {@linkcode
/// WriterPropertiesBuilder.build} to create an instance of `WriterProperties`.
#[wasm_bindgen]
pub struct WriterProperties(parquet::file::properties::WriterProperties);
impl From<WriterProperties> for parquet::file::properties::WriterProperties {
fn from(props: WriterProperties) -> Self {
props.0
}
}
/// Builder to create a writing configuration for `writeParquet`
///
/// Call {@linkcode build} on the finished builder to create an immputable {@linkcode WriterProperties} to pass to `writeParquet`
#[wasm_bindgen]
pub struct WriterPropertiesBuilder(parquet::file::properties::WriterPropertiesBuilder);
#[wasm_bindgen]
impl WriterPropertiesBuilder {
/// Returns default state of the builder.
#[wasm_bindgen(constructor)]
pub fn new() -> WriterPropertiesBuilder {
WriterPropertiesBuilder(parquet::file::properties::WriterProperties::builder())
}
/// Finalizes the configuration and returns immutable writer properties struct.
#[wasm_bindgen]
pub fn build(self) -> WriterProperties {
WriterProperties(self.0.build())
}
// ----------------------------------------------------------------------
// Writer properties related to a file
/// Sets writer version.
#[wasm_bindgen(js_name = setWriterVersion)]
pub fn set_writer_version(self, value: WriterVersion) -> Self {
Self(self.0.set_writer_version(value.into()))
}
/// Sets data page size limit.
#[wasm_bindgen(js_name = setDataPageSizeLimit)]
pub fn set_data_page_size_limit(self, value: usize) -> Self {
Self(self.0.set_data_page_size_limit(value))
}
/// Sets dictionary page size limit.
#[wasm_bindgen(js_name = setDictionaryPageSizeLimit)]
pub fn set_dictionary_page_size_limit(self, value: usize) -> Self {
Self(self.0.set_dictionary_page_size_limit(value))
}
/// Sets write batch size.
#[wasm_bindgen(js_name = setWriteBatchSize)]
pub fn set_write_batch_size(self, value: usize) -> Self {
Self(self.0.set_write_batch_size(value))
}
/// Sets maximum number of rows in a row group.
#[wasm_bindgen(js_name = setMaxRowGroupSize)]
pub fn set_max_row_group_size(self, value: usize) -> Self {
Self(self.0.set_max_row_group_size(value))
}
/// Sets "created by" property.
#[wasm_bindgen(js_name = setCreatedBy)]
pub fn set_created_by(self, value: String) -> Self {
Self(self.0.set_created_by(value))
}
// /// Sets "key_value_metadata" property.
// #[wasm_bindgen(js_name = setKeyValueMetadata)]
// pub fn set_key_value_metadata(
// self,
// value: Option<Vec<parquet::file::metadata::KeyValue>>,
// ) -> Self {
// Self {
// 0: self.0.set_key_value_metadata(value),
// }
// }
// ----------------------------------------------------------------------
// Setters for any column (global)
/// Sets encoding for any column.
///
/// If dictionary is not enabled, this is treated as a primary encoding for all
/// columns. In case when dictionary is enabled for any column, this value is
/// considered to be a fallback encoding for that column.
///
/// Panics if user tries to set dictionary encoding here, regardless of dictionary
/// encoding flag being set.
#[wasm_bindgen(js_name = setEncoding)]
pub fn set_encoding(self, value: Encoding) -> Self {
Self(self.0.set_encoding(value.into()))
}
/// Sets compression codec for any column.
#[wasm_bindgen(js_name = setCompression)]
pub fn set_compression(self, value: Compression) -> Self {
Self(self.0.set_compression(value.into()))
}
/// Sets flag to enable/disable dictionary encoding for any column.
///
/// Use this method to set dictionary encoding, instead of explicitly specifying
/// encoding in `set_encoding` method.
#[wasm_bindgen(js_name = setDictionaryEnabled)]
pub fn set_dictionary_enabled(self, value: bool) -> Self {
Self(self.0.set_dictionary_enabled(value))
}
/// Sets flag to enable/disable statistics for any column.
#[wasm_bindgen(js_name = setStatisticsEnabled)]
pub fn set_statistics_enabled(self, value: EnabledStatistics) -> Self {
Self(self.0.set_statistics_enabled(value.into()))
}
/// Sets max statistics size for any column.
/// Applicable only if statistics are enabled.
#[wasm_bindgen(js_name = setMaxStatisticsSize)]
pub fn set_max_statistics_size(self, value: usize) -> Self {
Self(self.0.set_max_statistics_size(value))
}
// ----------------------------------------------------------------------
// Setters for a specific column
/// Sets encoding for a column.
/// Takes precedence over globally defined settings.
///
/// If dictionary is not enabled, this is treated as a primary encoding for this
/// column. In case when dictionary is enabled for this column, either through
/// global defaults or explicitly, this value is considered to be a fallback
/// encoding for this column.
///
/// Panics if user tries to set dictionary encoding here, regardless of dictionary
/// encoding flag being set.
#[wasm_bindgen(js_name = setColumnEncoding)]
pub fn set_column_encoding(self, col: String, value: Encoding) -> Self {
let column_path = parquet::schema::types::ColumnPath::from(col);
Self(self.0.set_column_encoding(column_path, value.into()))
}
/// Sets compression codec for a column.
/// Takes precedence over globally defined settings.
#[wasm_bindgen(js_name = setColumnCompression)]
pub fn set_column_compression(self, col: String, value: Compression) -> Self {
let column_path = parquet::schema::types::ColumnPath::from(col);
Self(self.0.set_column_compression(column_path, value.into()))
}
/// Sets flag to enable/disable dictionary encoding for a column.
/// Takes precedence over globally defined settings.
#[wasm_bindgen(js_name = setColumnDictionaryEnabled)]
pub fn set_column_dictionary_enabled(self, col: String, value: bool) -> Self {
let column_path = parquet::schema::types::ColumnPath::from(col);
Self(self.0.set_column_dictionary_enabled(column_path, value))
}
/// Sets flag to enable/disable statistics for a column.
/// Takes precedence over globally defined settings.
#[wasm_bindgen(js_name = setColumnStatisticsEnabled)]
pub fn set_column_statistics_enabled(self, col: String, value: EnabledStatistics) -> Self {
let column_path = parquet::schema::types::ColumnPath::from(col);
Self(
self.0
.set_column_statistics_enabled(column_path, value.into()),
)
}
/// Sets max size for statistics for a column.
/// Takes precedence over globally defined settings.
#[wasm_bindgen(js_name = setColumnMaxStatisticsSize)]
pub fn set_column_max_statistics_size(self, col: String, value: usize) -> Self {
let column_path = parquet::schema::types::ColumnPath::from(col);
Self(self.0.set_column_max_statistics_size(column_path, value))
}
}
impl Default for WriterPropertiesBuilder {
fn default() -> Self {
WriterPropertiesBuilder::new()
}
}
|
use std::fmt::{Display, Formatter, Result as FmtResult};
use std::path::{Path, PathBuf};
use std::str::FromStr;
use serde::de::{self, Deserialize, Deserializer};
use serde::ser::{Serialize, Serializer};
use super::{FilesystemId, ManifestId};
use crate::hash::Hash;
use crate::name::Name;
#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub struct OutputId {
name: Name,
version: String,
output: Option<Name>,
hash: Hash,
}
impl OutputId {
#[inline]
pub const fn new(name: Name, version: String, output: Option<Name>, hash: Hash) -> Self {
OutputId {
name,
version,
output,
hash,
}
}
pub fn parse<S>(name: S, version: S, output: Option<S>, hash: S) -> Result<Self, ()>
where
S: AsRef<str>,
{
let output = match output {
Some(s) => Some(s.as_ref().parse()?),
None => None,
};
Ok(OutputId {
name: name.as_ref().parse()?,
version: version.as_ref().to_string(),
output,
hash: hash.as_ref().parse()?,
})
}
#[inline]
pub fn name(&self) -> &str {
self.name.as_str()
}
#[inline]
pub fn version(&self) -> &str {
self.version.as_str()
}
#[inline]
pub fn output(&self) -> Option<&str> {
self.output.as_ref().map(|out| out.as_str())
}
#[inline]
pub const fn hash(&self) -> &Hash {
&self.hash
}
pub fn is_same_package(&self, manifest_id: &ManifestId) -> bool {
let name_matches = self.name.as_str() == manifest_id.name();
let version_matches = self.version.as_str() == manifest_id.version();
name_matches && version_matches
}
}
impl Display for OutputId {
fn fmt(&self, fmt: &mut Formatter) -> FmtResult {
let out = self
.output
.as_ref()
.map(|out| format!(":{}", out))
.unwrap_or_default();
write!(fmt, "{}@{}{}-{}", self.name, self.version, out, self.hash)
}
}
impl FilesystemId for OutputId {
fn from_path<P: AsRef<Path>>(path: P) -> Result<Self, ()> {
let raw_name = path.as_ref().file_name().ok_or(())?;
let name = raw_name.to_str().ok_or(())?;
OutputId::from_str(name)
}
fn to_path(&self) -> PathBuf {
PathBuf::from(self.to_string())
}
}
impl FromStr for OutputId {
type Err = ();
fn from_str(s: &str) -> Result<Self, Self::Err> {
let mut tokens = s.rsplitn(2, '-');
let hash = tokens.next().ok_or(())?;
let remainder = tokens.next().ok_or(())?;
let mut tokens = remainder.rsplitn(2, '@');
let identifier = tokens.next().ok_or(())?;
let name = tokens.next().ok_or(())?;
let mut tokens = identifier.splitn(2, ':');
let version = tokens.next().ok_or(())?;
let output = tokens.next();
OutputId::parse(name, version, output, hash)
}
}
impl PartialEq<str> for OutputId {
fn eq(&self, other: &str) -> bool {
let s = self.to_string();
s.as_str() == other
}
}
impl PartialEq<&'_ str> for OutputId {
fn eq(&self, other: &&str) -> bool {
self == *other
}
}
impl PartialEq<OutputId> for str {
fn eq(&self, other: &OutputId) -> bool {
other.to_string().as_str() == self
}
}
impl PartialEq<OutputId> for &'_ str {
fn eq(&self, other: &OutputId) -> bool {
other == self
}
}
impl<'de> Deserialize<'de> for OutputId {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where
D: Deserializer<'de>,
{
let s: &str = Deserialize::deserialize(deserializer)?;
OutputId::from_str(&s).map_err(|_err| de::Error::custom("failed to deserialize"))
}
}
impl Serialize for OutputId {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
{
self.to_string().serialize(serializer)
}
}
#[cfg(test)]
mod tests {
use super::*;
const HASH: &'static str = "fc3j3vub6kodu4jtfoakfs5xhumqi62m";
const SIMPLE_ID: &'static str = "foobar@1.0.0-fc3j3vub6kodu4jtfoakfs5xhumqi62m";
const WITH_OUTPUT_NAME: &'static str = "foobar@1.0.0:man-fc3j3vub6kodu4jtfoakfs5xhumqi62m";
#[test]
fn is_send_and_sync() {
fn assert_send_sync<T: Send + Sync>() {}
assert_send_sync::<OutputId>();
}
#[test]
fn parse_simple_id_from_string() {
let expected = OutputId::parse("foobar", "1.0.0", None, HASH).expect("Failed to init ID");
let actual: OutputId = SIMPLE_ID.parse().expect("Failed to parse ID");
assert_eq!(expected, actual);
assert_eq!(expected.name(), actual.name());
assert_eq!(expected.version(), actual.version());
assert_eq!(expected.output(), actual.output());
assert_eq!(expected.hash(), actual.hash());
}
#[test]
fn parse_simple_roundtrip() {
let original: OutputId = SIMPLE_ID.parse().expect("Failed to parse ID");
let text_form = original.to_string();
let parsed: OutputId = text_form.parse().expect("Failed to parse ID from text");
assert_eq!(original, parsed);
}
#[test]
fn parse_id_with_name_from_string() {
let expected =
OutputId::parse("foobar", "1.0.0", Some("man"), HASH).expect("Failed to init ID");
let actual: OutputId = WITH_OUTPUT_NAME.parse().expect("Failed to parse ID");
assert_eq!(expected, actual);
assert_eq!(expected.name(), actual.name());
assert_eq!(expected.version(), actual.version());
assert_eq!(expected.output(), actual.output());
assert_eq!(expected.hash(), actual.hash());
}
#[test]
fn parse_id_with_name_roundtrip() {
let original: OutputId = WITH_OUTPUT_NAME.parse().expect("Failed to parse ID");
let text_form = original.to_string();
let parsed: OutputId = text_form.parse().expect("Failed to parse ID from text");
assert_eq!(original, parsed);
}
}
|
use hello_world::customer_service::CustomerService;
use hello_world::event_publishing::DomainEventPublisher;
use hello_world::mysql_util::new_connection_pool;
use std::sync::Arc;
use std::time::SystemTime;
#[actix_rt::test]
async fn customer_service_saves_and_finds_customers() {
let pool = new_connection_pool().await.unwrap();
let domain_event_publisher = Arc::new(DomainEventPublisher{});
let customer_service : CustomerService = CustomerService::new(&domain_event_publisher, &pool);
let name = "Fred";
let credit_limit = 101;
let cid = customer_service.save_customer(&name.to_string(), credit_limit).await.unwrap();
let c = customer_service.find_customer(cid).await.unwrap().unwrap();
assert_eq!(cid, c.id);
assert_eq!(credit_limit, c.credit_limit);
assert_eq!("Fred", c.name);
}
#[actix_rt::test]
async fn customer_service_find_non_existent_customer() {
let pool = new_connection_pool().await.unwrap();
let domain_event_publisher = Arc::new(DomainEventPublisher{});
let customer_service : CustomerService = CustomerService::new(&domain_event_publisher, &pool);
let id = SystemTime::now().duration_since(SystemTime::UNIX_EPOCH).unwrap().as_millis();
let c = customer_service.find_customer(id as i64).await.unwrap();
assert_eq!(None, c);
}
|
//! Contains types related to defining shared resources which can be accessed inside systems.
//!
//! Use resources to share persistent data between systems or to provide a system with state
//! external to entities.
use std::{
any::TypeId,
collections::{hash_map::Entry, HashMap},
fmt::{Display, Formatter},
hash::{BuildHasherDefault, Hasher},
marker::PhantomData,
};
use atomic_refcell::{AtomicRef, AtomicRefCell, AtomicRefMut};
use downcast_rs::{impl_downcast, Downcast};
use crate::internals::{
hash::ComponentTypeIdHasher,
query::view::{read::Read, write::Write, ReadOnly},
};
/// Unique ID for a resource.
#[derive(Copy, Clone, Debug, Eq, PartialOrd, Ord)]
pub struct ResourceTypeId {
type_id: TypeId,
#[cfg(debug_assertions)]
name: &'static str,
}
impl ResourceTypeId {
/// Returns the resource type ID of the given resource type.
pub fn of<T: Resource>() -> Self {
Self {
type_id: TypeId::of::<T>(),
#[cfg(debug_assertions)]
name: std::any::type_name::<T>(),
}
}
}
impl std::hash::Hash for ResourceTypeId {
fn hash<H: Hasher>(&self, state: &mut H) {
self.type_id.hash(state);
}
}
impl PartialEq for ResourceTypeId {
fn eq(&self, other: &Self) -> bool {
self.type_id.eq(&other.type_id)
}
}
impl Display for ResourceTypeId {
#[cfg(debug_assertions)]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.name)
}
#[cfg(not(debug_assertions))]
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
write!(f, "{:?}", self.type_id)
}
}
/// Blanket trait for resource types.
pub trait Resource: 'static + Downcast {}
impl<T> Resource for T where T: 'static {}
impl_downcast!(Resource);
/// Trait which is implemented for tuples of resources and singular resources. This abstracts
/// fetching resources to allow for ergonomic fetching.
///
/// # Example:
/// ```
/// struct TypeA(usize);
/// struct TypeB(usize);
///
/// # use legion::*;
/// # use legion::systems::ResourceSet;
/// let mut resources = Resources::default();
/// resources.insert(TypeA(55));
/// resources.insert(TypeB(12));
///
/// {
/// let (a, mut b) = <(Read<TypeA>, Write<TypeB>)>::fetch_mut(&mut resources);
/// assert_ne!(a.0, b.0);
/// b.0 = a.0;
/// }
///
/// {
/// let (a, b) = <(Read<TypeA>, Read<TypeB>)>::fetch(&resources);
/// assert_eq!(a.0, b.0);
/// }
/// ```
pub trait ResourceSet<'a> {
/// The resource reference returned during a fetch.
type Result: 'a;
/// Fetches all defined resources, without checking mutability.
///
/// # Safety
/// It is up to the end user to validate proper mutability rules across the resources being accessed.
unsafe fn fetch_unchecked(resources: &'a UnsafeResources) -> Self::Result;
/// Fetches all defined resources.
fn fetch_mut(resources: &'a mut Resources) -> Self::Result {
// safe because mutable borrow ensures exclusivity
unsafe { Self::fetch_unchecked(&resources.internal) }
}
/// Fetches all defined resources.
fn fetch(resources: &'a Resources) -> Self::Result
where
Self: ReadOnly,
{
unsafe { Self::fetch_unchecked(&resources.internal) }
}
}
impl<'a> ResourceSet<'a> for () {
type Result = ();
unsafe fn fetch_unchecked(_: &UnsafeResources) -> Self::Result {}
}
impl<'a, T: Resource> ResourceSet<'a> for Read<T> {
type Result = AtomicRef<'a, T>;
unsafe fn fetch_unchecked(resources: &'a UnsafeResources) -> Self::Result {
let type_id = &ResourceTypeId::of::<T>();
resources
.get(&type_id)
.map(|x| x.get::<T>())
.unwrap_or_else(|| panic_nonexistent_resource(type_id))
}
}
impl<'a, T: Resource> ResourceSet<'a> for Write<T> {
type Result = AtomicRefMut<'a, T>;
unsafe fn fetch_unchecked(resources: &'a UnsafeResources) -> Self::Result {
let type_id = &ResourceTypeId::of::<T>();
resources
.get(&type_id)
.map(|x| x.get_mut::<T>())
.unwrap_or_else(|| panic_nonexistent_resource(type_id))
}
}
fn panic_nonexistent_resource(type_id: &ResourceTypeId) -> ! {
#[cfg(debug_assertions)]
panic!("resource {} does not exist", type_id.name);
#[cfg(not(debug_assertions))]
panic!("some resource does not exist");
}
macro_rules! resource_tuple {
($head_ty:ident) => {
impl_resource_tuple!($head_ty);
};
($head_ty:ident, $( $tail_ty:ident ),*) => (
impl_resource_tuple!($head_ty, $( $tail_ty ),*);
resource_tuple!($( $tail_ty ),*);
);
}
macro_rules! impl_resource_tuple {
( $( $ty: ident ),* ) => {
#[allow(unused_parens, non_snake_case)]
impl<'a, $( $ty: ResourceSet<'a> ),*> ResourceSet<'a> for ($( $ty, )*)
{
type Result = ($( $ty::Result, )*);
unsafe fn fetch_unchecked(resources: &'a UnsafeResources) -> Self::Result {
($( $ty::fetch_unchecked(resources), )*)
}
}
};
}
#[cfg(feature = "extended-tuple-impls")]
resource_tuple!(A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z);
#[cfg(not(feature = "extended-tuple-impls"))]
resource_tuple!(A, B, C, D, E, F, G, H);
pub struct ResourceCell {
data: AtomicRefCell<Box<dyn Resource>>,
}
impl ResourceCell {
fn new(resource: Box<dyn Resource>) -> Self {
Self {
data: AtomicRefCell::new(resource),
}
}
fn into_inner(self) -> Box<dyn Resource> {
self.data.into_inner()
}
/// # Safety
/// Types which are !Sync should only be retrieved on the thread which owns the resource
/// collection.
pub fn get<T: Resource>(&self) -> AtomicRef<T> {
let borrow = self.data.borrow();
AtomicRef::map(borrow, |inner| inner.downcast_ref::<T>().unwrap())
}
/// # Safety
/// Types which are !Send should only be retrieved on the thread which owns the resource
/// collection.
pub fn get_mut<T: Resource>(&self) -> AtomicRefMut<T> {
let borrow = self.data.borrow_mut(); // panics if this is borrowed already
AtomicRefMut::map(borrow, |inner| inner.downcast_mut::<T>().unwrap())
}
}
/// A container for resources which performs runtime borrow checking
/// but _does not_ ensure that `!Sync` resources aren't accessed across threads.
#[derive(Default)]
pub struct UnsafeResources {
map: HashMap<ResourceTypeId, ResourceCell, BuildHasherDefault<ComponentTypeIdHasher>>,
}
unsafe impl Send for UnsafeResources {}
unsafe impl Sync for UnsafeResources {}
impl UnsafeResources {
fn contains(&self, type_id: &ResourceTypeId) -> bool {
self.map.contains_key(type_id)
}
/// # Safety
/// Resources which are `!Sync` or `!Send` must be retrieved or inserted only on the main thread.
unsafe fn entry(&mut self, type_id: ResourceTypeId) -> Entry<ResourceTypeId, ResourceCell> {
self.map.entry(type_id)
}
/// # Safety
/// Resources which are `!Send` must be retrieved or inserted only on the main thread.
unsafe fn insert<T: Resource>(&mut self, resource: T) {
self.map.insert(
ResourceTypeId::of::<T>(),
ResourceCell::new(Box::new(resource)),
);
}
/// # Safety
/// Resources which are `!Send` must be retrieved or inserted only on the main thread.
unsafe fn remove(&mut self, type_id: &ResourceTypeId) -> Option<Box<dyn Resource>> {
self.map.remove(type_id).map(|cell| cell.into_inner())
}
fn get(&self, type_id: &ResourceTypeId) -> Option<&ResourceCell> {
self.map.get(type_id)
}
/// # Safety
/// Resources which are `!Sync` must be retrieved or inserted only on the main thread.
unsafe fn merge(&mut self, mut other: Self) {
// Merge resources, retaining our local ones but moving in any non-existant ones
for resource in other.map.drain() {
self.map.entry(resource.0).or_insert(resource.1);
}
}
}
/// Resources container. Shared resources stored here can be retrieved in systems.
#[derive(Default)]
pub struct Resources {
internal: UnsafeResources,
// marker to make `Resources` !Send and !Sync
_not_send_sync: PhantomData<*const u8>,
}
impl Resources {
pub(crate) fn internal(&self) -> &UnsafeResources {
&self.internal
}
/// Creates an accessor to resources which are Send and Sync, which itself can be sent
/// between threads.
pub fn sync(&mut self) -> SyncResources {
SyncResources {
internal: &self.internal,
}
}
/// Returns `true` if type `T` exists in the store. Otherwise, returns `false`.
pub fn contains<T: Resource>(&self) -> bool {
self.internal.contains(&ResourceTypeId::of::<T>())
}
/// Inserts the instance of `T` into the store. If the type already exists, it will be silently
/// overwritten. If you would like to retain the instance of the resource that already exists,
/// call `remove` first to retrieve it.
pub fn insert<T: Resource>(&mut self, value: T) {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
unsafe {
self.internal.insert(value);
}
}
/// Removes the type `T` from this store if it exists.
///
/// # Returns
/// If the type `T` was stored, the inner instance of `T is returned. Otherwise, `None`.
pub fn remove<T: Resource>(&mut self) -> Option<T> {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
unsafe {
let resource = self
.internal
.remove(&ResourceTypeId::of::<T>())?
.downcast::<T>()
.ok()?;
Some(*resource)
}
}
/// Retrieve an immutable reference to `T` from the store if it exists. Otherwise, return `None`.
///
/// # Panics
/// Panics if the resource is already borrowed mutably.
pub fn get<T: Resource>(&self) -> Option<AtomicRef<T>> {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
let type_id = &ResourceTypeId::of::<T>();
self.internal.get(&type_id).map(|x| x.get::<T>())
}
/// Retrieve a mutable reference to `T` from the store if it exists. Otherwise, return `None`.
pub fn get_mut<T: Resource>(&self) -> Option<AtomicRefMut<T>> {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
let type_id = &ResourceTypeId::of::<T>();
self.internal.get(&type_id).map(|x| x.get_mut::<T>())
}
/// Attempts to retrieve an immutable reference to `T` from the store. If it does not exist,
/// the closure `f` is called to construct the object and it is then inserted into the store.
pub fn get_or_insert_with<T: Resource, F: FnOnce() -> T>(&mut self, f: F) -> AtomicRef<T> {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
let type_id = ResourceTypeId::of::<T>();
unsafe {
self.internal
.entry(type_id)
.or_insert_with(|| ResourceCell::new(Box::new((f)())))
.get()
}
}
/// Attempts to retrieve a mutable reference to `T` from the store. If it does not exist,
/// the closure `f` is called to construct the object and it is then inserted into the store.
pub fn get_mut_or_insert_with<T: Resource, F: FnOnce() -> T>(
&mut self,
f: F,
) -> AtomicRefMut<T> {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
let type_id = ResourceTypeId::of::<T>();
unsafe {
self.internal
.entry(type_id)
.or_insert_with(|| ResourceCell::new(Box::new((f)())))
.get_mut()
}
}
/// Attempts to retrieve an immutable reference to `T` from the store. If it does not exist,
/// the provided value is inserted and then a reference to it is returned.
pub fn get_or_insert<T: Resource>(&mut self, value: T) -> AtomicRef<T> {
self.get_or_insert_with(|| value)
}
/// Attempts to retrieve a mutable reference to `T` from the store. If it does not exist,
/// the provided value is inserted and then a reference to it is returned.
pub fn get_mut_or_insert<T: Resource>(&mut self, value: T) -> AtomicRefMut<T> {
self.get_mut_or_insert_with(|| value)
}
/// Attempts to retrieve an immutable reference to `T` from the store. If it does not exist,
/// the default constructor for `T` is called.
///
/// `T` must implement `Default` for this method.
pub fn get_or_default<T: Resource + Default>(&mut self) -> AtomicRef<T> {
self.get_or_insert_with(T::default)
}
/// Attempts to retrieve a mutable reference to `T` from the store. If it does not exist,
/// the default constructor for `T` is called.
///
/// `T` must implement `Default` for this method.
pub fn get_mut_or_default<T: Resource + Default>(&mut self) -> AtomicRefMut<T> {
self.get_mut_or_insert_with(T::default)
}
/// Performs merging of two resource storages, which occurs during a world merge.
/// This merge will retain any already-existant resources in the local world, while moving any
/// new resources from the source world into this one, consuming the resources.
pub fn merge(&mut self, other: Resources) {
// safety:
// this type is !Send and !Sync, and so can only be accessed from the thread which
// owns the resources collection
unsafe {
self.internal.merge(other.internal);
}
}
}
/// A resource collection which is `Send` and `Sync`, but which only allows access to resources
/// which are `Sync`.
pub struct SyncResources<'a> {
internal: &'a UnsafeResources,
}
impl<'a> SyncResources<'a> {
/// Retrieve an immutable reference to `T` from the store if it exists. Otherwise, return `None`.
///
/// # Panics
/// Panics if the resource is already borrowed mutably.
pub fn get<T: Resource + Sync>(&self) -> Option<AtomicRef<T>> {
let type_id = &ResourceTypeId::of::<T>();
self.internal.get(&type_id).map(|x| x.get::<T>())
}
/// Retrieve a mutable reference to `T` from the store if it exists. Otherwise, return `None`.
pub fn get_mut<T: Resource + Send>(&self) -> Option<AtomicRefMut<T>> {
let type_id = &ResourceTypeId::of::<T>();
self.internal.get(&type_id).map(|x| x.get_mut::<T>())
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn simple_read_write_test() {
struct TestOne {
value: String,
}
struct TestTwo {
value: String,
}
struct NotSync {
ptr: *const u8,
}
let mut resources = Resources::default();
resources.insert(TestOne {
value: "one".to_string(),
});
resources.insert(TestTwo {
value: "two".to_string(),
});
resources.insert(NotSync {
ptr: std::ptr::null(),
});
assert_eq!(resources.get::<TestOne>().unwrap().value, "one");
assert_eq!(resources.get::<TestTwo>().unwrap().value, "two");
assert_eq!(resources.get::<NotSync>().unwrap().ptr, std::ptr::null());
// test re-ownership
let owned = resources.remove::<TestTwo>();
assert_eq!(owned.unwrap().value, "two");
}
}
|
//! A logical persistence queue abstraction.
use std::{fmt::Debug, sync::Arc};
use async_trait::async_trait;
use parking_lot::Mutex;
use tokio::sync::oneshot;
use crate::buffer_tree::partition::{persisting::PersistingData, PartitionData};
/// An abstract logical queue into which [`PersistingData`] (and their matching
/// [`PartitionData`]) are placed to be persisted.
///
/// Implementations MAY reorder persist jobs placed in this queue, and MAY block
/// indefinitely.
///
/// It is a logical error to enqueue a [`PartitionData`] with a
/// [`PersistingData`] from another instance.
#[async_trait]
pub trait PersistQueue: Send + Sync + Debug {
/// Place `data` from `partition` into the persistence queue,
/// (asynchronously) blocking until enqueued.
async fn enqueue(
&self,
partition: Arc<Mutex<PartitionData>>,
data: PersistingData,
) -> oneshot::Receiver<()>;
}
#[async_trait]
impl<T> PersistQueue for Arc<T>
where
T: PersistQueue,
{
#[allow(clippy::async_yields_async)]
async fn enqueue(
&self,
partition: Arc<Mutex<PartitionData>>,
data: PersistingData,
) -> oneshot::Receiver<()> {
(**self).enqueue(partition, data).await
}
}
/// This needs to be pub for the benchmarks but should not be used outside the crate.
#[cfg(feature = "benches")]
pub use mock::*;
/// This needs to be pub for the benchmarks but should not be used outside the crate.
#[cfg(feature = "benches")]
pub use crate::persist::completion_observer::*;
#[cfg(any(test, feature = "benches"))]
pub(crate) mod mock {
use std::{sync::Arc, time::Duration};
use data_types::{
ColumnId, ColumnSet, NamespaceId, ParquetFileParams, PartitionHashId, PartitionKey,
TableId, Timestamp, TransitionPartitionId,
};
use test_helpers::timeout::FutureTimeout;
use tokio::task::JoinHandle;
use super::*;
use crate::persist::completion_observer::{
CompletedPersist, NopObserver, PersistCompletionObserver,
};
#[derive(Debug, Default)]
struct State {
/// Observed PartitionData instances.
calls: Vec<Arc<Mutex<PartitionData>>>,
/// Spawned tasks that call [`PartitionData::mark_persisted()`] - may
/// have already terminated.
handles: Vec<JoinHandle<()>>,
}
impl Drop for State {
fn drop(&mut self) {
std::mem::take(&mut self.handles)
.into_iter()
.for_each(|h| h.abort());
}
}
/// A mock [`PersistQueue`] implementation.
#[derive(Debug)]
pub struct MockPersistQueue<O> {
state: Mutex<State>,
completion_observer: O,
}
impl Default for MockPersistQueue<NopObserver> {
fn default() -> Self {
Self {
state: Default::default(),
completion_observer: Default::default(),
}
}
}
impl<O> MockPersistQueue<O>
where
O: PersistCompletionObserver + 'static,
{
/// Creates a queue that notifies the [`PersistCompletionObserver`]
/// on persist enqueue completion.
pub fn new_with_observer(completion_observer: O) -> Self {
Self {
state: Default::default(),
completion_observer,
}
}
/// Return all observed [`PartitionData`].
pub fn calls(&self) -> Vec<Arc<Mutex<PartitionData>>> {
self.state.lock().calls.clone()
}
/// Wait for all outstanding mock persist jobs to complete, propagating
/// any panics.
pub async fn join(self) {
let handles = std::mem::take(&mut self.state.lock().handles);
for h in handles.into_iter() {
h.with_timeout_panic(Duration::from_secs(5))
.await
.expect("mock mark persist panic");
}
}
}
#[async_trait]
impl<O> PersistQueue for MockPersistQueue<O>
where
O: PersistCompletionObserver + Clone + 'static,
{
#[allow(clippy::async_yields_async)]
async fn enqueue(
&self,
partition: Arc<Mutex<PartitionData>>,
data: PersistingData,
) -> oneshot::Receiver<()> {
let (tx, rx) = oneshot::channel();
let mut guard = self.state.lock();
guard.calls.push(Arc::clone(&partition));
let completion_observer = self.completion_observer.clone();
// Spawn a persist task that randomly completes (soon) in the
// future.
//
// This helps ensure a realistic mock, and that implementations do
// not depend on ordered persist operations (which the persist
// system does not provide).
guard.handles.push(tokio::spawn(async move {
let wait_ms: u64 = rand::random::<u64>() % 100;
tokio::time::sleep(Duration::from_millis(wait_ms)).await;
let sequence_numbers = partition.lock().mark_persisted(data);
let table_id = TableId::new(2);
let partition_hash_id =
PartitionHashId::new(table_id, &PartitionKey::from("arbitrary"));
let partition_id = TransitionPartitionId::Deterministic(partition_hash_id);
completion_observer
.persist_complete(Arc::new(CompletedPersist::new(
ParquetFileParams {
namespace_id: NamespaceId::new(1),
table_id,
partition_id,
object_store_id: Default::default(),
min_time: Timestamp::new(42),
max_time: Timestamp::new(42),
file_size_bytes: 42424242,
row_count: 24,
compaction_level: data_types::CompactionLevel::Initial,
created_at: Timestamp::new(1234),
column_set: ColumnSet::new([1, 2, 3, 4].into_iter().map(ColumnId::new)),
max_l0_created_at: Timestamp::new(42),
},
sequence_numbers,
)))
.await;
let _ = tx.send(());
}));
rx
}
}
}
|
use reqwest::{StatusCode, header::{COOKIE, LOCATION, SET_COOKIE, HeaderMap, HeaderValue}};
pub struct Session {
client: reqwest::Client,
cookies: cookie::CookieJar,
}
impl Session {
// reqwest 0.9.6 doesn't handle `set-cookie` header in case of a redirect,
// so i have to do it myself.
// see this for detail: https://github.com/seanmonstar/reqwest/issues/14#issuecomment-342833155
pub fn new() -> Self {
let client = reqwest::Client::builder()
.redirect(reqwest::RedirectPolicy::none())
.build()
.expect("Client failed to initialize");
Session { client, cookies: cookie::CookieJar::new() }
}
pub fn execute<F, U>(
&mut self, mut method: reqwest::Method, url: U, cb: F
) -> reqwest::Result<reqwest::Response>
where F: FnOnce(reqwest::RequestBuilder) -> reqwest::RequestBuilder,
U: reqwest::IntoUrl
{
let url = url.into_url()?;
self.drop_cookies();
let req = cb(self.client.request(method.clone(), url.clone()))
.headers(self.cookie_header(&url))
.build()?;
let mut resp = self.client.execute(req)?;
self.set_cookies(&url, &resp.headers());
// loop until isn't redirection
loop {
let status = resp.status();
if !status.is_redirection() {
break Ok(resp)
}
let mut body = vec![];
resp.copy_to(&mut body)?;
let loc = resp
.headers()
.get(LOCATION)
.expect("Redirection without Location header.")
.to_str()
.expect("Ivalid characters in Location header.")
.parse::<reqwest::Url>()
.expect("Can't parse Location header.");
let mut headers = resp.headers().clone();
while let Some(_) = headers.remove(SET_COOKIE) {}
// keep referrer method for 307-308
method = match status {
StatusCode::TEMPORARY_REDIRECT |
StatusCode::PERMANENT_REDIRECT => method,
_ => reqwest::Method::GET
};
self.drop_cookies();
let req = self.client
.request(method.clone(), loc.clone())
.body(body)
.headers(headers)
.headers(self.cookie_header(&loc))
.build()?;
resp = self.client.execute(req)?;
self.set_cookies(&loc, &resp.headers());
}
}
fn drop_cookies(&mut self) {
let to_remove: Vec<cookie::Cookie> = self.cookies
.iter()
// max-age is not implemented
.filter(|c| match c.expires() {
Some(t) => t < time::now(),
None => false
})
.map(|c| c.clone())
.collect();
to_remove.into_iter().for_each(|c| self.cookies.force_remove(c));
}
/// Gives matched cookies for a request.
///
/// Maps cookies from cookie-rs into hyper, filters them
/// by the url's domain and path.
fn cookie_header(&self, url: &reqwest::Url) -> HeaderMap
{
let domain = url.domain().unwrap_or("");
let path = url.path();
let cookie_value = self.cookies.iter()
.filter(|c| match c.domain() {
// it doesn't handle a cookie with
// top level domain and some subdomains: ".com", ".co.uk" ...
// so you SHOULD NOT use it anywhere if you are working with multiple domains
Some(d) => domain == d || domain.ends_with(d),
None => false
} && match c.path() {
Some(p) => path.starts_with(p),
None => false
})
.fold("".to_string(), |mut a, c| {
let (name, value) = c.name_value();
if !a.is_empty() {
a.push_str("; ");
}
a.push_str(name);
a.push_str("=");
a.push_str(value);
a
});
let mut header = HeaderMap::new();
if let Ok(value) = HeaderValue::from_str(cookie_value.as_str()) {
header.insert(COOKIE, value);
}
header
}
/// Saves cookies to the session.
///
/// Maps cookies from hyper into cookie-rs and stores them in CookieJar.
fn set_cookies(&mut self, url: &reqwest::Url, headers: &HeaderMap)
{
let domain = url.domain().unwrap_or("");
let path = url.path();
headers.get_all(SET_COOKIE).iter()
.filter_map(|sc| sc.to_str().ok())
.filter_map(|s| s.parse::<cookie::Cookie>().ok())
.filter(|c| if let Some(c_domain) = c.domain() {
// it doesn't handle a cookie with
// top level domain and some subdomains: ".com", ".co.uk" ...
// so you SHOULD NOT use it if you are working with multiple domains
domain == c_domain || domain.ends_with(c_domain)
} else {
!domain.is_empty()
})
.for_each(|mut c| {
if let None = c.domain() {
c.set_domain(domain.to_owned());
}
if let None = c.path() {
c.set_path(path.to_owned());
}
self.cookies.add_original(c);
});
}
} |
#[test]
fn cycle_test() {
let names = ["Batman", "Superman", "Spiderman"];
let mut cycle = names.iter().cycle();
assert_eq!(cycle.next(), Some(&"Batman"));
assert_eq!(cycle.next(), Some(&"Superman"));
assert_eq!(cycle.next(), Some(&"Spiderman"));
assert_eq!(cycle.next(), Some(&"Batman"));
assert_eq!(cycle.next(), Some(&"Superman"));
}
|
fn main() {
let a = [1, 2, 3, 4, 5];
let _first = a[0];
let _second = a[1];
}
|
mod part;
mod part_attributes;
mod partkind;
pub mod parts;
mod reply;
mod reply_type;
mod request;
mod request_type;
mod server_usage;
pub(crate) mod util;
#[cfg(feature = "async")]
pub(crate) mod util_async;
pub(crate) mod util_sync;
pub use self::{
part::Part, part_attributes::PartAttributes, partkind::PartKind, reply::Reply,
reply_type::ReplyType, request::Request, request::HOLD_CURSORS_OVER_COMMIT,
request_type::RequestType,
};
pub use self::server_usage::ServerUsage;
|
// the lifetime annotations in the fn signature
// mean that any values that do not adhere to
// this contract should be rejected by the
// borrow checker
// lifetime annotations always go in fn sig
// and not in the fn body!!!
fn longest<'a>(x: &'a str, y: &'a str) -> &'a str {
if x.len() > y.len() {
x
} else {
y
}
}
fn main() {
// we want string slices (references)
// since we don't want the fn to take
// ownership of its arguments
// slice of a String
let string1 = String::from("long string is long");
// // string literal
// let string2 = "xyz";
// let result = longest(string1.as_str(), string2);
// println!("The longest string is {}", result);
let result;
{
let string2 = String::from("xyz");
result = longest(string1.as_str(), string2.as_str());
}
println!("The longest string is {}", result);
}
|
extern crate json;
use algo_tools::load_json_tests;
use algo_tools::treenode::{TreeNode,vector2tree};
use std::rc::Rc;
use std::cell::RefCell;
use std::iter;
type Tree = Option<Rc<RefCell<TreeNode>>>;
struct Solution;
impl Solution {
fn dfs(root: &Tree, branch_sum: i32, tree_sum: i32) -> i32 {
let mut ts = tree_sum;
if let Some(root) = root {
let bs = branch_sum * 10 + root.borrow().val;
//println!("Visiting {}, branch_sum is {}", root.borrow().val, bs);
if root.borrow().left.is_none() && root.borrow().right.is_none() {
// root is a leaf
ts += bs;
} else {
ts = Self::dfs(&root.borrow().left, bs, ts);
ts = Self::dfs(&root.borrow().right, bs, ts);
}
}
ts
}
pub fn sum_numbers(root: Tree) -> i32 {
Self::dfs(&root, 0, 0)
}
}
fn run_test_case(test_case: &json::JsonValue) -> i32 {
let _nums = &test_case["in"];
let expected = test_case["expected"].as_i32().unwrap();
let mut nums = Vec::new();
for num in _nums.members() {
nums.push(num.as_i32().unwrap());
}
//let mut tree : Vec<Rc<RefCell<TreeNode>>> = vec!(Rc::new(RefCell::new(TreeNode::new(0))); nums.len());
let mut tree: Vec<_> = iter::repeat_with(|| Rc::new(RefCell::new(TreeNode::new(0))))
.take(nums.len())
.collect();
let root = vector2tree(&nums, &mut tree);
let result = Solution::sum_numbers(root);
if result == expected {
return 0;
}
println!("sum_numbers({:?}) returned {} but expected {}\n",
tree[0], result, expected);
1
}
fn main() {
let (tests, test_idx) = load_json_tests();
let (mut successes, mut failures) = (0, 0);
if test_idx >= tests.len() as i32 {
println!("Wrong index {}, only {} tests available!!", test_idx, tests.len());
return
}
if test_idx != -1 {
let rc = run_test_case(&tests[test_idx as usize]);
if rc == 0 { successes += 1; }
else { failures += 1; }
} else {
println!("{} tests specified", tests.len());
for i in 0..tests.len() {
let rc = run_test_case(&tests[i]);
if rc == 0 { successes += 1; }
else { failures += 1; }
}
}
if failures > 0 {
println!("{} tests succeeded and {} tests failed!!", successes, failures);
} else {
println!("All {} tests succeeded!!", successes);
}
}
/*impl Solution {
pub fn sum_numbers(root: Tree) -> i32 {
fn traverse(root: &Tree, sum: i32) -> i32 {
root.as_ref().map(|node| {
let node = node.borrow();
let next = sum * 10 + node.val;
if node.left.is_none() & node.right.is_none() {
return next;
}
traverse(&node.left, next) + traverse(&node.right, next)
}).unwrap_or(0)
}
traverse(&root, 0)
}
}*/
|
mod element;
mod style;
mod update;
use crate::{
addon::{Addon, AddonState},
config::{load_config, Config, Flavor},
curse_api,
error::ClientError,
tukui_api, wowinterface_api, Result,
};
use iced::{
button, pick_list, scrollable, Application, Column, Command, Container, Element, Length,
Settings, Space,
};
use std::path::PathBuf;
use image::ImageFormat;
static WINDOW_ICON: &[u8] = include_bytes!("../../resources/windows/ajour.ico");
#[derive(Debug)]
pub enum AjourState {
Idle,
Error(ClientError),
}
#[derive(Debug, Clone)]
pub enum Interaction {
OpenDirectory,
Settings,
Refresh,
UpdateAll,
Update(String),
Delete(String),
Expand(String),
}
#[derive(Debug)]
pub enum Message {
Parse(Result<Config>),
ParsedAddons(Result<Vec<Addon>>),
PartialParsedAddons(Result<Vec<Addon>>),
DownloadedAddon((String, Result<()>)),
UnpackedAddon((String, Result<()>)),
CursePackage((String, Result<curse_api::Package>)),
CursePackages((String, u32, Result<Vec<curse_api::Package>>)),
TukuiPackage((String, Result<tukui_api::Package>)),
WowinterfacePackages((String, Result<Vec<wowinterface_api::Package>>)),
Interaction(Interaction),
Error(ClientError),
UpdateDirectory(Option<PathBuf>),
FlavorSelected(Flavor),
}
pub struct Ajour {
state: AjourState,
update_all_button_state: button::State,
refresh_button_state: button::State,
settings_button_state: button::State,
directory_button_state: button::State,
addons_scrollable_state: scrollable::State,
flavor_list_state: pick_list::State<Flavor>,
addons: Vec<Addon>,
config: Config,
expanded_addon: Option<Addon>,
is_showing_settings: bool,
}
impl Default for Ajour {
fn default() -> Self {
Self {
state: AjourState::Idle,
update_all_button_state: Default::default(),
settings_button_state: Default::default(),
refresh_button_state: Default::default(),
directory_button_state: Default::default(),
addons_scrollable_state: Default::default(),
flavor_list_state: Default::default(),
addons: Vec::new(),
config: Config::default(),
expanded_addon: None,
is_showing_settings: false,
}
}
}
impl Application for Ajour {
type Executor = iced::executor::Default;
type Message = Message;
type Flags = ();
fn new(_flags: ()) -> (Self, Command<Message>) {
(
Ajour::default(),
Command::perform(load_config(), Message::Parse),
)
}
fn title(&self) -> String {
String::from("Ajour")
}
fn update(&mut self, message: Message) -> Command<Message> {
match update::handle_message(self, message) {
Ok(x) => x,
Err(e) => Command::perform(async { e }, Message::Error),
}
}
fn view(&mut self) -> Element<Message> {
// Menu container at the top of the applications.
// This has all global buttons, such as Settings, Update All, etc.
let menu_container = element::menu_container(
&mut self.update_all_button_state,
&mut self.refresh_button_state,
&mut self.settings_button_state,
&self.state,
&self.addons,
&self.config,
);
// Addon row titles is a row of titles above the addon scrollable.
// This is to add titles above each section of the addon row, to let
// the user easily identify what the value is.
let addon_row_titles = element::addon_row_titles(&self.addons);
// A scrollable list containing rows.
// Each row holds data about a single addon.
let mut addons_scrollable = element::addon_scrollable(&mut self.addons_scrollable_state);
// Loops though the addons.
let hidden_addons = self.config.addons.hidden.as_ref();
for addon in &mut self
.addons
.iter_mut()
.filter(|a| a.is_parent() && !a.is_hidden(&hidden_addons))
{
// Checks if the current addon is expanded.
let is_addon_expanded = match &self.expanded_addon {
Some(expanded_addon) => addon.id == expanded_addon.id,
None => false,
};
// A container cell which has all data about the current addon.
// If the addon is expanded, then this is also included in this container.
let addon_data_cell = element::addon_data_cell(addon, is_addon_expanded);
// Adds the addon data cell to the scrollable.
addons_scrollable = addons_scrollable.push(addon_data_cell);
}
// Bottom space below the scrollable.
let bottom_space = Space::new(Length::FillPortion(1), Length::Units(10));
// This column gathers all the other elements together.
let mut content = Column::new().push(menu_container);
// This ensure we only draw settings, when we need to.
if self.is_showing_settings {
// Settings container, containing all data releated to settings.
let settings_container = element::settings_container(
&mut self.directory_button_state,
&mut self.flavor_list_state,
&self.config,
);
// Space below settings.
let space = Space::new(Length::Fill, Length::Units(10));
// Adds the settings container.
content = content.push(settings_container).push(space);
}
// Adds the rest of the elements to the content column.
content = content
.push(addon_row_titles)
.push(addons_scrollable)
.push(bottom_space)
.padding(3); // small padding to make scrollbar fit better.
// Finally wraps everything in a container.
Container::new(content)
.width(Length::Fill)
.height(Length::Fill)
.style(style::Content)
.into()
}
}
/// Starts the GUI.
/// This function does not return.
pub fn run() {
let mut settings = Settings::default();
settings.window.size = (900, 620);
// Enforce the usage of dedicated gpu if available.
settings.antialiasing = true;
// Sets the Window icon.
let image = image::load_from_memory_with_format(WINDOW_ICON, ImageFormat::Ico)
.expect("loading icon")
.to_rgba();
let (width, height) = image.dimensions();
let icon = iced::window::Icon::from_rgba(image.into_raw(), width, height);
settings.window.icon = Some(icon.unwrap());
// Runs the GUI.
Ajour::run(settings);
}
|
use std::convert::Infallible;
use crate::algorithms::DiffHook;
use crate::{group_diff_ops, DiffOp};
/// A [`DiffHook`] that captures all diff operations.
#[derive(Default, Clone)]
pub struct Capture(Vec<DiffOp>);
impl Capture {
/// Creates a new capture hook.
pub fn new() -> Capture {
Capture::default()
}
/// Converts the capture hook into a vector of ops.
pub fn into_ops(self) -> Vec<DiffOp> {
self.0
}
/// Isolate change clusters by eliminating ranges with no changes.
///
/// This is equivalent to calling [`group_diff_ops`] on [`Capture::into_ops`].
pub fn into_grouped_ops(self, n: usize) -> Vec<Vec<DiffOp>> {
group_diff_ops(self.into_ops(), n)
}
/// Accesses the captured operations.
pub fn ops(&self) -> &[DiffOp] {
&self.0
}
}
impl DiffHook for Capture {
type Error = Infallible;
#[inline(always)]
fn equal(&mut self, old_index: usize, new_index: usize, len: usize) -> Result<(), Self::Error> {
self.0.push(DiffOp::Equal {
old_index,
new_index,
len,
});
Ok(())
}
#[inline(always)]
fn delete(
&mut self,
old_index: usize,
old_len: usize,
new_index: usize,
) -> Result<(), Self::Error> {
self.0.push(DiffOp::Delete {
old_index,
old_len,
new_index,
});
Ok(())
}
#[inline(always)]
fn insert(
&mut self,
old_index: usize,
new_index: usize,
new_len: usize,
) -> Result<(), Self::Error> {
self.0.push(DiffOp::Insert {
old_index,
new_index,
new_len,
});
Ok(())
}
#[inline(always)]
fn replace(
&mut self,
old_index: usize,
old_len: usize,
new_index: usize,
new_len: usize,
) -> Result<(), Self::Error> {
self.0.push(DiffOp::Replace {
old_index,
old_len,
new_index,
new_len,
});
Ok(())
}
}
#[test]
fn test_capture_hook_grouping() {
use crate::algorithms::{diff_slices, Algorithm, Replace};
let rng = (1..100).collect::<Vec<_>>();
let mut rng_new = rng.clone();
rng_new[10] = 1000;
rng_new[13] = 1000;
rng_new[16] = 1000;
rng_new[34] = 1000;
let mut d = Replace::new(Capture::new());
diff_slices(Algorithm::Myers, &mut d, &rng, &rng_new).unwrap();
let ops = d.into_inner().into_grouped_ops(3);
let tags = ops
.iter()
.map(|group| group.iter().map(|x| x.as_tag_tuple()).collect::<Vec<_>>())
.collect::<Vec<_>>();
insta::assert_debug_snapshot!(ops);
insta::assert_debug_snapshot!(tags);
}
|
use crate::vec3::{Point3, Vec3, random_in_uint_disk};
use crate::ray::Ray;
pub struct Camera {
origin: Point3,
lower_left_corner: Point3,
horizontal: Vec3,
vertical: Vec3,
u: Vec3,
v: Vec3,
w: Vec3,
lens_radius: f32,
}
impl Camera {
pub fn camera(lookfrom: Point3, lookat: Point3, vup: Vec3, vfov: f32, aspect_ratio: f32, aperature: f32, focus_dist: f32) -> Self {
let theta = f32::to_radians(vfov);
let h = (theta/2.0).tan();
let viewport_height = 2.0 * h;
let viewport_width = aspect_ratio * viewport_height;
let w = Vec3::unit_vector(&(lookfrom - lookat));
let u = Vec3::unit_vector(&vup.cross(w));
let v = Vec3::cross(&w, u);
let origin = lookfrom;
let horizontal = u * viewport_width * focus_dist;
let vertical = v * viewport_height * focus_dist;
let lower_left_corner = origin - horizontal/2.0 - vertical/2.0 - w*focus_dist;
let lens_radius = aperature / 2.0;
Camera {
origin,
lower_left_corner,
horizontal,
vertical,
u,
v,
w,
lens_radius,
}
}
pub fn get_ray(&self, s: f32, t: f32) -> Ray {
let rd = random_in_uint_disk() * self.lens_radius;
let offset = self.u * rd.x() + self.v * rd.y();
Ray::ray(
self.origin + offset,
self.lower_left_corner + self.horizontal*s + self.vertical*t - self.origin - offset)
}
} |
mod sound {
fn guitar() {
}
pub mod instrument {
pub mod woodwind {
pub fn clarinet() {}
}
pub fn clarinet() {}
}
mod voice {
}
}
fn main() {
crate::sound::instrument::clarinet();
sound::instrument::clarinet();
sound::instrument::woodwind::clarinet();
{
use crate::sound::instrument::woodwind;
woodwind::clarinet();
}
//woodwind::clarinet(); //<- compilation error, as woodwind name not in scope here
let mut v = plant::Vegetable::new("brinjal");
v.name = String::from("eggplant");
let _order1 = menu::Appetizer::Soup;
let _order2 = menu::Appetizer::Salad;
}
mod plant {
pub struct Vegetable {
pub name: String, //public
id: i32, // private
}
impl Vegetable {
pub fn new(name: &str) -> Vegetable {
Vegetable {
name: String::from(name),
id: 1,
}
}
}
}
mod menu {
pub enum Appetizer {
Soup, //public
Salad,//public
}
}
use std::fmt::Result;
use std::io::Result as IoResult;
fn function1() -> Result {
Ok(())
}
fn function2() -> IoResult<()> {
Ok(())
}
mod performance_group {
pub use crate::sound::instrument;
pub fn clarinet_trio() {
instrument::clarinet();
instrument::clarinet();
instrument::clarinet();
}
}
fn pub_use_use() {
performance_group::clarinet_trio();
performance_group::instrument::clarinet();
}
fn common_use() {
{
use std::cmp::Ordering;
use std::io;
}
{
use std::{cmp::Ordering, io};
}
{
use std::io;
use std::io::Write;
}
{
use std::io::{self, Write};
}
{use std::collections::*;}
}
|
#![allow(non_snake_case, non_camel_case_types, non_upper_case_globals, clashing_extern_declarations, clippy::all)]
#[cfg(feature = "Devices_Pwm_Provider")]
pub mod Provider;
#[link(name = "windows")]
extern "system" {}
pub type PwmController = *mut ::core::ffi::c_void;
pub type PwmPin = *mut ::core::ffi::c_void;
#[repr(transparent)]
pub struct PwmPulsePolarity(pub i32);
impl PwmPulsePolarity {
pub const ActiveHigh: Self = Self(0i32);
pub const ActiveLow: Self = Self(1i32);
}
impl ::core::marker::Copy for PwmPulsePolarity {}
impl ::core::clone::Clone for PwmPulsePolarity {
fn clone(&self) -> Self {
*self
}
}
|
use environment::{LocalEnv, GraphChain};
use io::{Io, open_read};
use document::{NodeP, Ptr};
use std::boxed::FnBox;
use futures::Future;
use futures::future::{ok, join_all};
use super::{LoomError};
use istring::IString;
pub fn register(env: &mut LocalEnv) {
// env.add_command("fontsize", cmd_fontsize);
env.add_command("group", cmd_group);
env.add_command("hyphens", cmd_hyphens);
env.add_command("load", cmd_load);
env.add_command("use", cmd_use);
env.add_command("symbol", cmd_symbol);
env.add_command("aside", cmd_aside);
}
#[allow(unused_macros)]
macro_rules! try_msg {
($msg:expr ; $arg:expr) => {
match $expr {
Ok(r) => r,
Err(e) => CommandError {
msg: $msg,
cause: e.into()
}
}
};
}
macro_rules! cmd_args {
($args:expr; $($out:ident),+) => {
let mut iter = $args.into_iter();
$(
let $out = match iter.next() {
Some(v) => v,
None => return Err(LoomError::MissingArg(stringify!(out)))
};
)+
};
}
fn complete<F: FnOnce(&GraphChain, &mut LocalEnv) + 'static>(f: F) -> CommandComplete {
(box f) as CommandComplete
}
pub type CommandComplete = Box<FnBox(&GraphChain, &mut LocalEnv)>;
pub type CommandResult = Result<Box<Future<Item=CommandComplete, Error=LoomError>>, LoomError>;
pub type Command = fn(&Io, &GraphChain, Vec<IString>) -> CommandResult;
/*
fn cmd_fontsize(_io: &Io, _env: GraphChain, args: Vec<String>)
-> CommandResult
{
cmd_args!{args;
size,
};
//let scale: f32 = try!(size.parse().into());
//local.set_default_font(RustTypeEngine::default().scale(scale));
println!("fontsize set to {}", size);
box ok(complete(|_| ()))
}
*/
fn cmd_group(io: &Io, _env: &GraphChain, args: Vec<IString>)
-> CommandResult
{
cmd_args!{args;
opening,
name,
closing
};
let io = io.clone();
Ok(box ok(complete(move |env: &GraphChain, local| {
let t = local.get_target(&name).or_else(|| env.get_target(&name)).cloned();
if let Some(n) = t {
local.add_group(opening, closing, n);
} else {
error!(io.log, "group '{}' not found", name);
//Err(LoomError::MissingItem(name.to_string()))
}
})))
}
fn cmd_hyphens(io: &Io, _env: &GraphChain, args: Vec<IString>)
-> CommandResult
{
use hyphenation::Hyphenator;
if args.len() != 1 {
return Err(LoomError::MissingArg("filename"))
}
let f = io.config(|conf| open_read(&conf.data_dir, &args[0]))
.and_then(|data| {
Hyphenator::load(data.to_vec())
.map_err(|e| LoomError::Hyphenator(e))
.and_then(|h|
Ok(complete(|_env: &GraphChain, local: &mut LocalEnv| local.set_hyphenator(h)))
)
});
Ok(box f)
}
fn cmd_load(io: &Io, env: &GraphChain, args: Vec<IString>)
-> CommandResult
{
use nodes::Module;
let modules = args.into_iter()
.map(move |arg| {
// FIXME
let io = io.clone();
let env = env.clone();
let name = arg.to_string();
debug!(io.log, "load '{}'", name);
let filename = format!("{}.yarn", name);
io.config(|conf| open_read(&conf.yarn_dir, &filename))
.and_then(move |data| {
let string = String::from_utf8(data.to_vec()).unwrap();
Module::parse(io, env, string)
})
.map(|module| (module, name))
})
.collect::<Vec<_>>();
let f = join_all(modules)
.and_then(|mut modules: Vec<(NodeP, String)>| {
Ok(complete(move |_env: &GraphChain, local: &mut LocalEnv| {
for (module, name) in modules.drain(..) {
local.add_target(name.into(), module);
}
}))
});
Ok(box f)
}
/// for each argument:
/// 1. first looks whether the name is in the envonmentment
/// 2. if not presend, checks the presens of the name.yarn in CWD
/// 3. if not present, check presence of file in $LOOM_DATA
/// 4. otherwise gives an error
fn cmd_use(io: &Io, _env: &GraphChain, args: Vec<IString>)
-> CommandResult
{
let io = io.clone();
let f = move |env: &GraphChain, local: &mut LocalEnv| {
for arg in args.iter() {
let mut parts = arg.split('/').peekable();
let name = parts.next().unwrap();
let mut current = match local.get_target(name).or_else(|| env.get_target(name)) {
Some(n) => n.clone(),
None => {
warn!(io.log, "use: name '{}' not found", name);
continue;
}
};
while let Some(name) = parts.next() {
if parts.peek().is_some() {
// not the end yet
let next = {
let env = match current.env() {
Some(env) => env,
None => {
warn!(io.log, "use: '{}' has no environment", name);
break;
}
};
if let Some(c) = env.get_target(name) {
c.clone()
} else {
warn!(io.log, "use: name '{}' not found", name);
break;
}
};
current = next;
continue;
}
// end
if name == "*" {
// import all
if let Some(env) = current.env() {
for (t, node) in env.targets() {
local.add_target(t.clone(), node.clone());
}
} else {
warn!(io.log, "use: '{}' has no environment", arg);
}
} else {
local.add_target(name.into(), current.clone());
}
}
}
};
Ok(box ok(complete(f)))
}
fn cmd_symbol(_io: &Io, _env: &GraphChain, args: Vec<IString>)
-> CommandResult
{
cmd_args!{args;
src,
dst
};
Ok(box ok(complete(move |_env: &GraphChain, local: &mut LocalEnv| {
local.add_symbol(&src, &dst)
})))
}
fn cmd_aside(io: &Io, _: &GraphChain, args: Vec<IString>) -> CommandResult
{
cmd_args!{args; name};
let io = io.clone();
use nodes::Aside;
Ok(box ok(complete(move |env: &GraphChain, local: &mut LocalEnv| {
let target = match local.get_target(&name).or_else(|| env.get_target(&name)) {
Some(target) => target.clone(),
None => return warn!(io.log, "aside: can't find target: {}", name)
};
let node = Ptr::new(Aside::new(target));
local.add_target(name, node.into());
})))
}
|
pub mod binary;
pub mod current_symbol_table;
mod subfield;
mod typed_value;
|
// SPDX-License-Identifier: (MIT OR Apache-2.0)
pub use self::isodirectory::{ISODirectory, ISODirectoryIterator};
pub use self::isofile::{ISOFile, ISOFileReader};
use crate::parse::{DirectoryEntryHeader, FileFlags};
use crate::{FileRef, ISO9660Reader, Result};
mod isodirectory;
mod isofile;
#[derive(Clone, Debug)]
pub enum DirectoryEntry<T: ISO9660Reader> {
Directory(ISODirectory<T>),
File(ISOFile<T>),
}
impl<T: ISO9660Reader> DirectoryEntry<T> {
pub(crate) fn new(
header: DirectoryEntryHeader,
identifier: String,
file: FileRef<T>,
) -> Result<Self> {
if header.file_flags.contains(FileFlags::DIRECTORY) {
Ok(DirectoryEntry::Directory(ISODirectory::new(
header, identifier, file,
)))
} else {
Ok(DirectoryEntry::File(ISOFile::new(
header, identifier, file,
)?))
}
}
pub fn header(&self) -> &DirectoryEntryHeader {
match *self {
DirectoryEntry::Directory(ref dir) => &dir.header,
DirectoryEntry::File(ref file) => &file.header,
}
}
pub fn identifier(&self) -> &str {
match *self {
DirectoryEntry::Directory(ref dir) => &dir.identifier,
DirectoryEntry::File(ref file) => &file.identifier,
}
}
}
|
use super::{Lab, EPSILON, KAPPA};
use std::arch::x86_64::*;
use std::{iter, mem};
static BLANK_RGB: [u8; 3] = [0u8; 3];
/// Converts a slice of `[u8; 3]` RGB triples to `Lab`s using 256-bit SIMD operations.
///
/// # Panics
/// This function will panic if executed on a non-x86_64 CPU or one without AVX
/// and SSE 4.1 support.
/// ```ignore
/// if is_x86_feature_detected!("avx") && is_x86_feature_detected!("sse4.1") {
/// lab::simd::rgbs_to_labs(&rgbs);
/// }
/// ```
pub fn rgbs_to_labs(rgbs: &[[u8; 3]]) -> Vec<Lab> {
let chunks = rgbs.chunks_exact(8);
let remainder = chunks.remainder();
let mut vs = chunks.fold(Vec::with_capacity(rgbs.len()), |mut v, rgbs| {
let labs = unsafe { slice_rgbs_to_slice_labs(rgbs) };
v.extend_from_slice(&labs);
v
});
// While we could simplify this block by just calling the scalar version
// of the code on the remainder, there are some variations between scalar
// and SIMD floating point math (especially on TravisCI for some reason?)
// and I don't want the trailing N items to be computed by a different
// algorithm.
if remainder.len() > 0 {
let rgbs: Vec<[u8; 3]> = remainder
.iter()
.cloned()
.chain(iter::repeat(BLANK_RGB))
.take(8)
.collect();
let labs = unsafe { slice_rgbs_to_slice_labs(&rgbs) };
vs.extend_from_slice(&labs[..remainder.len()]);
}
vs
}
/// Convert a slice of 8 `[u8; 3]` RGB tripes into an array of 8 `Lab` structs.
///
/// This is the fundamental unit of work that `lab::simd::rgbs_to_labs` performs.
/// If you need to control how to parallelize this work, use this function.
///
/// Only the first 8 elements of the input slice will be converted. The example given
/// is very close to the implementation of `lab::simd::rgbs_to_labs`. Because this
/// library makes no assumptions about how to parallelize work, use this function
/// to add parallelization with Rayon, etc.
///
/// # Example
/// ```
/// # use lab::Lab;
/// # use std::iter;
/// # let rgbs: Vec<[u8; 3]> = vec![];
/// ##[cfg(target_arch = "x86_64")]
/// {
/// if is_x86_feature_detected!("avx") && is_x86_feature_detected!("sse4.1") {
/// let chunks = rgbs.chunks_exact(8);
/// let remainder = chunks.remainder();
/// // Parallelizing work with Rayon? Do it here, at `.fold()`
/// let mut vs = chunks.fold(Vec::with_capacity(rgbs.len()), |mut v, rgbs| {
/// let labs = lab::simd::rgbs_to_labs_chunk(rgbs);
/// v.extend_from_slice(&labs);
/// v
/// });
///
/// if remainder.len() > 0 {
/// const BLANK_RGB: [u8; 3] = [0u8; 3];
/// let rgbs: Vec<[u8; 3]> =
/// remainder.iter().cloned().chain(iter::repeat(BLANK_RGB))
/// .take(8)
/// .collect();
///
/// let labs = lab::simd::rgbs_to_labs_chunk(&rgbs);
/// vs.extend_from_slice(&labs[..remainder.len()]);
/// }
/// }
/// }
/// ```
///
/// # Panics
/// This function will panic of the input slice has fewer than 8 elements. Consider
/// padding the input slice with blank values and then truncating the result.
///
/// Additionally, it will panic if run on a CPU that does not support x86_64's AVX
/// and SSE 4.1 instructions.
pub fn rgbs_to_labs_chunk(rgbs: &[[u8; 3]]) -> [Lab; 8] {
unsafe { slice_rgbs_to_slice_labs(rgbs) }
}
unsafe fn slice_rgbs_to_slice_labs(rgbs: &[[u8; 3]]) -> [Lab; 8] {
let (r, g, b) = rgb_slice_to_simd(rgbs);
let (x, y, z) = rgbs_to_xyzs(r, g, b);
let (l, a, b) = xyzs_to_labs(x, y, z);
simd_to_lab_array(l, a, b)
}
#[inline]
unsafe fn rgb_slice_to_simd(rgbs: &[[u8; 3]]) -> (__m256, __m256, __m256) {
let r = _mm256_set_ps(
rgbs[0][0] as f32,
rgbs[1][0] as f32,
rgbs[2][0] as f32,
rgbs[3][0] as f32,
rgbs[4][0] as f32,
rgbs[5][0] as f32,
rgbs[6][0] as f32,
rgbs[7][0] as f32,
);
let g = _mm256_set_ps(
rgbs[0][1] as f32,
rgbs[1][1] as f32,
rgbs[2][1] as f32,
rgbs[3][1] as f32,
rgbs[4][1] as f32,
rgbs[5][1] as f32,
rgbs[6][1] as f32,
rgbs[7][1] as f32,
);
let b = _mm256_set_ps(
rgbs[0][2] as f32,
rgbs[1][2] as f32,
rgbs[2][2] as f32,
rgbs[3][2] as f32,
rgbs[4][2] as f32,
rgbs[5][2] as f32,
rgbs[6][2] as f32,
rgbs[7][2] as f32,
);
(r, g, b)
}
pub(super) unsafe fn rgbs_to_xyzs(r: __m256, g: __m256, b: __m256) -> (__m256, __m256, __m256) {
let r = rgbs_to_xyzs_map(r);
let g = rgbs_to_xyzs_map(g);
let b = rgbs_to_xyzs_map(b);
let x = {
let prod_r = _mm256_mul_ps(r, _mm256_set1_ps(0.4124564390896921));
let prod_g = _mm256_mul_ps(g, _mm256_set1_ps(0.357576077643909));
let prod_b = _mm256_mul_ps(b, _mm256_set1_ps(0.18043748326639894));
_mm256_add_ps(_mm256_add_ps(prod_r, prod_g), prod_b)
};
let y = {
let prod_r = _mm256_mul_ps(r, _mm256_set1_ps(0.21267285140562248));
let prod_g = _mm256_mul_ps(g, _mm256_set1_ps(0.715152155287818));
let prod_b = _mm256_mul_ps(b, _mm256_set1_ps(0.07217499330655958));
_mm256_add_ps(_mm256_add_ps(prod_r, prod_g), prod_b)
};
let z = {
let prod_r = _mm256_mul_ps(r, _mm256_set1_ps(0.019333895582329317));
let prod_g = _mm256_mul_ps(g, _mm256_set1_ps(0.119192025881303));
let prod_b = _mm256_mul_ps(b, _mm256_set1_ps(0.9503040785363677));
_mm256_add_ps(_mm256_add_ps(prod_r, prod_g), prod_b)
};
(x, y, z)
}
#[inline]
unsafe fn rgbs_to_xyzs_map(c: __m256) -> __m256 {
let mask = _mm256_cmp_ps(c, _mm256_set1_ps(10.0), _CMP_GT_OQ);
let true_branch = {
const A: f32 = 0.055 * 255.0;
const D: f32 = 1.055 * 255.0;
let t0 = _mm256_div_ps(_mm256_add_ps(c, _mm256_set1_ps(A)), _mm256_set1_ps(D));
let mut unpacked: [f32; 8] = mem::transmute(t0);
for el in unpacked.iter_mut() {
*el = el.powf(2.4);
}
mem::transmute(unpacked)
};
let false_branch = {
const D: f32 = 12.92 * 255.0;
_mm256_div_ps(c, _mm256_set1_ps(D))
};
_mm256_blendv_ps(false_branch, true_branch, mask)
}
pub(super) unsafe fn xyzs_to_labs(x: __m256, y: __m256, z: __m256) -> (__m256, __m256, __m256) {
let x = xyzs_to_labs_map(_mm256_div_ps(x, _mm256_set1_ps(0.95047)));
let y = xyzs_to_labs_map(y);
let z = xyzs_to_labs_map(_mm256_div_ps(z, _mm256_set1_ps(1.08883)));
let l = _mm256_add_ps(
_mm256_mul_ps(y, _mm256_set1_ps(116.0)),
_mm256_set1_ps(-16.0),
);
let a = _mm256_mul_ps(_mm256_sub_ps(x, y), _mm256_set1_ps(500.0));
let b = _mm256_mul_ps(_mm256_sub_ps(y, z), _mm256_set1_ps(200.0));
(l, a, b)
}
#[inline]
unsafe fn xyzs_to_labs_map(c: __m256) -> __m256 {
let mask = _mm256_cmp_ps(c, _mm256_set1_ps(EPSILON), _CMP_GT_OQ);
// do false branch first
let false_branch = _mm256_div_ps(
_mm256_add_ps(
_mm256_mul_ps(c, _mm256_set1_ps(KAPPA)),
_mm256_set1_ps(16.0),
),
_mm256_set1_ps(116.0),
);
let true_branch = {
let mut unpacked: [f32; 8] = mem::transmute(c);
let unpacked_mask: [f32; 8] = mem::transmute(mask);
for (el, test) in unpacked.iter_mut().zip(unpacked_mask.iter()) {
if test.is_nan() {
// NaN == true, 0.0 == false
*el = el.powf(1.0 / 3.0)
}
}
mem::transmute(unpacked)
};
_mm256_blendv_ps(false_branch, true_branch, mask)
}
pub(super) unsafe fn simd_to_lab_array(l: __m256, a: __m256, b: __m256) -> [Lab; 8] {
let l: [f32; 8] = mem::transmute(l);
let a: [f32; 8] = mem::transmute(a);
let b: [f32; 8] = mem::transmute(b);
// Per `https://doc.rust-lang.org/std/mem/union.MaybeUninit.html` this `assume_init`
// is safe because the MaybeUninits inside the array don't require initialization?
let mut labs: [mem::MaybeUninit<Lab>; 8] = mem::MaybeUninit::uninit().assume_init();
for (((&l, &a), &b), lab) in l
.iter()
.zip(a.iter())
.zip(b.iter())
.rev()
.zip(labs.iter_mut())
{
*lab = mem::MaybeUninit::new(Lab { l, a, b });
}
mem::transmute(labs)
}
// #[inline]
// unsafe fn clamp(r: __m256, g: __m256, b: __m256) -> (__m256, __m256, __m256) {
// let max = _mm256_set1_ps(1.0);
// let min = _mm256_set1_ps(0.0);
// let r = _mm256_max_ps(_mm256_min_ps(r, max), min);
// let g = _mm256_max_ps(_mm256_min_ps(g, max), min);
// let b = _mm256_max_ps(_mm256_min_ps(b, max), min);
// (r, g, b)
// }
// #[inline]
// unsafe fn normalize_short_to_unit(r: __m256i, g: __m256i, b: __m256i) -> (__m256, __m256, __m256) {
// let normalizer = _mm256_set1_ps(255.0);
// let r = _mm256_div_ps(r, normalizer);
// let g = _mm256_div_ps(g, normalizer);
// let b = _mm256_div_ps(b, normalizer);
// (r, g, b)
// }
// #[cfg(all(target_cpu = "x86_64", target_feature = "avx", target_feature = "sse4.1"))]
#[cfg(test)]
mod test {
use super::super::super::{rgbs_to_labs, simd};
use rand;
use rand::distributions::Standard;
use rand::Rng;
lazy_static! {
static ref RGBS: Vec<[u8; 3]> = {
let rand_seed = [0u8; 32];
let mut rng: rand::StdRng = rand::SeedableRng::from_seed(rand_seed);
rng.sample_iter(&Standard).take(512).collect()
};
}
#[test]
fn test_simd_rgbs_to_labs() {
let rgbs = vec![
[253, 120, 138], // Lab { l: 66.6348, a: 52.260696, b: 14.850557 }
[25, 20, 22], // Lab { l: 6.9093895, a: 2.8204322, b: -0.45616925 }
[63, 81, 181], // Lab { l: 38.336494, a: 25.586218, b: -55.288517 }
[21, 132, 102], // Lab { l: 49.033485, a: -36.959187, b: 7.9363704 }
[255, 193, 7], // Lab { l: 81.519325, a: 9.4045105, b: 82.69791 }
[233, 30, 99], // Lab { l: 50.865776, a: 74.61989, b: 15.343171 }
[155, 96, 132], // Lab { l: 48.260345, a: 29.383003, b: -9.950054 }
[249, 165, 33], // Lab { l: 74.29188, a: 21.827251, b: 72.75864 }
];
let labs_non_simd = rgbs_to_labs(&rgbs);
let labs_simd = simd::rgbs_to_labs(&rgbs);
assert_eq!(labs_simd, labs_non_simd);
}
#[test]
fn test_simd_rgbs_to_labs_many() {
let labs_non_simd = rgbs_to_labs(&RGBS);
let labs_simd = simd::rgbs_to_labs(&RGBS);
assert_eq!(labs_simd, labs_non_simd);
}
#[test]
fn test_simd_rgbs_to_labs_unsaturated() {
let rgbs = vec![[253, 120, 138]];
let labs_non_simd = rgbs_to_labs(&rgbs);
let labs_simd = simd::rgbs_to_labs(&rgbs);
assert_eq!(labs_simd, labs_non_simd);
}
}
|
#[doc = "Reader of register SR"]
pub type R = crate::R<u32, super::SR>;
#[doc = "Writer for register SR"]
pub type W = crate::W<u32, super::SR>;
#[doc = "Register SR `reset()`'s with value 0"]
impl crate::ResetValue for super::SR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `BSY`"]
pub type BSY_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `BSY`"]
pub struct BSY_W<'a> {
w: &'a mut W,
}
impl<'a> BSY_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 `WBNE`"]
pub type WBNE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `WBNE`"]
pub struct WBNE_W<'a> {
w: &'a mut W,
}
impl<'a> WBNE_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 `QW`"]
pub type QW_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `QW`"]
pub struct QW_W<'a> {
w: &'a mut W,
}
impl<'a> QW_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
self.w
}
}
#[doc = "Reader of field `CRC_BUSY`"]
pub type CRC_BUSY_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CRC_BUSY`"]
pub struct CRC_BUSY_W<'a> {
w: &'a mut W,
}
impl<'a> CRC_BUSY_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
self.w
}
}
#[doc = "Reader of field `EOP`"]
pub type EOP_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `EOP`"]
pub struct EOP_W<'a> {
w: &'a mut W,
}
impl<'a> EOP_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
self.w
}
}
#[doc = "Reader of field `WRPERR`"]
pub type WRPERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `WRPERR`"]
pub struct WRPERR_W<'a> {
w: &'a mut W,
}
impl<'a> WRPERR_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 `PGSERR`"]
pub type PGSERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `PGSERR`"]
pub struct PGSERR_W<'a> {
w: &'a mut W,
}
impl<'a> PGSERR_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18);
self.w
}
}
#[doc = "Reader of field `STRBERR`"]
pub type STRBERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `STRBERR`"]
pub struct STRBERR_W<'a> {
w: &'a mut W,
}
impl<'a> STRBERR_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 19)) | (((value as u32) & 0x01) << 19);
self.w
}
}
#[doc = "Reader of field `INCERR`"]
pub type INCERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `INCERR`"]
pub struct INCERR_W<'a> {
w: &'a mut W,
}
impl<'a> INCERR_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 `OPERR`"]
pub type OPERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `OPERR`"]
pub struct OPERR_W<'a> {
w: &'a mut W,
}
impl<'a> OPERR_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 `RDPERR`"]
pub type RDPERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RDPERR`"]
pub struct RDPERR_W<'a> {
w: &'a mut W,
}
impl<'a> RDPERR_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23);
self.w
}
}
#[doc = "Reader of field `RDSERR`"]
pub type RDSERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RDSERR`"]
pub struct RDSERR_W<'a> {
w: &'a mut W,
}
impl<'a> RDSERR_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
self.w
}
}
#[doc = "Reader of field `SNECCERR1`"]
pub type SNECCERR1_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SNECCERR1`"]
pub struct SNECCERR1_W<'a> {
w: &'a mut W,
}
impl<'a> SNECCERR1_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25);
self.w
}
}
#[doc = "Reader of field `DBECCERR`"]
pub type DBECCERR_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `DBECCERR`"]
pub struct DBECCERR_W<'a> {
w: &'a mut W,
}
impl<'a> DBECCERR_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
self.w
}
}
#[doc = "Reader of field `CRCEND`"]
pub type CRCEND_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `CRCEND`"]
pub struct CRCEND_W<'a> {
w: &'a mut W,
}
impl<'a> CRCEND_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
}
}
impl R {
#[doc = "Bit 0 - Bank 1 ongoing program flag"]
#[inline(always)]
pub fn bsy(&self) -> BSY_R {
BSY_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - Bank 1 write buffer not empty flag"]
#[inline(always)]
pub fn wbne(&self) -> WBNE_R {
WBNE_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Bank 1 wait queue flag"]
#[inline(always)]
pub fn qw(&self) -> QW_R {
QW_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 3 - Bank 1 CRC busy flag"]
#[inline(always)]
pub fn crc_busy(&self) -> CRC_BUSY_R {
CRC_BUSY_R::new(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 16 - Bank 1 end-of-program flag"]
#[inline(always)]
pub fn eop(&self) -> EOP_R {
EOP_R::new(((self.bits >> 16) & 0x01) != 0)
}
#[doc = "Bit 17 - Bank 1 write protection error flag"]
#[inline(always)]
pub fn wrperr(&self) -> WRPERR_R {
WRPERR_R::new(((self.bits >> 17) & 0x01) != 0)
}
#[doc = "Bit 18 - Bank 1 programming sequence error flag"]
#[inline(always)]
pub fn pgserr(&self) -> PGSERR_R {
PGSERR_R::new(((self.bits >> 18) & 0x01) != 0)
}
#[doc = "Bit 19 - Bank 1 strobe error flag"]
#[inline(always)]
pub fn strberr(&self) -> STRBERR_R {
STRBERR_R::new(((self.bits >> 19) & 0x01) != 0)
}
#[doc = "Bit 21 - Bank 1 inconsistency error flag"]
#[inline(always)]
pub fn incerr(&self) -> INCERR_R {
INCERR_R::new(((self.bits >> 21) & 0x01) != 0)
}
#[doc = "Bit 22 - Bank 1 write/erase error flag"]
#[inline(always)]
pub fn operr(&self) -> OPERR_R {
OPERR_R::new(((self.bits >> 22) & 0x01) != 0)
}
#[doc = "Bit 23 - Bank 1 read protection error flag"]
#[inline(always)]
pub fn rdperr(&self) -> RDPERR_R {
RDPERR_R::new(((self.bits >> 23) & 0x01) != 0)
}
#[doc = "Bit 24 - Bank 1 secure error flag"]
#[inline(always)]
pub fn rdserr(&self) -> RDSERR_R {
RDSERR_R::new(((self.bits >> 24) & 0x01) != 0)
}
#[doc = "Bit 25 - Bank 1 single correction error flag"]
#[inline(always)]
pub fn sneccerr1(&self) -> SNECCERR1_R {
SNECCERR1_R::new(((self.bits >> 25) & 0x01) != 0)
}
#[doc = "Bit 26 - Bank 1 ECC double detection error flag"]
#[inline(always)]
pub fn dbeccerr(&self) -> DBECCERR_R {
DBECCERR_R::new(((self.bits >> 26) & 0x01) != 0)
}
#[doc = "Bit 27 - Bank 1 CRC-complete flag"]
#[inline(always)]
pub fn crcend(&self) -> CRCEND_R {
CRCEND_R::new(((self.bits >> 27) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - Bank 1 ongoing program flag"]
#[inline(always)]
pub fn bsy(&mut self) -> BSY_W {
BSY_W { w: self }
}
#[doc = "Bit 1 - Bank 1 write buffer not empty flag"]
#[inline(always)]
pub fn wbne(&mut self) -> WBNE_W {
WBNE_W { w: self }
}
#[doc = "Bit 2 - Bank 1 wait queue flag"]
#[inline(always)]
pub fn qw(&mut self) -> QW_W {
QW_W { w: self }
}
#[doc = "Bit 3 - Bank 1 CRC busy flag"]
#[inline(always)]
pub fn crc_busy(&mut self) -> CRC_BUSY_W {
CRC_BUSY_W { w: self }
}
#[doc = "Bit 16 - Bank 1 end-of-program flag"]
#[inline(always)]
pub fn eop(&mut self) -> EOP_W {
EOP_W { w: self }
}
#[doc = "Bit 17 - Bank 1 write protection error flag"]
#[inline(always)]
pub fn wrperr(&mut self) -> WRPERR_W {
WRPERR_W { w: self }
}
#[doc = "Bit 18 - Bank 1 programming sequence error flag"]
#[inline(always)]
pub fn pgserr(&mut self) -> PGSERR_W {
PGSERR_W { w: self }
}
#[doc = "Bit 19 - Bank 1 strobe error flag"]
#[inline(always)]
pub fn strberr(&mut self) -> STRBERR_W {
STRBERR_W { w: self }
}
#[doc = "Bit 21 - Bank 1 inconsistency error flag"]
#[inline(always)]
pub fn incerr(&mut self) -> INCERR_W {
INCERR_W { w: self }
}
#[doc = "Bit 22 - Bank 1 write/erase error flag"]
#[inline(always)]
pub fn operr(&mut self) -> OPERR_W {
OPERR_W { w: self }
}
#[doc = "Bit 23 - Bank 1 read protection error flag"]
#[inline(always)]
pub fn rdperr(&mut self) -> RDPERR_W {
RDPERR_W { w: self }
}
#[doc = "Bit 24 - Bank 1 secure error flag"]
#[inline(always)]
pub fn rdserr(&mut self) -> RDSERR_W {
RDSERR_W { w: self }
}
#[doc = "Bit 25 - Bank 1 single correction error flag"]
#[inline(always)]
pub fn sneccerr1(&mut self) -> SNECCERR1_W {
SNECCERR1_W { w: self }
}
#[doc = "Bit 26 - Bank 1 ECC double detection error flag"]
#[inline(always)]
pub fn dbeccerr(&mut self) -> DBECCERR_W {
DBECCERR_W { w: self }
}
#[doc = "Bit 27 - Bank 1 CRC-complete flag"]
#[inline(always)]
pub fn crcend(&mut self) -> CRCEND_W {
CRCEND_W { w: self }
}
}
|
#[macro_use]
extern crate log;
extern crate env_logger;
extern crate clap;
extern crate csv;
extern crate sli2dli;
extern crate time;
use clap::{App, Arg};
use sli2dli::*;
use std::env;
use std::fs;
use std::os::unix::fs::MetadataExt;
use time::PreciseTime;
use self::manifest::manifest::Manifest;
use self::options::options::Options;
use self::processor::processor::Processor;
use self::profiler::*;
use self::types::formatter::human_format;
const AUTHOR: &'static str = env!("CARGO_PKG_AUTHORS");
const DESCRIPTION: &'static str = env!("CARGO_PKG_DESCRIPTION");
const VERSION: &'static str = env!("CARGO_PKG_VERSION");
fn main() {
let _p = ProfileObject::new();
let matches = App::new(DESCRIPTION)
.version(VERSION)
.author(AUTHOR)
.about("Disk Usage Information")
.arg(Arg::with_name("verbose")
.help("Verbose mode")
.short("v")
.long("verbose")
.multiple(true))
.arg(Arg::with_name("cache")
.help("Cache results")
.short("c")
.long("cache"))
.arg(Arg::with_name("channel-size")
.help("Size of sync_channel used by transpose thread")
.takes_value(true)
.long("channel-size")
.default_value("100"))
.arg(Arg::with_name("delimiter")
.help("Delimiter")
.short("d")
.long("delimiter")
.default_value(","))
.arg(Arg::with_name("has-header")
.help("CSV has header row")
.long("has-header"))
.arg(Arg::with_name("flexible")
.help("Records in the CSV data can have different lengths")
.long("flexible"))
.arg(Arg::with_name("manifest")
.help("Path to manifest file")
.takes_value(true)
.short("m")
.long("manifest")
.required(true))
.arg(Arg::with_name("bulk-size")
.help("Size of IO bulk (number of rows)")
.takes_value(true)
.short("b")
.long("bulk-size")
.default_value("100"))
.arg(Arg::with_name("sync-io")
.help("Synchronous IO thread messaging")
.short("s")
.long("sync-io"))
.arg(Arg::with_name("FILE")
.help("Files to process")
.index(1)
.required(true)
.multiple(true))
.get_matches();
let opts = Options::from(&matches);
match matches.occurrences_of("verbose") {
0 => {}
1 => env::set_var("RUST_LOG", "warn"),
2 => env::set_var("RUST_LOG", "info"),
_ => env::set_var("RUST_LOG", "debug"),
}
env_logger::init().unwrap();
debug!("Raw options are {:?}", &matches);
debug!("Parsed options are {:?}", &opts);
if let Ok(delimiter) = String::from_utf8(vec![opts.csv.delimiter]) {
debug!("Delimiter character is {:?}", delimiter);
}
let files: Vec<_> = match matches.values_of("FILE") {
Some(dirs) => dirs.map(|d| d.to_string()).collect(),
_ => vec![String::from(".")],
};
let manifest: Manifest = match opts.manifest.as_ref() {
Some(path) => Manifest::from_file(path),
_ => Manifest { manifest: None },
};
debug!("{:?}", manifest);
for file in &files {
let metadata = Box::new(fs::metadata(&file).unwrap()) as Box<MetadataExt>;
let size = metadata.size();
let start = PreciseTime::now();
debug!("Processing file {:?}", &file);
let mut processor = Processor::default();
processor.process(file, &manifest, &opts);
let diff = start.to(PreciseTime::now());
let elapsed_secs = diff.num_nanoseconds().unwrap() as f64 * 1e-9;
let human_size = human_format(size as f32);
let human_speed = human_format(size as f32 / elapsed_secs as f32);
println!("Stats - size: {:.2}{}B, time: {:.2}s, speed: {:.2}{}Bps",
human_size.0,
human_size.1,
elapsed_secs,
human_speed.0,
human_speed.1);
}
debug!("Finished!");
}
|
pub use VkBufferUsageFlags::*;
#[repr(u32)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VkBufferUsageFlags {
VK_BUFFER_USAGE_TRANSFER_SRC_BIT = 0x0000_0001,
VK_BUFFER_USAGE_TRANSFER_DST_BIT = 0x0000_0002,
VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT = 0x0000_0004,
VK_BUFFER_USAGE_STORAGE_TEXEL_BUFFER_BIT = 0x0000_0008,
VK_BUFFER_USAGE_UNIFORM_BUFFER_BIT = 0x0000_0010,
VK_BUFFER_USAGE_STORAGE_BUFFER_BIT = 0x0000_0020,
VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x0000_0040,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x0000_0080,
VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x0000_0100,
VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_BUFFER_BIT_EXT = 0x0000_0800,
VK_BUFFER_USAGE_TRANSFORM_FEEDBACK_COUNTER_BUFFER_BIT_EXT = 0x0000_1000,
VK_BUFFER_USAGE_CONDITIONAL_RENDERING_BIT_EXT = 0x0000_0200,
VK_BUFFER_USAGE_RAY_TRACING_BIT_NV = 0x0000_0400,
VK_BUFFER_USAGE_SHADER_DEVICE_ADDRESS_BIT_EXT = 0x0002_0000,
}
use crate::SetupVkFlags;
#[repr(C)]
#[derive(Clone, Copy, Eq, PartialEq, Hash, Default)]
pub struct VkBufferUsageFlagBits(u32);
SetupVkFlags!(VkBufferUsageFlags, VkBufferUsageFlagBits);
|
use crate::{util::HashableHashSet, Rewrite, RewritePlan};
use std::hash::Hash;
use super::Id;
/// A collection of timers that have been set for a given actor.
#[derive(Clone, Debug, Hash, PartialEq, Eq, serde::Serialize)]
pub struct Timers<T: Hash + Eq>(HashableHashSet<T>);
impl<T: Hash + Eq> Default for Timers<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> Timers<T>
where
T: Hash + Eq,
{
/// Create a new timer set.
pub fn new() -> Self {
Self(HashableHashSet::new())
}
/// Set a timer.
pub fn set(&mut self, timer: T) -> bool {
self.0.insert(timer)
}
/// Cancel a timer.
pub fn cancel(&mut self, timer: &T) -> bool {
self.0.remove(timer)
}
/// Cancels all timers.
pub fn cancel_all(&mut self) {
self.0.clear();
}
/// Iterate through the currently set timers.
pub fn iter(&self) -> impl Iterator<Item = &T> {
self.0.iter()
}
}
impl<T> Rewrite<Id> for Timers<T>
where
T: Eq + Hash + Clone,
{
fn rewrite<S>(&self, _plan: &RewritePlan<Id, S>) -> Self {
self.clone()
}
}
|
use futures::{try_ready, Future, Poll};
use http;
use linkerd2_error::Error;
/// Determines how a request's response should be classified.
pub trait Classify {
type Class;
type ClassifyEos: ClassifyEos<Class = Self::Class>;
/// Classifies responses.
///
/// Instances are intended to be used as an `http::Extension` that may be
/// cloned to inner stack layers. Cloned instances are **not** intended to
/// share state. Each clone should maintain its own internal state.
type ClassifyResponse: ClassifyResponse<Class = Self::Class, ClassifyEos = Self::ClassifyEos>
+ Clone
+ Send
+ Sync
+ 'static;
fn classify<B>(&self, req: &http::Request<B>) -> Self::ClassifyResponse;
}
/// Classifies a single response.
pub trait ClassifyResponse {
/// A response classification.
type Class;
type ClassifyEos: ClassifyEos<Class = Self::Class>;
/// Produce a stream classifier for this response.
fn start<B>(self, headers: &http::Response<B>) -> Self::ClassifyEos;
/// Classifies the given error.
fn error(self, error: &Error) -> Self::Class;
}
pub trait ClassifyEos {
type Class;
/// Update the classifier with an EOS.
///
/// Because trailers indicate an EOS, a classification must be returned.
fn eos(self, trailers: Option<&http::HeaderMap>) -> Self::Class;
/// Update the classifier with an underlying error.
///
/// Because errors indicate an end-of-stream, a classification must be
/// returned.
fn error(self, error: &Error) -> Self::Class;
}
// Used for stack targets that can produce a `Classify` implementation.
pub trait CanClassify {
type Classify: Classify;
fn classify(&self) -> Self::Classify;
}
#[derive(Debug, Clone)]
pub struct Layer();
#[derive(Clone, Debug)]
pub struct Stack<M> {
inner: M,
}
pub struct MakeFuture<C, F> {
classify: Option<C>,
inner: F,
}
#[derive(Clone, Debug)]
pub struct Service<C, S> {
classify: C,
inner: S,
}
pub fn layer() -> Layer {
Layer()
}
impl<M> tower::layer::Layer<M> for Layer {
type Service = Stack<M>;
fn layer(&self, inner: M) -> Self::Service {
Stack { inner }
}
}
impl<T, M> tower::Service<T> for Stack<M>
where
T: CanClassify,
M: tower::Service<T>,
{
type Response = Service<T::Classify, M::Response>;
type Error = M::Error;
type Future = MakeFuture<T::Classify, M::Future>;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.inner.poll_ready()
}
fn call(&mut self, target: T) -> Self::Future {
let classify = Some(target.classify());
let inner = self.inner.call(target);
MakeFuture { classify, inner }
}
}
impl<C, F: Future> Future for MakeFuture<C, F> {
type Item = Service<C, F::Item>;
type Error = F::Error;
fn poll(&mut self) -> Poll<Self::Item, Self::Error> {
let inner = try_ready!(self.inner.poll());
let classify = self.classify.take().expect("polled more than once");
Ok(Service { classify, inner }.into())
}
}
impl<C, S, A, B> tower::Service<http::Request<A>> for Service<C, S>
where
C: Classify,
S: tower::Service<http::Request<A>, Response = http::Response<B>>,
{
type Response = S::Response;
type Error = S::Error;
type Future = S::Future;
fn poll_ready(&mut self) -> Poll<(), Self::Error> {
self.inner.poll_ready()
}
fn call(&mut self, mut req: http::Request<A>) -> Self::Future {
let classify_rsp = self.classify.classify(&req);
let _ = req.extensions_mut().insert(classify_rsp);
self.inner.call(req)
}
}
|
//! Contains objects representing image parameters
use crate::utils::*;
/// The region parameter defines the rectangular portion of the
/// full image to be returned. Region can be specified by pixel coordinates,
/// percentage or by the value “full”, which specifies that the entire image
/// should be returned.
///
/// The default is Region::Full.
///
/// | Form | Description |
/// |-------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
/// | Full | The complete image is returned, without any cropping. |
/// | Square | The region is defined as an area where the width and height are both equal to the length of the shorter dimension of the complete image. The region may be positioned anywhere in the longer dimension of the image content at the server’s discretion, and centered is often a reasonable default. |
/// | Absolute(x,y,w,h) | The region of the full image to be returned is specified in terms of absolute pixel values. The value of x represents the number of pixels from the 0 position on the horizontal axis. The value of y represents the number of pixels from the 0 position on the vertical axis. Thus the x,y position 0,0 is the upper left-most pixel of the image. w represents the width of the region and h represents the height of the region in pixels. |
/// | Percentage(x,y,w,h) | The region to be returned is specified as a sequence of percentages of the full image’s dimensions, as reported in the image information document. Thus, x represents the number of pixels from the 0 position on the horizontal axis, calculated as a percentage of the reported width. w represents the width of the region, also calculated as a percentage of the reported width. The same applies to y and h respectively. These may be floating point numbers. |#[derive(Debug, Clone, PartialEq)]
#[derive(Debug, Clone, PartialEq)]
pub enum Region {
Full,
Square,
Abs(Absolute),
Pct(Percentage)
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Absolute {
pub x: usize,
pub y: usize,
pub w: usize,
pub h: usize,
}
#[derive(Default, Debug, Clone, PartialEq)]
pub struct Percentage {
pub x: f32,
pub y: f32,
pub w: f32,
pub h: f32,
}
/// The size parameter determines the dimensions to which the extracted region is to be scaled.
///
/// The default is full, this setting will be deprecated in version 3.0 in favor of max
///
/// | Form | Description |
/// |-------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
/// | Full | The image or region is not scaled, and is returned at its full size. Note deprecation warning. |
/// | Max | The image or region is returned at the maximum size available, as indicated by maxWidth, maxHeight, maxArea in the profile description. This is the same as full if none of these properties are provided. |
/// | W(w) | The image or region should be scaled so that its width is exactly equal to w, and the height will be a calculated value that maintains the aspect ratio of the extracted region. |
/// | H(h| The image or region should be scaled so that its height is exactly equal to h, and the width will be a calculated value that maintains the aspect ratio of the extracted region. |
/// | Pct(n) | The width and height of the returned image is scaled to n% of the width and height of the extracted region. The aspect ratio of the returned image is the same as that of the extracted region. |
/// | WH(w,h) | The width and height of the returned image are exactly w and h. The aspect ratio of the returned image may be different than the extracted region, resulting in a distorted image. |
/// | LtWH(w,h) | The image content is scaled for the best fit such that the resulting width and height are less than or equal to the requested width and height. The exact scaling may be determined by the service provider, based on characteristics including image quality and system performance. The dimensions of the returned image content are calculated to maintain the aspect ratio of the extracted region. |
#[derive(Debug, Clone, PartialEq)]
pub enum Size {
Full,
Max,
W(usize),
H(usize),
Pct(u16),
WH(usize,usize),
LtWH(usize, usize)
}
/// The rotation parameter specifies mirroring and rotation. A leading exclamation mark (“!”) indicates that the image should be mirrored by reflection on the vertical axis before any rotation is applied. The numerical value represents the number of degrees of clockwise rotation, and may be any floating point number from 0 to 360.
///
/// The default is Rotation::N(0.0)
///
/// | Form | Description |
/// |------|---------------------------------------------------------|
/// | Normal(n) | The degrees of clockwise rotation from 0 up to 360. |
/// | Mirror(n) | The image should be mirrored and then rotated as above. |
#[derive(Debug, Clone, PartialEq)]
pub enum Rotation {
Normal(f32),
Mirror(f32)
}
/// The quality parameter determines whether the image is delivered in color, grayscale or black and white.
///
/// The default is Quality::ServerDefault
///
/// | Quality | Parameter Returned |
/// |---------|-------------------------------------------------------------------------------------------------------|
/// | color | The image is returned in full color. |
/// | gray | The image is returned in grayscale, where each pixel is black, white or any shade of gray in between. |
/// | bitonal | The image returned is bitonal, where each pixel is either black or white. |
/// | default | The image is returned using the server’s default quality (e.g. color, gray or bitonal) for the image. |
#[derive(Debug, Clone, PartialEq)]
pub enum Quality {
ServerDefault,
Color,
Gray,
Bitonal
}
///The format of the returned image is expressed as an extension at the end of the URI.
///
/// The default is Format::Jpg
///
/// A format value that is unsupported should result in a 400 status code.
#[derive(Debug, Clone, PartialEq)]
pub enum Format {
Jpg,
Tif,
Png,
Gif,
Jp2,
Pdf,
Webp
}
impl ToString for Region {
fn to_string(&self) -> String {
match self {
Region::Full => "full".into(),
Region::Square => "square".into(),
Region::Abs(a) => a.to_string(),
Region::Pct(p) => p.to_string()
}
}
}
impl ToString for Absolute {
fn to_string(&self) -> String {
join_coords(self.x, self.y, self.w, self.h)
}
}
impl ToString for Percentage {
fn to_string(&self) -> String {
let floats =format_floats(vec![self.x, self.y, self.w, self.h]);
let coords = join_coords(&floats[0], &floats[1], &floats[2], &floats[3]);
["pct:".to_string(), coords].join("")
}
}
impl ToString for Size {
fn to_string(&self) -> String {
match self {
Size::Full => "full".into(),
Size::Max => "max".into(),
Size::W(w) => format!("{},", w),
Size::H(h) => format!(",{}", h),
Size::Pct(n) => format!("pct:{}", n),
Size::WH(w,h) => format!("{},{}", w, h),
Size::LtWH(w,h) => format!("!{},{}", w, h)
}
}
}
impl ToString for Rotation {
// limit float values to 3 decimal places
fn to_string(&self) -> String {
match self {
Rotation::Normal(n) => format!("{:.5}", n.to_string()),
Rotation::Mirror(n) => format!("!{:.5}", n.to_string())
}
}
}
impl ToString for Quality {
fn to_string(&self) -> String {
match self {
Quality::ServerDefault => "default".into(),
Quality::Color => "color".into(),
Quality::Bitonal => "bitonal".into(),
Quality::Gray => "gray".into()
}
}
}
impl ToString for Format {
fn to_string(&self) -> String {
match self {
Format::Jpg => "jpg".into(),
Format::Tif => "tif".into(),
Format::Png => "png".into(),
Format::Gif => "gif".into(),
Format::Jp2 => "jp2".into(),
Format::Pdf => "pdf".into(),
Format::Webp => "webp".into()
}
}
}
// Default image settings
impl Default for Region {
fn default() -> Self { Region::Full }
}
impl Default for Size {
fn default() -> Self { Size::Full }
}
impl Default for Rotation {
fn default() -> Self { Rotation::Normal(0.0) }
}
impl Default for Quality {
fn default() -> Self { Quality::ServerDefault }
}
impl Default for Format {
fn default() -> Self { Format::Jpg }
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn absolute_to_string() {
let abs = Absolute {
x: 1,
y: 2,
w: 3,
h: 4
};
assert_eq!("1,2,3,4", abs.to_string());
}
#[test]
fn percentage_to_string() {
let pct = Percentage {
x: 1.2345,
y: 2f32,
w: 3.03,
h: 4.0
};
assert_eq!("pct:1.234,2,3.03,4", pct.to_string());
}
} |
use std::env;
use std::error::Error;
use std::fs;
pub fn genome_from_path(text: &[&str]) -> String {
let mut seq: String = text[0].into();
for kmer in &text[1..] {
seq.push(kmer.chars().last().unwrap());
}
seq
}
fn main() -> Result<(), Box<dyn Error>> {
let input: String = env::args()
.nth(1)
.unwrap_or("data/rosalind_ba3b.txt".into());
let data = fs::read_to_string(input)?;
let lines: Vec<&str> = data.lines().collect();
println!("{}", genome_from_path(&lines));
Ok(())
}
|
use std::env;
fn main() {
let args: Vec<_> = env::args().collect();
if args.len() > 2{
let a = &args[1];
let b = &args[2];
hex_xor(a,b);
}
}
fn hex_xor(a: &str, b: &str){
if a.len() != b.len() {
println!("Lenght error");
}else{
//using for to handle arbitrary large numbers without storing the entire value
for i in 0..a.len(){
let mut d = 0;
let mut c = 0;
match u64::from_str_radix(&a[i..i+1],16){
Ok(n) => d = n,
Err(_) => println!(),
}
match u64::from_str_radix(&b[i..i+1],16){
Ok(n) => c = n,
Err(_) => println!(),
}
print!("{:x}",d ^ c);
}
}
} |
extern crate rand;
pub mod core;
mod tests;
|
#[doc = "Reader of register MPCBB1_VCTR38"]
pub type R = crate::R<u32, super::MPCBB1_VCTR38>;
#[doc = "Writer for register MPCBB1_VCTR38"]
pub type W = crate::W<u32, super::MPCBB1_VCTR38>;
#[doc = "Register MPCBB1_VCTR38 `reset()`'s with value 0"]
impl crate::ResetValue for super::MPCBB1_VCTR38 {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `B1216`"]
pub type B1216_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1216`"]
pub struct B1216_W<'a> {
w: &'a mut W,
}
impl<'a> B1216_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 `B1217`"]
pub type B1217_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1217`"]
pub struct B1217_W<'a> {
w: &'a mut W,
}
impl<'a> B1217_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 `B1218`"]
pub type B1218_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1218`"]
pub struct B1218_W<'a> {
w: &'a mut W,
}
impl<'a> B1218_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
self.w
}
}
#[doc = "Reader of field `B1219`"]
pub type B1219_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1219`"]
pub struct B1219_W<'a> {
w: &'a mut W,
}
impl<'a> B1219_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 3)) | (((value as u32) & 0x01) << 3);
self.w
}
}
#[doc = "Reader of field `B1220`"]
pub type B1220_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1220`"]
pub struct B1220_W<'a> {
w: &'a mut W,
}
impl<'a> B1220_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 `B1221`"]
pub type B1221_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1221`"]
pub struct B1221_W<'a> {
w: &'a mut W,
}
impl<'a> B1221_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
self.w
}
}
#[doc = "Reader of field `B1222`"]
pub type B1222_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1222`"]
pub struct B1222_W<'a> {
w: &'a mut W,
}
impl<'a> B1222_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
self.w
}
}
#[doc = "Reader of field `B1223`"]
pub type B1223_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1223`"]
pub struct B1223_W<'a> {
w: &'a mut W,
}
impl<'a> B1223_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
self.w
}
}
#[doc = "Reader of field `B1224`"]
pub type B1224_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1224`"]
pub struct B1224_W<'a> {
w: &'a mut W,
}
impl<'a> B1224_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
self.w
}
}
#[doc = "Reader of field `B1225`"]
pub type B1225_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1225`"]
pub struct B1225_W<'a> {
w: &'a mut W,
}
impl<'a> B1225_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
self.w
}
}
#[doc = "Reader of field `B1226`"]
pub type B1226_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1226`"]
pub struct B1226_W<'a> {
w: &'a mut W,
}
impl<'a> B1226_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 `B1227`"]
pub type B1227_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1227`"]
pub struct B1227_W<'a> {
w: &'a mut W,
}
impl<'a> B1227_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 `B1228`"]
pub type B1228_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1228`"]
pub struct B1228_W<'a> {
w: &'a mut W,
}
impl<'a> B1228_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
self.w
}
}
#[doc = "Reader of field `B1229`"]
pub type B1229_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1229`"]
pub struct B1229_W<'a> {
w: &'a mut W,
}
impl<'a> B1229_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
self.w
}
}
#[doc = "Reader of field `B1230`"]
pub type B1230_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1230`"]
pub struct B1230_W<'a> {
w: &'a mut W,
}
impl<'a> B1230_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 `B1231`"]
pub type B1231_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1231`"]
pub struct B1231_W<'a> {
w: &'a mut W,
}
impl<'a> B1231_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
self.w
}
}
#[doc = "Reader of field `B1232`"]
pub type B1232_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1232`"]
pub struct B1232_W<'a> {
w: &'a mut W,
}
impl<'a> B1232_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 16)) | (((value as u32) & 0x01) << 16);
self.w
}
}
#[doc = "Reader of field `B1233`"]
pub type B1233_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1233`"]
pub struct B1233_W<'a> {
w: &'a mut W,
}
impl<'a> B1233_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 `B1234`"]
pub type B1234_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1234`"]
pub struct B1234_W<'a> {
w: &'a mut W,
}
impl<'a> B1234_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 18)) | (((value as u32) & 0x01) << 18);
self.w
}
}
#[doc = "Reader of field `B1235`"]
pub type B1235_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1235`"]
pub struct B1235_W<'a> {
w: &'a mut W,
}
impl<'a> B1235_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 19)) | (((value as u32) & 0x01) << 19);
self.w
}
}
#[doc = "Reader of field `B1236`"]
pub type B1236_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1236`"]
pub struct B1236_W<'a> {
w: &'a mut W,
}
impl<'a> B1236_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 `B1237`"]
pub type B1237_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1237`"]
pub struct B1237_W<'a> {
w: &'a mut W,
}
impl<'a> B1237_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 `B1238`"]
pub type B1238_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1238`"]
pub struct B1238_W<'a> {
w: &'a mut W,
}
impl<'a> B1238_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 `B1239`"]
pub type B1239_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1239`"]
pub struct B1239_W<'a> {
w: &'a mut W,
}
impl<'a> B1239_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 23)) | (((value as u32) & 0x01) << 23);
self.w
}
}
#[doc = "Reader of field `B1240`"]
pub type B1240_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1240`"]
pub struct B1240_W<'a> {
w: &'a mut W,
}
impl<'a> B1240_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 24)) | (((value as u32) & 0x01) << 24);
self.w
}
}
#[doc = "Reader of field `B1241`"]
pub type B1241_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1241`"]
pub struct B1241_W<'a> {
w: &'a mut W,
}
impl<'a> B1241_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 25)) | (((value as u32) & 0x01) << 25);
self.w
}
}
#[doc = "Reader of field `B1242`"]
pub type B1242_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1242`"]
pub struct B1242_W<'a> {
w: &'a mut W,
}
impl<'a> B1242_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 26)) | (((value as u32) & 0x01) << 26);
self.w
}
}
#[doc = "Reader of field `B1243`"]
pub type B1243_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1243`"]
pub struct B1243_W<'a> {
w: &'a mut W,
}
impl<'a> B1243_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 `B1244`"]
pub type B1244_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1244`"]
pub struct B1244_W<'a> {
w: &'a mut W,
}
impl<'a> B1244_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 `B1245`"]
pub type B1245_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1245`"]
pub struct B1245_W<'a> {
w: &'a mut W,
}
impl<'a> B1245_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 29)) | (((value as u32) & 0x01) << 29);
self.w
}
}
#[doc = "Reader of field `B1246`"]
pub type B1246_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1246`"]
pub struct B1246_W<'a> {
w: &'a mut W,
}
impl<'a> B1246_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 `B1247`"]
pub type B1247_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `B1247`"]
pub struct B1247_W<'a> {
w: &'a mut W,
}
impl<'a> B1247_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 - B1216"]
#[inline(always)]
pub fn b1216(&self) -> B1216_R {
B1216_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - B1217"]
#[inline(always)]
pub fn b1217(&self) -> B1217_R {
B1217_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - B1218"]
#[inline(always)]
pub fn b1218(&self) -> B1218_R {
B1218_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 3 - B1219"]
#[inline(always)]
pub fn b1219(&self) -> B1219_R {
B1219_R::new(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 4 - B1220"]
#[inline(always)]
pub fn b1220(&self) -> B1220_R {
B1220_R::new(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 5 - B1221"]
#[inline(always)]
pub fn b1221(&self) -> B1221_R {
B1221_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 6 - B1222"]
#[inline(always)]
pub fn b1222(&self) -> B1222_R {
B1222_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 7 - B1223"]
#[inline(always)]
pub fn b1223(&self) -> B1223_R {
B1223_R::new(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bit 8 - B1224"]
#[inline(always)]
pub fn b1224(&self) -> B1224_R {
B1224_R::new(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 9 - B1225"]
#[inline(always)]
pub fn b1225(&self) -> B1225_R {
B1225_R::new(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 10 - B1226"]
#[inline(always)]
pub fn b1226(&self) -> B1226_R {
B1226_R::new(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 11 - B1227"]
#[inline(always)]
pub fn b1227(&self) -> B1227_R {
B1227_R::new(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bit 12 - B1228"]
#[inline(always)]
pub fn b1228(&self) -> B1228_R {
B1228_R::new(((self.bits >> 12) & 0x01) != 0)
}
#[doc = "Bit 13 - B1229"]
#[inline(always)]
pub fn b1229(&self) -> B1229_R {
B1229_R::new(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 14 - B1230"]
#[inline(always)]
pub fn b1230(&self) -> B1230_R {
B1230_R::new(((self.bits >> 14) & 0x01) != 0)
}
#[doc = "Bit 15 - B1231"]
#[inline(always)]
pub fn b1231(&self) -> B1231_R {
B1231_R::new(((self.bits >> 15) & 0x01) != 0)
}
#[doc = "Bit 16 - B1232"]
#[inline(always)]
pub fn b1232(&self) -> B1232_R {
B1232_R::new(((self.bits >> 16) & 0x01) != 0)
}
#[doc = "Bit 17 - B1233"]
#[inline(always)]
pub fn b1233(&self) -> B1233_R {
B1233_R::new(((self.bits >> 17) & 0x01) != 0)
}
#[doc = "Bit 18 - B1234"]
#[inline(always)]
pub fn b1234(&self) -> B1234_R {
B1234_R::new(((self.bits >> 18) & 0x01) != 0)
}
#[doc = "Bit 19 - B1235"]
#[inline(always)]
pub fn b1235(&self) -> B1235_R {
B1235_R::new(((self.bits >> 19) & 0x01) != 0)
}
#[doc = "Bit 20 - B1236"]
#[inline(always)]
pub fn b1236(&self) -> B1236_R {
B1236_R::new(((self.bits >> 20) & 0x01) != 0)
}
#[doc = "Bit 21 - B1237"]
#[inline(always)]
pub fn b1237(&self) -> B1237_R {
B1237_R::new(((self.bits >> 21) & 0x01) != 0)
}
#[doc = "Bit 22 - B1238"]
#[inline(always)]
pub fn b1238(&self) -> B1238_R {
B1238_R::new(((self.bits >> 22) & 0x01) != 0)
}
#[doc = "Bit 23 - B1239"]
#[inline(always)]
pub fn b1239(&self) -> B1239_R {
B1239_R::new(((self.bits >> 23) & 0x01) != 0)
}
#[doc = "Bit 24 - B1240"]
#[inline(always)]
pub fn b1240(&self) -> B1240_R {
B1240_R::new(((self.bits >> 24) & 0x01) != 0)
}
#[doc = "Bit 25 - B1241"]
#[inline(always)]
pub fn b1241(&self) -> B1241_R {
B1241_R::new(((self.bits >> 25) & 0x01) != 0)
}
#[doc = "Bit 26 - B1242"]
#[inline(always)]
pub fn b1242(&self) -> B1242_R {
B1242_R::new(((self.bits >> 26) & 0x01) != 0)
}
#[doc = "Bit 27 - B1243"]
#[inline(always)]
pub fn b1243(&self) -> B1243_R {
B1243_R::new(((self.bits >> 27) & 0x01) != 0)
}
#[doc = "Bit 28 - B1244"]
#[inline(always)]
pub fn b1244(&self) -> B1244_R {
B1244_R::new(((self.bits >> 28) & 0x01) != 0)
}
#[doc = "Bit 29 - B1245"]
#[inline(always)]
pub fn b1245(&self) -> B1245_R {
B1245_R::new(((self.bits >> 29) & 0x01) != 0)
}
#[doc = "Bit 30 - B1246"]
#[inline(always)]
pub fn b1246(&self) -> B1246_R {
B1246_R::new(((self.bits >> 30) & 0x01) != 0)
}
#[doc = "Bit 31 - B1247"]
#[inline(always)]
pub fn b1247(&self) -> B1247_R {
B1247_R::new(((self.bits >> 31) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - B1216"]
#[inline(always)]
pub fn b1216(&mut self) -> B1216_W {
B1216_W { w: self }
}
#[doc = "Bit 1 - B1217"]
#[inline(always)]
pub fn b1217(&mut self) -> B1217_W {
B1217_W { w: self }
}
#[doc = "Bit 2 - B1218"]
#[inline(always)]
pub fn b1218(&mut self) -> B1218_W {
B1218_W { w: self }
}
#[doc = "Bit 3 - B1219"]
#[inline(always)]
pub fn b1219(&mut self) -> B1219_W {
B1219_W { w: self }
}
#[doc = "Bit 4 - B1220"]
#[inline(always)]
pub fn b1220(&mut self) -> B1220_W {
B1220_W { w: self }
}
#[doc = "Bit 5 - B1221"]
#[inline(always)]
pub fn b1221(&mut self) -> B1221_W {
B1221_W { w: self }
}
#[doc = "Bit 6 - B1222"]
#[inline(always)]
pub fn b1222(&mut self) -> B1222_W {
B1222_W { w: self }
}
#[doc = "Bit 7 - B1223"]
#[inline(always)]
pub fn b1223(&mut self) -> B1223_W {
B1223_W { w: self }
}
#[doc = "Bit 8 - B1224"]
#[inline(always)]
pub fn b1224(&mut self) -> B1224_W {
B1224_W { w: self }
}
#[doc = "Bit 9 - B1225"]
#[inline(always)]
pub fn b1225(&mut self) -> B1225_W {
B1225_W { w: self }
}
#[doc = "Bit 10 - B1226"]
#[inline(always)]
pub fn b1226(&mut self) -> B1226_W {
B1226_W { w: self }
}
#[doc = "Bit 11 - B1227"]
#[inline(always)]
pub fn b1227(&mut self) -> B1227_W {
B1227_W { w: self }
}
#[doc = "Bit 12 - B1228"]
#[inline(always)]
pub fn b1228(&mut self) -> B1228_W {
B1228_W { w: self }
}
#[doc = "Bit 13 - B1229"]
#[inline(always)]
pub fn b1229(&mut self) -> B1229_W {
B1229_W { w: self }
}
#[doc = "Bit 14 - B1230"]
#[inline(always)]
pub fn b1230(&mut self) -> B1230_W {
B1230_W { w: self }
}
#[doc = "Bit 15 - B1231"]
#[inline(always)]
pub fn b1231(&mut self) -> B1231_W {
B1231_W { w: self }
}
#[doc = "Bit 16 - B1232"]
#[inline(always)]
pub fn b1232(&mut self) -> B1232_W {
B1232_W { w: self }
}
#[doc = "Bit 17 - B1233"]
#[inline(always)]
pub fn b1233(&mut self) -> B1233_W {
B1233_W { w: self }
}
#[doc = "Bit 18 - B1234"]
#[inline(always)]
pub fn b1234(&mut self) -> B1234_W {
B1234_W { w: self }
}
#[doc = "Bit 19 - B1235"]
#[inline(always)]
pub fn b1235(&mut self) -> B1235_W {
B1235_W { w: self }
}
#[doc = "Bit 20 - B1236"]
#[inline(always)]
pub fn b1236(&mut self) -> B1236_W {
B1236_W { w: self }
}
#[doc = "Bit 21 - B1237"]
#[inline(always)]
pub fn b1237(&mut self) -> B1237_W {
B1237_W { w: self }
}
#[doc = "Bit 22 - B1238"]
#[inline(always)]
pub fn b1238(&mut self) -> B1238_W {
B1238_W { w: self }
}
#[doc = "Bit 23 - B1239"]
#[inline(always)]
pub fn b1239(&mut self) -> B1239_W {
B1239_W { w: self }
}
#[doc = "Bit 24 - B1240"]
#[inline(always)]
pub fn b1240(&mut self) -> B1240_W {
B1240_W { w: self }
}
#[doc = "Bit 25 - B1241"]
#[inline(always)]
pub fn b1241(&mut self) -> B1241_W {
B1241_W { w: self }
}
#[doc = "Bit 26 - B1242"]
#[inline(always)]
pub fn b1242(&mut self) -> B1242_W {
B1242_W { w: self }
}
#[doc = "Bit 27 - B1243"]
#[inline(always)]
pub fn b1243(&mut self) -> B1243_W {
B1243_W { w: self }
}
#[doc = "Bit 28 - B1244"]
#[inline(always)]
pub fn b1244(&mut self) -> B1244_W {
B1244_W { w: self }
}
#[doc = "Bit 29 - B1245"]
#[inline(always)]
pub fn b1245(&mut self) -> B1245_W {
B1245_W { w: self }
}
#[doc = "Bit 30 - B1246"]
#[inline(always)]
pub fn b1246(&mut self) -> B1246_W {
B1246_W { w: self }
}
#[doc = "Bit 31 - B1247"]
#[inline(always)]
pub fn b1247(&mut self) -> B1247_W {
B1247_W { w: self }
}
}
|
use juniper::ID;
use serde_json::{json, Value};
use crate::app_env::get_env;
pub struct MailTemplate {
pub id: String,
pub data: Value,
}
impl MailTemplate {
pub fn register_confirmation(activation_id: &ID, email: &String) -> MailTemplate {
MailTemplate {
id: get_env::sendgrid_template_register(),
data: json!({
"confirm_registration_link":
format!(
"https://app.taskach.ru/confirm?id={}&email={}",
activation_id, email
)
}),
}
}
}
|
#[doc = r"Register block"]
#[repr(C)]
pub struct RegisterBlock {
#[doc = "0x00 - Device Identification 0"]
pub did0: DID0,
#[doc = "0x04 - Device Identification 1"]
pub did1: DID1,
#[doc = "0x08 - Device Capabilities 0"]
pub dc0: DC0,
_reserved3: [u8; 4usize],
#[doc = "0x10 - Device Capabilities 1"]
pub dc1: DC1,
#[doc = "0x14 - Device Capabilities 2"]
pub dc2: DC2,
#[doc = "0x18 - Device Capabilities 3"]
pub dc3: DC3,
#[doc = "0x1c - Device Capabilities 4"]
pub dc4: DC4,
#[doc = "0x20 - Device Capabilities 5"]
pub dc5: DC5,
#[doc = "0x24 - Device Capabilities 6"]
pub dc6: DC6,
#[doc = "0x28 - Device Capabilities 7"]
pub dc7: DC7,
#[doc = "0x2c - Device Capabilities 8"]
pub dc8: DC8,
#[doc = "0x30 - Brown-Out Reset Control"]
pub pborctl: PBORCTL,
_reserved12: [u8; 12usize],
#[doc = "0x40 - Software Reset Control 0"]
pub srcr0: SRCR0,
#[doc = "0x44 - Software Reset Control 1"]
pub srcr1: SRCR1,
#[doc = "0x48 - Software Reset Control 2"]
pub srcr2: SRCR2,
_reserved15: [u8; 4usize],
#[doc = "0x50 - Raw Interrupt Status"]
pub ris: RIS,
#[doc = "0x54 - Interrupt Mask Control"]
pub imc: IMC,
#[doc = "0x58 - Masked Interrupt Status and Clear"]
pub misc: MISC,
#[doc = "0x5c - Reset Cause"]
pub resc: RESC,
#[doc = "0x60 - Run-Mode Clock Configuration"]
pub rcc: RCC,
_reserved20: [u8; 8usize],
#[doc = "0x6c - GPIO High-Performance Bus Control"]
pub gpiohbctl: GPIOHBCTL,
#[doc = "0x70 - Run-Mode Clock Configuration 2"]
pub rcc2: RCC2,
_reserved22: [u8; 8usize],
#[doc = "0x7c - Main Oscillator Control"]
pub moscctl: MOSCCTL,
_reserved23: [u8; 128usize],
#[doc = "0x100 - Run Mode Clock Gating Control Register 0"]
pub rcgc0: RCGC0,
#[doc = "0x104 - Run Mode Clock Gating Control Register 1"]
pub rcgc1: RCGC1,
#[doc = "0x108 - Run Mode Clock Gating Control Register 2"]
pub rcgc2: RCGC2,
_reserved26: [u8; 4usize],
#[doc = "0x110 - Sleep Mode Clock Gating Control Register 0"]
pub scgc0: SCGC0,
#[doc = "0x114 - Sleep Mode Clock Gating Control Register 1"]
pub scgc1: SCGC1,
#[doc = "0x118 - Sleep Mode Clock Gating Control Register 2"]
pub scgc2: SCGC2,
_reserved29: [u8; 4usize],
#[doc = "0x120 - Deep Sleep Mode Clock Gating Control Register 0"]
pub dcgc0: DCGC0,
#[doc = "0x124 - Deep-Sleep Mode Clock Gating Control Register 1"]
pub dcgc1: DCGC1,
#[doc = "0x128 - Deep Sleep Mode Clock Gating Control Register 2"]
pub dcgc2: DCGC2,
_reserved32: [u8; 24usize],
#[doc = "0x144 - Deep Sleep Clock Configuration"]
pub dslpclkcfg: DSLPCLKCFG,
_reserved33: [u8; 4usize],
#[doc = "0x14c - System Properties"]
pub sysprop: SYSPROP,
#[doc = "0x150 - Precision Internal Oscillator Calibration"]
pub piosccal: PIOSCCAL,
#[doc = "0x154 - Precision Internal Oscillator Statistics"]
pub pioscstat: PIOSCSTAT,
_reserved36: [u8; 8usize],
#[doc = "0x160 - PLL Frequency 0"]
pub pllfreq0: PLLFREQ0,
#[doc = "0x164 - PLL Frequency 1"]
pub pllfreq1: PLLFREQ1,
#[doc = "0x168 - PLL Status"]
pub pllstat: PLLSTAT,
_reserved39: [u8; 28usize],
#[doc = "0x188 - Sleep Power Configuration"]
pub slppwrcfg: SLPPWRCFG,
#[doc = "0x18c - Deep-Sleep Power Configuration"]
pub dslppwrcfg: DSLPPWRCFG,
#[doc = "0x190 - Device Capabilities 9"]
pub dc9: DC9,
_reserved42: [u8; 12usize],
#[doc = "0x1a0 - Non-Volatile Memory Information"]
pub nvmstat: NVMSTAT,
_reserved43: [u8; 16usize],
#[doc = "0x1b4 - LDO Sleep Power Control"]
pub ldospctl: LDOSPCTL,
_reserved44: [u8; 4usize],
#[doc = "0x1bc - LDO Deep-Sleep Power Control"]
pub ldodpctl: LDODPCTL,
_reserved45: [u8; 320usize],
#[doc = "0x300 - Watchdog Timer Peripheral Present"]
pub ppwd: PPWD,
#[doc = "0x304 - 16/32-Bit General-Purpose Timer Peripheral Present"]
pub pptimer: PPTIMER,
#[doc = "0x308 - General-Purpose Input/Output Peripheral Present"]
pub ppgpio: PPGPIO,
#[doc = "0x30c - Micro Direct Memory Access Peripheral Present"]
pub ppdma: PPDMA,
_reserved49: [u8; 4usize],
#[doc = "0x314 - Hibernation Peripheral Present"]
pub pphib: PPHIB,
#[doc = "0x318 - Universal Asynchronous Receiver/Transmitter Peripheral Present"]
pub ppuart: PPUART,
#[doc = "0x31c - Synchronous Serial Interface Peripheral Present"]
pub ppssi: PPSSI,
#[doc = "0x320 - Inter-Integrated Circuit Peripheral Present"]
pub ppi2c: PPI2C,
_reserved53: [u8; 4usize],
#[doc = "0x328 - Universal Serial Bus Peripheral Present"]
pub ppusb: PPUSB,
_reserved54: [u8; 8usize],
#[doc = "0x334 - Controller Area Network Peripheral Present"]
pub ppcan: PPCAN,
#[doc = "0x338 - Analog-to-Digital Converter Peripheral Present"]
pub ppadc: PPADC,
#[doc = "0x33c - Analog Comparator Peripheral Present"]
pub ppacmp: PPACMP,
#[doc = "0x340 - Pulse Width Modulator Peripheral Present"]
pub pppwm: PPPWM,
#[doc = "0x344 - Quadrature Encoder Interface Peripheral Present"]
pub ppqei: PPQEI,
_reserved59: [u8; 16usize],
#[doc = "0x358 - EEPROM Peripheral Present"]
pub ppeeprom: PPEEPROM,
#[doc = "0x35c - 32/64-Bit Wide General-Purpose Timer Peripheral Present"]
pub ppwtimer: PPWTIMER,
_reserved61: [u8; 416usize],
#[doc = "0x500 - Watchdog Timer Software Reset"]
pub srwd: SRWD,
#[doc = "0x504 - 16/32-Bit General-Purpose Timer Software Reset"]
pub srtimer: SRTIMER,
#[doc = "0x508 - General-Purpose Input/Output Software Reset"]
pub srgpio: SRGPIO,
#[doc = "0x50c - Micro Direct Memory Access Software Reset"]
pub srdma: SRDMA,
_reserved65: [u8; 4usize],
#[doc = "0x514 - Hibernation Software Reset"]
pub srhib: SRHIB,
#[doc = "0x518 - Universal Asynchronous Receiver/Transmitter Software Reset"]
pub sruart: SRUART,
#[doc = "0x51c - Synchronous Serial Interface Software Reset"]
pub srssi: SRSSI,
#[doc = "0x520 - Inter-Integrated Circuit Software Reset"]
pub sri2c: SRI2C,
_reserved69: [u8; 4usize],
#[doc = "0x528 - Universal Serial Bus Software Reset"]
pub srusb: SRUSB,
_reserved70: [u8; 8usize],
#[doc = "0x534 - Controller Area Network Software Reset"]
pub srcan: SRCAN,
#[doc = "0x538 - Analog-to-Digital Converter Software Reset"]
pub sradc: SRADC,
#[doc = "0x53c - Analog Comparator Software Reset"]
pub sracmp: SRACMP,
#[doc = "0x540 - Pulse Width Modulator Software Reset"]
pub srpwm: SRPWM,
#[doc = "0x544 - Quadrature Encoder Interface Software Reset"]
pub srqei: SRQEI,
_reserved75: [u8; 16usize],
#[doc = "0x558 - EEPROM Software Reset"]
pub sreeprom: SREEPROM,
#[doc = "0x55c - 32/64-Bit Wide General-Purpose Timer Software Reset"]
pub srwtimer: SRWTIMER,
_reserved77: [u8; 160usize],
#[doc = "0x600 - Watchdog Timer Run Mode Clock Gating Control"]
pub rcgcwd: RCGCWD,
#[doc = "0x604 - 16/32-Bit General-Purpose Timer Run Mode Clock Gating Control"]
pub rcgctimer: RCGCTIMER,
#[doc = "0x608 - General-Purpose Input/Output Run Mode Clock Gating Control"]
pub rcgcgpio: RCGCGPIO,
#[doc = "0x60c - Micro Direct Memory Access Run Mode Clock Gating Control"]
pub rcgcdma: RCGCDMA,
_reserved81: [u8; 4usize],
#[doc = "0x614 - Hibernation Run Mode Clock Gating Control"]
pub rcgchib: RCGCHIB,
#[doc = "0x618 - Universal Asynchronous Receiver/Transmitter Run Mode Clock Gating Control"]
pub rcgcuart: RCGCUART,
#[doc = "0x61c - Synchronous Serial Interface Run Mode Clock Gating Control"]
pub rcgcssi: RCGCSSI,
#[doc = "0x620 - Inter-Integrated Circuit Run Mode Clock Gating Control"]
pub rcgci2c: RCGCI2C,
_reserved85: [u8; 4usize],
#[doc = "0x628 - Universal Serial Bus Run Mode Clock Gating Control"]
pub rcgcusb: RCGCUSB,
_reserved86: [u8; 8usize],
#[doc = "0x634 - Controller Area Network Run Mode Clock Gating Control"]
pub rcgccan: RCGCCAN,
#[doc = "0x638 - Analog-to-Digital Converter Run Mode Clock Gating Control"]
pub rcgcadc: RCGCADC,
#[doc = "0x63c - Analog Comparator Run Mode Clock Gating Control"]
pub rcgcacmp: RCGCACMP,
#[doc = "0x640 - Pulse Width Modulator Run Mode Clock Gating Control"]
pub rcgcpwm: RCGCPWM,
#[doc = "0x644 - Quadrature Encoder Interface Run Mode Clock Gating Control"]
pub rcgcqei: RCGCQEI,
_reserved91: [u8; 16usize],
#[doc = "0x658 - EEPROM Run Mode Clock Gating Control"]
pub rcgceeprom: RCGCEEPROM,
#[doc = "0x65c - 32/64-Bit Wide General-Purpose Timer Run Mode Clock Gating Control"]
pub rcgcwtimer: RCGCWTIMER,
_reserved93: [u8; 160usize],
#[doc = "0x700 - Watchdog Timer Sleep Mode Clock Gating Control"]
pub scgcwd: SCGCWD,
#[doc = "0x704 - 16/32-Bit General-Purpose Timer Sleep Mode Clock Gating Control"]
pub scgctimer: SCGCTIMER,
#[doc = "0x708 - General-Purpose Input/Output Sleep Mode Clock Gating Control"]
pub scgcgpio: SCGCGPIO,
#[doc = "0x70c - Micro Direct Memory Access Sleep Mode Clock Gating Control"]
pub scgcdma: SCGCDMA,
_reserved97: [u8; 4usize],
#[doc = "0x714 - Hibernation Sleep Mode Clock Gating Control"]
pub scgchib: SCGCHIB,
#[doc = "0x718 - Universal Asynchronous Receiver/Transmitter Sleep Mode Clock Gating Control"]
pub scgcuart: SCGCUART,
#[doc = "0x71c - Synchronous Serial Interface Sleep Mode Clock Gating Control"]
pub scgcssi: SCGCSSI,
#[doc = "0x720 - Inter-Integrated Circuit Sleep Mode Clock Gating Control"]
pub scgci2c: SCGCI2C,
_reserved101: [u8; 4usize],
#[doc = "0x728 - Universal Serial Bus Sleep Mode Clock Gating Control"]
pub scgcusb: SCGCUSB,
_reserved102: [u8; 8usize],
#[doc = "0x734 - Controller Area Network Sleep Mode Clock Gating Control"]
pub scgccan: SCGCCAN,
#[doc = "0x738 - Analog-to-Digital Converter Sleep Mode Clock Gating Control"]
pub scgcadc: SCGCADC,
#[doc = "0x73c - Analog Comparator Sleep Mode Clock Gating Control"]
pub scgcacmp: SCGCACMP,
#[doc = "0x740 - Pulse Width Modulator Sleep Mode Clock Gating Control"]
pub scgcpwm: SCGCPWM,
#[doc = "0x744 - Quadrature Encoder Interface Sleep Mode Clock Gating Control"]
pub scgcqei: SCGCQEI,
_reserved107: [u8; 16usize],
#[doc = "0x758 - EEPROM Sleep Mode Clock Gating Control"]
pub scgceeprom: SCGCEEPROM,
#[doc = "0x75c - 32/64-Bit Wide General-Purpose Timer Sleep Mode Clock Gating Control"]
pub scgcwtimer: SCGCWTIMER,
_reserved109: [u8; 160usize],
#[doc = "0x800 - Watchdog Timer Deep-Sleep Mode Clock Gating Control"]
pub dcgcwd: DCGCWD,
#[doc = "0x804 - 16/32-Bit General-Purpose Timer Deep-Sleep Mode Clock Gating Control"]
pub dcgctimer: DCGCTIMER,
#[doc = "0x808 - General-Purpose Input/Output Deep-Sleep Mode Clock Gating Control"]
pub dcgcgpio: DCGCGPIO,
#[doc = "0x80c - Micro Direct Memory Access Deep-Sleep Mode Clock Gating Control"]
pub dcgcdma: DCGCDMA,
_reserved113: [u8; 4usize],
#[doc = "0x814 - Hibernation Deep-Sleep Mode Clock Gating Control"]
pub dcgchib: DCGCHIB,
#[doc = "0x818 - Universal Asynchronous Receiver/Transmitter Deep-Sleep Mode Clock Gating Control"]
pub dcgcuart: DCGCUART,
#[doc = "0x81c - Synchronous Serial Interface Deep-Sleep Mode Clock Gating Control"]
pub dcgcssi: DCGCSSI,
#[doc = "0x820 - Inter-Integrated Circuit Deep-Sleep Mode Clock Gating Control"]
pub dcgci2c: DCGCI2C,
_reserved117: [u8; 4usize],
#[doc = "0x828 - Universal Serial Bus Deep-Sleep Mode Clock Gating Control"]
pub dcgcusb: DCGCUSB,
_reserved118: [u8; 8usize],
#[doc = "0x834 - Controller Area Network Deep-Sleep Mode Clock Gating Control"]
pub dcgccan: DCGCCAN,
#[doc = "0x838 - Analog-to-Digital Converter Deep-Sleep Mode Clock Gating Control"]
pub dcgcadc: DCGCADC,
#[doc = "0x83c - Analog Comparator Deep-Sleep Mode Clock Gating Control"]
pub dcgcacmp: DCGCACMP,
#[doc = "0x840 - Pulse Width Modulator Deep-Sleep Mode Clock Gating Control"]
pub dcgcpwm: DCGCPWM,
#[doc = "0x844 - Quadrature Encoder Interface Deep-Sleep Mode Clock Gating Control"]
pub dcgcqei: DCGCQEI,
_reserved123: [u8; 16usize],
#[doc = "0x858 - EEPROM Deep-Sleep Mode Clock Gating Control"]
pub dcgceeprom: DCGCEEPROM,
#[doc = "0x85c - 32/64-Bit Wide General-Purpose Timer Deep-Sleep Mode Clock Gating Control"]
pub dcgcwtimer: DCGCWTIMER,
_reserved125: [u8; 416usize],
#[doc = "0xa00 - Watchdog Timer Peripheral Ready"]
pub prwd: PRWD,
#[doc = "0xa04 - 16/32-Bit General-Purpose Timer Peripheral Ready"]
pub prtimer: PRTIMER,
#[doc = "0xa08 - General-Purpose Input/Output Peripheral Ready"]
pub prgpio: PRGPIO,
#[doc = "0xa0c - Micro Direct Memory Access Peripheral Ready"]
pub prdma: PRDMA,
_reserved129: [u8; 4usize],
#[doc = "0xa14 - Hibernation Peripheral Ready"]
pub prhib: PRHIB,
#[doc = "0xa18 - Universal Asynchronous Receiver/Transmitter Peripheral Ready"]
pub pruart: PRUART,
#[doc = "0xa1c - Synchronous Serial Interface Peripheral Ready"]
pub prssi: PRSSI,
#[doc = "0xa20 - Inter-Integrated Circuit Peripheral Ready"]
pub pri2c: PRI2C,
_reserved133: [u8; 4usize],
#[doc = "0xa28 - Universal Serial Bus Peripheral Ready"]
pub prusb: PRUSB,
_reserved134: [u8; 8usize],
#[doc = "0xa34 - Controller Area Network Peripheral Ready"]
pub prcan: PRCAN,
#[doc = "0xa38 - Analog-to-Digital Converter Peripheral Ready"]
pub pradc: PRADC,
#[doc = "0xa3c - Analog Comparator Peripheral Ready"]
pub pracmp: PRACMP,
#[doc = "0xa40 - Pulse Width Modulator Peripheral Ready"]
pub prpwm: PRPWM,
#[doc = "0xa44 - Quadrature Encoder Interface Peripheral Ready"]
pub prqei: PRQEI,
_reserved139: [u8; 16usize],
#[doc = "0xa58 - EEPROM Peripheral Ready"]
pub preeprom: PREEPROM,
#[doc = "0xa5c - 32/64-Bit Wide General-Purpose Timer Peripheral Ready"]
pub prwtimer: PRWTIMER,
}
#[doc = "Device Identification 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [did0](did0) module"]
pub type DID0 = crate::Reg<u32, _DID0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DID0;
#[doc = "`read()` method returns [did0::R](did0::R) reader structure"]
impl crate::Readable for DID0 {}
#[doc = "Device Identification 0"]
pub mod did0;
#[doc = "Device Identification 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [did1](did1) module"]
pub type DID1 = crate::Reg<u32, _DID1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DID1;
#[doc = "`read()` method returns [did1::R](did1::R) reader structure"]
impl crate::Readable for DID1 {}
#[doc = "Device Identification 1"]
pub mod did1;
#[doc = "Device Capabilities 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc0](dc0) module"]
pub type DC0 = crate::Reg<u32, _DC0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC0;
#[doc = "`read()` method returns [dc0::R](dc0::R) reader structure"]
impl crate::Readable for DC0 {}
#[doc = "Device Capabilities 0"]
pub mod dc0;
#[doc = "Device Capabilities 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc1](dc1) module"]
pub type DC1 = crate::Reg<u32, _DC1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC1;
#[doc = "`read()` method returns [dc1::R](dc1::R) reader structure"]
impl crate::Readable for DC1 {}
#[doc = "Device Capabilities 1"]
pub mod dc1;
#[doc = "Device Capabilities 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc2](dc2) module"]
pub type DC2 = crate::Reg<u32, _DC2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC2;
#[doc = "`read()` method returns [dc2::R](dc2::R) reader structure"]
impl crate::Readable for DC2 {}
#[doc = "Device Capabilities 2"]
pub mod dc2;
#[doc = "Device Capabilities 3\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc3](dc3) module"]
pub type DC3 = crate::Reg<u32, _DC3>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC3;
#[doc = "`read()` method returns [dc3::R](dc3::R) reader structure"]
impl crate::Readable for DC3 {}
#[doc = "Device Capabilities 3"]
pub mod dc3;
#[doc = "Device Capabilities 4\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc4](dc4) module"]
pub type DC4 = crate::Reg<u32, _DC4>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC4;
#[doc = "`read()` method returns [dc4::R](dc4::R) reader structure"]
impl crate::Readable for DC4 {}
#[doc = "Device Capabilities 4"]
pub mod dc4;
#[doc = "Device Capabilities 5\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc5](dc5) module"]
pub type DC5 = crate::Reg<u32, _DC5>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC5;
#[doc = "`read()` method returns [dc5::R](dc5::R) reader structure"]
impl crate::Readable for DC5 {}
#[doc = "Device Capabilities 5"]
pub mod dc5;
#[doc = "Device Capabilities 6\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc6](dc6) module"]
pub type DC6 = crate::Reg<u32, _DC6>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC6;
#[doc = "`read()` method returns [dc6::R](dc6::R) reader structure"]
impl crate::Readable for DC6 {}
#[doc = "Device Capabilities 6"]
pub mod dc6;
#[doc = "Device Capabilities 7\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc7](dc7) module"]
pub type DC7 = crate::Reg<u32, _DC7>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC7;
#[doc = "`read()` method returns [dc7::R](dc7::R) reader structure"]
impl crate::Readable for DC7 {}
#[doc = "Device Capabilities 7"]
pub mod dc7;
#[doc = "Device Capabilities 8\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc8](dc8) module"]
pub type DC8 = crate::Reg<u32, _DC8>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC8;
#[doc = "`read()` method returns [dc8::R](dc8::R) reader structure"]
impl crate::Readable for DC8 {}
#[doc = "Device Capabilities 8"]
pub mod dc8;
#[doc = "Brown-Out Reset Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pborctl](pborctl) module"]
pub type PBORCTL = crate::Reg<u32, _PBORCTL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PBORCTL;
#[doc = "`read()` method returns [pborctl::R](pborctl::R) reader structure"]
impl crate::Readable for PBORCTL {}
#[doc = "`write(|w| ..)` method takes [pborctl::W](pborctl::W) writer structure"]
impl crate::Writable for PBORCTL {}
#[doc = "Brown-Out Reset Control"]
pub mod pborctl;
#[doc = "Software Reset Control 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srcr0](srcr0) module"]
pub type SRCR0 = crate::Reg<u32, _SRCR0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRCR0;
#[doc = "`read()` method returns [srcr0::R](srcr0::R) reader structure"]
impl crate::Readable for SRCR0 {}
#[doc = "Software Reset Control 0"]
pub mod srcr0;
#[doc = "Software Reset Control 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srcr1](srcr1) module"]
pub type SRCR1 = crate::Reg<u32, _SRCR1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRCR1;
#[doc = "`read()` method returns [srcr1::R](srcr1::R) reader structure"]
impl crate::Readable for SRCR1 {}
#[doc = "Software Reset Control 1"]
pub mod srcr1;
#[doc = "Software Reset Control 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srcr2](srcr2) module"]
pub type SRCR2 = crate::Reg<u32, _SRCR2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRCR2;
#[doc = "`read()` method returns [srcr2::R](srcr2::R) reader structure"]
impl crate::Readable for SRCR2 {}
#[doc = "Software Reset Control 2"]
pub mod srcr2;
#[doc = "Raw Interrupt Status\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ris](ris) module"]
pub type RIS = crate::Reg<u32, _RIS>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RIS;
#[doc = "`read()` method returns [ris::R](ris::R) reader structure"]
impl crate::Readable for RIS {}
#[doc = "Raw Interrupt Status"]
pub mod ris;
#[doc = "Interrupt Mask Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [imc](imc) module"]
pub type IMC = crate::Reg<u32, _IMC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _IMC;
#[doc = "`read()` method returns [imc::R](imc::R) reader structure"]
impl crate::Readable for IMC {}
#[doc = "`write(|w| ..)` method takes [imc::W](imc::W) writer structure"]
impl crate::Writable for IMC {}
#[doc = "Interrupt Mask Control"]
pub mod imc;
#[doc = "Masked Interrupt Status and Clear\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [misc](misc) module"]
pub type MISC = crate::Reg<u32, _MISC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _MISC;
#[doc = "`read()` method returns [misc::R](misc::R) reader structure"]
impl crate::Readable for MISC {}
#[doc = "`write(|w| ..)` method takes [misc::W](misc::W) writer structure"]
impl crate::Writable for MISC {}
#[doc = "Masked Interrupt Status and Clear"]
pub mod misc;
#[doc = "Reset Cause\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [resc](resc) module"]
pub type RESC = crate::Reg<u32, _RESC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RESC;
#[doc = "`read()` method returns [resc::R](resc::R) reader structure"]
impl crate::Readable for RESC {}
#[doc = "`write(|w| ..)` method takes [resc::W](resc::W) writer structure"]
impl crate::Writable for RESC {}
#[doc = "Reset Cause"]
pub mod resc;
#[doc = "Run-Mode Clock Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcc](rcc) module"]
pub type RCC = crate::Reg<u32, _RCC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCC;
#[doc = "`read()` method returns [rcc::R](rcc::R) reader structure"]
impl crate::Readable for RCC {}
#[doc = "`write(|w| ..)` method takes [rcc::W](rcc::W) writer structure"]
impl crate::Writable for RCC {}
#[doc = "Run-Mode Clock Configuration"]
pub mod rcc;
#[doc = "GPIO High-Performance Bus Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [gpiohbctl](gpiohbctl) module"]
pub type GPIOHBCTL = crate::Reg<u32, _GPIOHBCTL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _GPIOHBCTL;
#[doc = "`read()` method returns [gpiohbctl::R](gpiohbctl::R) reader structure"]
impl crate::Readable for GPIOHBCTL {}
#[doc = "`write(|w| ..)` method takes [gpiohbctl::W](gpiohbctl::W) writer structure"]
impl crate::Writable for GPIOHBCTL {}
#[doc = "GPIO High-Performance Bus Control"]
pub mod gpiohbctl;
#[doc = "Run-Mode Clock Configuration 2\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcc2](rcc2) module"]
pub type RCC2 = crate::Reg<u32, _RCC2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCC2;
#[doc = "`read()` method returns [rcc2::R](rcc2::R) reader structure"]
impl crate::Readable for RCC2 {}
#[doc = "`write(|w| ..)` method takes [rcc2::W](rcc2::W) writer structure"]
impl crate::Writable for RCC2 {}
#[doc = "Run-Mode Clock Configuration 2"]
pub mod rcc2;
#[doc = "Main Oscillator Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [moscctl](moscctl) module"]
pub type MOSCCTL = crate::Reg<u32, _MOSCCTL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _MOSCCTL;
#[doc = "`read()` method returns [moscctl::R](moscctl::R) reader structure"]
impl crate::Readable for MOSCCTL {}
#[doc = "`write(|w| ..)` method takes [moscctl::W](moscctl::W) writer structure"]
impl crate::Writable for MOSCCTL {}
#[doc = "Main Oscillator Control"]
pub mod moscctl;
#[doc = "Run Mode Clock Gating Control Register 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgc0](rcgc0) module"]
pub type RCGC0 = crate::Reg<u32, _RCGC0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGC0;
#[doc = "`read()` method returns [rcgc0::R](rcgc0::R) reader structure"]
impl crate::Readable for RCGC0 {}
#[doc = "Run Mode Clock Gating Control Register 0"]
pub mod rcgc0;
#[doc = "Run Mode Clock Gating Control Register 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgc1](rcgc1) module"]
pub type RCGC1 = crate::Reg<u32, _RCGC1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGC1;
#[doc = "`read()` method returns [rcgc1::R](rcgc1::R) reader structure"]
impl crate::Readable for RCGC1 {}
#[doc = "Run Mode Clock Gating Control Register 1"]
pub mod rcgc1;
#[doc = "Run Mode Clock Gating Control Register 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgc2](rcgc2) module"]
pub type RCGC2 = crate::Reg<u32, _RCGC2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGC2;
#[doc = "`read()` method returns [rcgc2::R](rcgc2::R) reader structure"]
impl crate::Readable for RCGC2 {}
#[doc = "Run Mode Clock Gating Control Register 2"]
pub mod rcgc2;
#[doc = "Sleep Mode Clock Gating Control Register 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgc0](scgc0) module"]
pub type SCGC0 = crate::Reg<u32, _SCGC0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGC0;
#[doc = "`read()` method returns [scgc0::R](scgc0::R) reader structure"]
impl crate::Readable for SCGC0 {}
#[doc = "Sleep Mode Clock Gating Control Register 0"]
pub mod scgc0;
#[doc = "Sleep Mode Clock Gating Control Register 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgc1](scgc1) module"]
pub type SCGC1 = crate::Reg<u32, _SCGC1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGC1;
#[doc = "`read()` method returns [scgc1::R](scgc1::R) reader structure"]
impl crate::Readable for SCGC1 {}
#[doc = "Sleep Mode Clock Gating Control Register 1"]
pub mod scgc1;
#[doc = "Sleep Mode Clock Gating Control Register 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgc2](scgc2) module"]
pub type SCGC2 = crate::Reg<u32, _SCGC2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGC2;
#[doc = "`read()` method returns [scgc2::R](scgc2::R) reader structure"]
impl crate::Readable for SCGC2 {}
#[doc = "Sleep Mode Clock Gating Control Register 2"]
pub mod scgc2;
#[doc = "Deep Sleep Mode Clock Gating Control Register 0\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgc0](dcgc0) module"]
pub type DCGC0 = crate::Reg<u32, _DCGC0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGC0;
#[doc = "`read()` method returns [dcgc0::R](dcgc0::R) reader structure"]
impl crate::Readable for DCGC0 {}
#[doc = "Deep Sleep Mode Clock Gating Control Register 0"]
pub mod dcgc0;
#[doc = "Deep-Sleep Mode Clock Gating Control Register 1\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgc1](dcgc1) module"]
pub type DCGC1 = crate::Reg<u32, _DCGC1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGC1;
#[doc = "`read()` method returns [dcgc1::R](dcgc1::R) reader structure"]
impl crate::Readable for DCGC1 {}
#[doc = "Deep-Sleep Mode Clock Gating Control Register 1"]
pub mod dcgc1;
#[doc = "Deep Sleep Mode Clock Gating Control Register 2\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgc2](dcgc2) module"]
pub type DCGC2 = crate::Reg<u32, _DCGC2>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGC2;
#[doc = "`read()` method returns [dcgc2::R](dcgc2::R) reader structure"]
impl crate::Readable for DCGC2 {}
#[doc = "Deep Sleep Mode Clock Gating Control Register 2"]
pub mod dcgc2;
#[doc = "Deep Sleep Clock Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dslpclkcfg](dslpclkcfg) module"]
pub type DSLPCLKCFG = crate::Reg<u32, _DSLPCLKCFG>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DSLPCLKCFG;
#[doc = "`read()` method returns [dslpclkcfg::R](dslpclkcfg::R) reader structure"]
impl crate::Readable for DSLPCLKCFG {}
#[doc = "`write(|w| ..)` method takes [dslpclkcfg::W](dslpclkcfg::W) writer structure"]
impl crate::Writable for DSLPCLKCFG {}
#[doc = "Deep Sleep Clock Configuration"]
pub mod dslpclkcfg;
#[doc = "System Properties\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sysprop](sysprop) module"]
pub type SYSPROP = crate::Reg<u32, _SYSPROP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SYSPROP;
#[doc = "`read()` method returns [sysprop::R](sysprop::R) reader structure"]
impl crate::Readable for SYSPROP {}
#[doc = "System Properties"]
pub mod sysprop;
#[doc = "Precision Internal Oscillator Calibration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [piosccal](piosccal) module"]
pub type PIOSCCAL = crate::Reg<u32, _PIOSCCAL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PIOSCCAL;
#[doc = "`read()` method returns [piosccal::R](piosccal::R) reader structure"]
impl crate::Readable for PIOSCCAL {}
#[doc = "`write(|w| ..)` method takes [piosccal::W](piosccal::W) writer structure"]
impl crate::Writable for PIOSCCAL {}
#[doc = "Precision Internal Oscillator Calibration"]
pub mod piosccal;
#[doc = "Precision Internal Oscillator Statistics\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pioscstat](pioscstat) module"]
pub type PIOSCSTAT = crate::Reg<u32, _PIOSCSTAT>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PIOSCSTAT;
#[doc = "`read()` method returns [pioscstat::R](pioscstat::R) reader structure"]
impl crate::Readable for PIOSCSTAT {}
#[doc = "Precision Internal Oscillator Statistics"]
pub mod pioscstat;
#[doc = "PLL Frequency 0\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pllfreq0](pllfreq0) module"]
pub type PLLFREQ0 = crate::Reg<u32, _PLLFREQ0>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PLLFREQ0;
#[doc = "`read()` method returns [pllfreq0::R](pllfreq0::R) reader structure"]
impl crate::Readable for PLLFREQ0 {}
#[doc = "`write(|w| ..)` method takes [pllfreq0::W](pllfreq0::W) writer structure"]
impl crate::Writable for PLLFREQ0 {}
#[doc = "PLL Frequency 0"]
pub mod pllfreq0;
#[doc = "PLL Frequency 1\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pllfreq1](pllfreq1) module"]
pub type PLLFREQ1 = crate::Reg<u32, _PLLFREQ1>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PLLFREQ1;
#[doc = "`read()` method returns [pllfreq1::R](pllfreq1::R) reader structure"]
impl crate::Readable for PLLFREQ1 {}
#[doc = "`write(|w| ..)` method takes [pllfreq1::W](pllfreq1::W) writer structure"]
impl crate::Writable for PLLFREQ1 {}
#[doc = "PLL Frequency 1"]
pub mod pllfreq1;
#[doc = "PLL Status\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pllstat](pllstat) module"]
pub type PLLSTAT = crate::Reg<u32, _PLLSTAT>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PLLSTAT;
#[doc = "`read()` method returns [pllstat::R](pllstat::R) reader structure"]
impl crate::Readable for PLLSTAT {}
#[doc = "PLL Status"]
pub mod pllstat;
#[doc = "Sleep Power Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [slppwrcfg](slppwrcfg) module"]
pub type SLPPWRCFG = crate::Reg<u32, _SLPPWRCFG>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SLPPWRCFG;
#[doc = "`read()` method returns [slppwrcfg::R](slppwrcfg::R) reader structure"]
impl crate::Readable for SLPPWRCFG {}
#[doc = "`write(|w| ..)` method takes [slppwrcfg::W](slppwrcfg::W) writer structure"]
impl crate::Writable for SLPPWRCFG {}
#[doc = "Sleep Power Configuration"]
pub mod slppwrcfg;
#[doc = "Deep-Sleep Power Configuration\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dslppwrcfg](dslppwrcfg) module"]
pub type DSLPPWRCFG = crate::Reg<u32, _DSLPPWRCFG>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DSLPPWRCFG;
#[doc = "`read()` method returns [dslppwrcfg::R](dslppwrcfg::R) reader structure"]
impl crate::Readable for DSLPPWRCFG {}
#[doc = "`write(|w| ..)` method takes [dslppwrcfg::W](dslppwrcfg::W) writer structure"]
impl crate::Writable for DSLPPWRCFG {}
#[doc = "Deep-Sleep Power Configuration"]
pub mod dslppwrcfg;
#[doc = "Device Capabilities 9\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dc9](dc9) module"]
pub type DC9 = crate::Reg<u32, _DC9>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DC9;
#[doc = "`read()` method returns [dc9::R](dc9::R) reader structure"]
impl crate::Readable for DC9 {}
#[doc = "Device Capabilities 9"]
pub mod dc9;
#[doc = "Non-Volatile Memory Information\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [nvmstat](nvmstat) module"]
pub type NVMSTAT = crate::Reg<u32, _NVMSTAT>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _NVMSTAT;
#[doc = "`read()` method returns [nvmstat::R](nvmstat::R) reader structure"]
impl crate::Readable for NVMSTAT {}
#[doc = "Non-Volatile Memory Information"]
pub mod nvmstat;
#[doc = "LDO Sleep Power Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ldospctl](ldospctl) module"]
pub type LDOSPCTL = crate::Reg<u32, _LDOSPCTL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _LDOSPCTL;
#[doc = "`read()` method returns [ldospctl::R](ldospctl::R) reader structure"]
impl crate::Readable for LDOSPCTL {}
#[doc = "`write(|w| ..)` method takes [ldospctl::W](ldospctl::W) writer structure"]
impl crate::Writable for LDOSPCTL {}
#[doc = "LDO Sleep Power Control"]
pub mod ldospctl;
#[doc = "LDO Deep-Sleep Power Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ldodpctl](ldodpctl) module"]
pub type LDODPCTL = crate::Reg<u32, _LDODPCTL>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _LDODPCTL;
#[doc = "`read()` method returns [ldodpctl::R](ldodpctl::R) reader structure"]
impl crate::Readable for LDODPCTL {}
#[doc = "`write(|w| ..)` method takes [ldodpctl::W](ldodpctl::W) writer structure"]
impl crate::Writable for LDODPCTL {}
#[doc = "LDO Deep-Sleep Power Control"]
pub mod ldodpctl;
#[doc = "Watchdog Timer Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppwd](ppwd) module"]
pub type PPWD = crate::Reg<u32, _PPWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPWD;
#[doc = "`read()` method returns [ppwd::R](ppwd::R) reader structure"]
impl crate::Readable for PPWD {}
#[doc = "Watchdog Timer Peripheral Present"]
pub mod ppwd;
#[doc = "16/32-Bit General-Purpose Timer Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pptimer](pptimer) module"]
pub type PPTIMER = crate::Reg<u32, _PPTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPTIMER;
#[doc = "`read()` method returns [pptimer::R](pptimer::R) reader structure"]
impl crate::Readable for PPTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Peripheral Present"]
pub mod pptimer;
#[doc = "General-Purpose Input/Output Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppgpio](ppgpio) module"]
pub type PPGPIO = crate::Reg<u32, _PPGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPGPIO;
#[doc = "`read()` method returns [ppgpio::R](ppgpio::R) reader structure"]
impl crate::Readable for PPGPIO {}
#[doc = "General-Purpose Input/Output Peripheral Present"]
pub mod ppgpio;
#[doc = "Micro Direct Memory Access Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppdma](ppdma) module"]
pub type PPDMA = crate::Reg<u32, _PPDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPDMA;
#[doc = "`read()` method returns [ppdma::R](ppdma::R) reader structure"]
impl crate::Readable for PPDMA {}
#[doc = "Micro Direct Memory Access Peripheral Present"]
pub mod ppdma;
#[doc = "Hibernation Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pphib](pphib) module"]
pub type PPHIB = crate::Reg<u32, _PPHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPHIB;
#[doc = "`read()` method returns [pphib::R](pphib::R) reader structure"]
impl crate::Readable for PPHIB {}
#[doc = "Hibernation Peripheral Present"]
pub mod pphib;
#[doc = "Universal Asynchronous Receiver/Transmitter Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppuart](ppuart) module"]
pub type PPUART = crate::Reg<u32, _PPUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPUART;
#[doc = "`read()` method returns [ppuart::R](ppuart::R) reader structure"]
impl crate::Readable for PPUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Peripheral Present"]
pub mod ppuart;
#[doc = "Synchronous Serial Interface Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppssi](ppssi) module"]
pub type PPSSI = crate::Reg<u32, _PPSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPSSI;
#[doc = "`read()` method returns [ppssi::R](ppssi::R) reader structure"]
impl crate::Readable for PPSSI {}
#[doc = "Synchronous Serial Interface Peripheral Present"]
pub mod ppssi;
#[doc = "Inter-Integrated Circuit Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppi2c](ppi2c) module"]
pub type PPI2C = crate::Reg<u32, _PPI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPI2C;
#[doc = "`read()` method returns [ppi2c::R](ppi2c::R) reader structure"]
impl crate::Readable for PPI2C {}
#[doc = "Inter-Integrated Circuit Peripheral Present"]
pub mod ppi2c;
#[doc = "Universal Serial Bus Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppusb](ppusb) module"]
pub type PPUSB = crate::Reg<u32, _PPUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPUSB;
#[doc = "`read()` method returns [ppusb::R](ppusb::R) reader structure"]
impl crate::Readable for PPUSB {}
#[doc = "Universal Serial Bus Peripheral Present"]
pub mod ppusb;
#[doc = "Controller Area Network Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppcan](ppcan) module"]
pub type PPCAN = crate::Reg<u32, _PPCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPCAN;
#[doc = "`read()` method returns [ppcan::R](ppcan::R) reader structure"]
impl crate::Readable for PPCAN {}
#[doc = "Controller Area Network Peripheral Present"]
pub mod ppcan;
#[doc = "Analog-to-Digital Converter Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppadc](ppadc) module"]
pub type PPADC = crate::Reg<u32, _PPADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPADC;
#[doc = "`read()` method returns [ppadc::R](ppadc::R) reader structure"]
impl crate::Readable for PPADC {}
#[doc = "Analog-to-Digital Converter Peripheral Present"]
pub mod ppadc;
#[doc = "Analog Comparator Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppacmp](ppacmp) module"]
pub type PPACMP = crate::Reg<u32, _PPACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPACMP;
#[doc = "`read()` method returns [ppacmp::R](ppacmp::R) reader structure"]
impl crate::Readable for PPACMP {}
#[doc = "Analog Comparator Peripheral Present"]
pub mod ppacmp;
#[doc = "Pulse Width Modulator Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pppwm](pppwm) module"]
pub type PPPWM = crate::Reg<u32, _PPPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPPWM;
#[doc = "`read()` method returns [pppwm::R](pppwm::R) reader structure"]
impl crate::Readable for PPPWM {}
#[doc = "Pulse Width Modulator Peripheral Present"]
pub mod pppwm;
#[doc = "Quadrature Encoder Interface Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppqei](ppqei) module"]
pub type PPQEI = crate::Reg<u32, _PPQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPQEI;
#[doc = "`read()` method returns [ppqei::R](ppqei::R) reader structure"]
impl crate::Readable for PPQEI {}
#[doc = "Quadrature Encoder Interface Peripheral Present"]
pub mod ppqei;
#[doc = "EEPROM Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppeeprom](ppeeprom) module"]
pub type PPEEPROM = crate::Reg<u32, _PPEEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPEEPROM;
#[doc = "`read()` method returns [ppeeprom::R](ppeeprom::R) reader structure"]
impl crate::Readable for PPEEPROM {}
#[doc = "EEPROM Peripheral Present"]
pub mod ppeeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Peripheral Present\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [ppwtimer](ppwtimer) module"]
pub type PPWTIMER = crate::Reg<u32, _PPWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PPWTIMER;
#[doc = "`read()` method returns [ppwtimer::R](ppwtimer::R) reader structure"]
impl crate::Readable for PPWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Peripheral Present"]
pub mod ppwtimer;
#[doc = "Watchdog Timer Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srwd](srwd) module"]
pub type SRWD = crate::Reg<u32, _SRWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRWD;
#[doc = "`read()` method returns [srwd::R](srwd::R) reader structure"]
impl crate::Readable for SRWD {}
#[doc = "`write(|w| ..)` method takes [srwd::W](srwd::W) writer structure"]
impl crate::Writable for SRWD {}
#[doc = "Watchdog Timer Software Reset"]
pub mod srwd;
#[doc = "16/32-Bit General-Purpose Timer Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srtimer](srtimer) module"]
pub type SRTIMER = crate::Reg<u32, _SRTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRTIMER;
#[doc = "`read()` method returns [srtimer::R](srtimer::R) reader structure"]
impl crate::Readable for SRTIMER {}
#[doc = "`write(|w| ..)` method takes [srtimer::W](srtimer::W) writer structure"]
impl crate::Writable for SRTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Software Reset"]
pub mod srtimer;
#[doc = "General-Purpose Input/Output Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srgpio](srgpio) module"]
pub type SRGPIO = crate::Reg<u32, _SRGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRGPIO;
#[doc = "`read()` method returns [srgpio::R](srgpio::R) reader structure"]
impl crate::Readable for SRGPIO {}
#[doc = "`write(|w| ..)` method takes [srgpio::W](srgpio::W) writer structure"]
impl crate::Writable for SRGPIO {}
#[doc = "General-Purpose Input/Output Software Reset"]
pub mod srgpio;
#[doc = "Micro Direct Memory Access Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srdma](srdma) module"]
pub type SRDMA = crate::Reg<u32, _SRDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRDMA;
#[doc = "`read()` method returns [srdma::R](srdma::R) reader structure"]
impl crate::Readable for SRDMA {}
#[doc = "`write(|w| ..)` method takes [srdma::W](srdma::W) writer structure"]
impl crate::Writable for SRDMA {}
#[doc = "Micro Direct Memory Access Software Reset"]
pub mod srdma;
#[doc = "Hibernation Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srhib](srhib) module"]
pub type SRHIB = crate::Reg<u32, _SRHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRHIB;
#[doc = "`read()` method returns [srhib::R](srhib::R) reader structure"]
impl crate::Readable for SRHIB {}
#[doc = "`write(|w| ..)` method takes [srhib::W](srhib::W) writer structure"]
impl crate::Writable for SRHIB {}
#[doc = "Hibernation Software Reset"]
pub mod srhib;
#[doc = "Universal Asynchronous Receiver/Transmitter Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sruart](sruart) module"]
pub type SRUART = crate::Reg<u32, _SRUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRUART;
#[doc = "`read()` method returns [sruart::R](sruart::R) reader structure"]
impl crate::Readable for SRUART {}
#[doc = "`write(|w| ..)` method takes [sruart::W](sruart::W) writer structure"]
impl crate::Writable for SRUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Software Reset"]
pub mod sruart;
#[doc = "Synchronous Serial Interface Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srssi](srssi) module"]
pub type SRSSI = crate::Reg<u32, _SRSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRSSI;
#[doc = "`read()` method returns [srssi::R](srssi::R) reader structure"]
impl crate::Readable for SRSSI {}
#[doc = "`write(|w| ..)` method takes [srssi::W](srssi::W) writer structure"]
impl crate::Writable for SRSSI {}
#[doc = "Synchronous Serial Interface Software Reset"]
pub mod srssi;
#[doc = "Inter-Integrated Circuit Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sri2c](sri2c) module"]
pub type SRI2C = crate::Reg<u32, _SRI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRI2C;
#[doc = "`read()` method returns [sri2c::R](sri2c::R) reader structure"]
impl crate::Readable for SRI2C {}
#[doc = "`write(|w| ..)` method takes [sri2c::W](sri2c::W) writer structure"]
impl crate::Writable for SRI2C {}
#[doc = "Inter-Integrated Circuit Software Reset"]
pub mod sri2c;
#[doc = "Universal Serial Bus Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srusb](srusb) module"]
pub type SRUSB = crate::Reg<u32, _SRUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRUSB;
#[doc = "`read()` method returns [srusb::R](srusb::R) reader structure"]
impl crate::Readable for SRUSB {}
#[doc = "`write(|w| ..)` method takes [srusb::W](srusb::W) writer structure"]
impl crate::Writable for SRUSB {}
#[doc = "Universal Serial Bus Software Reset"]
pub mod srusb;
#[doc = "Controller Area Network Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srcan](srcan) module"]
pub type SRCAN = crate::Reg<u32, _SRCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRCAN;
#[doc = "`read()` method returns [srcan::R](srcan::R) reader structure"]
impl crate::Readable for SRCAN {}
#[doc = "`write(|w| ..)` method takes [srcan::W](srcan::W) writer structure"]
impl crate::Writable for SRCAN {}
#[doc = "Controller Area Network Software Reset"]
pub mod srcan;
#[doc = "Analog-to-Digital Converter Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sradc](sradc) module"]
pub type SRADC = crate::Reg<u32, _SRADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRADC;
#[doc = "`read()` method returns [sradc::R](sradc::R) reader structure"]
impl crate::Readable for SRADC {}
#[doc = "`write(|w| ..)` method takes [sradc::W](sradc::W) writer structure"]
impl crate::Writable for SRADC {}
#[doc = "Analog-to-Digital Converter Software Reset"]
pub mod sradc;
#[doc = "Analog Comparator Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sracmp](sracmp) module"]
pub type SRACMP = crate::Reg<u32, _SRACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRACMP;
#[doc = "`read()` method returns [sracmp::R](sracmp::R) reader structure"]
impl crate::Readable for SRACMP {}
#[doc = "`write(|w| ..)` method takes [sracmp::W](sracmp::W) writer structure"]
impl crate::Writable for SRACMP {}
#[doc = "Analog Comparator Software Reset"]
pub mod sracmp;
#[doc = "Pulse Width Modulator Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srpwm](srpwm) module"]
pub type SRPWM = crate::Reg<u32, _SRPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRPWM;
#[doc = "`read()` method returns [srpwm::R](srpwm::R) reader structure"]
impl crate::Readable for SRPWM {}
#[doc = "`write(|w| ..)` method takes [srpwm::W](srpwm::W) writer structure"]
impl crate::Writable for SRPWM {}
#[doc = "Pulse Width Modulator Software Reset"]
pub mod srpwm;
#[doc = "Quadrature Encoder Interface Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srqei](srqei) module"]
pub type SRQEI = crate::Reg<u32, _SRQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRQEI;
#[doc = "`read()` method returns [srqei::R](srqei::R) reader structure"]
impl crate::Readable for SRQEI {}
#[doc = "`write(|w| ..)` method takes [srqei::W](srqei::W) writer structure"]
impl crate::Writable for SRQEI {}
#[doc = "Quadrature Encoder Interface Software Reset"]
pub mod srqei;
#[doc = "EEPROM Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [sreeprom](sreeprom) module"]
pub type SREEPROM = crate::Reg<u32, _SREEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SREEPROM;
#[doc = "`read()` method returns [sreeprom::R](sreeprom::R) reader structure"]
impl crate::Readable for SREEPROM {}
#[doc = "`write(|w| ..)` method takes [sreeprom::W](sreeprom::W) writer structure"]
impl crate::Writable for SREEPROM {}
#[doc = "EEPROM Software Reset"]
pub mod sreeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Software Reset\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [srwtimer](srwtimer) module"]
pub type SRWTIMER = crate::Reg<u32, _SRWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SRWTIMER;
#[doc = "`read()` method returns [srwtimer::R](srwtimer::R) reader structure"]
impl crate::Readable for SRWTIMER {}
#[doc = "`write(|w| ..)` method takes [srwtimer::W](srwtimer::W) writer structure"]
impl crate::Writable for SRWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Software Reset"]
pub mod srwtimer;
#[doc = "Watchdog Timer Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcwd](rcgcwd) module"]
pub type RCGCWD = crate::Reg<u32, _RCGCWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCWD;
#[doc = "`read()` method returns [rcgcwd::R](rcgcwd::R) reader structure"]
impl crate::Readable for RCGCWD {}
#[doc = "`write(|w| ..)` method takes [rcgcwd::W](rcgcwd::W) writer structure"]
impl crate::Writable for RCGCWD {}
#[doc = "Watchdog Timer Run Mode Clock Gating Control"]
pub mod rcgcwd;
#[doc = "16/32-Bit General-Purpose Timer Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgctimer](rcgctimer) module"]
pub type RCGCTIMER = crate::Reg<u32, _RCGCTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCTIMER;
#[doc = "`read()` method returns [rcgctimer::R](rcgctimer::R) reader structure"]
impl crate::Readable for RCGCTIMER {}
#[doc = "`write(|w| ..)` method takes [rcgctimer::W](rcgctimer::W) writer structure"]
impl crate::Writable for RCGCTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Run Mode Clock Gating Control"]
pub mod rcgctimer;
#[doc = "General-Purpose Input/Output Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcgpio](rcgcgpio) module"]
pub type RCGCGPIO = crate::Reg<u32, _RCGCGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCGPIO;
#[doc = "`read()` method returns [rcgcgpio::R](rcgcgpio::R) reader structure"]
impl crate::Readable for RCGCGPIO {}
#[doc = "`write(|w| ..)` method takes [rcgcgpio::W](rcgcgpio::W) writer structure"]
impl crate::Writable for RCGCGPIO {}
#[doc = "General-Purpose Input/Output Run Mode Clock Gating Control"]
pub mod rcgcgpio;
#[doc = "Micro Direct Memory Access Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcdma](rcgcdma) module"]
pub type RCGCDMA = crate::Reg<u32, _RCGCDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCDMA;
#[doc = "`read()` method returns [rcgcdma::R](rcgcdma::R) reader structure"]
impl crate::Readable for RCGCDMA {}
#[doc = "`write(|w| ..)` method takes [rcgcdma::W](rcgcdma::W) writer structure"]
impl crate::Writable for RCGCDMA {}
#[doc = "Micro Direct Memory Access Run Mode Clock Gating Control"]
pub mod rcgcdma;
#[doc = "Hibernation Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgchib](rcgchib) module"]
pub type RCGCHIB = crate::Reg<u32, _RCGCHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCHIB;
#[doc = "`read()` method returns [rcgchib::R](rcgchib::R) reader structure"]
impl crate::Readable for RCGCHIB {}
#[doc = "`write(|w| ..)` method takes [rcgchib::W](rcgchib::W) writer structure"]
impl crate::Writable for RCGCHIB {}
#[doc = "Hibernation Run Mode Clock Gating Control"]
pub mod rcgchib;
#[doc = "Universal Asynchronous Receiver/Transmitter Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcuart](rcgcuart) module"]
pub type RCGCUART = crate::Reg<u32, _RCGCUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCUART;
#[doc = "`read()` method returns [rcgcuart::R](rcgcuart::R) reader structure"]
impl crate::Readable for RCGCUART {}
#[doc = "`write(|w| ..)` method takes [rcgcuart::W](rcgcuart::W) writer structure"]
impl crate::Writable for RCGCUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Run Mode Clock Gating Control"]
pub mod rcgcuart;
#[doc = "Synchronous Serial Interface Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcssi](rcgcssi) module"]
pub type RCGCSSI = crate::Reg<u32, _RCGCSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCSSI;
#[doc = "`read()` method returns [rcgcssi::R](rcgcssi::R) reader structure"]
impl crate::Readable for RCGCSSI {}
#[doc = "`write(|w| ..)` method takes [rcgcssi::W](rcgcssi::W) writer structure"]
impl crate::Writable for RCGCSSI {}
#[doc = "Synchronous Serial Interface Run Mode Clock Gating Control"]
pub mod rcgcssi;
#[doc = "Inter-Integrated Circuit Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgci2c](rcgci2c) module"]
pub type RCGCI2C = crate::Reg<u32, _RCGCI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCI2C;
#[doc = "`read()` method returns [rcgci2c::R](rcgci2c::R) reader structure"]
impl crate::Readable for RCGCI2C {}
#[doc = "`write(|w| ..)` method takes [rcgci2c::W](rcgci2c::W) writer structure"]
impl crate::Writable for RCGCI2C {}
#[doc = "Inter-Integrated Circuit Run Mode Clock Gating Control"]
pub mod rcgci2c;
#[doc = "Universal Serial Bus Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcusb](rcgcusb) module"]
pub type RCGCUSB = crate::Reg<u32, _RCGCUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCUSB;
#[doc = "`read()` method returns [rcgcusb::R](rcgcusb::R) reader structure"]
impl crate::Readable for RCGCUSB {}
#[doc = "`write(|w| ..)` method takes [rcgcusb::W](rcgcusb::W) writer structure"]
impl crate::Writable for RCGCUSB {}
#[doc = "Universal Serial Bus Run Mode Clock Gating Control"]
pub mod rcgcusb;
#[doc = "Controller Area Network Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgccan](rcgccan) module"]
pub type RCGCCAN = crate::Reg<u32, _RCGCCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCCAN;
#[doc = "`read()` method returns [rcgccan::R](rcgccan::R) reader structure"]
impl crate::Readable for RCGCCAN {}
#[doc = "`write(|w| ..)` method takes [rcgccan::W](rcgccan::W) writer structure"]
impl crate::Writable for RCGCCAN {}
#[doc = "Controller Area Network Run Mode Clock Gating Control"]
pub mod rcgccan;
#[doc = "Analog-to-Digital Converter Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcadc](rcgcadc) module"]
pub type RCGCADC = crate::Reg<u32, _RCGCADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCADC;
#[doc = "`read()` method returns [rcgcadc::R](rcgcadc::R) reader structure"]
impl crate::Readable for RCGCADC {}
#[doc = "`write(|w| ..)` method takes [rcgcadc::W](rcgcadc::W) writer structure"]
impl crate::Writable for RCGCADC {}
#[doc = "Analog-to-Digital Converter Run Mode Clock Gating Control"]
pub mod rcgcadc;
#[doc = "Analog Comparator Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcacmp](rcgcacmp) module"]
pub type RCGCACMP = crate::Reg<u32, _RCGCACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCACMP;
#[doc = "`read()` method returns [rcgcacmp::R](rcgcacmp::R) reader structure"]
impl crate::Readable for RCGCACMP {}
#[doc = "`write(|w| ..)` method takes [rcgcacmp::W](rcgcacmp::W) writer structure"]
impl crate::Writable for RCGCACMP {}
#[doc = "Analog Comparator Run Mode Clock Gating Control"]
pub mod rcgcacmp;
#[doc = "Pulse Width Modulator Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcpwm](rcgcpwm) module"]
pub type RCGCPWM = crate::Reg<u32, _RCGCPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCPWM;
#[doc = "`read()` method returns [rcgcpwm::R](rcgcpwm::R) reader structure"]
impl crate::Readable for RCGCPWM {}
#[doc = "`write(|w| ..)` method takes [rcgcpwm::W](rcgcpwm::W) writer structure"]
impl crate::Writable for RCGCPWM {}
#[doc = "Pulse Width Modulator Run Mode Clock Gating Control"]
pub mod rcgcpwm;
#[doc = "Quadrature Encoder Interface Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcqei](rcgcqei) module"]
pub type RCGCQEI = crate::Reg<u32, _RCGCQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCQEI;
#[doc = "`read()` method returns [rcgcqei::R](rcgcqei::R) reader structure"]
impl crate::Readable for RCGCQEI {}
#[doc = "`write(|w| ..)` method takes [rcgcqei::W](rcgcqei::W) writer structure"]
impl crate::Writable for RCGCQEI {}
#[doc = "Quadrature Encoder Interface Run Mode Clock Gating Control"]
pub mod rcgcqei;
#[doc = "EEPROM Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgceeprom](rcgceeprom) module"]
pub type RCGCEEPROM = crate::Reg<u32, _RCGCEEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCEEPROM;
#[doc = "`read()` method returns [rcgceeprom::R](rcgceeprom::R) reader structure"]
impl crate::Readable for RCGCEEPROM {}
#[doc = "`write(|w| ..)` method takes [rcgceeprom::W](rcgceeprom::W) writer structure"]
impl crate::Writable for RCGCEEPROM {}
#[doc = "EEPROM Run Mode Clock Gating Control"]
pub mod rcgceeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Run Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [rcgcwtimer](rcgcwtimer) module"]
pub type RCGCWTIMER = crate::Reg<u32, _RCGCWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _RCGCWTIMER;
#[doc = "`read()` method returns [rcgcwtimer::R](rcgcwtimer::R) reader structure"]
impl crate::Readable for RCGCWTIMER {}
#[doc = "`write(|w| ..)` method takes [rcgcwtimer::W](rcgcwtimer::W) writer structure"]
impl crate::Writable for RCGCWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Run Mode Clock Gating Control"]
pub mod rcgcwtimer;
#[doc = "Watchdog Timer Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcwd](scgcwd) module"]
pub type SCGCWD = crate::Reg<u32, _SCGCWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCWD;
#[doc = "`read()` method returns [scgcwd::R](scgcwd::R) reader structure"]
impl crate::Readable for SCGCWD {}
#[doc = "`write(|w| ..)` method takes [scgcwd::W](scgcwd::W) writer structure"]
impl crate::Writable for SCGCWD {}
#[doc = "Watchdog Timer Sleep Mode Clock Gating Control"]
pub mod scgcwd;
#[doc = "16/32-Bit General-Purpose Timer Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgctimer](scgctimer) module"]
pub type SCGCTIMER = crate::Reg<u32, _SCGCTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCTIMER;
#[doc = "`read()` method returns [scgctimer::R](scgctimer::R) reader structure"]
impl crate::Readable for SCGCTIMER {}
#[doc = "`write(|w| ..)` method takes [scgctimer::W](scgctimer::W) writer structure"]
impl crate::Writable for SCGCTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Sleep Mode Clock Gating Control"]
pub mod scgctimer;
#[doc = "General-Purpose Input/Output Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcgpio](scgcgpio) module"]
pub type SCGCGPIO = crate::Reg<u32, _SCGCGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCGPIO;
#[doc = "`read()` method returns [scgcgpio::R](scgcgpio::R) reader structure"]
impl crate::Readable for SCGCGPIO {}
#[doc = "`write(|w| ..)` method takes [scgcgpio::W](scgcgpio::W) writer structure"]
impl crate::Writable for SCGCGPIO {}
#[doc = "General-Purpose Input/Output Sleep Mode Clock Gating Control"]
pub mod scgcgpio;
#[doc = "Micro Direct Memory Access Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcdma](scgcdma) module"]
pub type SCGCDMA = crate::Reg<u32, _SCGCDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCDMA;
#[doc = "`read()` method returns [scgcdma::R](scgcdma::R) reader structure"]
impl crate::Readable for SCGCDMA {}
#[doc = "`write(|w| ..)` method takes [scgcdma::W](scgcdma::W) writer structure"]
impl crate::Writable for SCGCDMA {}
#[doc = "Micro Direct Memory Access Sleep Mode Clock Gating Control"]
pub mod scgcdma;
#[doc = "Hibernation Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgchib](scgchib) module"]
pub type SCGCHIB = crate::Reg<u32, _SCGCHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCHIB;
#[doc = "`read()` method returns [scgchib::R](scgchib::R) reader structure"]
impl crate::Readable for SCGCHIB {}
#[doc = "`write(|w| ..)` method takes [scgchib::W](scgchib::W) writer structure"]
impl crate::Writable for SCGCHIB {}
#[doc = "Hibernation Sleep Mode Clock Gating Control"]
pub mod scgchib;
#[doc = "Universal Asynchronous Receiver/Transmitter Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcuart](scgcuart) module"]
pub type SCGCUART = crate::Reg<u32, _SCGCUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCUART;
#[doc = "`read()` method returns [scgcuart::R](scgcuart::R) reader structure"]
impl crate::Readable for SCGCUART {}
#[doc = "`write(|w| ..)` method takes [scgcuart::W](scgcuart::W) writer structure"]
impl crate::Writable for SCGCUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Sleep Mode Clock Gating Control"]
pub mod scgcuart;
#[doc = "Synchronous Serial Interface Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcssi](scgcssi) module"]
pub type SCGCSSI = crate::Reg<u32, _SCGCSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCSSI;
#[doc = "`read()` method returns [scgcssi::R](scgcssi::R) reader structure"]
impl crate::Readable for SCGCSSI {}
#[doc = "`write(|w| ..)` method takes [scgcssi::W](scgcssi::W) writer structure"]
impl crate::Writable for SCGCSSI {}
#[doc = "Synchronous Serial Interface Sleep Mode Clock Gating Control"]
pub mod scgcssi;
#[doc = "Inter-Integrated Circuit Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgci2c](scgci2c) module"]
pub type SCGCI2C = crate::Reg<u32, _SCGCI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCI2C;
#[doc = "`read()` method returns [scgci2c::R](scgci2c::R) reader structure"]
impl crate::Readable for SCGCI2C {}
#[doc = "`write(|w| ..)` method takes [scgci2c::W](scgci2c::W) writer structure"]
impl crate::Writable for SCGCI2C {}
#[doc = "Inter-Integrated Circuit Sleep Mode Clock Gating Control"]
pub mod scgci2c;
#[doc = "Universal Serial Bus Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcusb](scgcusb) module"]
pub type SCGCUSB = crate::Reg<u32, _SCGCUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCUSB;
#[doc = "`read()` method returns [scgcusb::R](scgcusb::R) reader structure"]
impl crate::Readable for SCGCUSB {}
#[doc = "`write(|w| ..)` method takes [scgcusb::W](scgcusb::W) writer structure"]
impl crate::Writable for SCGCUSB {}
#[doc = "Universal Serial Bus Sleep Mode Clock Gating Control"]
pub mod scgcusb;
#[doc = "Controller Area Network Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgccan](scgccan) module"]
pub type SCGCCAN = crate::Reg<u32, _SCGCCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCCAN;
#[doc = "`read()` method returns [scgccan::R](scgccan::R) reader structure"]
impl crate::Readable for SCGCCAN {}
#[doc = "`write(|w| ..)` method takes [scgccan::W](scgccan::W) writer structure"]
impl crate::Writable for SCGCCAN {}
#[doc = "Controller Area Network Sleep Mode Clock Gating Control"]
pub mod scgccan;
#[doc = "Analog-to-Digital Converter Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcadc](scgcadc) module"]
pub type SCGCADC = crate::Reg<u32, _SCGCADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCADC;
#[doc = "`read()` method returns [scgcadc::R](scgcadc::R) reader structure"]
impl crate::Readable for SCGCADC {}
#[doc = "`write(|w| ..)` method takes [scgcadc::W](scgcadc::W) writer structure"]
impl crate::Writable for SCGCADC {}
#[doc = "Analog-to-Digital Converter Sleep Mode Clock Gating Control"]
pub mod scgcadc;
#[doc = "Analog Comparator Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcacmp](scgcacmp) module"]
pub type SCGCACMP = crate::Reg<u32, _SCGCACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCACMP;
#[doc = "`read()` method returns [scgcacmp::R](scgcacmp::R) reader structure"]
impl crate::Readable for SCGCACMP {}
#[doc = "`write(|w| ..)` method takes [scgcacmp::W](scgcacmp::W) writer structure"]
impl crate::Writable for SCGCACMP {}
#[doc = "Analog Comparator Sleep Mode Clock Gating Control"]
pub mod scgcacmp;
#[doc = "Pulse Width Modulator Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcpwm](scgcpwm) module"]
pub type SCGCPWM = crate::Reg<u32, _SCGCPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCPWM;
#[doc = "`read()` method returns [scgcpwm::R](scgcpwm::R) reader structure"]
impl crate::Readable for SCGCPWM {}
#[doc = "`write(|w| ..)` method takes [scgcpwm::W](scgcpwm::W) writer structure"]
impl crate::Writable for SCGCPWM {}
#[doc = "Pulse Width Modulator Sleep Mode Clock Gating Control"]
pub mod scgcpwm;
#[doc = "Quadrature Encoder Interface Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcqei](scgcqei) module"]
pub type SCGCQEI = crate::Reg<u32, _SCGCQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCQEI;
#[doc = "`read()` method returns [scgcqei::R](scgcqei::R) reader structure"]
impl crate::Readable for SCGCQEI {}
#[doc = "`write(|w| ..)` method takes [scgcqei::W](scgcqei::W) writer structure"]
impl crate::Writable for SCGCQEI {}
#[doc = "Quadrature Encoder Interface Sleep Mode Clock Gating Control"]
pub mod scgcqei;
#[doc = "EEPROM Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgceeprom](scgceeprom) module"]
pub type SCGCEEPROM = crate::Reg<u32, _SCGCEEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCEEPROM;
#[doc = "`read()` method returns [scgceeprom::R](scgceeprom::R) reader structure"]
impl crate::Readable for SCGCEEPROM {}
#[doc = "`write(|w| ..)` method takes [scgceeprom::W](scgceeprom::W) writer structure"]
impl crate::Writable for SCGCEEPROM {}
#[doc = "EEPROM Sleep Mode Clock Gating Control"]
pub mod scgceeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [scgcwtimer](scgcwtimer) module"]
pub type SCGCWTIMER = crate::Reg<u32, _SCGCWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _SCGCWTIMER;
#[doc = "`read()` method returns [scgcwtimer::R](scgcwtimer::R) reader structure"]
impl crate::Readable for SCGCWTIMER {}
#[doc = "`write(|w| ..)` method takes [scgcwtimer::W](scgcwtimer::W) writer structure"]
impl crate::Writable for SCGCWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Sleep Mode Clock Gating Control"]
pub mod scgcwtimer;
#[doc = "Watchdog Timer Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcwd](dcgcwd) module"]
pub type DCGCWD = crate::Reg<u32, _DCGCWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCWD;
#[doc = "`read()` method returns [dcgcwd::R](dcgcwd::R) reader structure"]
impl crate::Readable for DCGCWD {}
#[doc = "`write(|w| ..)` method takes [dcgcwd::W](dcgcwd::W) writer structure"]
impl crate::Writable for DCGCWD {}
#[doc = "Watchdog Timer Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcwd;
#[doc = "16/32-Bit General-Purpose Timer Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgctimer](dcgctimer) module"]
pub type DCGCTIMER = crate::Reg<u32, _DCGCTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCTIMER;
#[doc = "`read()` method returns [dcgctimer::R](dcgctimer::R) reader structure"]
impl crate::Readable for DCGCTIMER {}
#[doc = "`write(|w| ..)` method takes [dcgctimer::W](dcgctimer::W) writer structure"]
impl crate::Writable for DCGCTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Deep-Sleep Mode Clock Gating Control"]
pub mod dcgctimer;
#[doc = "General-Purpose Input/Output Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcgpio](dcgcgpio) module"]
pub type DCGCGPIO = crate::Reg<u32, _DCGCGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCGPIO;
#[doc = "`read()` method returns [dcgcgpio::R](dcgcgpio::R) reader structure"]
impl crate::Readable for DCGCGPIO {}
#[doc = "`write(|w| ..)` method takes [dcgcgpio::W](dcgcgpio::W) writer structure"]
impl crate::Writable for DCGCGPIO {}
#[doc = "General-Purpose Input/Output Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcgpio;
#[doc = "Micro Direct Memory Access Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcdma](dcgcdma) module"]
pub type DCGCDMA = crate::Reg<u32, _DCGCDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCDMA;
#[doc = "`read()` method returns [dcgcdma::R](dcgcdma::R) reader structure"]
impl crate::Readable for DCGCDMA {}
#[doc = "`write(|w| ..)` method takes [dcgcdma::W](dcgcdma::W) writer structure"]
impl crate::Writable for DCGCDMA {}
#[doc = "Micro Direct Memory Access Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcdma;
#[doc = "Hibernation Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgchib](dcgchib) module"]
pub type DCGCHIB = crate::Reg<u32, _DCGCHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCHIB;
#[doc = "`read()` method returns [dcgchib::R](dcgchib::R) reader structure"]
impl crate::Readable for DCGCHIB {}
#[doc = "`write(|w| ..)` method takes [dcgchib::W](dcgchib::W) writer structure"]
impl crate::Writable for DCGCHIB {}
#[doc = "Hibernation Deep-Sleep Mode Clock Gating Control"]
pub mod dcgchib;
#[doc = "Universal Asynchronous Receiver/Transmitter Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcuart](dcgcuart) module"]
pub type DCGCUART = crate::Reg<u32, _DCGCUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCUART;
#[doc = "`read()` method returns [dcgcuart::R](dcgcuart::R) reader structure"]
impl crate::Readable for DCGCUART {}
#[doc = "`write(|w| ..)` method takes [dcgcuart::W](dcgcuart::W) writer structure"]
impl crate::Writable for DCGCUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcuart;
#[doc = "Synchronous Serial Interface Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcssi](dcgcssi) module"]
pub type DCGCSSI = crate::Reg<u32, _DCGCSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCSSI;
#[doc = "`read()` method returns [dcgcssi::R](dcgcssi::R) reader structure"]
impl crate::Readable for DCGCSSI {}
#[doc = "`write(|w| ..)` method takes [dcgcssi::W](dcgcssi::W) writer structure"]
impl crate::Writable for DCGCSSI {}
#[doc = "Synchronous Serial Interface Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcssi;
#[doc = "Inter-Integrated Circuit Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgci2c](dcgci2c) module"]
pub type DCGCI2C = crate::Reg<u32, _DCGCI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCI2C;
#[doc = "`read()` method returns [dcgci2c::R](dcgci2c::R) reader structure"]
impl crate::Readable for DCGCI2C {}
#[doc = "`write(|w| ..)` method takes [dcgci2c::W](dcgci2c::W) writer structure"]
impl crate::Writable for DCGCI2C {}
#[doc = "Inter-Integrated Circuit Deep-Sleep Mode Clock Gating Control"]
pub mod dcgci2c;
#[doc = "Universal Serial Bus Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcusb](dcgcusb) module"]
pub type DCGCUSB = crate::Reg<u32, _DCGCUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCUSB;
#[doc = "`read()` method returns [dcgcusb::R](dcgcusb::R) reader structure"]
impl crate::Readable for DCGCUSB {}
#[doc = "`write(|w| ..)` method takes [dcgcusb::W](dcgcusb::W) writer structure"]
impl crate::Writable for DCGCUSB {}
#[doc = "Universal Serial Bus Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcusb;
#[doc = "Controller Area Network Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgccan](dcgccan) module"]
pub type DCGCCAN = crate::Reg<u32, _DCGCCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCCAN;
#[doc = "`read()` method returns [dcgccan::R](dcgccan::R) reader structure"]
impl crate::Readable for DCGCCAN {}
#[doc = "`write(|w| ..)` method takes [dcgccan::W](dcgccan::W) writer structure"]
impl crate::Writable for DCGCCAN {}
#[doc = "Controller Area Network Deep-Sleep Mode Clock Gating Control"]
pub mod dcgccan;
#[doc = "Analog-to-Digital Converter Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcadc](dcgcadc) module"]
pub type DCGCADC = crate::Reg<u32, _DCGCADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCADC;
#[doc = "`read()` method returns [dcgcadc::R](dcgcadc::R) reader structure"]
impl crate::Readable for DCGCADC {}
#[doc = "`write(|w| ..)` method takes [dcgcadc::W](dcgcadc::W) writer structure"]
impl crate::Writable for DCGCADC {}
#[doc = "Analog-to-Digital Converter Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcadc;
#[doc = "Analog Comparator Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcacmp](dcgcacmp) module"]
pub type DCGCACMP = crate::Reg<u32, _DCGCACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCACMP;
#[doc = "`read()` method returns [dcgcacmp::R](dcgcacmp::R) reader structure"]
impl crate::Readable for DCGCACMP {}
#[doc = "`write(|w| ..)` method takes [dcgcacmp::W](dcgcacmp::W) writer structure"]
impl crate::Writable for DCGCACMP {}
#[doc = "Analog Comparator Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcacmp;
#[doc = "Pulse Width Modulator Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcpwm](dcgcpwm) module"]
pub type DCGCPWM = crate::Reg<u32, _DCGCPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCPWM;
#[doc = "`read()` method returns [dcgcpwm::R](dcgcpwm::R) reader structure"]
impl crate::Readable for DCGCPWM {}
#[doc = "`write(|w| ..)` method takes [dcgcpwm::W](dcgcpwm::W) writer structure"]
impl crate::Writable for DCGCPWM {}
#[doc = "Pulse Width Modulator Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcpwm;
#[doc = "Quadrature Encoder Interface Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcqei](dcgcqei) module"]
pub type DCGCQEI = crate::Reg<u32, _DCGCQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCQEI;
#[doc = "`read()` method returns [dcgcqei::R](dcgcqei::R) reader structure"]
impl crate::Readable for DCGCQEI {}
#[doc = "`write(|w| ..)` method takes [dcgcqei::W](dcgcqei::W) writer structure"]
impl crate::Writable for DCGCQEI {}
#[doc = "Quadrature Encoder Interface Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcqei;
#[doc = "EEPROM Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgceeprom](dcgceeprom) module"]
pub type DCGCEEPROM = crate::Reg<u32, _DCGCEEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCEEPROM;
#[doc = "`read()` method returns [dcgceeprom::R](dcgceeprom::R) reader structure"]
impl crate::Readable for DCGCEEPROM {}
#[doc = "`write(|w| ..)` method takes [dcgceeprom::W](dcgceeprom::W) writer structure"]
impl crate::Writable for DCGCEEPROM {}
#[doc = "EEPROM Deep-Sleep Mode Clock Gating Control"]
pub mod dcgceeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Deep-Sleep Mode Clock Gating Control\n\nThis register you can [`read`](crate::generic::Reg::read), [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero), [`modify`](crate::generic::Reg::modify). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [dcgcwtimer](dcgcwtimer) module"]
pub type DCGCWTIMER = crate::Reg<u32, _DCGCWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _DCGCWTIMER;
#[doc = "`read()` method returns [dcgcwtimer::R](dcgcwtimer::R) reader structure"]
impl crate::Readable for DCGCWTIMER {}
#[doc = "`write(|w| ..)` method takes [dcgcwtimer::W](dcgcwtimer::W) writer structure"]
impl crate::Writable for DCGCWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Deep-Sleep Mode Clock Gating Control"]
pub mod dcgcwtimer;
#[doc = "Watchdog Timer Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prwd](prwd) module"]
pub type PRWD = crate::Reg<u32, _PRWD>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRWD;
#[doc = "`read()` method returns [prwd::R](prwd::R) reader structure"]
impl crate::Readable for PRWD {}
#[doc = "Watchdog Timer Peripheral Ready"]
pub mod prwd;
#[doc = "16/32-Bit General-Purpose Timer Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prtimer](prtimer) module"]
pub type PRTIMER = crate::Reg<u32, _PRTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRTIMER;
#[doc = "`read()` method returns [prtimer::R](prtimer::R) reader structure"]
impl crate::Readable for PRTIMER {}
#[doc = "16/32-Bit General-Purpose Timer Peripheral Ready"]
pub mod prtimer;
#[doc = "General-Purpose Input/Output Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prgpio](prgpio) module"]
pub type PRGPIO = crate::Reg<u32, _PRGPIO>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRGPIO;
#[doc = "`read()` method returns [prgpio::R](prgpio::R) reader structure"]
impl crate::Readable for PRGPIO {}
#[doc = "General-Purpose Input/Output Peripheral Ready"]
pub mod prgpio;
#[doc = "Micro Direct Memory Access Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prdma](prdma) module"]
pub type PRDMA = crate::Reg<u32, _PRDMA>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRDMA;
#[doc = "`read()` method returns [prdma::R](prdma::R) reader structure"]
impl crate::Readable for PRDMA {}
#[doc = "Micro Direct Memory Access Peripheral Ready"]
pub mod prdma;
#[doc = "Hibernation Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prhib](prhib) module"]
pub type PRHIB = crate::Reg<u32, _PRHIB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRHIB;
#[doc = "`read()` method returns [prhib::R](prhib::R) reader structure"]
impl crate::Readable for PRHIB {}
#[doc = "Hibernation Peripheral Ready"]
pub mod prhib;
#[doc = "Universal Asynchronous Receiver/Transmitter Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pruart](pruart) module"]
pub type PRUART = crate::Reg<u32, _PRUART>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRUART;
#[doc = "`read()` method returns [pruart::R](pruart::R) reader structure"]
impl crate::Readable for PRUART {}
#[doc = "Universal Asynchronous Receiver/Transmitter Peripheral Ready"]
pub mod pruart;
#[doc = "Synchronous Serial Interface Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prssi](prssi) module"]
pub type PRSSI = crate::Reg<u32, _PRSSI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRSSI;
#[doc = "`read()` method returns [prssi::R](prssi::R) reader structure"]
impl crate::Readable for PRSSI {}
#[doc = "Synchronous Serial Interface Peripheral Ready"]
pub mod prssi;
#[doc = "Inter-Integrated Circuit Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pri2c](pri2c) module"]
pub type PRI2C = crate::Reg<u32, _PRI2C>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRI2C;
#[doc = "`read()` method returns [pri2c::R](pri2c::R) reader structure"]
impl crate::Readable for PRI2C {}
#[doc = "Inter-Integrated Circuit Peripheral Ready"]
pub mod pri2c;
#[doc = "Universal Serial Bus Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prusb](prusb) module"]
pub type PRUSB = crate::Reg<u32, _PRUSB>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRUSB;
#[doc = "`read()` method returns [prusb::R](prusb::R) reader structure"]
impl crate::Readable for PRUSB {}
#[doc = "Universal Serial Bus Peripheral Ready"]
pub mod prusb;
#[doc = "Controller Area Network Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prcan](prcan) module"]
pub type PRCAN = crate::Reg<u32, _PRCAN>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRCAN;
#[doc = "`read()` method returns [prcan::R](prcan::R) reader structure"]
impl crate::Readable for PRCAN {}
#[doc = "Controller Area Network Peripheral Ready"]
pub mod prcan;
#[doc = "Analog-to-Digital Converter Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pradc](pradc) module"]
pub type PRADC = crate::Reg<u32, _PRADC>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRADC;
#[doc = "`read()` method returns [pradc::R](pradc::R) reader structure"]
impl crate::Readable for PRADC {}
#[doc = "Analog-to-Digital Converter Peripheral Ready"]
pub mod pradc;
#[doc = "Analog Comparator Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [pracmp](pracmp) module"]
pub type PRACMP = crate::Reg<u32, _PRACMP>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRACMP;
#[doc = "`read()` method returns [pracmp::R](pracmp::R) reader structure"]
impl crate::Readable for PRACMP {}
#[doc = "Analog Comparator Peripheral Ready"]
pub mod pracmp;
#[doc = "Pulse Width Modulator Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prpwm](prpwm) module"]
pub type PRPWM = crate::Reg<u32, _PRPWM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRPWM;
#[doc = "`read()` method returns [prpwm::R](prpwm::R) reader structure"]
impl crate::Readable for PRPWM {}
#[doc = "Pulse Width Modulator Peripheral Ready"]
pub mod prpwm;
#[doc = "Quadrature Encoder Interface Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prqei](prqei) module"]
pub type PRQEI = crate::Reg<u32, _PRQEI>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRQEI;
#[doc = "`read()` method returns [prqei::R](prqei::R) reader structure"]
impl crate::Readable for PRQEI {}
#[doc = "Quadrature Encoder Interface Peripheral Ready"]
pub mod prqei;
#[doc = "EEPROM Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [preeprom](preeprom) module"]
pub type PREEPROM = crate::Reg<u32, _PREEPROM>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PREEPROM;
#[doc = "`read()` method returns [preeprom::R](preeprom::R) reader structure"]
impl crate::Readable for PREEPROM {}
#[doc = "EEPROM Peripheral Ready"]
pub mod preeprom;
#[doc = "32/64-Bit Wide General-Purpose Timer Peripheral Ready\n\nThis register you can [`read`](crate::generic::Reg::read). See [API](https://docs.rs/svd2rust/#read--modify--write-api).\n\nFor information about available fields see [prwtimer](prwtimer) module"]
pub type PRWTIMER = crate::Reg<u32, _PRWTIMER>;
#[allow(missing_docs)]
#[doc(hidden)]
pub struct _PRWTIMER;
#[doc = "`read()` method returns [prwtimer::R](prwtimer::R) reader structure"]
impl crate::Readable for PRWTIMER {}
#[doc = "32/64-Bit Wide General-Purpose Timer Peripheral Ready"]
pub mod prwtimer;
|
use {
std::{
path::Path,
collections::HashMap,
}
}
enum Asset<T>{
Loading(T),
Loaded(T),
}
struct Assetmanager{
cache:Vec<Asset<Font>>,
}
impl Assetmanager {
fn load<T>(&mut self, future:T) {
self.cache.insert(P, future);
}
}
|
use serde::Deserialize;
use std::fmt;
const API_URL: &'static str = "https://www.swr3.de/ext/cf=42/actions/feed/onair.json";
#[derive(Debug, Deserialize)]
pub struct Swr3ApiResponse {
pub playlist: Vec<Swr3Song>,
}
#[derive(Debug, Deserialize, Clone, PartialEq)]
pub struct Swr3Song {
pub title: String,
pub artist: String,
}
impl fmt::Display for Swr3Song {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, r#""{}" by {}"#, self.title, self.artist)
}
}
pub fn get_current_played_song() -> Option<Swr3Song> {
let response = reqwest::get(API_URL);
response
.and_then(|mut result| result.json::<Swr3ApiResponse>())
.ok()
.map(|x| x.playlist)
.and_then(|x| x.iter().nth(0).cloned())
}
|
use generic_array::{ArrayLength, GenericArray};
use itertools::{IntoChunks, Itertools};
use crate::raw;
use std::marker::PhantomData;
use crate::FlannError;
use crate::Indexable;
use crate::Neighbor;
use crate::Parameters;
pub struct Index<T: Indexable, N: ArrayLength<T>> {
index: raw::flann_index_t,
storage: Vec<Vec<T>>,
parameters: raw::FLANNParameters,
rebuild_threshold: f32,
_phantom: PhantomData<(T, N)>,
}
impl<T: Indexable, N: ArrayLength<T>> Drop for Index<T, N> {
fn drop(&mut self) {
unsafe {
T::free_index(self.index, &mut self.parameters);
}
}
}
impl<T: Indexable, N: ArrayLength<T>> Index<T, N> {
pub fn new<I>(points: I, parameters: Parameters) -> Result<Self, FlannError>
where
I: IntoIterator<Item = GenericArray<T, N>>,
{
let points_vec: Vec<T> = points.into_iter().flat_map(|p| p.into_iter()).collect();
if points_vec.is_empty() {
return Err(FlannError::ZeroInputPoints);
}
let mut speedup = 0.0;
let rebuild_threshold = parameters.rebuild_threshold;
let mut flann_params = parameters.into();
let index = unsafe {
T::build_index(
points_vec.as_ptr() as *mut T,
(points_vec.len() / N::to_usize()) as i32,
N::to_i32(),
&mut speedup,
&mut flann_params,
)
};
if index.is_null() {
return Err(FlannError::FailedToBuildIndex);
}
Ok(Self {
index,
storage: vec![points_vec],
parameters: flann_params,
rebuild_threshold,
_phantom: PhantomData,
})
}
/// Adds a point to the index.
pub fn add(&mut self, point: GenericArray<T, N>) {
let points_vec: Vec<T> = point.into_iter().collect();
let retval = unsafe {
T::add_points(
self.index,
points_vec.as_ptr() as *mut T,
1,
N::to_i32(),
self.rebuild_threshold,
)
};
self.storage.push(points_vec);
assert_eq!(retval, 0);
}
/// Adds multiple points to the index.
pub fn add_multiple<I>(&mut self, points: I)
where
I: IntoIterator<Item = GenericArray<T, N>>,
{
let points_vec: Vec<T> = points.into_iter().flat_map(|p| p.into_iter()).collect();
if points_vec.is_empty() {
return;
}
let retval = unsafe {
T::add_points(
self.index,
points_vec.as_ptr() as *mut T,
(points_vec.len() / N::to_usize()) as i32,
N::to_i32(),
self.rebuild_threshold,
)
};
self.storage.push(points_vec);
assert_eq!(retval, 0);
}
/// Get the point that corresponds to this index `idx`.
pub fn get(&self, idx: usize) -> Option<&GenericArray<T, N>> {
if idx < self.len() {
let point = unsafe { T::get_point(self.index, idx as u32) };
assert!(!point.is_null());
Some(unsafe { &*(point as *const GenericArray<T, N>) })
} else {
None
}
}
/// Removes a point at index `idx`.
pub fn remove(&mut self, idx: usize) {
let retval = unsafe { T::remove_point(self.index, idx as u32) };
assert_eq!(retval, 0);
}
pub fn len(&self) -> usize {
unsafe { T::size(self.index) as usize }
}
pub fn is_empty(&self) -> bool {
self.len() == 0
}
/// Performs a search to find only the closest neighbor.
pub fn find_nearest_neighbor(&mut self, point: &GenericArray<T, N>) -> Neighbor<T::ResultType> {
let mut index = -1;
let mut distance_squared = T::ResultType::default();
let retval = unsafe {
T::find_nearest_neighbors_index(
self.index,
point.as_ptr() as *mut T,
1,
&mut index,
&mut distance_squared,
1,
&mut self.parameters,
)
};
assert_eq!(retval, 0);
Neighbor {
index: index as usize,
distance_squared,
}
}
/// Performs k-NN search for `num` neighbors.
/// If there are less points in the set than `num` it returns that many neighbors.
pub fn find_nearest_neighbors(
&mut self,
num: usize,
point: &GenericArray<T, N>,
) -> impl Iterator<Item = Neighbor<T::ResultType>> {
let num = num.min(self.len());
let mut indices: Vec<i32> = vec![-1; num];
let mut distances_squared: Vec<T::ResultType> = vec![T::ResultType::default(); num];
let retval = unsafe {
T::find_nearest_neighbors_index(
self.index,
point.as_ptr() as *mut T,
1,
indices.as_mut_ptr(),
distances_squared.as_mut_ptr(),
num as i32,
&mut self.parameters,
)
};
assert_eq!(retval, 0);
indices
.into_iter()
.zip(distances_squared.into_iter())
.map(|(index, distance_squared)| Neighbor {
index: index as usize,
distance_squared,
})
}
/// Performs k-NN search for `num` neighbors.
/// If there are less points in the set than `num` it returns that many neighbors.
pub fn find_nearest_neighbors_radius(
&mut self,
num: usize,
radius_squared: f32,
point: &GenericArray<T, N>,
) -> impl Iterator<Item = Neighbor<T::ResultType>> {
let num = num.min(self.len());
let mut indices: Vec<i32> = vec![-1; num];
let mut distances_squared: Vec<T::ResultType> = vec![T::ResultType::default(); num];
let retval = unsafe {
T::radius_search(
self.index,
point.as_ptr() as *mut T,
indices.as_mut_ptr(),
distances_squared.as_mut_ptr(),
num as i32,
radius_squared,
&mut self.parameters,
)
};
assert!(retval >= 0);
indices
.into_iter()
.zip(distances_squared.into_iter())
.take(retval as usize)
.map(|(index, distance_squared)| Neighbor {
index: index as usize,
distance_squared,
})
}
/// Performs k-NN search on `num` neighbors for several points.
///
/// If there are less points in the set than `num` it returns that many
/// neighbors for each point.
pub fn find_many_nearest_neighbors(
&mut self,
num: usize,
points: &[GenericArray<T, N>],
) -> IntoChunks<impl Iterator<Item = Neighbor<T::ResultType>>> {
let neighbor_from_index_distance = |(index, distance_squared)| Neighbor {
index: index as usize,
distance_squared,
};
if points.is_empty() {
let indices: Vec<i32> = Vec::new();
let distances: Vec<T::ResultType> = Vec::new();
return indices
.into_iter()
.zip(distances.into_iter())
.map(neighbor_from_index_distance)
.chunks(num);
}
let num = num.min(self.len());
let mut indices: Vec<i32> = vec![-1; num * points.len()];
let mut distances_squared: Vec<T::ResultType> =
vec![T::ResultType::default(); num * points.len()];
let retval = unsafe {
T::find_nearest_neighbors_index(
self.index,
points.as_ptr() as *mut T,
points.len() as i32,
indices.as_mut_ptr(),
distances_squared.as_mut_ptr(),
num as i32,
&mut self.parameters,
)
};
assert_eq!(retval, 0);
indices
.into_iter()
.zip(distances_squared.into_iter())
.map(neighbor_from_index_distance)
.chunks(num)
}
}
|
extern crate regex;
fn get_base(s: &str) -> (u128, u32) {
use regex::Regex;
if Regex::new(r"\.").unwrap().is_match(format!("{}", s).trim()) {
(
Regex::new(r"(?P<a>\d*)\.(?P<b>\d*)")
.unwrap()
.replace_all(format!("{}", s).trim(), "$a$b")
.parse()
.unwrap(),
format!("{}", s).trim().len() as u32
- Regex::new(r"\.")
.unwrap()
.find(format!("{}", s).trim())
.unwrap()
.start() as u32
- 1,
)
} else {
(format!("{}", s).trim().parse().unwrap(), 0)
}
}
fn str_to_u32(s: &str) -> u32 {
format!("{}", s).trim().parse().unwrap()
}
fn to_u128(s: String) -> u128 {
use regex::Regex;
let m = Regex::new(r"u128e").unwrap().find(&*s).unwrap();
let (base, unpow) = get_base(&s[0..m.start()]);
base * 10u128.pow(str_to_u32(&s[m.end()..])) / 10u128.pow(unpow)
}
macro_rules! numero_entero {
(let $numero:ident = $texto:tt) => {
let $numero = to_u128(stringify!($texto).to_string());
};
(let mut $numero:ident = $texto:tt) => {
let mut $numero = to_u128(stringify!($texto).to_string());
};
($numero:ident = $texto:tt) => {
$numero = to_u128(stringify!($texto).to_string());
};
}
fn main() {
numero_entero!(let foo = 1.1u128e18);
println!("{}", foo);
numero_entero!(let mut bar = 2u128e18);
println!("{}", bar);
numero_entero!(bar = 3.2u128e5);
println!("{}", bar);
}
|
// Copyright 2013 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use color::Color;
use layers::Layer;
use scene::Scene;
use texturegl::Texture;
use texturegl::Flip::VerticalFlip;
use texturegl::TextureTarget::{TextureTarget2D, TextureTargetRectangle};
use tiling::Tile;
use platform::surface::NativeDisplay;
use euclid::{Matrix4D, Point2D, Rect, Size2D};
use libc::c_int;
use gleam::gl;
use gleam::gl::{GLenum, GLfloat, GLint, GLsizei, GLuint};
use std::fmt;
use std::mem;
use std::rc::Rc;
use std::cmp::Ordering;
#[derive(Copy, Clone, Debug)]
pub struct ColorVertex {
x: f32,
y: f32,
}
#[cfg(feature = "heapsize")]
known_heap_size!(0, ColorVertex);
impl ColorVertex {
pub fn new(point: Point2D<f32>) -> ColorVertex {
ColorVertex {
x: point.x,
y: point.y,
}
}
}
#[derive(Copy, Clone, Debug)]
pub struct TextureVertex {
x: f32,
y: f32,
u: f32,
v: f32,
}
#[cfg(feature = "heapsize")]
known_heap_size!(0, TextureVertex);
impl TextureVertex {
pub fn new(point: Point2D<f32>, texture_coordinates: Point2D<f32>) -> TextureVertex {
TextureVertex {
x: point.x,
y: point.y,
u: texture_coordinates.x,
v: texture_coordinates.y,
}
}
}
const ORTHO_NEAR_PLANE: f32 = -1000000.0;
const ORTHO_FAR_PLANE: f32 = 1000000.0;
fn create_ortho(scene_size: &Size2D<f32>) -> Matrix4D<f32> {
Matrix4D::ortho(0.0, scene_size.width, scene_size.height, 0.0, ORTHO_NEAR_PLANE, ORTHO_FAR_PLANE)
}
static TEXTURE_FRAGMENT_SHADER_SOURCE: &'static str = "
#ifdef GL_ES
precision mediump float;
#endif
varying vec2 vTextureCoord;
uniform samplerType uSampler;
uniform float uOpacity;
void main(void) {
vec4 lFragColor = uOpacity * samplerFunction(uSampler, vTextureCoord);
gl_FragColor = lFragColor;
}
";
static SOLID_COLOR_FRAGMENT_SHADER_SOURCE: &'static str = "
#ifdef GL_ES
precision mediump float;
#endif
uniform vec4 uColor;
void main(void) {
gl_FragColor = uColor;
}
";
static TEXTURE_VERTEX_SHADER_SOURCE: &'static str = "
attribute vec2 aVertexPosition;
attribute vec2 aVertexUv;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform mat4 uTextureSpaceTransform;
varying vec2 vTextureCoord;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 0.0, 1.0);
vTextureCoord = (uTextureSpaceTransform * vec4(aVertexUv, 0., 1.)).xy;
}
";
static SOLID_COLOR_VERTEX_SHADER_SOURCE: &'static str = "
attribute vec2 aVertexPosition;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
void main(void) {
gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 0.0, 1.0);
}
";
static TILE_DEBUG_BORDER_COLOR: Color = Color { r: 0., g: 1., b: 1., a: 1.0 };
static TILE_DEBUG_BORDER_THICKNESS: usize = 1;
static LAYER_DEBUG_BORDER_COLOR: Color = Color { r: 1., g: 0.5, b: 0., a: 1.0 };
static LAYER_DEBUG_BORDER_THICKNESS: usize = 2;
static LAYER_AABB_DEBUG_BORDER_COLOR: Color = Color { r: 1., g: 0.0, b: 0., a: 1.0 };
static LAYER_AABB_DEBUG_BORDER_THICKNESS: usize = 1;
#[derive(Copy, Clone)]
struct Buffers {
quad_vertex_buffer: GLuint,
line_quad_vertex_buffer: GLuint,
}
#[derive(Copy, Clone)]
struct ShaderProgram {
id: GLuint,
}
impl ShaderProgram {
pub fn new(vertex_shader_source: &str, fragment_shader_source: &str) -> ShaderProgram {
let id = gl::create_program();
gl::attach_shader(id, ShaderProgram::compile_shader(fragment_shader_source, gl::FRAGMENT_SHADER));
gl::attach_shader(id, ShaderProgram::compile_shader(vertex_shader_source, gl::VERTEX_SHADER));
gl::link_program(id);
if gl::get_program_iv(id, gl::LINK_STATUS) == (0 as GLint) {
panic!("Failed to compile shader program: {}", gl::get_program_info_log(id));
}
ShaderProgram {
id: id,
}
}
pub fn compile_shader(source_string: &str, shader_type: GLenum) -> GLuint {
let id = gl::create_shader(shader_type);
gl::shader_source(id, &[ source_string.as_bytes() ]);
gl::compile_shader(id);
if gl::get_shader_iv(id, gl::COMPILE_STATUS) == (0 as GLint) {
panic!("Failed to compile shader: {}", gl::get_shader_info_log(id));
}
id
}
pub fn get_attribute_location(&self, name: &str) -> GLint {
gl::get_attrib_location(self.id, name)
}
pub fn get_uniform_location(&self, name: &str) -> GLint {
gl::get_uniform_location(self.id, name)
}
}
#[derive(Copy, Clone)]
struct TextureProgram {
program: ShaderProgram,
vertex_position_attr: c_int,
vertex_uv_attr: c_int,
modelview_uniform: c_int,
projection_uniform: c_int,
sampler_uniform: c_int,
texture_space_transform_uniform: c_int,
opacity_uniform: c_int,
}
impl TextureProgram {
fn new(sampler_function: &str, sampler_type: &str) -> TextureProgram {
let fragment_shader_source
= fmt::format(format_args!("#define samplerFunction {}\n#define samplerType {}\n{}",
sampler_function,
sampler_type,
TEXTURE_FRAGMENT_SHADER_SOURCE));
let program = ShaderProgram::new(TEXTURE_VERTEX_SHADER_SOURCE, &fragment_shader_source);
TextureProgram {
program: program,
vertex_position_attr: program.get_attribute_location("aVertexPosition"),
vertex_uv_attr: program.get_attribute_location("aVertexUv"),
modelview_uniform: program.get_uniform_location("uMVMatrix"),
projection_uniform: program.get_uniform_location("uPMatrix"),
sampler_uniform: program.get_uniform_location("uSampler"),
texture_space_transform_uniform: program.get_uniform_location("uTextureSpaceTransform"),
opacity_uniform: program.get_uniform_location("uOpacity"),
}
}
fn bind_uniforms_and_attributes(&self,
vertices: &[TextureVertex; 4],
transform: &Matrix4D<f32>,
projection_matrix: &Matrix4D<f32>,
texture_space_transform: &Matrix4D<f32>,
buffers: &Buffers,
opacity: f32) {
gl::uniform_1i(self.sampler_uniform, 0);
gl::uniform_matrix_4fv(self.modelview_uniform,
false,
&transform.to_row_major_array());
gl::uniform_matrix_4fv(self.projection_uniform,
false,
&projection_matrix.to_row_major_array());
let vertex_size = mem::size_of::<TextureVertex>();
gl::bind_buffer(gl::ARRAY_BUFFER, buffers.quad_vertex_buffer);
gl::buffer_data(gl::ARRAY_BUFFER, vertices, gl::DYNAMIC_DRAW);
gl::vertex_attrib_pointer_f32(self.vertex_position_attr as GLuint,2, false, vertex_size as i32, 0);
gl::vertex_attrib_pointer_f32(self.vertex_uv_attr as GLuint, 2, false, vertex_size as i32, 8);
gl::uniform_matrix_4fv(self.texture_space_transform_uniform,
false,
&texture_space_transform.to_row_major_array());
gl::uniform_1f(self.opacity_uniform, opacity);
}
fn enable_attribute_arrays(&self) {
gl::enable_vertex_attrib_array(self.vertex_position_attr as GLuint);
gl::enable_vertex_attrib_array(self.vertex_uv_attr as GLuint);
}
fn disable_attribute_arrays(&self) {
gl::disable_vertex_attrib_array(self.vertex_uv_attr as GLuint);
gl::disable_vertex_attrib_array(self.vertex_position_attr as GLuint);
}
fn create_2d_program() -> TextureProgram {
TextureProgram::new("texture2D", "sampler2D")
}
#[cfg(target_os="macos")]
fn create_rectangle_program_if_necessary() -> Option<TextureProgram> {
gl::enable(gl::TEXTURE_RECTANGLE_ARB);
Some(TextureProgram::new("texture2DRect", "sampler2DRect"))
}
#[cfg(not(target_os="macos"))]
fn create_rectangle_program_if_necessary() -> Option<TextureProgram> {
None
}
}
#[derive(Copy, Clone)]
struct SolidColorProgram {
program: ShaderProgram,
vertex_position_attr: c_int,
modelview_uniform: c_int,
projection_uniform: c_int,
color_uniform: c_int,
}
impl SolidColorProgram {
fn new() -> SolidColorProgram {
let program = ShaderProgram::new(SOLID_COLOR_VERTEX_SHADER_SOURCE,
SOLID_COLOR_FRAGMENT_SHADER_SOURCE);
SolidColorProgram {
program: program,
vertex_position_attr: program.get_attribute_location("aVertexPosition"),
modelview_uniform: program.get_uniform_location("uMVMatrix"),
projection_uniform: program.get_uniform_location("uPMatrix"),
color_uniform: program.get_uniform_location("uColor"),
}
}
fn bind_uniforms_and_attributes_common(&self,
transform: &Matrix4D<f32>,
projection_matrix: &Matrix4D<f32>,
color: &Color) {
gl::uniform_matrix_4fv(self.modelview_uniform,
false,
&transform.to_row_major_array());
gl::uniform_matrix_4fv(self.projection_uniform,
false,
&projection_matrix.to_row_major_array());
gl::uniform_4f(self.color_uniform,
color.r as GLfloat,
color.g as GLfloat,
color.b as GLfloat,
color.a as GLfloat);
}
fn bind_uniforms_and_attributes_for_lines(&self,
vertices: &[ColorVertex; 5],
transform: &Matrix4D<f32>,
projection_matrix: &Matrix4D<f32>,
buffers: &Buffers,
color: &Color) {
self.bind_uniforms_and_attributes_common(transform, projection_matrix, color);
gl::bind_buffer(gl::ARRAY_BUFFER, buffers.line_quad_vertex_buffer);
gl::buffer_data(gl::ARRAY_BUFFER, vertices, gl::DYNAMIC_DRAW);
gl::vertex_attrib_pointer_f32(self.vertex_position_attr as GLuint, 2, false, 0, 0);
}
fn bind_uniforms_and_attributes_for_quad(&self,
vertices: &[ColorVertex; 4],
transform: &Matrix4D<f32>,
projection_matrix: &Matrix4D<f32>,
buffers: &Buffers,
color: &Color) {
self.bind_uniforms_and_attributes_common(transform, projection_matrix, color);
gl::bind_buffer(gl::ARRAY_BUFFER, buffers.quad_vertex_buffer);
gl::buffer_data(gl::ARRAY_BUFFER, vertices, gl::DYNAMIC_DRAW);
gl::vertex_attrib_pointer_f32(self.vertex_position_attr as GLuint, 2, false, 0, 0);
}
fn enable_attribute_arrays(&self) {
gl::enable_vertex_attrib_array(self.vertex_position_attr as GLuint);
}
fn disable_attribute_arrays(&self) {
gl::disable_vertex_attrib_array(self.vertex_position_attr as GLuint);
}
}
struct RenderContextChild<T> {
layer: Option<Rc<Layer<T>>>,
context: Option<RenderContext3D<T>>,
paint_order: usize,
z_center: f32,
}
pub struct RenderContext3D<T>{
children: Vec<RenderContextChild<T>>,
clip_rect: Option<Rect<f32>>,
}
impl<T> RenderContext3D<T> {
fn new(layer: Rc<Layer<T>>) -> RenderContext3D<T> {
let mut render_context = RenderContext3D {
children: vec!(),
clip_rect: RenderContext3D::calculate_context_clip(layer.clone(), None),
};
layer.build(&mut render_context);
render_context.sort_children();
render_context
}
fn build_child(layer: Rc<Layer<T>>,
parent_clip_rect: Option<Rect<f32>>)
-> Option<RenderContext3D<T>> {
let clip_rect = RenderContext3D::calculate_context_clip(layer.clone(), parent_clip_rect);
if let Some(ref clip_rect) = clip_rect {
if clip_rect.is_empty() {
return None;
}
}
let mut render_context = RenderContext3D {
children: vec!(),
clip_rect: clip_rect,
};
for child in layer.children().iter() {
child.build(&mut render_context);
}
render_context.sort_children();
Some(render_context)
}
fn sort_children(&mut self) {
// TODO(gw): This is basically what FF does, which breaks badly
// when there are intersecting polygons. Need to split polygons
// to handle this case correctly (Blink uses a BSP tree).
self.children.sort_by(|a, b| {
if a.z_center < b.z_center {
Ordering::Less
} else if a.z_center > b.z_center {
Ordering::Greater
} else if a.paint_order < b.paint_order {
Ordering::Less
} else if a.paint_order > b.paint_order {
Ordering::Greater
} else {
Ordering::Equal
}
});
}
fn calculate_context_clip(layer: Rc<Layer<T>>,
parent_clip_rect: Option<Rect<f32>>)
-> Option<Rect<f32>> {
// TODO(gw): This doesn't work for iframes that are transformed.
if !*layer.masks_to_bounds.borrow() {
return parent_clip_rect;
}
let layer_clip = match layer.transform_state.borrow().screen_rect.as_ref() {
Some(screen_rect) => screen_rect.rect,
None => return Some(Rect::zero()), // Layer is entirely clipped away.
};
match parent_clip_rect {
Some(parent_clip_rect) => match layer_clip.intersection(&parent_clip_rect) {
Some(intersected_clip) => Some(intersected_clip),
None => Some(Rect::zero()), // No intersection.
},
None => Some(layer_clip),
}
}
fn add_child(&mut self,
layer: Option<Rc<Layer<T>>>,
child_context: Option<RenderContext3D<T>>,
z_center: f32) {
let paint_order = self.children.len();
self.children.push(RenderContextChild {
layer: layer,
context: child_context,
z_center: z_center,
paint_order: paint_order,
});
}
}
pub trait RenderContext3DBuilder<T> {
fn build(&self, current_context: &mut RenderContext3D<T>);
}
impl<T> RenderContext3DBuilder<T> for Rc<Layer<T>> {
fn build(&self, current_context: &mut RenderContext3D<T>) {
let (layer, z_center) = match self.transform_state.borrow().screen_rect {
Some(ref rect) => (Some(self.clone()), rect.z_center),
None => (None, 0.), // Layer is entirely clipped.
};
if !self.children.borrow().is_empty() && self.establishes_3d_context {
let child_context =
RenderContext3D::build_child(self.clone(), current_context.clip_rect);
if child_context.is_some() {
current_context.add_child(layer, child_context, z_center);
return;
}
};
// If we are completely clipped out, don't add anything to this context.
if layer.is_none() {
return;
}
current_context.add_child(layer, None, z_center);
for child in self.children().iter() {
child.build(current_context);
}
}
}
#[derive(Copy, Clone)]
pub struct RenderContext {
texture_2d_program: TextureProgram,
texture_rectangle_program: Option<TextureProgram>,
solid_color_program: SolidColorProgram,
buffers: Buffers,
/// The platform-specific graphics context.
compositing_display: NativeDisplay,
/// Whether to show lines at border and tile boundaries for debugging purposes.
show_debug_borders: bool,
force_near_texture_filter: bool,
}
impl RenderContext {
pub fn new(compositing_display: NativeDisplay,
show_debug_borders: bool,
force_near_texture_filter: bool) -> RenderContext {
gl::enable(gl::TEXTURE_2D);
// Each layer uses premultiplied alpha!
gl::enable(gl::BLEND);
gl::blend_func(gl::ONE, gl::ONE_MINUS_SRC_ALPHA);
let texture_2d_program = TextureProgram::create_2d_program();
let solid_color_program = SolidColorProgram::new();
let texture_rectangle_program = TextureProgram::create_rectangle_program_if_necessary();
RenderContext {
texture_2d_program: texture_2d_program,
texture_rectangle_program: texture_rectangle_program,
solid_color_program: solid_color_program,
buffers: RenderContext::init_buffers(),
compositing_display: compositing_display,
show_debug_borders: show_debug_borders,
force_near_texture_filter: force_near_texture_filter,
}
}
fn init_buffers() -> Buffers {
let quad_vertex_buffer = gl::gen_buffers(1)[0];
gl::bind_buffer(gl::ARRAY_BUFFER, quad_vertex_buffer);
let line_quad_vertex_buffer = gl::gen_buffers(1)[0];
gl::bind_buffer(gl::ARRAY_BUFFER, line_quad_vertex_buffer);
Buffers {
quad_vertex_buffer: quad_vertex_buffer,
line_quad_vertex_buffer: line_quad_vertex_buffer,
}
}
fn bind_and_render_solid_quad(&self,
vertices: &[ColorVertex; 4],
transform: &Matrix4D<f32>,
projection: &Matrix4D<f32>,
color: &Color) {
self.solid_color_program.enable_attribute_arrays();
gl::use_program(self.solid_color_program.program.id);
self.solid_color_program.bind_uniforms_and_attributes_for_quad(vertices,
transform,
projection,
&self.buffers,
color);
gl::draw_arrays(gl::TRIANGLE_STRIP, 0, 4);
self.solid_color_program.disable_attribute_arrays();
}
fn bind_and_render_quad(&self,
vertices: &[TextureVertex; 4],
texture: &Texture,
transform: &Matrix4D<f32>,
projection_matrix: &Matrix4D<f32>,
opacity: f32) {
let mut texture_coordinates_need_to_be_scaled_by_size = false;
let program = match texture.target {
TextureTarget2D => self.texture_2d_program,
TextureTargetRectangle => match self.texture_rectangle_program {
Some(program) => {
texture_coordinates_need_to_be_scaled_by_size = true;
program
}
None => panic!("There is no shader program for texture rectangle"),
},
};
program.enable_attribute_arrays();
gl::use_program(program.program.id);
gl::active_texture(gl::TEXTURE0);
gl::bind_texture(texture.target.as_gl_target(), texture.native_texture());
let filter_mode = if self.force_near_texture_filter {
gl::NEAREST
} else {
gl::LINEAR
} as GLint;
gl::tex_parameter_i(texture.target.as_gl_target(), gl::TEXTURE_MAG_FILTER, filter_mode);
gl::tex_parameter_i(texture.target.as_gl_target(), gl::TEXTURE_MIN_FILTER, filter_mode);
// We calculate a transformation matrix for the texture coordinates
// which is useful for flipping the texture vertically or scaling the
// coordinates when dealing with GL_ARB_texture_rectangle.
let mut texture_transform = Matrix4D::identity();
if texture.flip == VerticalFlip {
texture_transform = texture_transform.pre_scaled(1.0, -1.0, 1.0);
}
if texture_coordinates_need_to_be_scaled_by_size {
texture_transform = texture_transform.pre_scaled(
texture.size.width as f32, texture.size.height as f32, 1.0);
}
if texture.flip == VerticalFlip {
texture_transform = texture_transform.pre_translated(0.0, -1.0, 0.0);
}
program.bind_uniforms_and_attributes(vertices,
transform,
&projection_matrix,
&texture_transform,
&self.buffers,
opacity);
// Draw!
gl::draw_arrays(gl::TRIANGLE_STRIP, 0, 4);
gl::bind_texture(gl::TEXTURE_2D, 0);
gl::bind_texture(texture.target.as_gl_target(), 0);
program.disable_attribute_arrays()
}
pub fn bind_and_render_quad_lines(&self,
vertices: &[ColorVertex; 5],
transform: &Matrix4D<f32>,
projection: &Matrix4D<f32>,
color: &Color,
line_thickness: usize) {
self.solid_color_program.enable_attribute_arrays();
gl::use_program(self.solid_color_program.program.id);
self.solid_color_program.bind_uniforms_and_attributes_for_lines(vertices,
transform,
projection,
&self.buffers,
color);
gl::line_width(line_thickness as GLfloat);
gl::draw_arrays(gl::LINE_STRIP, 0, 5);
self.solid_color_program.disable_attribute_arrays();
}
fn render_layer<T>(&self,
layer: Rc<Layer<T>>,
transform: &Matrix4D<f32>,
projection: &Matrix4D<f32>,
clip_rect: Option<Rect<f32>>,
gfx_context: &NativeDisplay) {
let ts = layer.transform_state.borrow();
let transform = transform.pre_mul(&ts.final_transform);
let background_color = *layer.background_color.borrow();
// Create native textures for this layer
layer.create_textures(gfx_context);
let layer_rect = clip_rect.map_or(ts.world_rect, |clip_rect| {
match clip_rect.intersection(&ts.world_rect) {
Some(layer_rect) => layer_rect,
None => Rect::zero(),
}
});
if layer_rect.is_empty() {
return;
}
if background_color.a != 0.0 {
let bg_vertices = [
ColorVertex::new(layer_rect.origin),
ColorVertex::new(layer_rect.top_right()),
ColorVertex::new(layer_rect.bottom_left()),
ColorVertex::new(layer_rect.bottom_right()),
];
self.bind_and_render_solid_quad(&bg_vertices,
&transform,
&projection,
&background_color);
}
layer.do_for_all_tiles(|tile: &Tile| {
self.render_tile(tile,
&ts.world_rect.origin,
&transform,
projection,
clip_rect,
*layer.opacity.borrow());
});
if self.show_debug_borders {
let debug_vertices = [
ColorVertex::new(layer_rect.origin),
ColorVertex::new(layer_rect.top_right()),
ColorVertex::new(layer_rect.bottom_right()),
ColorVertex::new(layer_rect.bottom_left()),
ColorVertex::new(layer_rect.origin),
];
self.bind_and_render_quad_lines(&debug_vertices,
&transform,
projection,
&LAYER_DEBUG_BORDER_COLOR,
LAYER_DEBUG_BORDER_THICKNESS);
let aabb = ts.screen_rect.as_ref().unwrap().rect;
let debug_vertices = [
ColorVertex::new(aabb.origin),
ColorVertex::new(aabb.top_right()),
ColorVertex::new(aabb.bottom_right()),
ColorVertex::new(aabb.bottom_left()),
ColorVertex::new(aabb.origin),
];
self.bind_and_render_quad_lines(&debug_vertices,
&Matrix4D::identity(),
projection,
&LAYER_AABB_DEBUG_BORDER_COLOR,
LAYER_AABB_DEBUG_BORDER_THICKNESS);
}
}
fn render_tile(&self,
tile: &Tile,
layer_origin: &Point2D<f32>,
transform: &Matrix4D<f32>,
projection: &Matrix4D<f32>,
clip_rect: Option<Rect<f32>>,
opacity: f32) {
if tile.texture.is_zero() || !tile.bounds.is_some() {
return;
}
let tile_rect = tile.bounds.unwrap().to_untyped().translate(layer_origin);
let clipped_tile_rect = clip_rect.map_or(tile_rect, |clip_rect| {
match clip_rect.intersection(&tile_rect) {
Some(clipped_tile_rect) => clipped_tile_rect,
None => Rect::zero(),
}
});
if clipped_tile_rect.is_empty() {
return;
}
let texture_rect_origin = clipped_tile_rect.origin - tile_rect.origin;
let texture_rect = Rect::new(
Point2D::new(texture_rect_origin.x / tile_rect.size.width,
texture_rect_origin.y / tile_rect.size.height),
Size2D::new(clipped_tile_rect.size.width / tile_rect.size.width,
clipped_tile_rect.size.height / tile_rect.size.height));
let tile_vertices: [TextureVertex; 4] = [
TextureVertex::new(clipped_tile_rect.origin, texture_rect.origin),
TextureVertex::new(clipped_tile_rect.top_right(), texture_rect.top_right()),
TextureVertex::new(clipped_tile_rect.bottom_left(), texture_rect.bottom_left()),
TextureVertex::new(clipped_tile_rect.bottom_right(), texture_rect.bottom_right()),
];
if self.show_debug_borders {
let debug_vertices = [
// The weird ordering is converting from triangle-strip into a line-strip.
ColorVertex::new(clipped_tile_rect.origin),
ColorVertex::new(clipped_tile_rect.top_right()),
ColorVertex::new(clipped_tile_rect.bottom_right()),
ColorVertex::new(clipped_tile_rect.bottom_left()),
ColorVertex::new(clipped_tile_rect.origin),
];
self.bind_and_render_quad_lines(&debug_vertices,
&transform,
projection,
&TILE_DEBUG_BORDER_COLOR,
TILE_DEBUG_BORDER_THICKNESS);
}
self.bind_and_render_quad(&tile_vertices,
&tile.texture,
&transform,
projection,
opacity);
}
fn render_3d_context<T>(&self,
context: &RenderContext3D<T>,
transform: &Matrix4D<f32>,
projection: &Matrix4D<f32>,
gfx_context: &NativeDisplay) {
if context.children.is_empty() {
return;
}
// Clear the z-buffer for each 3d render context
// TODO(gw): Potential optimization here if there are no
// layer intersections to disable z-buffering and
// avoid clear.
gl::clear(gl::DEPTH_BUFFER_BIT);
// Render child layers with z-testing.
for child in &context.children {
if let Some(ref layer) = child.layer {
// TODO(gw): Disable clipping on 3d layers for now.
// Need to implement proper polygon clipping to
// make this work correctly.
let clip_rect = context.clip_rect.and_then(|cr| {
let m = layer.transform_state.borrow().final_transform;
// See https://drafts.csswg.org/css-transforms/#2d-matrix
let is_3d_transform = m.m31 != 0.0 || m.m32 != 0.0 ||
m.m13 != 0.0 || m.m23 != 0.0 ||
m.m43 != 0.0 || m.m14 != 0.0 ||
m.m24 != 0.0 || m.m34 != 0.0 ||
m.m33 != 1.0 || m.m44 != 1.0;
if is_3d_transform {
None
} else {
// If the transform is 2d, invert it and back-transform
// the clip rect into world space.
let transform = m.inverse().unwrap();
let xform_2d = transform.to_2d();
Some(xform_2d.transform_rect(&cr))
}
});
self.render_layer(layer.clone(),
transform,
projection,
clip_rect,
gfx_context);
}
if let Some(ref context) = child.context {
self.render_3d_context(context,
transform,
projection,
gfx_context);
}
}
}
}
pub fn render_scene<T>(root_layer: Rc<Layer<T>>,
render_context: RenderContext,
scene: &Scene<T>) {
// Set the viewport.
let v = scene.viewport.to_untyped();
gl::viewport(v.origin.x as GLint, v.origin.y as GLint,
v.size.width as GLsizei, v.size.height as GLsizei);
// Enable depth testing for 3d transforms. Set z-mode to LESS-EQUAL
// so that layers with equal Z are able to paint correctly in
// the order they are specified.
gl::enable(gl::DEPTH_TEST);
gl::clear_color(1.0, 1.0, 1.0, 1.0);
gl::clear(gl::COLOR_BUFFER_BIT | gl::DEPTH_BUFFER_BIT);
gl::depth_func(gl::LEQUAL);
// Set up the initial modelview matrix.
let transform = Matrix4D::identity().pre_scaled(scene.scale.get(), scene.scale.get(), 1.0);
let projection = create_ortho(&scene.viewport.size.to_untyped());
// Build the list of render items
render_context.render_3d_context(&RenderContext3D::new(root_layer.clone()),
&transform,
&projection,
&render_context.compositing_display);
}
|
use std::{thread, time};
use reqwest::{Client as HttpClient, Url};
use super::API_BASE_URL;
use serde::{de, Deserialize, Deserializer, Serialize};
use websocket::{
ClientBuilder,
client::sync::Client as WsClientSync,
stream::sync::{
TlsStream as WsTlsStreamSync,
TcpStream as WsTcpStreamSync,
},
client::r#async::{
Client,
ClientNew,
TlsStream,
TcpStream,
},
OwnedMessage::Text,
Message,
message,
futures::{Future, Stream, Sink},
//--------------------------------------------------------------//
};
use tokio::runtime::Builder;
use tokio::runtime::Runtime;
use tokio::prelude::Async::{Ready, NotReady};
#[derive(Deserialize,Debug)]
struct GatewayResponse {
pub url: String,
pub shards: u32,
pub session_start_limit: GatewaySessionStartLimit,
}
#[derive(Deserialize,Debug)]
struct GatewaySessionStartLimit {
pub total: u32,
pub remaining: u32,
pub reset_after: u32,
}
#[derive(Debug)]
struct GatewayPayload{
pub op: i32, // Op-code
pub d: GatewayPayloadData,
pub s: Option<i32>, // Sequence number
pub t: Option<String>, // Event name
}
#[derive(Serialize,Debug)]
#[serde(untagged)]
enum GatewayPayloadData {
Hello(HelloMsg),
_Empty,
}
// After gateway websocket connection is initiated a hello message is sent from server
#[derive(Deserialize,Serialize,Debug)]
struct HelloMsg{
// Client should send a heartbeat to server every <heartbeat_interval> milliseconds
heartbeat_interval: u64,
}
// GatewayPayload contains both opcode and data where the format of data is dependant
// of the opcode. This is the custom intermediate deserialization that first extracts
// the data as raw json value and deserializes after exstracting the opcode
impl<'de> Deserialize<'de> for GatewayPayload {
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>, {
#[derive(Deserialize, Debug)]
struct Helper {
op: i32,
d: serde_json::Value,
s: Option<i32>,
t: Option<String>,
}
let helper = Helper::deserialize(deserializer)?;
fn deserialize_payload_data<'a,T>(val: serde_json::Value) -> Result<T, serde_json::Error>
where for<'de> T: serde::Deserialize<'de>{
serde_json::from_value(val)
}
let data = match helper.op {
10 => {
match deserialize_payload_data::<HelloMsg>(helper.d) {
Ok(m) => Ok(GatewayPayloadData::Hello(m)),
Err(e) => Err(e),
}
}
x => {
panic!("Unknown discord gateway payload opcode {}", x);
},
};
match data {
Ok(data) => {
Ok(GatewayPayload{
op: helper.op,
d: data,
s: helper.s,
t: helper.t,
})
},
Err(_) => Err(de::Error::custom("Could not deserialize gateway payload")),
}
}
}
fn send_get(client: &HttpClient, url: &Url) -> String {
let req = client.get(url.clone());
let mut resp = req.send().unwrap();
let body = resp.text().unwrap();
body
}
// General helping deserialization function. Used for reducing verbosity until
// a more robust option is created
fn deserialize<'a, T: Deserialize<'a>>(body: &'a str) -> T {
let v : T = match serde_json::from_str(body) {
Err(e) => {
println!("Something went wrong with deserializing json: {}", body);
panic!(e);
},
Ok(a) => a,
};
v
}
// Creates and initiates connection for the websocket to the specified url and
// panics if it is unable to connect. Sets version and encoding headers for the
// connection
fn create_websocket(url: &mut Url) -> WsClientSync<WsTlsStreamSync<WsTcpStreamSync>> {
url.set_query(Some("v=6&encoding=json"));
let mut ws_client = ClientBuilder::from_url(&url);
println!("Connecting to {}", url);
let ws_client = match ws_client.connect_secure(None) {
Err(e) => {
println!("Error: {}", e);
panic!(format!("Could not connect websocket to {}", url));
}
Ok(c) => c,
};
ws_client
}
// Parses a URL from a string and panics if it can't be parsed
fn create_url(url: &str) -> Url {
let url: Url = match Url::parse(url) {
Ok(v) => v,
Err(_) => {
panic!(format!("Can't parse websocket url: {}", url));
},
};
url
}
// Blocks thread for param ms milliseconds
fn thread_sleep(time_ms: u64){
let time_ms = time::Duration::from_millis(time_ms);
thread::sleep(time_ms);
}
// Handles the custom blocking eventloop for a discord websocket gateway
fn gateway_eventloop_sync(
client: &mut WsClientSync<WsTlsStreamSync<WsTcpStreamSync>>,
sleep_ms: u64
){
loop {
thread_sleep(sleep_ms);
println!("Loop");
// Handle heartbeat
let resp: message::OwnedMessage = match client.recv_message(){
Err(e) => {
println!("Error with receiving message from websocket: {}", e);
continue;
},
Ok(r) => r,
};
println!("{:?}",resp);
}
}
fn create_websocket_async(url :&mut Url) -> ClientNew<TlsStream<TcpStream>>{
url.set_query(Some("v=6&encoding=json"));
// create a Future of a client
let client_future: ClientNew<TlsStream<TcpStream>> =
ClientBuilder::from_url(url)
.async_connect_secure(None);
client_future
}
// Hello message containing the heartbeat interval that should be used
// This function extracts that value and returns it
fn handle_message_hello(payload :&GatewayPayload, client: &mut Client<TlsStream<TcpStream>>)
-> Option<u64> {
let data = match &payload.d {
GatewayPayloadData::Hello(msg) => msg,
_ => {
println!("Unexpected data type in payload: {:?}", payload);
return None;
},
};
let heartbeat_interval = data.heartbeat_interval;
Some(heartbeat_interval)
}
fn handle_message_text(client: &mut Client<TlsStream<TcpStream>>, message :&str){
let payload: GatewayPayload = deserialize(message);
match payload.op {
10 => {
match handle_message_hello(&payload, client) {
Some(heartbeat_interval) => {
println!("Heartbeat_interval: {}", heartbeat_interval);
},
None => {},
};
},
unhandled_code => {
println!("Unhandled opcode in gateway message: {:?}", unhandled_code);
},
};
}
fn poll_messages(client: &mut Client<TlsStream<TcpStream>>){
//If error occurs too many times then panic
let mut errors = 0;
let errors_max = 5;
loop {
let res = client.poll();
match res {
Ok(Ready(x)) => {
match x {
Some(Text(msg)) => {
handle_message_text(client, &msg);
},
Some(_) => {println!("Non text gateway message received")},
None => {println!("Found none when gateway message should be ready");},
};
},
Ok(NotReady) => {
break;
},
Err(e) => {
errors += 1;
println!("An error occurred: {:?}", e);
if errors >= errors_max {
panic!("Too many errors when polling messages.. last known error: {:?}", e);
}else{
continue;
}
},
};
}
}
fn setup_discord_gateway_async(gateway_url :&mut Url){
let client_future = create_websocket_async(gateway_url);
let gateway_message_handler = client_future.map(|(mut client,_)| {
loop {
let time: u64 = 500;
println!("Sleeping for {} ms to try to poll for messages", time);
thread_sleep(time);
poll_messages(&mut client);
}
});
let mut runtime = Builder::new().build().unwrap();
let res = runtime.block_on(gateway_message_handler);
//println!("Res {:?}", res);
}
pub fn initiate_gateway(client: &HttpClient) -> bool{
let gateway_url = create_url(&format!("{}gateway/bot", API_BASE_URL));
let body = send_get(client, &gateway_url);
let v : GatewayResponse = deserialize(&body);
let mut gateway_url = create_url(&v.url);
/////////////// ASYNC ////////////////////////////////////
setup_discord_gateway_async(&mut gateway_url);
let a = true;
if a {
return true;
}
//////////////////////////////////////////////////////////////
//TODO add explicit version and encoding parameters to request
let mut ws = create_websocket(&mut create_url(&v.url));
gateway_eventloop_sync(&mut ws, 500);
println!("----\n{:?}\n------", v);
true
}
|
#![warn(unused_imports)]
#![warn(unused_variables)]
use arrayvec::ArrayVec;
use crate::sprite;
use std::cmp::max;
use std::fmt;
use std::fs::File;
use std::io::Read;
use std::path::PathBuf;
const RAM_SIZE: usize = 0x1000;
const PROGRAM_START: usize = 0x200;
const PROGRAM_MAX_SIZE: usize = RAM_SIZE - PROGRAM_START;
pub struct Chip8 {
program: [u8; 0x1000 - 0x200],
freq: u16,
pc: u16,
sp: u8,
v: [u8; 16],
i: u16,
stack: ArrayVec<[u16; 16]>,
dt: u8,
st: u8,
pub ram: [u8; 0x1000],
vram: [u8; 64 * 32],
}
impl Chip8 {
pub fn new() -> Self {
let mut chip8 = Chip8 {
program: [0; 0x1000 - 0x200],
freq: 500,
pc: PROGRAM_START as u16,
sp: 0,
v: [0; 16],
i: 0,
stack: ArrayVec::new(),
dt: 0,
st: 0,
ram: [0; RAM_SIZE],
vram: [0; 64 * 32],
};
chip8.load_charset();
chip8
}
pub fn reset(&mut self) {
self.freq = 500;
self.pc = PROGRAM_START as u16;
self.sp = 0;
self.v = [0; 16];
self.i = 0;
self.stack = ArrayVec::new();
self.dt = 0;
self.st = 0;
self.ram = [0; RAM_SIZE];
self.vram = [0; 64 * 32];
self.load_charset();
self.ram[PROGRAM_START..].copy_from_slice(&self.program);
}
///Stores the group of Hexadecimal sprites at the start of the interpreter RAM
fn load_charset(&mut self) {
let charset = sprite::CHARSET.concat();
self.ram[0..charset.len()].copy_from_slice(&charset);
}
pub fn load_rom(&mut self, path: PathBuf) {
let mut rom_file = File::open(path).unwrap();
let mut buf = Vec::new();
let bytes_read = rom_file.read_to_end(&mut buf).unwrap();
self.program[..bytes_read].copy_from_slice(&buf[..]);
self.reset();
}
pub fn run(&mut self) {
loop {
println!("{:04X}", self.pc);
let instruction = self.fetch();
let mut function = self.decode(instruction);
function();
}
}
fn fetch(&self) -> u16 {
let pc = self.pc as usize;
((self.ram[pc] as u16) << 8) + self.ram[pc + 1] as u16
}
fn decode<'a>(&'a mut self, data: u16) -> Box<FnMut() -> () + 'a> {
let a = ((data & 0xF000) >> 12) as u8;
let b = ((data & 0x0F00) >> 8) as u8;
let c = ((data & 0x00F0) >> 4) as u8;
let d = ((data & 0x000F) >> 0) as u8;
let bcd = ((data & 0x0FFF) >> 0) as u16;
let bc = ((data & 0x0FF0) >> 4) as u8;
let cd = ((data & 0x00FF) >> 0) as u8;
println!("{:X} {:X} {:X} {:X}", a, b, c, d);
let res: Box<FnMut()> = match (a, b, c, d) {
(0x0, 0x0, 0xE, 0x0) => Box::new(move || self.CLS()),
(0x0, 0x0, 0xE, 0xE) => Box::new(move || self.RET()),
(0x0, _, _, _) => Box::new(move || self.SYS(bcd)),
(0x1, _, _, _) => Box::new(move || self.JP_address(bcd)),
(0x2, _, _, _) => Box::new(move || self.CALL(bcd)),
(0x3, x, k1, k2) => Box::new(move || self.SE_reg_byte(x, cd)),
(0x4, x, k1, k2) => Box::new(move || self.SNE_reg_byte(x, cd)),
(0x5, x, y, 0x0) => Box::new(move || self.SE_reg_reg(x, y)),
(0x6, x, k1, k2) => Box::new(move || self.LD_reg_byte(x, cd)),
(0x7, x, k1, k2) => Box::new(move || self.ADD_reg_byte(x, cd)),
(0x8, x, y, 0x0) => Box::new(move || self.LD_reg_reg(x, y)),
(0x8, x, y, 0x1) => Box::new(move || self.OR(x, y)),
(0x8, x, y, 0x2) => Box::new(move || self.AND(x, y)),
(0x8, x, y, 0x3) => Box::new(move || self.XOR(x, y)),
(0x8, x, y, 0x4) => Box::new(move || self.ADD_reg_reg(x, y)),
(0x8, x, y, 0x5) => Box::new(move || self.SUB(x, y)),
(0x8, x, y, 0x6) => Box::new(move || self.SHR(x, y)),
(0x8, x, y, 0x7) => Box::new(move || self.SUBN(x, y)),
(0x8, x, y, 0xE) => Box::new(move || self.SHL(x, y)),
(0x9, x, y, 0x0) => Box::new(move || self.SNE_reg_reg(x, y)),
(0xA, _, _, _) => Box::new(move || self.LD_i(bcd)),
(0xB, _, _, _) => Box::new(move || self.JP_address_plus_v0(bcd)),
(0xC, x, k1, k2) => Box::new(move || self.RND(x, cd)),
(0xD, x, y, z) => Box::new(move || self.DRW(x, y, z)),
(0xE, x, 0x9, 0xE) => Box::new(move || self.SKP(x)),
(0xE, x, 0xA, 0x1) => Box::new(move || self.SKNP(x)),
(0xF, x, 0x0, 0x7) => Box::new(move || self.LD_from_dt(x)),
(0xF, x, 0x0, 0xA) => Box::new(move || self.LD_key(x)),
(0xF, x, 0x1, 0x5) => Box::new(move || self.LD_to_dt(x)),
(0xF, x, 0x1, 0x8) => Box::new(move || self.LD_to_st(x)),
(0xF, x, 0x1, 0xE) => Box::new(move || self.ADD_i_reg(x)),
(0xF, x, 0x2, 0x9) => Box::new(move || self.LD_i_sprite(x)),
(0xF, x, 0x3, 0x3) => Box::new(move || self.LD_i_bcd(x)),
(0xF, x, 0x5, 0x5) => Box::new(move || self.LD_i_range(x)),
(0xF, x, 0x6, 0x5) => Box::new(move || self.LD_range_i(x)),
(0xF, x, num1, num2) => Box::new(move || self.CLS()),
_ => Box::new(move || self.RET()),
};
res
}
fn CLS(&mut self) {
self.vram = [0; 64 * 32];
self.pc += 2;
}
fn SYS(&mut self, address: u16) {
self.pc = address;
}
fn RET(&mut self) {
self.pc = self.stack.pop().unwrap();
self.sp -= 1;
self.pc += 2;
}
fn JP_address(&mut self, address: u16) {
self.pc = address;
}
fn CALL(&mut self, address: u16) {
self.stack.push(self.pc);
self.sp += 1;
self.pc = address;
}
fn SE_reg_byte(&mut self, reg: u8, value: u8) {
if self.v[reg as usize] == value {
self.pc += 4;
} else {
self.pc += 2;
};
}
fn SNE_reg_byte(&mut self, reg: u8, value: u8) {
if self.v[reg as usize] != value {
self.pc += 4;
} else {
self.pc += 2;
};
}
fn SE_reg_reg(&mut self, reg1: u8, reg2: u8) {
if self.v[reg1 as usize] == self.v[reg2 as usize] {
self.pc += 4;
} else {
self.pc += 2;
};
}
fn LD_reg_byte(&mut self, reg: u8, value: u8) {
self.v[reg as usize] = value;
self.pc += 2;
}
fn ADD_reg_byte(&mut self, reg: u8, value: u8) {
self.v[reg as usize] += value;
self.pc += 2;
}
fn LD_reg_reg(&mut self, reg1: u8, reg2: u8) {
self.v[reg1 as usize] = self.v[reg2 as usize];
self.pc += 2;
}
fn OR(&mut self, reg1: u8, reg2: u8) {
self.v[reg1 as usize] |= self.v[reg2 as usize];
self.pc += 2;
}
fn AND(&mut self, reg1: u8, reg2: u8) {
self.v[reg1 as usize] &= self.v[reg2 as usize];
self.pc += 2;
}
fn XOR(&mut self, reg1: u8, reg2: u8) {
self.v[reg1 as usize] ^= self.v[reg2 as usize];
self.pc += 2;
}
fn ADD_reg_reg(&mut self, reg1: u8, reg2: u8) {
self.v[reg1 as usize] += self.v[reg2 as usize];
if self.v[reg1 as usize] > 0x00FF {
self.v[0xF] = 1;
self.v[reg1 as usize] &= 0x00FF;
} else {
self.v[0xF] = 0;
}
self.pc += 2;
}
fn SUB(&mut self, reg1: u8, reg2: u8) {
if self.v[reg1 as usize] > self.v[reg2 as usize] {
self.v[0xF] = 1;
} else {
self.v[0xF] = 0;
}
self.v[reg1 as usize] -= self.v[reg2 as usize];
self.pc += 2;
}
/* !! */
fn SHR(&self, reg1: u8, reg2: u8) {}
fn SUBN(&self, reg1: u8, reg2: u8) {}
/* !! */
fn SHL(&self, reg1: u8, reg2: u8) {}
fn SNE_reg_reg(&self, reg1: u8, reg2: u8) {}
fn LD_i(&self, addr: u16) {}
fn JP_address_plus_v0(&self, address: u16) {}
fn RND(&self, reg: u8, value: u8) {}
fn DRW(&self, reg1: u8, reg2: u8, numbytes: u8) {}
fn SKP(&self, reg: u8) {}
fn SKNP(&self, reg: u8) {}
fn LD_from_dt(&mut self, reg: u8) {
self.v[reg as usize] = self.dt;
}
fn LD_key(&mut self, reg: u8) {
//DO THIS FROM KEY.
}
fn LD_to_dt(&mut self, reg: u8) {
self.dt = self.v[reg as usize];
self.pc += 2;
}
fn LD_to_st(&mut self, reg: u8) {
self.st = self.v[reg as usize];
self.pc += 2;
}
fn ADD_i_reg(&mut self, reg: u8) {
self.i += self.v[reg as usize] as u16;
self.pc += 2;
}
fn LD_i_sprite(&self, reg: u8) {}
fn LD_i_bcd(&mut self, reg: u8) {
//Write passed end?
let i = self.i as usize;
let mut val = self.v[reg as usize];
self.ram[i] = val / 100;
val %= 100;
self.ram[i+1] = val / 10;
val %= 10;
self.ram[i+2] = val;
self.pc += 2;
}
fn LD_i_range(&mut self, reg: u8) {
//Write passed end?
let i = self.i as usize;
let reg = reg as usize;
self.ram[i..(i+reg)].copy_from_slice(&self.v[0..reg]);
self.pc += 2;
}
fn LD_range_i(&mut self, reg: u8) {
//Read passed end?
let i = self.i as usize;
let reg = reg as usize;
self.v[0..reg].copy_from_slice(&self.ram[i..(i+reg)]);
self.pc += 2;
}
}
impl fmt::Display for Chip8 {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
writeln!(f, "=============== CHIP8 ===============")?;
writeln!(f, "Frequency: {}Hz", self.freq)?;
writeln!(f, "============= Registers =============")?;
writeln!(f, "PC: 0x{:04X}", self.pc)?;
writeln!(f, "SP: 0x{:02X}", self.sp)?;
writeln!(
f,
"v0: 0x{:02X} v1: 0x{:02X} v2: 0x{:02X} v3: 0x{:02X}",
self.v[0], self.v[1], self.v[2], self.v[3]
)?;
writeln!(
f,
"v4: 0x{:02X} v5: 0x{:02X} v6: 0x{:02X} v7: 0x{:02X}",
self.v[4], self.v[5], self.v[6], self.v[7]
)?;
writeln!(
f,
"v8: 0x{:02X} v9: 0x{:02X} vA: 0x{:02X} va: 0x{:02X}",
self.v[8], self.v[9], self.v[10], self.v[11]
)?;
writeln!(
f,
"vc: 0x{:02X} vd: 0x{:02X} ve: 0x{:02X} vf: 0x{:02X}",
self.v[12], self.v[13], self.v[14], self.v[15]
)?;
writeln!(f, "i : 0x{:04X}", self.i)?;
writeln!(f, "=============== STACK ===============")?;
for (count, value) in self.stack.iter().enumerate().rev() {
writeln!(f, "{}: 0x{:04X}", count, value)?;
}
writeln!(f, "================ RAM ================")?;
let bytes_per_line = 16;
for (count, chunk) in self.ram.chunks(bytes_per_line).enumerate() {
let address = count * bytes_per_line;
write!(f, "0x{:04X} | ", address)?;
for byte in chunk.iter() {
write!(f, " {:02X}", byte)?;
}
writeln!(f)?;
}
Ok(())
}
}
|
mod _2_keys_keyboard;
mod _3sum;
mod coin_change;
mod dungeon_game;
mod maximal_square;
mod min_path_sum;
mod missing_number;
mod ones_and_zeroes;
mod perfect_number;
mod perfect_squares;
mod range_sum_query_immutable;
mod summary_ranges;
mod the_employee_that_worked_on_the_longest_task;
mod triangle;
mod two_sum;
|
{{~#*inline "args_decl"~}}
{{#each arguments~}}, mut {{this.[0]}}: {{this.[1].def.keys.IdType}}{{/each}}
{{~/inline~}}
{{~#*inline "args"}}({{#each arguments}}{{this.[0]}},{{/each}}){{/inline~}}
{{~#*inline "restrict_op"~}}
{{~#with choice_def.Counter~}}
{{~#ifeq kind "Add"}}apply_diff_add{{/ifeq~}}
{{~#ifeq kind "Mul"}}apply_diff_mul{{/ifeq~}}
{{~else~}}
restrict
{{~/with~}}
{{~/inline}}
/// Returns the domain of {name} for the given arguments.
#[allow(unused_mut)]
pub fn get_{{name}}(&self{{>args_decl}}) -> {{>value_type.name value_type}} {
{{#if is_symmetric~}}
if {{arguments.[0].[0]}} > {{arguments.[1].[0]}} {
std::mem::swap(&mut {{arguments.[0].[0]}}, &mut {{arguments.[1].[0]}});
self.{{name}}[&{{>args}}]{{#if is_antisymmetric}}.inverse(){{/if}}
} else {
{{~/if}} self.{{name}}[&{{>args}}] {{#if is_symmetric}} } {{/if}}
}
/// Returns the domain of {name} for the given arguments. If the domain has been restricted
/// but the change not yet applied, returns the old value.
#[allow(unused_mut)]
pub fn get_old_{{name}}(&self{{>args_decl}},diff: &DomainDiff) -> {{>value_type.name value_type}} {
{{#if is_symmetric~}}
if {{arguments.[0].[0]}} > {{arguments.[1].[0]}} {
std::mem::swap(&mut {{arguments.[0].[0]}}, &mut {{arguments.[1].[0]}});
diff.{{name}}.get(&{{>args}}).map(|&(old, _)| old)
.unwrap_or_else(|| self.{{name}}[&{{>args}}])
{{#if is_antisymmetric}}.inverse(){{/if}}
} else {
{{~/if~}}
diff.{{name}}.get(&{{>args}}).map(|&(old, _)| old)
.unwrap_or_else(|| self.{{name}}[&{{>args}}])
{{~#if is_symmetric}} } {{/if}}
}
/// Sets the domain of {name} for the given arguments.
#[allow(unused_mut)]
pub fn set_{{name}}(&mut self{{>args_decl}}, mut value: {{>value_type.name value_type}}) {
{{#if is_symmetric~}}
if {{arguments.[0].[0]}} > {{arguments.[1].[0]}} {
std::mem::swap(&mut {{arguments.[0].[0]}}, &mut {{arguments.[1].[0]}});
{{~#if is_antisymmetric}}value = value.inverse();{{/if}}
}
{{~/if}}
debug!("set {{name}}{:?} to {:?}", {{>args}}, value);
*unwrap!(Arc::make_mut(&mut self.{{name}}).get_mut(&{{>args}})) = value;
}
/// Restricts the domain of {name} for the given arguments. Put the old value in `diff`
/// and indicates if the new domain is failed.
#[allow(unused_mut)]
pub fn restrict_{{name}}(&mut self{{>args_decl}}, mut value: {{>value_type.name value_type}},
diff: &mut DomainDiff) -> Result<(), ()> {
{{#if is_symmetric~}}
if {{arguments.[0].[0]}} > {{arguments.[1].[0]}} {
std::mem::swap(&mut {{arguments.[0].[0]}}, &mut {{arguments.[1].[0]}});
{{~#if is_antisymmetric}}value = value.inverse();{{/if}}
}
{{~/if}}
let mut ptr = unwrap!(Arc::make_mut(&mut self.{{name}}).get_mut(&{{>args}}));
let old = *ptr;
ptr.{{>restrict_op}}(value);
if old != *ptr {
debug!("restrict {{name}}{:?} to {:?}", {{>args}}, *ptr);
diff.{{name}}.entry({{>args}}).or_insert((old, *ptr)).1 = *ptr;
}
if ptr.is_failed() { Err(()) } else { Ok(()) }
}
{{#if compute_counter~}}
/// Updates a counter by changing the value of an increment.
#[allow(unused_mut)]
fn update_{{name}}(&mut self{{>args_decl}}, old_incr: {{>value_type.name value_type}},
new_incr: {{>value_type.name value_type}}, diff: &mut DomainDiff) -> Result<(), ()> {
{{#if is_symmetric~}}
if {{arguments.[0].[0]}} > {{arguments.[1].[0]}} {
std::mem::swap(&mut {{arguments.[0].[0]}}, &mut {{arguments.[1].[0]}});
}
{{~/if}}
let mut ptr = unwrap!(Arc::make_mut(&mut self.{{name}}).get_mut(&{{>args}}));
let old = *ptr;
{{#*inline "op_name"~}}
{{#ifeq compute_counter.op "+"}}add{{else}}mul{{/ifeq~}}
{{/inline~}}
ptr.sub_{{>op_name}}(old_incr);
ptr.add_{{>op_name}}(new_incr);
if old != *ptr {
debug!("update {{name}}{:?} to {:?}", {{>args}}, *ptr);
diff.{{name}}.entry({{>args}}).or_insert((old, *ptr)).1 = *ptr;
}
if ptr.is_failed() { Err(()) } else { Ok(()) }
}
{{/if}}
|
#[doc = "Reader of register ODISR"]
pub type R = crate::R<u32, super::ODISR>;
#[doc = "Writer for register ODISR"]
pub type W = crate::W<u32, super::ODISR>;
#[doc = "Register ODISR `reset()`'s with value 0"]
impl crate::ResetValue for super::ODISR {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "TE2ODIS\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum TE2ODIS_A {
#[doc = "1: Disable output"]
DISABLE = 1,
}
impl From<TE2ODIS_A> for bool {
#[inline(always)]
fn from(variant: TE2ODIS_A) -> Self {
variant as u8 != 0
}
}
#[doc = "Reader of field `TE2ODIS`"]
pub type TE2ODIS_R = crate::R<bool, TE2ODIS_A>;
impl TE2ODIS_R {
#[doc = r"Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> crate::Variant<bool, TE2ODIS_A> {
use crate::Variant::*;
match self.bits {
true => Val(TE2ODIS_A::DISABLE),
i => Res(i),
}
}
#[doc = "Checks if the value of the field is `DISABLE`"]
#[inline(always)]
pub fn is_disable(&self) -> bool {
*self == TE2ODIS_A::DISABLE
}
}
#[doc = "Write proxy for field `TE2ODIS`"]
pub struct TE2ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TE2ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TE2ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
self.w
}
}
#[doc = "TE1ODIS"]
pub type TE1ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TE1ODIS`"]
pub type TE1ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TE1ODIS`"]
pub struct TE1ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TE1ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TE1ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
self.w
}
}
#[doc = "TD2ODIS"]
pub type TD2ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TD2ODIS`"]
pub type TD2ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TD2ODIS`"]
pub struct TD2ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TD2ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TD2ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 7)) | (((value as u32) & 0x01) << 7);
self.w
}
}
#[doc = "TD1ODIS"]
pub type TD1ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TD1ODIS`"]
pub type TD1ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TD1ODIS`"]
pub struct TD1ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TD1ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TD1ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 6)) | (((value as u32) & 0x01) << 6);
self.w
}
}
#[doc = "TC2ODIS"]
pub type TC2ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TC2ODIS`"]
pub type TC2ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TC2ODIS`"]
pub struct TC2ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TC2ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TC2ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
self.w
}
}
#[doc = "TC1ODIS"]
pub type TC1ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TC1ODIS`"]
pub type TC1ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TC1ODIS`"]
pub struct TC1ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TC1ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TC1ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[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 = "TB2ODIS"]
pub type TB2ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TB2ODIS`"]
pub type TB2ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TB2ODIS`"]
pub struct TB2ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TB2ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TB2ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[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 = "TB1ODIS"]
pub type TB1ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TB1ODIS`"]
pub type TB1ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TB1ODIS`"]
pub struct TB1ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TB1ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TB1ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[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 = "TA2ODIS"]
pub type TA2ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TA2ODIS`"]
pub type TA2ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TA2ODIS`"]
pub struct TA2ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TA2ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TA2ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[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 = "TA1ODIS"]
pub type TA1ODIS_A = TE2ODIS_A;
#[doc = "Reader of field `TA1ODIS`"]
pub type TA1ODIS_R = crate::R<bool, TE2ODIS_A>;
#[doc = "Write proxy for field `TA1ODIS`"]
pub struct TA1ODIS_W<'a> {
w: &'a mut W,
}
impl<'a> TA1ODIS_W<'a> {
#[doc = r"Writes `variant` to the field"]
#[inline(always)]
pub fn variant(self, variant: TA1ODIS_A) -> &'a mut W {
{
self.bit(variant.into())
}
}
#[doc = "Disable output"]
#[inline(always)]
pub fn disable(self) -> &'a mut W {
self.variant(TE2ODIS_A::DISABLE)
}
#[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
}
}
impl R {
#[doc = "Bit 9 - TE2ODIS"]
#[inline(always)]
pub fn te2odis(&self) -> TE2ODIS_R {
TE2ODIS_R::new(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 8 - TE1ODIS"]
#[inline(always)]
pub fn te1odis(&self) -> TE1ODIS_R {
TE1ODIS_R::new(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 7 - TD2ODIS"]
#[inline(always)]
pub fn td2odis(&self) -> TD2ODIS_R {
TD2ODIS_R::new(((self.bits >> 7) & 0x01) != 0)
}
#[doc = "Bit 6 - TD1ODIS"]
#[inline(always)]
pub fn td1odis(&self) -> TD1ODIS_R {
TD1ODIS_R::new(((self.bits >> 6) & 0x01) != 0)
}
#[doc = "Bit 5 - TC2ODIS"]
#[inline(always)]
pub fn tc2odis(&self) -> TC2ODIS_R {
TC2ODIS_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bit 4 - TC1ODIS"]
#[inline(always)]
pub fn tc1odis(&self) -> TC1ODIS_R {
TC1ODIS_R::new(((self.bits >> 4) & 0x01) != 0)
}
#[doc = "Bit 3 - TB2ODIS"]
#[inline(always)]
pub fn tb2odis(&self) -> TB2ODIS_R {
TB2ODIS_R::new(((self.bits >> 3) & 0x01) != 0)
}
#[doc = "Bit 2 - TB1ODIS"]
#[inline(always)]
pub fn tb1odis(&self) -> TB1ODIS_R {
TB1ODIS_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bit 1 - TA2ODIS"]
#[inline(always)]
pub fn ta2odis(&self) -> TA2ODIS_R {
TA2ODIS_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 0 - TA1ODIS"]
#[inline(always)]
pub fn ta1odis(&self) -> TA1ODIS_R {
TA1ODIS_R::new((self.bits & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 9 - TE2ODIS"]
#[inline(always)]
pub fn te2odis(&mut self) -> TE2ODIS_W {
TE2ODIS_W { w: self }
}
#[doc = "Bit 8 - TE1ODIS"]
#[inline(always)]
pub fn te1odis(&mut self) -> TE1ODIS_W {
TE1ODIS_W { w: self }
}
#[doc = "Bit 7 - TD2ODIS"]
#[inline(always)]
pub fn td2odis(&mut self) -> TD2ODIS_W {
TD2ODIS_W { w: self }
}
#[doc = "Bit 6 - TD1ODIS"]
#[inline(always)]
pub fn td1odis(&mut self) -> TD1ODIS_W {
TD1ODIS_W { w: self }
}
#[doc = "Bit 5 - TC2ODIS"]
#[inline(always)]
pub fn tc2odis(&mut self) -> TC2ODIS_W {
TC2ODIS_W { w: self }
}
#[doc = "Bit 4 - TC1ODIS"]
#[inline(always)]
pub fn tc1odis(&mut self) -> TC1ODIS_W {
TC1ODIS_W { w: self }
}
#[doc = "Bit 3 - TB2ODIS"]
#[inline(always)]
pub fn tb2odis(&mut self) -> TB2ODIS_W {
TB2ODIS_W { w: self }
}
#[doc = "Bit 2 - TB1ODIS"]
#[inline(always)]
pub fn tb1odis(&mut self) -> TB1ODIS_W {
TB1ODIS_W { w: self }
}
#[doc = "Bit 1 - TA2ODIS"]
#[inline(always)]
pub fn ta2odis(&mut self) -> TA2ODIS_W {
TA2ODIS_W { w: self }
}
#[doc = "Bit 0 - TA1ODIS"]
#[inline(always)]
pub fn ta1odis(&mut self) -> TA1ODIS_W {
TA1ODIS_W { w: self }
}
}
|
#![no_main]
use libfuzzer_sys::fuzz_target;
use std::pin::Pin;
use std::sync::{Arc, Mutex};
use std::task::{Context, Poll};
use async_std::io::Cursor;
use futures_io::{AsyncRead, AsyncWrite};
#[derive(Clone, Debug)]
struct RwWrapper(Arc<Mutex<Cursor<Vec<u8>>>>);
impl RwWrapper {
fn new(input: Vec<u8>) -> Self {
Self(Arc::new(Mutex::new(Cursor::new(input))))
}
}
impl AsyncRead for RwWrapper {
fn poll_read(
mut self: Pin<&mut Self>,
cx: &mut Context<'_>,
buf: &mut [u8],
) -> Poll<std::io::Result<usize>> {
Pin::new(&mut *self.0.lock().unwrap()).poll_read(cx, buf)
}
}
impl AsyncWrite for RwWrapper {
fn poll_write(
self: Pin<&mut Self>,
_cx: &mut Context<'_>,
buf: &[u8],
) -> Poll<std::io::Result<usize>> {
Poll::Ready(Ok(buf.len()))
}
fn poll_flush(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
Poll::Ready(Ok(()))
}
fn poll_close(self: Pin<&mut Self>, _cx: &mut Context<'_>) -> Poll<std::io::Result<()>> {
Poll::Ready(Ok(()))
}
}
fuzz_target!(|request: &[u8]| {
let stream = RwWrapper::new(request.to_vec());
async_std::task::block_on(async_h1::accept("http://localhost", stream, |req| async {
let mut res = http_types::Response::new(http_types::StatusCode::Ok);
res.set_body(req);
Ok(res)
}))
.ok();
});
|
use std::sync::Arc;
use super::{QoS, LastWill, PacketIdentifier, Protocol, ConnectReturnCode};
#[derive(Debug, Clone, PartialEq)]
pub enum Packet {
Connect(Box<Connect>),
Connack(Connack),
Publish(Box<Publish>),
Puback(PacketIdentifier),
Pubrec(PacketIdentifier),
Pubrel(PacketIdentifier),
Pubcomp(PacketIdentifier),
Subscribe(Box<Subscribe>),
Suback(Box<Suback>),
Unsubscribe(Box<Unsubscribe>),
Unsuback(PacketIdentifier),
Pingreq,
Pingresp,
Disconnect
}
#[derive(Debug, Clone, PartialEq)]
pub struct Connect {
pub protocol: Protocol,
pub keep_alive: u16,
pub client_id: String,
pub clean_session: bool,
pub last_will: Option<LastWill>,
pub username: Option<String>,
pub password: Option<String>
}
#[derive(Debug, Clone, Copy, PartialEq)]
pub struct Connack {
pub session_present: bool,
pub code: ConnectReturnCode
}
#[derive(Debug, Clone, PartialEq)]
pub struct Publish {
pub dup: bool,
pub qos: QoS,
pub retain: bool,
pub topic_name: String,
pub pid: Option<PacketIdentifier>,
pub payload: Arc<Vec<u8>>
}
#[derive(Debug, Clone, PartialEq)]
pub struct Subscribe {
pub pid: PacketIdentifier,
// (topic path, qos)
pub topics: Vec<SubscribeTopic>
}
#[derive(Debug, Clone, PartialEq)]
pub struct SubscribeTopic {
pub topic_path: String,
pub qos: QoS
}
#[derive(Debug, Clone, PartialEq)]
pub struct Suback {
pub pid: PacketIdentifier,
// (error, qos)
// TODO: replace with enum
pub return_codes: Vec<SubscribeReturnCodes>
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum SubscribeReturnCodes {
Success(QoS),
Failure
}
#[derive(Debug, Clone, PartialEq)]
pub struct Unsubscribe {
pub pid: PacketIdentifier,
pub topics: Vec<String>
}
|
extern crate cgmath;
extern crate objekt;
use cgmath::{Vector3, InnerSpace};
use rand::{Rng, thread_rng};
use crate::ray::Ray;
use crate::objects::{HitRecord};
type Vec3 = Vector3<f64>;
fn rand_f64() -> f64 {
thread_rng().gen::<f64>()
}
fn unit_vector(vector: &Vec3) -> Vec3 {
vector / vector.magnitude()
}
fn random_in_unit_sphere() -> Vec3 {
let mut p: Vec3;
while {
p = 2f64 * Vec3::new(rand_f64(), rand_f64(), rand_f64()) - Vec3::new(1f64, 1f64, 1f64);
p.magnitude2() >= 1f64
} {}
p
}
pub trait Material: std::marker::Sync + objekt::Clone {
fn scatter(&self, r: &Ray, rec: &mut HitRecord, attenuation: &mut Vec3, scattered: &mut Ray) -> bool;
}
objekt::clone_trait_object!(Material);
#[derive(Clone)]
pub struct Empty {}
impl Material for Empty {
fn scatter(&self, r: &Ray, _rec: &mut HitRecord, _attenuation: &mut Vec3, scattered: &mut Ray) -> bool {
*scattered = r.clone();
true
}
}
#[derive(Clone)]
pub struct Matte {
albedo: Vec3
}
impl Matte {
pub fn new(albedo: Vec3) -> Matte {
Matte {albedo}
}
}
impl Material for Matte {
fn scatter(&self, _r: &Ray, rec: &mut HitRecord, attenuation: &mut Vec3, scattered: &mut Ray) -> bool {
let target = rec.p + rec.normal + random_in_unit_sphere();
*scattered = Ray::new(rec.p, target - rec.p);
*attenuation = self.albedo;
true
}
}
#[derive(Clone)]
pub struct Metal {
albedo: Vec3,
fuzz: f64
}
impl Metal {
pub fn new(albedo: Vec3, f: f64) -> Metal {
let fuzz = if f < 1f64 { f } else { 1f64 };
Metal {albedo, fuzz}
}
fn reflect(v: Vec3, n: Vec3) -> Vec3 {
v - 2f64 * v.dot(n) * n
}
}
impl Material for Metal {
fn scatter(&self, r: &Ray, rec: &mut HitRecord, attenuation: &mut Vec3, scattered: &mut Ray) -> bool {
let reflected = Metal::reflect(unit_vector(&r.direction), rec.normal);
*scattered = Ray::new(rec.p, reflected + self.fuzz*random_in_unit_sphere());
*attenuation = self.albedo;
scattered.direction.dot(rec.normal) > 0f64
}
}
#[derive(Clone)]
pub struct Glass {
attenuation: Vec3,
ref_idx: f64,
}
impl Glass {
pub fn new(attenuation: Vec3, ref_idx: f64) -> Glass {
Glass {attenuation, ref_idx}
}
fn refract(v: &Vec3, n: &Vec3, ni_over_nt: f64, refracted: &mut Vec3) -> bool {
let uv = unit_vector(v);
let dt = uv.dot(*n);
let discriminant = 1f64 - ni_over_nt.powi(2)*(1f64-dt.powi(2));
if discriminant > 0f64 {
*refracted = ni_over_nt*(uv - n*dt) - n*discriminant.sqrt();
return true
}
false
}
fn reflect(v: Vec3, n: Vec3) -> Vec3 {
v - 2f64 * v.dot(n) * n
}
fn schlick(&self, cosine: f64) -> f64 {
let r0 = ((1f64-self.ref_idx) / (1f64+self.ref_idx)).powi(2);
r0 + (1f64-r0)*(1f64-cosine).powi(5)
}
}
impl Material for Glass {
fn scatter(&self, r: &Ray, rec: &mut HitRecord, attenuation: &mut Vec3, scattered: &mut Ray) -> bool {
let outward_normal: Vec3;
let reflected = Glass::reflect(r.direction, rec.normal);
let ni_over_nt: f64;
*attenuation = self.attenuation;
let mut refracted = Vec3::new(0f64, 0f64, 0f64);
let reflect_prob: f64;
let cosine: f64;
if r.direction.dot(rec.normal) > 0f64 {
outward_normal = -rec.normal;
ni_over_nt = self.ref_idx;
cosine = self.ref_idx * r.direction.dot(rec.normal) / r.direction.magnitude();
} else {
outward_normal = rec.normal;
ni_over_nt = 1f64 / self.ref_idx;
cosine = -(r.direction.dot(rec.normal) / r.direction.magnitude());
}
if Glass::refract(&r.direction, &outward_normal, ni_over_nt, &mut refracted) {
reflect_prob = self.schlick(cosine);
} else {
reflect_prob = 1f64;
}
if rand_f64() < reflect_prob {
*scattered = Ray::new(rec.p, reflected);
} else {
*scattered = Ray::new(rec.p, refracted);
}
true
}
}
|
// Copyright (c) 2014 Michael Woerister
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
use statemachine::{StateMachine, StateId, Char, Epsilon};
#[deriving(Clone, IterBytes, Eq)]
pub enum Regex {
Leaf(char),
Kleene(~Regex),
Seq(~Regex, ~Regex),
Union(~Regex, ~Regex),
}
impl Regex {
pub fn to_state_machine(&self) -> (StateMachine, StateId, StateId) {
match *self {
Leaf(c) => {
let mut sm = StateMachine::new();
let start_state = sm.add_state();
let end_state = sm.add_state();
sm.add_transition(start_state, end_state, Char(c));
(sm, start_state, end_state)
}
Kleene(ref sub) => {
let (mut sm, sub_start, sub_end) = sub.to_state_machine();
let start_state = sm.add_state();
let end_state = sm.add_state();
sm.add_transition(start_state, sub_start, Epsilon);
sm.add_transition(sub_end, sub_start, Epsilon);
sm.add_transition(sub_end, end_state, Epsilon);
sm.add_transition(start_state, end_state, Epsilon);
(sm, start_state, end_state)
}
Seq(ref left, ref right) => {
let (mut left_sm, left_start, left_end) = left.to_state_machine();
let (right_sm, right_start, right_end) = right.to_state_machine();
left_sm.consume(right_sm);
left_sm.add_transition(left_end, right_start, Epsilon);
(left_sm, left_start, right_end)
}
Union(ref left, ref right) => {
let (mut sm, left_start, left_end) = left.to_state_machine();
let (right_sm, right_start, right_end) = right.to_state_machine();
sm.consume(right_sm);
let start_state = sm.add_state();
let end_state = sm.add_state();
sm.add_transition(start_state, left_start, Epsilon);
sm.add_transition(start_state, right_start, Epsilon);
sm.add_transition(left_end, end_state, Epsilon);
sm.add_transition(right_end, end_state, Epsilon);
(sm, start_state, end_state)
}
}
}
}
#[cfg(test)]
mod test {
use super::{Regex, Seq, Union, Kleene, Leaf};
use statemachine::{StateMachine, StateId, StateSet, ToDfaResult};
fn compile(regex: &Regex) -> (StateMachine, StateId, ~[StateId]) {
let (sm, start, end) = regex.to_state_machine();
let end_states = [end];
let end_states: StateSet = end_states.iter().map(|x| *x).collect();
let ToDfaResult { dfa, start_state, end_state_map } = sm.to_dfa(start, &end_states);
let dfa_end_states = end_state_map.keys().map(|x| *x).to_owned_vec();
let partitioning = dfa.accepting_non_accepting_partitioning(dfa_end_states.iter().map(|s| *s));
let (minimized_dfa, state_map) = dfa.to_minimal(&partitioning);
let start_state = state_map.get_copy(&start_state);
let dfa_end_states = dfa_end_states.iter().map(|s| state_map.get_copy(s)).collect::<StateSet>();
(minimized_dfa, start_state, dfa_end_states.iter().map(|x| x.clone()).to_owned_vec())
}
fn matches(&(ref sm, start_state, ref end_states): &(StateMachine, StateId, ~[StateId]), s: &str) -> bool {
let result_state = sm.run(start_state, s);
end_states.iter().any(|&x| Some(x) == result_state)
}
#[test]
fn test_kleene() {
let sm = compile(&Kleene(~Leaf('a')));
assert!(matches(&sm, ""));
assert!(matches(&sm, "a"));
assert!(matches(&sm, "aaa"));
assert!(matches(&sm, "aaaaaaaaaaaaaaaaaaaaaaaaaa"));
assert!(!matches(&sm, "b"));
assert!(!matches(&sm, "caaaa"));
assert!(!matches(&sm, "daaa"));
assert!(!matches(&sm, "e"));
assert!(!matches(&sm, "ab"));
}
#[test]
fn test_seq() {
let sm = compile(&Seq(~Leaf('a'), ~Seq(~Leaf('b'),~Leaf('c'))));
assert!(!matches(&sm, ""));
assert!(!matches(&sm, "a"));
assert!(!matches(&sm, "ab"));
assert!(matches(&sm, "abc"));
assert!(!matches(&sm, "abcd"));
assert!(!matches(&sm, "bc"));
assert!(!matches(&sm, "c"));
assert!(!matches(&sm, "bca"));
}
#[test]
fn test_union() {
let sm = compile(&Union(~Leaf('a'), ~Union(~Leaf('b'),~Leaf('c'))));
assert!(!matches(&sm, ""));
assert!(matches(&sm, "a"));
assert!(matches(&sm, "b"));
assert!(matches(&sm, "c"));
assert!(!matches(&sm, "ab"));
assert!(!matches(&sm, "ac"));
assert!(!matches(&sm, "bc"));
}
#[test]
fn test_ident_like() {
let alpha = ~Union(
~Leaf('a'),
~Union(
~Leaf('b'),
~Union(
~Leaf('c'),
~Leaf('d')
)
)
);
let digit = ~Union(
~Leaf('1'),
~Union(
~Leaf('2'),
~Union(
~Leaf('3'),
~Leaf('4')
)
)
);
let regex = Seq(alpha.clone(), ~Kleene(~Union(alpha, digit)));
let sm = compile(®ex);
assert!(!matches(&sm, ""));
assert!(matches(&sm, "a"));
assert!(matches(&sm, "b"));
assert!(matches(&sm, "c"));
assert!(matches(&sm, "d"));
assert!(!matches(&sm, "1"));
assert!(!matches(&sm, "2"));
assert!(!matches(&sm, "3"));
assert!(!matches(&sm, "4"));
assert!(matches(&sm, "aaaa"));
assert!(matches(&sm, "a1b2"));
assert!(matches(&sm, "aab1a"));
assert!(matches(&sm, "dddaca"));
assert!(!matches(&sm, "1cbda"));
assert!(!matches(&sm, "2dca"));
assert!(!matches(&sm, "3da"));
assert!(!matches(&sm, "4d"));
assert!(!matches(&sm, "5ddda"));
}
} |
use futures::{StreamExt, TryStreamExt};
use object_store::{DynObjectStore, ObjectMeta};
use observability_deps::tracing::info;
use snafu::prelude::*;
use std::sync::Arc;
use tokio::sync::mpsc;
use tokio_util::sync::CancellationToken;
pub(crate) async fn perform(
shutdown: CancellationToken,
object_store: Arc<DynObjectStore>,
dry_run: bool,
concurrent_deletes: usize,
items: mpsc::Receiver<ObjectMeta>,
) -> Result<()> {
let stream_fu = tokio_stream::wrappers::ReceiverStream::new(items)
.map(|item| {
let object_store = Arc::clone(&object_store);
async move {
let path = item.location;
if dry_run {
info!(?path, "Not deleting due to dry run");
Ok(())
} else {
info!("Deleting {path}");
object_store
.delete(&path)
.await
.context(DeletingSnafu { path })
}
}
})
.buffer_unordered(concurrent_deletes)
.try_collect();
tokio::select! {
_ = shutdown.cancelled() => {
// Exit gracefully
}
res = stream_fu => {
// Propagate error
res?;
}
}
Ok(())
}
#[derive(Debug, Snafu)]
#[allow(missing_docs)]
pub enum Error {
#[snafu(display("{path} could not be deleted"))]
Deleting {
source: object_store::Error,
path: object_store::path::Path,
},
}
pub(crate) type Result<T, E = Error> = std::result::Result<T, E>;
#[cfg(test)]
mod tests {
use super::*;
use bytes::Bytes;
use chrono::Utc;
use data_types::{NamespaceId, PartitionId, TableId, TransitionPartitionId};
use object_store::path::Path;
use parquet_file::ParquetFilePath;
use std::time::Duration;
use uuid::Uuid;
#[tokio::test]
async fn perform_shutdown_gracefully() {
let shutdown = CancellationToken::new();
let nitems = 3;
let object_store: Arc<DynObjectStore> = Arc::new(object_store::memory::InMemory::new());
let items = populate_os_with_items(&object_store, nitems).await;
assert_eq!(count_os_element(&object_store).await, nitems);
let dry_run = false;
let concurrent_deletes = 2;
let (tx, rx) = mpsc::channel(1000);
tokio::spawn({
let shutdown = shutdown.clone();
async move {
for item in items {
tx.send(item.clone()).await.unwrap();
}
// Send a shutdown signal
shutdown.cancel();
// Prevent this thread from exiting. Exiting this thread will
// close the channel, which in turns close the processing stream.
loop {
tokio::time::sleep(std::time::Duration::from_secs(1)).await;
}
}
});
// This call should terminate because we send shutdown signal, but
// nothing can be said about the number of elements in object store.
// The processing stream may or may not have chance to process the
// items for deletion.
let perform_fu = perform(
shutdown,
Arc::clone(&object_store),
dry_run,
concurrent_deletes,
rx,
);
// Unusual test because there is no assertion but the call below should
// not panic which verifies that the deleter task shutdown gracefully.
tokio::time::timeout(Duration::from_secs(3), perform_fu)
.await
.unwrap()
.unwrap();
}
async fn count_os_element(os: &Arc<DynObjectStore>) -> usize {
let objects = os.list(None).await.unwrap();
objects.fold(0, |acc, _| async move { acc + 1 }).await
}
async fn populate_os_with_items(os: &Arc<DynObjectStore>, nitems: usize) -> Vec<ObjectMeta> {
let mut items = vec![];
for i in 0..nitems {
let object_meta = ObjectMeta {
location: new_object_meta_location(),
last_modified: Utc::now(),
size: 0,
e_tag: None,
};
os.put(&object_meta.location, Bytes::from(i.to_string()))
.await
.unwrap();
items.push(object_meta);
}
items
}
fn new_object_meta_location() -> Path {
ParquetFilePath::new(
NamespaceId::new(1),
TableId::new(2),
&TransitionPartitionId::Deprecated(PartitionId::new(4)),
Uuid::new_v4(),
)
.object_store_path()
}
}
|
use itertools::Itertools;
#[derive(Debug)]
struct SignalNote<'a> {
output: Vec<&'a str>,
}
impl<'a> SignalNote<'a> {
fn from_str(input: &'a str) -> Self {
let (_patterns, output) = input.split_once(" | ").unwrap();
Self {
output: output.split(' ').collect(),
}
}
}
fn notes(input: &str) -> Vec<SignalNote> {
input.lines().map(SignalNote::from_str).collect_vec()
}
#[cfg(test)]
const TEST_INPUT: &str = "be cfbegad cbdgef fgaecd cgeb fdcge agebfd fecdb fabcd edb | \
fdgacbe cefdb cefbgd gcbe
edbfga begcd cbg gc gcadebf fbgde acbgfd abcde gfcbed gfec | \
fcgedb cgb dgebacf gc
fgaebd cg bdaec gdafb agbcfd gdcbef bgcad gfac gcb cdgabef | \
cg cg fdcagb cbg
fbegcd cbd adcefb dageb afcb bc aefdc ecdab fgdeca fcdbega | \
efabcd cedba gadfec cb
aecbfdg fbg gf bafeg dbefa fcge gcbea fcaegb dgceab fcbdga | \
gecf egdcabf bgf bfgea
fgeab ca afcebg bdacfeg cfaedg gcfdb baec bfadeg bafgc acf | \
gebdcfa ecba ca fadegcb
dbcfg fgd bdegcaf fgec aegbdf ecdfab fbedc dacgb gdcebf gf | \
cefg dcbef fcge gbcadfe
bdfegc cbegaf gecbf dfcage bdacg ed bedf ced adcbefg gebcd | \
ed bcgafe cdgba cbgef
egadfb cdbfeg cegd fecab cgb gbdefca cg fgcdab egfdb bfceg | \
gbdfcae bgc cg cgb
gcafb gcf dcaebfg ecagb gf abcdeg gaef cafbge fdbac fegbdc | \
fgae cfgab fg bagce";
const fn unique_digit_from_len(len: u8) -> Option<u8> {
Some(match len {
2 => 1,
3 => 7,
4 => 4,
7 => 8,
_ => return None,
})
}
fn part1(input: &str) -> usize {
notes(input)
.iter()
.flat_map(|note| ¬e.output)
.filter(|output| unique_digit_from_len(output.len() as u8).is_some())
.count()
}
aoc::tests! {
fn part1:
TEST_INPUT => 26;
in => 543;
}
aoc::main!(part1);
|
use crate::io::BufMut;
use crate::mysql::protocol::{Capabilities, Encode};
// https://dev.mysql.com/doc/dev/mysql-server/8.0.12/page_protocol_com_query.html
#[derive(Debug)]
pub struct ComQuery<'a> {
pub query: &'a str,
}
impl Encode for ComQuery<'_> {
fn encode(&self, buf: &mut Vec<u8>, _: Capabilities) {
// COM_QUERY : int<1>
buf.put_u8(0x03);
// query : string<EOF>
buf.put_str(self.query);
}
}
|
use std::collections::VecDeque;
pub struct FIFOBuffer<T>
where T: Sync,
T: Send
{
items: VecDeque<T>,
desired_buffering: usize,
}
impl<T> FIFOBuffer<T>
where T: Sync,
T: Send
{
pub fn new(desired_buffering: usize) -> FIFOBuffer<T> {
FIFOBuffer::<T> {
items: VecDeque::with_capacity(desired_buffering),
desired_buffering: desired_buffering,
}
}
pub fn shift(&mut self) -> Option<T> {
self.items.pop_front()
}
pub fn push(&mut self, item: T) {
self.items.push_back(item);
}
pub fn topup(&mut self) -> Option<usize> {
let items_len = self.items.len();
if items_len < self.desired_buffering {
return Some(self.desired_buffering - items_len);
}
None
}
}
|
// Copyright 2019. The Tari Project
//
// Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
// following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following
// disclaimer.
//
// 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the
// following disclaimer in the documentation and/or other materials provided with the distribution.
//
// 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote
// products derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
// INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
// WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
use crate::{
chain_storage::{is_stxo, is_utxo, BlockchainBackend},
transactions::{transaction::Transaction, types::CryptoFactories},
validation::{StatelessValidation, Validation, ValidationError},
};
use log::*;
use tari_crypto::tari_utilities::hash::Hashable;
pub const LOG_TARGET: &str = "c::val::transaction_validators";
/// This validator will only check that a transaction is internally consistent. It requires no state information.
pub struct StatelessTxValidator {
factories: CryptoFactories,
}
impl StatelessTxValidator {
pub fn new(factories: CryptoFactories) -> Self {
Self { factories }
}
}
impl StatelessValidation<Transaction> for StatelessTxValidator {
fn validate(&self, tx: &Transaction) -> Result<(), ValidationError> {
verify_tx(tx, &self.factories)?;
Ok(())
}
}
/// This validator will perform a full verification of the transaction. In order the following will be checked:
/// Transaction integrity, All inputs exist in the backend, All timelocks (kernel lock heights and output maturities)
/// have passed
pub struct FullTxValidator {
factories: CryptoFactories,
}
impl FullTxValidator {
pub fn new(factories: CryptoFactories) -> Self {
Self { factories }
}
}
impl<B: BlockchainBackend> Validation<Transaction, B> for FullTxValidator {
fn validate(&self, tx: &Transaction, db: &B) -> Result<(), ValidationError> {
verify_tx(tx, &self.factories)?;
verify_inputs(tx, db)?;
let tip_height = db
.fetch_metadata()
.map_err(|e| ValidationError::CustomError(e.to_string()))?
.height_of_longest_chain
.unwrap_or(0);
verify_timelocks(tx, tip_height)?;
Ok(())
}
}
/// This validator assumes that the transaction was already validated and it will skip this step. It will only check, in
/// order,: All inputs exist in the backend, All timelocks (kernel lock heights and output maturities) have passed
pub struct TxInputAndMaturityValidator {}
impl<B: BlockchainBackend> Validation<Transaction, B> for TxInputAndMaturityValidator {
fn validate(&self, tx: &Transaction, db: &B) -> Result<(), ValidationError> {
verify_inputs(tx, db)?;
let tip_height = db
.fetch_metadata()
.map_err(|e| ValidationError::CustomError(e.to_string()))?
.height_of_longest_chain
.unwrap_or(0);
verify_timelocks(tx, tip_height)?;
Ok(())
}
}
/// This validator will only check that inputs exists in the backend.
pub struct InputTxValidator {}
impl<B: BlockchainBackend> Validation<Transaction, B> for InputTxValidator {
fn validate(&self, tx: &Transaction, db: &B) -> Result<(), ValidationError> {
verify_inputs(tx, db)?;
Ok(())
}
}
/// This validator will only check timelocks, it will check that kernel lock heights and output maturities have passed.
pub struct TimeLockTxValidator {}
impl<B: BlockchainBackend> Validation<Transaction, B> for TimeLockTxValidator {
fn validate(&self, tx: &Transaction, db: &B) -> Result<(), ValidationError> {
let tip_height = db
.fetch_metadata()
.map_err(|e| ValidationError::CustomError(e.to_string()))?
.height_of_longest_chain
.unwrap_or(0);
verify_timelocks(tx, tip_height)?;
Ok(())
}
}
// This function verifies that the provided transaction is internally sound and that no funds were created in the
// transaction.
fn verify_tx(tx: &Transaction, factories: &CryptoFactories) -> Result<(), ValidationError> {
tx.validate_internal_consistency(factories, None)
.map_err(ValidationError::TransactionError)
}
// This function checks that all the timelocks in the provided transaction pass. It checks kernel lock heights and
// input maturities
fn verify_timelocks(tx: &Transaction, current_height: u64) -> Result<(), ValidationError> {
if tx.min_spendable_height() > current_height + 1 {
return Err(ValidationError::MaturityError);
}
Ok(())
}
// This function checks that all inputs exist in the provided database backend
fn verify_inputs<B: BlockchainBackend>(tx: &Transaction, db: &B) -> Result<(), ValidationError> {
for input in tx.body.inputs() {
if is_stxo(db, input.hash()).map_err(|e| ValidationError::CustomError(e.to_string()))? {
// we dont want to log this as a node or wallet might retransmit a transaction
debug!(
target: LOG_TARGET,
"Transaction validation failed due to already spent input: {}", input
);
return Err(ValidationError::ContainsSTxO);
}
if !(is_utxo(db, input.hash())).map_err(|e| ValidationError::CustomError(e.to_string()))? {
warn!(
target: LOG_TARGET,
"Transaction validation failed due to unknown input: {}", input
);
return Err(ValidationError::UnknownInputs);
}
}
Ok(())
}
|
use std::vec::Vec;
use std::iter::range_step;
use std::num::{pow, one};
use std::num::FromPrimitive;
use std::mem::swap;
use std::default::Default;
use cgmath::{Point, Point2, Point3};
use cgmath::{Vector, Vector2, Vector3};
use cgmath::BaseNum;
use {Max, Min, Merge, Center, Intersects};
pub struct BvhBuilder<T, C, P> {
max: P,
min: P,
data: Vec<(C, Option<T>)>,
_data: Vec<(C, Option<T>)>,
reorder: Vec<(u32, u32)>
}
pub struct Bvh<T, C> {
depth: uint,
data: Vec<(C, Option<T>)>,
_data: Vec<(C, Option<T>)>,
reorder: Vec<(u32, u32)>
}
impl
<
S: BaseNum + FromPrimitive,
V: Vector<S>,
P: Point<S, V> + ToMorton<P, V> + Clone,
T: Clone,
C: Merge+Center<P>+Intersects<C>+Default+Max<P>+Min<P>+Clone
> BvhBuilder<T, C, P> {
pub fn new() -> BvhBuilder<T, C, P> {
BvhBuilder {
max: Point::origin(),
min: Point::origin(),
data: Vec::new(),
_data: Vec::new(),
reorder: Vec::new()
}
}
pub fn add(&mut self, collider: C, data: T) {
let min = collider.min();
let max = collider.max();
self.min = self.min.min(&min);
self.max = self.max.max(&max);
self.data.push((collider.clone(), Some(data)));
}
pub fn build(mut self) -> Bvh<T, C> {
let step = if self.data.len() != 0 {
let base = self.min.clone();
let scale: S = FromPrimitive::from_int(1023).unwrap();
let unit_vector: V = one();
let scale = unit_vector.mul_s(scale).div_v(&self.max.sub_p(&self.min));
self.reorder.truncate(0);
for (id, &(ref aabb, _)) in self.data.iter().enumerate() {
self.reorder.push((aabb.center().to_morton(&base, &scale), id as u32))
}
self.reorder.sort();
self._data.truncate(0);
let mut reorder_iter = self.reorder.iter();
for idx in range(0, self.reorder.len()*2-1) {
self._data.push(
if idx & 0x1 == 0 {
let &(_, v) = reorder_iter.next().unwrap();
let (ref aabb, ref dat) = self.data[v as uint];
(aabb.clone(), dat.clone())
} else {
(Default::default(), None)
}
);
}
let mut step = 1;
loop {
let reach = pow(2u, step);
let half_reach = pow(2u, step-1);
if reach > self._data.len() {
break
}
for i in range_step(reach-1, self._data.len(), pow(2u, step+1)) {
let left = i - half_reach;
let mut right = i + half_reach;
let mut hr = half_reach;
while right >= self._data.len() {
hr /= 2;
right = i + hr;
}
let new = match (&self._data[left], &self._data[right]) {
(&(ref left, _), &(ref right, _)) => left.merge(right)
};
*self._data.get_mut(i) = (new, None);
}
step += 1;
}
step
} else {
self.data.truncate(0);
self.reorder.truncate(0);
self._data.truncate(0);
0
};
let mut out = Bvh {
depth: step - 1,
data: Vec::new(),
_data: Vec::new(),
reorder: Vec::new()
};
swap(&mut out.data, &mut self._data);
swap(&mut out._data, &mut self.data);
swap(&mut out.reorder, &mut self.reorder);
out
}
}
pub trait ToMorton<P, V> {
fn to_morton(&self, b: &P, s: &V) -> u32;
}
impl<S: BaseNum+NumCast> ToMorton<Point3<S>, Vector3<S>> for Point3<S> {
fn to_morton(&self, base: &Point3<S>, scale: &Vector3<S>) -> u32 {
fn to_morton_code(val: u32) -> u32 {
let mut out = 0;
let mut mask = 0b1;
let mut rotate = 0;
for _ in range(0i, 10) {
out |= (val & mask) << rotate;
mask <<= 1;
rotate += 2;
}
out
}
let x: u32 = ((self.x - base.x) * scale.x).to_u32().unwrap();
let y: u32 = ((self.y - base.y) * scale.y).to_u32().unwrap();
let z: u32 = ((self.z - base.z) * scale.z).to_u32().unwrap();
((to_morton_code(x)<<2) | (to_morton_code(y)<<1) | to_morton_code(z))
}
}
impl<S: BaseNum+NumCast> ToMorton<Point2<S>, Vector2<S>> for Point2<S> {
fn to_morton(&self, base: &Point2<S>, scale: &Vector2<S>) -> u32 {
fn to_morton_code(val: u32) -> u32 {
let mut out = 0;
let mut mask = 0b1;
let mut rotate = 0;
for _ in range(0i, 10) {
out |= (val & mask) << rotate;
mask <<= 1;
rotate += 1;
}
out
}
let x: u32 = ((self.x - base.x) * scale.x).to_u32().unwrap();
let y: u32 = ((self.y - base.y) * scale.y).to_u32().unwrap();
((to_morton_code(x)<<1) | to_morton_code(y))
}
}
impl<
S: BaseNum + FromPrimitive,
V: Vector<S>,
P: Point<S, V> + ToMorton<P, V>,
T: Clone,
C: Merge+Center<P>+Intersects<C>+Default+Max<P>+Min<P>+Clone
> Bvh<T, C> {
fn depth(&self, idx: uint) -> uint {
let mut depth = 0;
let mut mask = 0b1;
loop {
if idx & mask != mask {
break
}
depth += 1;
mask |= 1 << depth;
}
assert!(depth != 0);
depth
}
fn children(&self, idx: uint) -> (uint, uint) {
let depth = self.depth(idx);
let mut half = pow(2u, depth-1);
let left = idx - half;
let mut right = idx + half;
// if the right is beyond the end, reselect a child node
while right >= self.data.len() {
half /= 2;
right = idx + half;
}
(left, right)
}
pub fn collision_iter<'a>(&'a self, collider: &'a C) -> BvhCollisionIter<'a, T, C> {
BvhCollisionIter {
bt: pow(2u, self.depth) - 1,
last: pow(2u, self.depth+1),
parent: Vec::new(),
tree: self,
collider: collider
}
}
pub fn to_builder(mut self) -> BvhBuilder<T, C, P> {
self.data.truncate(0);
self._data.truncate(0);
self.reorder.truncate(0);
let mut out = BvhBuilder {
max: Point::origin(),
min: Point::origin(),
data: Vec::new(),
_data: Vec::new(),
reorder: Vec::new()
};
swap(&mut out.data, &mut self.data);
swap(&mut out._data, &mut self._data);
swap(&mut out.reorder, &mut self.reorder);
out
}
}
pub struct BvhCollisionIter<'a, T:'a, C:'a> {
tree: &'a Bvh<T, C>,
bt: uint,
last: uint,
parent: Vec<uint>,
collider: &'a C
}
impl<
'a,
T: Clone,
S: BaseNum + FromPrimitive,
V: Vector<S>,
P: Point<S, V> + ToMorton<P, V>,
C: Merge+Center<P>+Intersects<C>+Default+Max<P>+Min<P>+Clone
> Iterator<(&'a C, &'a T)> for BvhCollisionIter<'a, T, C> {
fn next(&mut self) -> Option<(&'a C, &'a T)> {
loop {
let (ref aabb, ref dat) = self.tree.data[self.bt];
if dat.is_some() {
self.last = self.bt;
self.bt = match self.parent.pop() {
Some(p) => p,
None => return None
};
if aabb.intersect(self.collider) {
return Some((aabb, dat.as_ref().unwrap()));
}
}
let (left, right) = self.tree.children(self.bt);
// returning from right
if self.last == right {
self.parent.push(self.bt);
self.last = self.bt;
self.bt = left;
// return from left, all children have been exhausted so ascend
// or if we are new to this node, but do not collide with it
} else if self.last == left || !aabb.intersect(self.collider) {
self.last = self.bt;
self.bt = match self.parent.pop() {
Some(p) => p,
None => return None
}
// this collides with the cell, descend to the right branch
} else {
self.parent.push(self.bt);
self.last = self.bt;
self.bt = right;
}
}
}
}
|
extern crate rainwater;
use rainwater::scan_rayon;
fn main() {
let heights = vec![1; 1_000_000];
for _ in 0..100_000 {
scan_rayon::capacity(&heights, 32);
}
}
|
use chrono::prelude::{NaiveDateTime};
use std::borrow::Cow;
use usiem::components::common::LogParsingError;
use usiem::events::field::{SiemField, SiemIp};
use usiem::events::{SiemLog, SiemEvent};
use usiem::events::auth::{AuthEvent,AuthLoginType, LoginOutcome, RemoteLogin};
use std::collections::BTreeMap;
pub fn parse_general_log(log: SiemLog) -> Result<SiemLog, LogParsingError> {
let log_line = log.message().to_string();
let log_line = match log_line.find(" id=") {
None => return Err(LogParsingError::NoValidParser(log)),
Some(pos) => &log_line[pos + 1..]
};
let fields = extract_fields(log_line);
let timestamp = match fields.get("time") {
Some(timestamp) => {
match NaiveDateTime::parse_from_str(*timestamp, "%Y-%m-%d %H:%M:%S") {
Ok(timestamp) => timestamp.timestamp_millis(),
Err(_err) => return Err(LogParsingError::NoValidParser(log)),
}
},
None => return Err(LogParsingError::NoValidParser(log))
};
let observer_ip = match fields.get("fw") {
Some(fw) => {
match SiemIp::from_ip_str(fw) {
Ok(ip) => ip,
Err(_) => return Err(LogParsingError::ParserError(log)),
}
},
None => return Err(LogParsingError::NoValidParser(log))
};
let log = parse_msg_field(&fields, log);
match log {
Ok(mut log) => {
log.add_field("observer.ip", SiemField::IP(observer_ip));
log.set_event_created(timestamp);
log.set_service(Cow::Borrowed("PulseSecure"));
log.set_product(Cow::Borrowed("PulseSecure"));
log.set_category(Cow::Borrowed("VPN"));
return Ok(log)
},
Err(e) => return Err(e)
};
}
pub fn extract_fields<'a>(message: &'a str) -> BTreeMap<&'a str, &'a str> {
let mut field_map = BTreeMap::new();
let mut equal_pos = 0;
let mut prev_equal = 0;
let mut last_whitespace = 0;
let mut last_char = ' ';
let mut is_string = false;
let mut start_key_pos = 0;
let mut prev_start_key;
for (i, c) in message.char_indices() {
if !is_string {
if c == '=' {
prev_start_key = start_key_pos;
start_key_pos = if last_whitespace == 0 {
0
}else {
last_whitespace + 1
};
if equal_pos != prev_equal && (equal_pos + 1) != last_whitespace{
if &message[equal_pos + 1..equal_pos+2] == "\"" {
field_map.insert(&message[prev_start_key..equal_pos], &message[equal_pos+2..last_whitespace-1]);
}else{
field_map.insert(&message[prev_start_key..equal_pos], &message[equal_pos+1..last_whitespace]);
}
}
prev_equal = equal_pos;
equal_pos = i;
}else if c == ' ' {
last_whitespace = i;
}else if c == '"' {
is_string = true;
}
}else{
if last_char != '\\' && c == '"' {
is_string = false;
}
}
last_char = c;
}
if (equal_pos+2) < message.len() && &message[equal_pos + 1..equal_pos+2] == "\"" {
field_map.insert(&message[last_whitespace + 1..equal_pos], &message[equal_pos + 2.. message.len() - 1]);
}else{
field_map.insert(&message[last_whitespace + 1..equal_pos], &message[equal_pos + 1..]);
}
field_map
}
pub fn parse_msg_field(fields : &BTreeMap<&str, &str>, mut log: SiemLog) -> Result<SiemLog, LogParsingError> {
let msg = match fields.get("msg") {
Some(fw) => *fw,
None => return Ok(log)
};
let (id, _content) = match msg.find(": ") {
Some(pos) => (&msg[..pos], &msg[pos + 2..]),
None => return Err(LogParsingError::ParserError(log))
};
let typ = &id[0..3];
let id = match (&id[3..]).parse::<u32>() {
Ok(id) => id,
Err(_) => return Err(LogParsingError::ParserError(log))
};
let user = match fields.get("user") {
Some(user) => user,
None => ""
};
let user_domain = match fields.get("realm") {
Some(dm) => dm,
None => "_NONE_"
};
let hostname = match fields.get("fw") {
Some(user) => user,
None => "_NONE_"
};
let source = match fields.get("src") {
Some(src) => *src,
None => "_NONE_"
};
match fields.get("agent") {
Some(agnt) => {
if agnt.len() > 0{
log.add_field("user_agent.original", SiemField::Text(Cow::Owned(agnt.to_string())));
}
},
None => {}
};
// Add Event ID from msg field and dataset
log.add_field("event.code", SiemField::U32(id));
log.add_field("event.dataset", SiemField::from_str(typ.to_string()));
match typ {
"AUT" => {
match id {
23457 => {
//Login failed
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::FAIL,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
31504 => {
//Login succeded
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::SUCCESS,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
24412 => {
// SOAP login succeeded for
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::SUCCESS,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
24414 => {
// SOAP login succeeded for
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::SUCCESS,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
24326 => {
//Primary authentication successful
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::ESTABLISH,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
30684 => {
//Primary authentication successful for admin
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::ESTABLISH,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
24327 => {
//Primary authentication failed
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::FAIL,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
30685 => {
//Primary authentication failed for admin
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::FAIL,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
22673 => {
//Logout
},
31085 => {
//Concurrent connection limit
},
_ => {}
}
return Ok(log)
},
"USR" => {
return Ok(log)
},
"ADM" => {
match id {
22668 => {
//Login succeded
log.set_event(SiemEvent::Auth(AuthEvent {
hostname : Cow::Owned(hostname.to_string()),
outcome : LoginOutcome::SUCCESS,
login_type : AuthLoginType::Remote(RemoteLogin {
user_name : Cow::Owned(user.to_string()),
domain : Cow::Owned(user_domain.to_string()),
source_address : Cow::Owned(source.to_string()),
})
}));
},
20716 => {
// User accounts modified
},
23452 => {
//Super admin session created using token
},
24511 => {
//Admin token is created
},
22671 => {
//Logout
},
_ => {}
}
return Ok(log)
},
"PTR" => {
// Policy Trace
return Ok(log)
},
"NWC" => {
// Network Connect
return Ok(log)
},
"ERR" => {
// System Error
return Ok(log)
},
"WEB" => {
// WebRequest
return Ok(log)
},
"ARC" => {
// Archive
return Ok(log)
},
_ => return Ok(log)
}
}
#[cfg(test)]
mod filterlog_tests {
use super::{parse_general_log, extract_fields};
use usiem::events::{SiemLog};
use usiem::events::field::{SiemIp, SiemField};
use usiem::events::auth::{LoginOutcome};
#[test]
fn test_extract_fields() {
let log = "id=firewall time=\"2021-04-08 11:57:48\" pri=6 fw=10.0.0.9 vpn=ive ivs=Default Network user=usettest1 realm=\"\" roles=\"\" proto=auth src=82.213.178.130 dst= dstname= type=vpn op= arg=\"\" result= sent= rcvd= agent=\"\" duration= msg=\"AUT22673: Logout from 82.213.178.130 (session:00000000)\"";
let map = extract_fields(log);
assert_eq!(map.get("id"), Some(&"firewall"));
assert_eq!(map.get("time"), Some(&"2021-04-08 11:57:48"));
assert_eq!(map.get("fw"), Some(&"10.0.0.9"));
assert_eq!(map.get("user"), Some(&"usettest1"));
assert_eq!(map.get("ivs"), Some(&"Default Network"));
assert_eq!(map.get("msg"), Some(&"AUT22673: Logout from 82.213.178.130 (session:00000000)"));
}
#[test]
fn test_login_success() {
let log = "2021-04-08T12:14:18-07:00 10.0.0.111 PulseSecure: id=firewall time=\"2021-04-08 12:14:18\" pri=6 fw=10.0.0.9 vpn=ive ivs=Default Network user=usertest2 realm=\"Users\" roles=\"Users\" proto=auth src=82.213.178.130 dst= dstname= type=vpn op= arg=\"\" result= sent= rcvd= agent=\"Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0\" duration= msg=\"AUT31504: Login succeeded for usertest2/Users (session:00000000) from 82.213.178.130 with Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0.\"";
let log = SiemLog::new(log.to_string(), 0, SiemIp::V4(0));
let res = parse_general_log(log);
match res {
Ok(log) => {
assert_eq!(log.field("user.name"), Some(&SiemField::User(String::from("usertest2"))));
assert_eq!(log.field("source.ip"), Some(&SiemField::IP(SiemIp::from_ip_str("82.213.178.130").unwrap())));
assert_eq!(log.field("user.domain"), Some(&SiemField::Domain(String::from("Users"))));
assert_eq!(log.field("event.code"), Some(&SiemField::U32(31504)));
assert_eq!(log.field("observer.ip"), Some(&SiemField::IP(SiemIp::from_ip_str("10.0.0.9").unwrap())));
assert_eq!(log.field("user_agent.original"), Some(&SiemField::from_str("Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:87.0) Gecko/20100101 Firefox/87.0")));
assert_eq!(log.field("event.outcome"), Some(&SiemField::from_str(LoginOutcome::SUCCESS.to_string())));
},
Err(_) => panic!("Must be parsed")
}
}
#[test]
fn test_login_failed() {
let log = "2021-04-08T11:58:04-07:00 10.0.0.111 PulseSecure: id=firewall time=\"2021-04-08 11:58:04\" pri=6 fw=10.0.0.9 vpn=ive ivs=Default Network user=userasdad realm=\"Users\" roles=\"\" proto=auth src=82.213.178.130 dst= dstname= type=vpn op= arg=\"\" result= sent= rcvd= agent=\"\" duration= msg=\"AUT23457: Login failed using auth server System Local (Local Authentication). Reason: Failed\"";
let log = SiemLog::new(log.to_string(), 0, SiemIp::V4(0));
let res = parse_general_log(log);
match res {
Ok(log) => {
assert_eq!(log.field("user.name"), Some(&SiemField::User(String::from("userasdad"))));
assert_eq!(log.field("source.ip"), Some(&SiemField::IP(SiemIp::from_ip_str("82.213.178.130").unwrap())));
assert_eq!(log.field("user.domain"), Some(&SiemField::Domain(String::from("Users"))));
assert_eq!(log.field("event.code"), Some(&SiemField::U32(23457)));
assert_eq!(log.field("observer.ip"), Some(&SiemField::IP(SiemIp::from_ip_str("10.0.0.9").unwrap())));
assert_eq!(log.field("event.outcome"), Some(&SiemField::from_str(LoginOutcome::FAIL.to_string())));
},
Err(_) => panic!("Must be parsed")
}
}
}
|
use std::{
io::ErrorKind,
net::{TcpListener, UdpSocket},
};
use crate::{
common::{ListenerId, NetProtocol},
socket::{Socket, SocketTcp, SocketUdp},
IpAddress, Port, SocketAddress, SocketId,
};
/// 1 MB buffer for UDP "connections"
const DEFAULT_UDP_BUFFER: usize = 1_000_000;
pub trait Listener: Send + Sync {
/// Retrieve listener ID
fn get_id(&self) -> ListenerId;
/// Set listener ID
fn set_id(&mut self, id: ListenerId);
/// Returns listener type
fn get_type(&self) -> NetProtocol;
/// Creates a new listener.
/// Listens on localhost:<port> for incoming connections.
/// Optionally specify the listener's ID
fn listen(port: Port, listener_id: Option<ListenerId>) -> Result<Self, ()>
where
Self: Sized;
/// Check and accept an incoming connection
fn check_incoming(&mut self) -> Result<Option<Box<dyn Socket>>, ()>;
/// Check for connection errors
fn check_err(&mut self) -> Result<(), ()>;
/// Close the listener (deny new connections)
fn close(&mut self) -> Result<(), ()>;
}
/// TCP listener
pub struct ListenerTcp {
id: ListenerId,
listener: TcpListener,
connections: Vec<SocketId>,
open: bool,
}
impl Listener for ListenerTcp {
fn get_id(&self) -> SocketId {
self.id
}
fn set_id(&mut self, id: SocketId) {
self.id = id;
}
fn get_type(&self) -> NetProtocol {
NetProtocol::Tcp
}
fn listen(port: u16, listener_id: Option<ListenerId>) -> Result<Self, ()>
where
Self: Sized,
{
let addr = SocketAddress::new(IpAddress::from([127, 0, 0, 1]), port);
let listener = TcpListener::bind(addr).map_err(|_| ())?;
listener.set_nonblocking(true).map_err(|_| ())?;
Ok(ListenerTcp {
id: listener_id.unwrap_or(ListenerId::new()),
connections: vec![],
open: true,
listener,
})
}
fn check_incoming(&mut self) -> Result<Option<Box<dyn Socket>>, ()> {
match self.listener.accept() {
Ok(connection) => {
let socket = Box::new(SocketTcp::from_existing(connection.0));
self.connections.push(socket.get_id());
Ok(Some(socket))
}
Err(err) => {
if err.kind() == ErrorKind::WouldBlock {
Ok(None)
} else {
Err(())
}
}
}
}
fn check_err(&mut self) -> Result<(), ()> {
if let Ok(e) = self.listener.take_error() {
if let Some(_) = e {
Err(())
} else {
Ok(())
}
} else {
Err(())
}
}
fn close(&mut self) -> Result<(), ()> {
self.open = false;
Ok(())
}
}
/// UDP listener type
pub struct ListenerUdp {
id: ListenerId,
listener: UdpSocket,
connections: Vec<SocketId>,
buf: Vec<u8>,
open: bool,
}
impl Listener for ListenerUdp {
fn get_id(&self) -> SocketId {
self.id
}
fn set_id(&mut self, id: SocketId) {
self.id = id;
}
fn get_type(&self) -> NetProtocol {
NetProtocol::Udp
}
fn listen(port: u16, listener_id: Option<ListenerId>) -> Result<Self, ()>
where
Self: Sized,
{
let addr = SocketAddress::new(IpAddress::from([127, 0, 0, 1]), port);
let listener = UdpSocket::bind(addr).map_err(|_| ())?;
listener.set_nonblocking(true).map_err(|_| ())?;
Ok(ListenerUdp {
id: listener_id.unwrap_or(ListenerId::new()),
connections: vec![],
buf: vec![0; DEFAULT_UDP_BUFFER],
open: true,
listener,
})
}
/// For UDP, this function will create a new socket on a new port.
/// If you wish to use the same port (meaning no new socket) please call the `read_incoming` method instead
fn check_incoming(&mut self) -> Result<Option<Box<dyn Socket>>, ()> {
// As UDP is connectionless, we have to receive some data in order to establish a "connection"
match self.listener.peek_from(&mut self.buf) {
Ok(connection) => {
let socket = Box::new(SocketUdp::connect(
connection.1,
None,
None,
Some(DEFAULT_UDP_BUFFER),
)?);
self.connections.push(socket.get_id());
Ok(Some(socket))
}
Err(err) => {
if err.kind() == ErrorKind::WouldBlock {
Ok(None)
} else {
Err(())
}
}
}
}
fn check_err(&mut self) -> Result<(), ()> {
if let Ok(e) = self.listener.take_error() {
if let Some(_) = e {
Err(())
} else {
Ok(())
}
} else {
Err(())
}
}
fn close(&mut self) -> Result<(), ()> {
self.open = false;
Ok(())
}
}
impl ListenerUdp {
/// Read incoming data without opening a new connection.
/// Returns the data read and the remote address
pub fn read_incoming(&mut self) -> Result<Option<(&Vec<u8>, SocketAddress)>, ()> {
match self.listener.recv_from(&mut self.buf) {
Ok(connection) => Ok(Some((&self.buf, connection.1))),
Err(err) => {
if err.kind() == ErrorKind::WouldBlock {
Ok(None)
} else {
Err(())
}
}
}
}
}
|
use anyhow::{anyhow, Result};
use async_channel::{Receiver, Sender};
use bitvec::{order::Msb0, prelude::BitVec};
use std::{collections::HashMap, net::SocketAddr, sync::Arc};
use tokio::{
io::{AsyncReadExt, AsyncWriteExt},
net::TcpStream,
task::JoinHandle,
};
use crate::torrent::TorrentContext;
#[derive(Debug)]
pub enum Message {
Choke,
Unchoke,
Interested,
NotInterested,
Have(u32),
Bitfield(BitVec<Msb0, u8>),
Request(u32, u32, u32),
Piece(u32, u32, Vec<u8>),
Cancel(u32, u32, u32),
KeepAlive,
Invalid,
}
impl std::fmt::Display for Message {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Message::Choke => {
write!(f, "Choke")
}
Message::Unchoke => {
write!(f, "Unchoke")
}
Message::Interested => {
write!(f, "Interested")
}
Message::NotInterested => {
write!(f, "NotInterested")
}
Message::Have(index) => {
write!(f, "Have({})", index)
}
Message::Bitfield(_) => {
write!(f, "Bitfield")
}
Message::Request(index, begin, length) => {
write!(f, "Request({}, {}, {})", index, begin, length)
}
Message::Piece(index, begin, piece) => {
write!(f, "Piece({}, {}, [{}])", index, begin, piece.len())
}
Message::Cancel(index, begin, length) => {
write!(f, "Cancel({}, {}, {})", index, begin, length)
}
Message::KeepAlive => {
write!(f, "KeepAlive")
}
Message::Invalid => {
write!(f, "Invalid")
}
}
}
}
impl From<Vec<u8>> for Message {
fn from(bytes: Vec<u8>) -> Self {
if bytes.len() == 0 {
return Message::KeepAlive;
}
match bytes[0] {
0 => Message::Choke,
1 => Message::Unchoke,
2 => Message::Interested,
3 => Message::NotInterested,
4 => {
let mut payload: [u8; 4] = [0; 4];
payload.copy_from_slice(&bytes[1..]);
let index = u32::from_be_bytes(payload);
Message::Have(index)
}
5 => {
let payload = bytes[1..].to_vec();
Message::Bitfield(BitVec::from_vec(payload))
}
6 => {
let mut payload: [u8; 4] = [0; 4];
payload.copy_from_slice(&bytes[1..5]);
let index = u32::from_be_bytes(payload);
payload.copy_from_slice(&bytes[5..9]);
let begin = u32::from_be_bytes(payload);
payload.copy_from_slice(&bytes[9..13]);
let length = u32::from_be_bytes(payload);
Message::Request(index, begin, length)
}
7 => {
let mut payload: [u8; 4] = [0; 4];
payload.copy_from_slice(&bytes[1..5]);
let index = u32::from_be_bytes(payload);
payload.copy_from_slice(&bytes[5..9]);
let begin = u32::from_be_bytes(payload);
let piece = bytes[9..].to_vec();
Message::Piece(index, begin, piece)
}
8 => {
let mut payload: [u8; 4] = [0; 4];
payload.copy_from_slice(&bytes[1..5]);
let index = u32::from_be_bytes(payload);
payload.copy_from_slice(&bytes[5..9]);
let begin = u32::from_be_bytes(payload);
payload.copy_from_slice(&bytes[9..13]);
let length = u32::from_be_bytes(payload);
Message::Cancel(index, begin, length)
}
_ => Message::Invalid,
}
}
}
impl Into<Vec<u8>> for Message {
fn into(self) -> Vec<u8> {
let mut message = vec![];
match self {
Message::Choke => {
message.extend(&(1 as u32).to_be_bytes());
message.push(0);
}
Message::Unchoke => {
message.extend(&(1 as u32).to_be_bytes());
message.push(1);
}
Message::Interested => {
message.extend(&(1 as u32).to_be_bytes());
message.push(2);
}
Message::NotInterested => {
message.extend(&(1 as u32).to_be_bytes());
message.push(3);
}
Message::Have(index) => {
message.extend(&(5 as u32).to_be_bytes());
message.push(4);
message.extend(&index.to_be_bytes());
}
Message::Bitfield(index) => {
message.extend(&(1 + index.len()).to_be_bytes());
message.push(5);
message.extend(index.as_raw_slice());
}
Message::Request(index, begin, length) => {
message.extend(&(13 as u32).to_be_bytes());
message.push(6);
message.extend(&index.to_be_bytes());
message.extend(&begin.to_be_bytes());
message.extend(&length.to_be_bytes());
}
Message::Piece(index, begin, piece) => {
message.extend(&(1 + piece.len()).to_be_bytes());
message.push(7);
message.extend(&index.to_be_bytes());
message.extend(&begin.to_be_bytes());
message.extend(&piece);
}
Message::Cancel(index, begin, length) => {
message.extend(&(13 as u32).to_be_bytes());
message.push(8);
message.append(&mut index.to_be_bytes().to_vec());
message.append(&mut begin.to_be_bytes().to_vec());
message.append(&mut length.to_be_bytes().to_vec());
}
Message::KeepAlive => {}
Message::Invalid => {}
}
return message;
}
}
pub enum AlertMessage {
Received(SocketAddr, Message),
Connecting(SocketAddr),
Connected(SocketAddr),
Quit(SocketAddr),
}
pub enum PeerCommand {
Send(Message),
Shutdown,
}
pub struct Peer {
pub peer_id: [u8; 20],
pub address: SocketAddr,
ctx: Arc<TorrentContext>,
conn: Option<TcpStream>,
peer_tx: Sender<AlertMessage>,
cmd_rx: Receiver<PeerCommand>,
bitfield: BitVec<Msb0, u8>,
choke: bool,
ready: bool,
}
impl Peer {
pub fn new(
ctx: Arc<TorrentContext>,
address: SocketAddr,
peer_tx: Sender<AlertMessage>,
cmd_rx: Receiver<PeerCommand>,
) -> Self {
Self {
peer_id: [0; 20],
address,
conn: None,
peer_tx,
cmd_rx,
ctx,
bitfield: BitVec::new(),
choke: false,
ready: true,
}
}
pub async fn initiate_outgoing_connection(&mut self) -> Result<()> {
self.conn = match TcpStream::connect(self.address).await {
Ok(conn) => Some(conn),
Err(e) => {
return Err(anyhow!("{} > connection: {}", self.address, e));
}
};
let info_hash = self.ctx.metainfo.info_hash;
// if there is error while handshaking, disconnect and try again
if let Err(e) = self.handshake(&info_hash).await {
return Err(anyhow!("{} > handshake: {}", self.address, e));
}
// if there is error while send message Interested, disconnect and try again
if let Err(e) = self.send_message(Message::Interested).await {
return Err(anyhow!("{} > interested: {}", self.address, e));
};
Ok(())
}
pub async fn run(&mut self) -> Result<()> {
self.peer_tx
.send(AlertMessage::Connecting(self.address))
.await
.unwrap();
// if there is no connection, try connecting
if let Err(e) = self.initiate_outgoing_connection().await {
self.peer_tx
.send(AlertMessage::Quit(self.address))
.await
.unwrap();
return Err(e);
}
self.peer_tx
.send(AlertMessage::Connected(self.address))
.await
.unwrap();
loop {
if let Ok(cmd) = self.cmd_rx.try_recv() {
match cmd {
PeerCommand::Send(_) => {}
PeerCommand::Shutdown => {
return Ok(());
}
}
}
let msg = match self.read_message().await {
Ok(msg) => msg,
Err(e) => {
// quit from peer if read_message return error
return Err(e);
}
};
if let Some(msg) = msg {
info!("{} > Receive: {}", self.address, msg);
match &msg {
Message::Choke => {
self.choke = true;
}
Message::Unchoke => {
self.choke = false;
self.ready = true;
}
Message::Bitfield(index) => {
self.bitfield.clone_from(index);
}
Message::Have(index) => {
self.bitfield.set(*index as usize, true);
}
_ => {
self.peer_tx
.send(AlertMessage::Received(self.address, msg))
.await
.unwrap();
self.ready = true;
}
}
}
// pop outgoing request from front
// send request message if there is request queue
if !self.choke && self.ready {
let block = {
let mut outgoing_requests = self.ctx.outgoing_requests.write().await;
let req = outgoing_requests.front();
if let Some(req) = req {
if let Some(val) = self.bitfield.get(req.index as usize).as_deref() {
if *val {
outgoing_requests.pop_front()
} else {
None
}
} else {
None
}
} else {
None
}
};
if let Some(req) = block {
if !self.ctx.piece_counter.read().await.downloaded[req.index as usize]
[req.begin as usize / 16384]
{
// send request message
info!("{:?} > Send {:?}", self.address, req);
if let Err(e) = self
.send_message(Message::Request(req.index, req.begin, req.length))
.await
{
return Err(anyhow!(e));
}
self.ready = false;
}
}
}
tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
}
}
pub async fn handshake(&mut self, info_hash: &[u8]) -> Result<(), anyhow::Error> {
if let Some(conn) = self.conn.as_mut() {
let mut buf = vec![];
buf.push(19);
buf.extend(b"BitTorrent protocol");
buf.extend(&[0; 8]);
buf.extend(info_hash);
buf.extend(&[0; 20]);
match conn.write_all(&buf).await {
Ok(_) => {}
Err(e) => {
error!("failed to send handsake {}", e);
self.conn = None;
return Err(anyhow::anyhow!(e));
}
}
let mut reply = [0; 68];
match conn.read_exact(&mut reply).await {
Ok(_) => {}
Err(e) => {
error!("failed to read handshake message {}", e);
return Err(anyhow::anyhow!(e));
}
}
if reply[0] != 19 {
self.conn = None;
return Err(anyhow::anyhow!(
"{} > wrong first byte: {:?}",
self.address,
reply
));
}
if String::from_utf8(reply[1..20].to_vec()).unwrap()
!= "BitTorrent protocol".to_string()
{
self.conn = None;
return Err(anyhow::anyhow!("wrong protocol"));
}
Ok(())
} else {
Err(anyhow!("{} > Connection not exist", self.address))
}
}
pub async fn read_message(&mut self) -> Result<Option<Message>> {
if let Some(conn) = self.conn.as_mut() {
let mut len_prefix = [0; 4];
match tokio::time::timeout(std::time::Duration::from_secs(1), conn.read_exact(&mut len_prefix)).await {
Ok(res) => {
match res {
Ok(_) => {}
Err(e) => {
error!("failed to read length message {}", e);
return Err(anyhow::anyhow!(e));
}
}
}
Err(_) => {
return Ok(None);
}
}
let length = u32::from_be_bytes(len_prefix);
let mut message = vec![0; length as usize];
match tokio::time::timeout(std::time::Duration::from_secs(1), conn.read_exact(&mut message)).await {
Ok(res) => {
match res {
Ok(_) => {}
Err(e) => {
error!("failed to read message {}", e);
return Err(anyhow::anyhow!(e));
}
}
}
Err(_) => {
return Ok(None);
}
}
Ok(Some(message.into()))
} else {
Err(anyhow!("{} > Connection not exist", self.address))
}
}
pub async fn send_message(&mut self, message: Message) -> Result<()> {
if let Some(conn) = self.conn.as_mut() {
let payload: Vec<u8> = message.into();
match conn.write_all(&payload).await {
Ok(_) => {}
Err(e) => {
error!("failed to send message {}", e);
return Err(anyhow::anyhow!(e));
}
}
Ok(())
} else {
Err(anyhow!("Connection not exist"))
}
}
}
pub struct Session {
handle: JoinHandle<()>,
}
impl Session {
pub fn new(mut peer: Peer) -> Self {
let handle = tokio::spawn(async move {
let _ = peer.run().await;
});
Self { handle }
}
}
pub struct PeerManager {
pub ctx: Arc<TorrentContext>,
pub peer_tx: Sender<AlertMessage>,
pub cmd_rx: Receiver<PeerCommand>,
pub available_peers: Vec<SocketAddr>,
pub peers: HashMap<SocketAddr, Session>,
}
impl PeerManager {
pub fn new(
peer_tx: Sender<AlertMessage>,
ctx: Arc<TorrentContext>,
) -> (Self, Sender<PeerCommand>) {
let (cmd_tx, cmd_rx) = async_channel::unbounded();
(
Self {
ctx,
peer_tx,
cmd_rx,
available_peers: Vec::new(),
peers: HashMap::new(),
},
cmd_tx,
)
}
pub fn set_available_peers(&mut self, address: Vec<SocketAddr>) {
self.available_peers = address;
}
pub fn connect_peers(&mut self) {
let max_connection = if self.available_peers.len() > 5 {
5
} else {
self.available_peers.len()
};
if self.peers.len() > max_connection {
return;
}
for addr in self.available_peers.drain(..max_connection) {
let peer = Peer::new(
self.ctx.clone(),
addr,
self.peer_tx.clone(),
self.cmd_rx.clone(),
);
self.peers.insert(addr, Session::new(peer));
}
}
pub fn shutdown_peer(&mut self, peer: SocketAddr) {
self.peers.remove(&peer);
}
}
|
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn it_works() {
assert_eq!(2 + 2, 4);
}
#[test]
fn system() {
let s = System::new();
}
}
mod numa;
mod node;
mod set;
mod mask;
extern crate errno;
use numa::*;
pub use set::{CpuSet, NodeSet};
pub use mask::{CpuMask, NodeMask};
pub use node::Node;
#[derive(Clone, Debug)]
enum ErrorKind {
Unexpected,
Errno,
}
#[derive(Clone, Debug)]
pub struct Error {
kind: ErrorKind,
message: String,
}
impl Error {
fn new(kind: ErrorKind, message: &str) -> Error {
Error {
kind: kind,
message: message.to_owned(),
}
}
}
impl From<errno::Errno> for Error {
fn from(e: errno::Errno) -> Error {
Error::new(ErrorKind::Errno, &format!("{}", e))
}
}
type Result<T> = std::result::Result<T, Error>;
pub struct System {
all_cpus: CpuSet,
all_nodes: NodeSet,
}
impl System {
pub fn new() -> System {
let all_cpus = CpuSet::from(CpuMask::from( unsafe {numa_all_cpus_ptr} ));
let all_nodes = NodeSet::from(NodeMask::from( unsafe {numa_all_nodes_ptr} ));
System {
all_cpus: all_cpus,
all_nodes: all_nodes,
}
}
pub fn is_available(&self) -> bool {
match unsafe { numa_available() } {
-1 => return false,
0 => return true,
_ => panic!("Unexpected"),
}
}
pub fn all_cpus_ref(&self) -> &CpuSet {
&self.all_cpus
}
pub fn all_nodes_ref(&self) -> &NodeSet {
&self.all_nodes
}
pub fn run_on(&mut self, nodes: NodeSet) -> Result<()> {
/*
numa_run_on_node() runs the current task and its children on a
specific node. They will not migrate to CPUs of other nodes until the
node affinity is reset with a new call to numa_run_on_node_mask().
Passing -1 permits the kernel to schedule on all nodes again. On
success, 0 is returned; on error -1 is returned, and errno is set to
indicate the error.
*/
let mut mask = NodeMask::from(nodes);
let res = unsafe { numa_run_on_node_mask(mask.raw_mut()) };
match res {
0 => Ok(()),
-1 => Err(Error::from(errno::errno())),
_ => Err(Error::new(ErrorKind::Unexpected, "numa_run_on_node_mask returned unexpected"))
}
}
/// get CPUs that the system is currently allowed to use
pub fn run_cpus(&self) -> CpuSet {
let mask = unsafe { numa_get_run_node_mask() };
CpuSet::from(CpuMask::from(mask))
}
/// get numa nodes that the sysm is currently allowed to use
pub fn run_nodes(&self) -> NodeSet {
let mask = unsafe { numa_get_membind() };
NodeSet::from(NodeMask::from(mask))
}
}
/*
numa_allocate_nodemask() returns a bitmask of a size equal to the
kernel's node mask (kernel type nodemask_t). In other words, large
enough to represent MAX_NUMNODES nodes. This number of nodes can be
gotten by calling numa_num_possible_nodes(). The bitmask is zero-
filled.
*/
/*
numa_allocate_cpumask () returns a bitmask of a size equal to the
kernel's cpu mask (kernel type cpumask_t). In other words, large
enough to represent NR_CPUS cpus. This number of cpus can be gotten
by calling numa_num_possible_cpus(). The bitmask is zero-filled.
*/
|
extern crate num;
use num::clamp;
use std::collections::{HashMap, VecDeque};
use std::io::{self, Write};
use std::sync::mpsc::channel;
use std::thread;
use std::time::Instant;
use termion::cursor::Goto;
use termion::event::Key;
use termion::raw::IntoRawMode;
use tui::backend::TermionBackend;
use tui::layout::{Constraint, Direction, Layout, Rect};
use tui::style::{Color, Style};
use tui::widgets::canvas::Canvas;
use tui::widgets::{Block, Borders, Gauge, Paragraph, Text, Widget};
use tui::Terminal;
use unicode_width::UnicodeWidthStr;
#[macro_use]
extern crate strum_macros;
mod action;
mod commands;
mod entities;
mod event;
mod event_queue;
mod game_event;
mod global_handlers;
mod room;
mod rooms;
mod sound;
mod state;
mod timer;
mod utils;
use crate::action::{Action, ActionHandled};
use crate::commands::try_handle_command;
use crate::entities::enemy::initialize_enemies;
use crate::event::{Event, Events};
use crate::event_queue::EventQueue;
use crate::game_event::{GameEvent, GameEventType};
use crate::global_handlers::handle_action;
use crate::room::{Room, RoomType};
use crate::rooms::{CorridorRoom, CryobayRoom, Cryocontrol, SlushLobbyRoom};
use crate::sound::{AudioEvent, Effect};
use crate::state::State;
use crate::utils::{duration_to_msec_u64, BoxShape};
#[derive(Debug)]
pub struct App {
// The size of the console window.
pub size: Rect,
// The system event, like rendering stuff in the console.
pub log: VecDeque<GameEvent>,
// The input in the command box.
pub input: String,
// The global game state.
pub state: State,
// The list of rooms.
pub rooms: HashMap<RoomType, Box<Room>>,
// The action event queue.
pub event_queue: EventQueue,
}
impl App {
fn new(state: State) -> Self {
App {
size: Default::default(),
log: Default::default(),
input: "".into(),
state: state,
rooms: Default::default(),
event_queue: Default::default(),
}
}
pub fn try_handle_room_action(&mut self, action: &Action) -> Option<ActionHandled> {
let current_room = self.rooms.get_mut(&self.state.current_room)?;
match current_room.handle_action(&mut self.state, &mut self.event_queue, action) {
ActionHandled::Handled => Some(ActionHandled::Handled),
_ => None,
}
}
pub fn try_handle_command(&mut self, tokens: String) {
let actions = try_handle_command(tokens, &self.state);
self.event_queue.schedule_actions(actions);
}
}
fn main() -> Result<(), io::Error> {
let (snd_send, snd_recv) = channel();
snd_send.send(AudioEvent::Effect(Effect::Typing));
thread::spawn(move || {
sound::start(snd_recv);
});
let stdout = io::stdout().into_raw_mode()?;
let backend = TermionBackend::new(stdout);
let mut terminal = Terminal::new(backend)?;
let events = Events::new();
let mut state = State::new();
let mut app = App::new(state);
app.rooms
.insert(RoomType::Cryobay, Box::new(CryobayRoom::new()));
app.rooms
.insert(RoomType::Cryocontrol, Box::new(Cryocontrol::new()));
app.rooms
.insert(RoomType::SlushLobby, Box::new(SlushLobbyRoom::new()));
app.rooms
.insert(RoomType::Corridor, Box::new(CorridorRoom::new()));
app.event_queue
.schedule_action(Action::Enter(RoomType::Cryobay));
let mut now = Instant::now();
initialize_enemies(&mut app.state);
loop {
let size = terminal.size()?;
if size != app.size {
terminal.resize(size)?;
app.size = size;
}
// Draw.
terminal.draw(|mut f| {
let h_chunks = Layout::default()
// Split along the horizontal axis.
.direction(Direction::Horizontal)
.margin(1)
.constraints([Constraint::Percentage(70), Constraint::Percentage(30)].as_ref())
.split(size);
let v_chunks_left = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Length(3), Constraint::Min(1)].as_ref())
.split(h_chunks[0]);
let input_status_line = Layout::default()
.direction(Direction::Horizontal)
.constraints([Constraint::Percentage(50), Constraint::Percentage(50)].as_ref())
.split(v_chunks_left[0]);
let v_chunks_right = Layout::default()
.direction(Direction::Vertical)
.constraints([Constraint::Percentage(30), Constraint::Percentage(70)].as_ref())
.split(h_chunks[1]);
let v_chunks_right_up = Layout::default()
.direction(Direction::Vertical)
.constraints(
[
Constraint::Max(3),
Constraint::Max(3),
Constraint::Max(3),
Constraint::Max(3),
Constraint::Max(3),
Constraint::Max(0),
]
.as_ref(),
)
.split(v_chunks_right[0]);
let styled_log = {
let mut log = vec![];
for game_event in &app.log {
let style = match game_event.game_event_type {
GameEventType::Combat => Style::default().fg(Color::Red),
GameEventType::Normal => Style::default(),
GameEventType::Success => Style::default().fg(Color::Green),
GameEventType::Failure => Style::default().fg(Color::Red),
GameEventType::Debug => Style::default().fg(Color::Blue),
};
log.push(Text::styled(game_event.content.clone(), style));
}
log
};
if cfg!(debug_assertions) {
Paragraph::new([Text::raw("DEV MODE: no movement restrictions + other cheats enabled")].iter())
.style(Style::default().fg(Color::Red))
.render(&mut f, *v_chunks_right_up.last().unwrap())
}
Paragraph::new(styled_log.iter())
.block(Block::default().borders(Borders::ALL).title("Events"))
.wrap(true)
.render(&mut f, v_chunks_left[1]);
Paragraph::new([Text::raw(&app.input)].iter())
.style(Style::default().fg(Color::Yellow))
.block(Block::default().borders(Borders::ALL).title("Input"))
.render(&mut f, input_status_line[0]);
Paragraph::new(app.state.player.format_player_info().iter())
.style(Style::default())
.block(Block::default().borders(Borders::ALL).title("Character"))
.render(&mut f, input_status_line[1]);
Canvas::default()
.block(Block::default().borders(Borders::ALL).title("Map"))
.paint(|ctx| {
ctx.draw(&BoxShape {
rect: Rect {
x: 20,
y: 70,
width: 20,
height: 20,
},
color: match app.state.current_room {
RoomType::Cryobay => Color::Red,
_ => Color::White,
},
});
ctx.draw(&BoxShape {
rect: Rect {
x: 30,
y: 60,
width: 5,
height: 10,
},
color: Color::White,
});
ctx.draw(&BoxShape {
rect: Rect {
x: 20,
y: 40,
width: 20,
height: 20,
},
color: match app.state.current_room {
RoomType::SlushLobby => Color::Red,
_ => Color::White,
},
});
ctx.draw(&BoxShape {
rect: Rect {
x: 40,
y: 45,
width: 10,
height: 5,
},
color: Color::White,
});
ctx.draw(&BoxShape {
rect: Rect {
x: 50,
y: 40,
width: 20,
height: 20,
},
color: match app.state.current_room {
RoomType::Cryocontrol => Color::Red,
_ => Color::White,
},
});
ctx.draw(&BoxShape {
rect: Rect {
x: 24,
y: 17,
width: 2,
height: 22,
},
color: Color::White,
});
ctx.draw(&BoxShape {
rect: Rect {
x: 20,
y: 5,
width: 35,
height: 12,
},
color: match app.state.current_room {
RoomType::Corridor => Color::Blue,
_ => Color::White,
},
});
})
.x_bounds([0.0, 100.0])
.y_bounds([0.0, 100.0])
.render(&mut f, v_chunks_right[1]);
let visible_timers = app
.event_queue
.timers
.iter()
.filter(|timer| timer.is_visual);
for (index, timer) in visible_timers.enumerate() {
// Only render the first 5 timers.
if index > 4 {
break;
}
let int_progress = clamp(
(timer.duration as i64 - timer.elapsed as i64) * 100i64 / timer.duration as i64,
0,
100,
) as u16;
Gauge::default()
.block(Block::default().title(&timer.label).borders(Borders::ALL))
.style(Style::default().fg(Color::Magenta).bg(Color::Green))
.percent(int_progress)
.label(&format!("{}", int_progress))
.render(&mut f, v_chunks_right_up[index]);
}
})?;
write!(
terminal.backend_mut(),
"{}",
Goto(3 + app.input.width() as u16, 3)
)?;
terminal.backend_mut().flush()?;
// Handle system events.
match events.next().unwrap() {
Event::Input(input) => match input {
Key::Esc => {
break;
}
Key::Char('\n') => {
if !app.input.is_empty() {
let mut content: String = app.input.drain(..).collect();
let command = Action::Command(content.clone());
content = format!("\n>>> {}", content);
content.push_str("\n\n");
app.log.push_front(GameEvent {
content: content,
game_event_type: GameEventType::Normal,
});
app.event_queue.schedule_action(command);
}
}
Key::Char(c) => {
snd_send.send(AudioEvent::Effect(Effect::Typing));
if app.input.is_empty() {
app.event_queue.schedule_action(Action::PlayerFinishedReading)
}
app.input.push(c);
}
Key::Backspace => {
snd_send.send(AudioEvent::Effect(Effect::Backspace));
app.input.pop();
}
_ => {}
},
event::Event::Tick => {
let elapsed = duration_to_msec_u64(&now.elapsed());
app.event_queue.schedule_action(Action::Tick(elapsed));
}
}
while let Some(next_action) = app.event_queue.get_next_action() {
match next_action {
Action::Audio(action) => {
snd_send.send(action).unwrap();
continue;
},
_ => (),
}
handle_action(&mut app, next_action);
}
now = Instant::now();
}
Ok(())
}
|
// RGB standard library
// Written in 2020 by
// Dr. Maxim Orlovsky <orlovsky@pandoracore.com>
//
// To the extent possible under law, the author(s) have dedicated all
// copyright and related and neighboring rights to this software to
// the public domain worldwide. This software is distributed without
// any warranty.
//
// You should have received a copy of the MIT License
// along with this software.
// If not, see <https://opensource.org/licenses/MIT>.
use serde_json;
use std::collections::HashMap;
use std::path::PathBuf;
use std::{fs, io, io::Read, io::Write};
use lnpbp::bitcoin;
use lnpbp::data_format::DataFormat;
use lnpbp::rgb::prelude::*;
use super::Cache;
use crate::error::{BootstrapError, ServiceErrorDomain};
use crate::fungible::cache::CacheError;
use crate::fungible::Asset;
use crate::util::file::*;
#[derive(Debug, Display, Error, From)]
#[display_from(Debug)]
pub enum FileCacheError {
#[derive_from]
Io(io::Error),
#[derive_from(bitcoin::hashes::Error)]
HashName,
#[derive_from(bitcoin::hashes::hex::Error)]
BrokenHexFilenames,
#[derive_from]
Encoding(lnpbp::strict_encoding::Error),
#[derive_from]
SerdeJson(serde_json::Error),
#[derive_from]
SerdeYaml(serde_yaml::Error),
#[derive_from(toml::de::Error, toml::ser::Error)]
SerdeToml,
#[derive_from(std::option::NoneError)]
NotFound,
}
impl From<FileCacheError> for ServiceErrorDomain {
fn from(_: FileCacheError) -> Self {
ServiceErrorDomain::Cache
}
}
impl From<FileCacheError> for BootstrapError {
fn from(_: FileCacheError) -> Self {
BootstrapError::CacheError
}
}
#[derive(Clone, PartialEq, Eq, Hash, Debug, Display)]
#[display_from(Debug)]
pub struct FileCacheConfig {
pub data_dir: PathBuf,
pub data_format: DataFormat,
}
impl FileCacheConfig {
#[inline]
pub fn assets_dir(&self) -> PathBuf {
self.data_dir.clone()
}
#[inline]
pub fn assets_filename(&self) -> PathBuf {
self.assets_dir()
.join("assets")
.with_extension(self.data_format.extension())
}
}
/// Keeps all source/binary RGB contract data, stash etc
#[derive(Debug, Display)]
#[display_from(Debug)]
pub struct FileCache {
config: FileCacheConfig,
assets: HashMap<ContractId, Asset>,
}
impl FileCache {
pub fn new(config: FileCacheConfig) -> Result<Self, FileCacheError> {
debug!("Instantiating RGB fungible assets storage (disk storage) ...");
let data_dir = config.data_dir.clone();
if !data_dir.exists() {
debug!(
"RGB fungible assets data directory '{:?}' is not found; creating one",
data_dir
);
fs::create_dir_all(data_dir)?;
}
let assets_dir = config.assets_dir();
if !assets_dir.exists() {
debug!(
"RGB fungible assets information directory '{:?}' is not found; creating one",
assets_dir
);
fs::create_dir_all(assets_dir)?;
}
let mut me = Self {
config,
assets: map![],
};
let filename = me.config.assets_filename();
if filename.exists() {
me.load()?;
} else {
debug!("Initializing assets file {:?} ...", filename.to_str());
me.save()?;
}
Ok(me)
}
fn load(&mut self) -> Result<(), FileCacheError> {
debug!("Reading assets information ...");
let filename = self.config.assets_filename();
let mut f = file(filename, FileMode::Read)?;
self.assets = match self.config.data_format {
DataFormat::Yaml => serde_yaml::from_reader(&f)?,
DataFormat::Json => serde_json::from_reader(&f)?,
DataFormat::Toml => {
let mut data = String::new();
f.read_to_string(&mut data)?;
toml::from_str(&data)?
}
DataFormat::StrictEncode => unimplemented!(),
};
Ok(())
}
pub fn save(&self) -> Result<(), FileCacheError> {
trace!("Saving assets information ...");
let filename = self.config.assets_filename();
let _ = fs::remove_file(&filename);
let mut f = file(filename, FileMode::Create)?;
match self.config.data_format {
DataFormat::Yaml => serde_yaml::to_writer(&f, &self.assets)?,
DataFormat::Json => serde_json::to_writer(&f, &self.assets)?,
DataFormat::Toml => f.write_all(&toml::to_vec(&self.assets)?)?,
DataFormat::StrictEncode => unimplemented!(),
}
Ok(())
}
pub fn export(&self) -> Result<Vec<u8>, FileCacheError> {
trace!("Exporting assets information ...");
let assets = self.assets.values().collect::<Vec<&Asset>>();
Ok(match self.config.data_format {
DataFormat::Yaml => serde_yaml::to_vec(&assets)?,
DataFormat::Json => serde_json::to_vec(&assets)?,
DataFormat::Toml => toml::to_vec(&assets)?,
DataFormat::StrictEncode => unimplemented!(),
})
}
}
impl Cache for FileCache {
type Error = CacheError;
fn assets(&self) -> Result<Vec<&Asset>, CacheError> {
Ok(self.assets.values().collect())
}
#[inline]
fn asset(&self, id: ContractId) -> Result<&Asset, CacheError> {
Ok(self.assets.get(&id).ok_or(CacheError::DataIntegrityError(
"Asset is not known".to_string(),
))?)
}
#[inline]
fn has_asset(&self, id: ContractId) -> Result<bool, CacheError> {
Ok(self.assets.contains_key(&id))
}
fn add_asset(&mut self, asset: Asset) -> Result<bool, CacheError> {
let exists = self.assets.insert(*asset.id(), asset).is_some();
self.save()?;
Ok(exists)
}
#[inline]
fn remove_asset(&mut self, id: ContractId) -> Result<bool, CacheError> {
let existed = self.assets.remove(&id).is_some();
self.save()?;
Ok(existed)
}
}
|
use super::*;
use super::{Crypto,Sr25519};
use sp_core::{ed25519, Pair, crypto::{Ss58Codec,Ss58AddressFormat}, blake2_256};
pub struct Ed25519;
impl Crypto for Ed25519 {
type Seed = [u8; 32];
type Pair = ed25519::Pair;
type Public = ed25519::Public;
fn seed_from_phrase(phrase: &str, password: Option<&str>) ->Result<Self::Seed,Error> {
Sr25519::seed_from_phrase(phrase, password)
}
fn pair_from_seed(seed: &Self::Seed) -> Self::Pair { ed25519::Pair::from_seed(&seed.clone()) }
fn pair_from_suri(suri: &str, password_override: Option<&str>) -> Result<Self::Pair,Error> {
Ok(ed25519::Pair::from_legacy_string(suri, password_override))
}
fn ss58_from_pair(pair: &Self::Pair,ss58_version:u8) -> String { pair.public().to_ss58check_with_version(Ss58AddressFormat::Custom(ss58_version)) }
fn public_from_pair(pair: &Self::Pair) -> Vec<u8> { (&pair.public().0[..]).to_owned() }
fn seed_from_pair(pair: &Self::Pair) -> Option<&Self::Seed> { Some(pair.seed()) }
fn sign(phrase: &str,msg:&[u8])->Result<[u8;64],Error>{
let seed = Self::seed_from_phrase(phrase,None)?;
let pair = Self::pair_from_seed(&seed);
if msg.len()>256 {
Ok(pair.sign(&blake2_256(msg)).0)
}else {
Ok(pair.sign(msg).0)
}
}
}
|
extern crate git2;
use std::error;
use std::fmt;
use std::io;
#[derive(Debug)]
pub enum HookError {
NoRemoteHost,
Io(io::Error),
Git(git2::Error),
}
impl fmt::Display for HookError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
HookError::Io(ref e) => write!(f, "IO Error: {}", e),
HookError::Git(ref e) => write!(f, "Git Error: {}", e),
HookError::NoRemoteHost => write!(f, "No Remote Host"),
}
}
}
impl error::Error for HookError {
fn description(&self) -> &str {
match *self {
HookError::Io(ref e) => e.description(),
HookError::Git(ref e) => e.description(),
HookError::NoRemoteHost => "no remote host",
}
}
fn cause(&self) -> Option<&error::Error> {
match *self {
HookError::Io(ref e) => Some(e),
HookError::Git(ref e) => Some(e),
HookError::NoRemoteHost => None,
}
}
}
impl From<io::Error> for HookError {
fn from(e: io::Error) -> HookError {
HookError::Io(e)
}
}
impl From<git2::Error> for HookError {
fn from(e: git2::Error) -> HookError {
HookError::Git(e)
}
}
pub enum Check {
Pass,
Fail(Vec<git2::Oid>),
}
|
// 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::fmt::Display;
use std::fmt::Formatter;
use crate::ast::Identifier;
use crate::ast::ShowLimit;
#[derive(Debug, Clone, PartialEq)] // Columns
pub struct ShowColumnsStmt {
pub catalog: Option<Identifier>,
pub database: Option<Identifier>,
pub table: Identifier,
pub full: bool,
pub limit: Option<ShowLimit>,
}
impl Display for ShowColumnsStmt {
fn fmt(&self, f: &mut Formatter) -> std::fmt::Result {
write!(f, "SHOW")?;
if self.full {
write!(f, " FULL")?;
}
write!(f, " COLUMNS FROM {}", self.table)?;
if let Some(database) = &self.database {
write!(f, " FROM ")?;
if let Some(catalog) = &self.catalog {
write!(f, "{catalog}.",)?;
}
write!(f, "{database}")?;
}
if let Some(limit) = &self.limit {
write!(f, " {limit}")?;
}
Ok(())
}
}
|
use proconio::input;
fn main() {
input! {
_n: u16,
m: u16,
x: u16,
t: u16,
d: u16,
};
if x <= m {
println!("{}", t);
} else {
println!("{}", t - d * (x - m));
}
}
|
use crate::render::*;
use crate::alloc::*;
use std::f32::consts::PI;
const TOLERANCE: f32 = 0.1;
pub struct Graphics {
dpi_factor: f32,
renderer: Renderer,
fonts: Slab<font_rs::font::Font<'static>>,
atlas: Atlas,
atlas_tex: TexId,
layers: Vec<(usize, usize)>,
stack: Vec<usize>,
items: Vec<DisplayItem>,
glyphs: Vec<Glyph>,
paths: Vec<PathSegment>,
}
impl Graphics {
pub fn new(dpi_factor: f32) -> Graphics {
let mut renderer = Renderer::new();
let atlas_tex = renderer.create_tex(TexFormat::A, 1024, 1024, &[0; 1024*1024]);
Graphics {
dpi_factor,
renderer,
fonts: Slab::new(),
atlas: Atlas::new(1024, 1024),
atlas_tex,
layers: Vec::new(),
stack: Vec::new(),
items: Vec::new(),
glyphs: Vec::new(),
paths: Vec::new(),
}
}
pub fn add_font(&mut self, bytes: &'static [u8]) -> FontId {
self.fonts.insert(font_rs::font::parse(bytes).unwrap())
}
pub fn remove_font(&mut self, font: FontId) {
self.fonts.remove(font);
}
pub fn clear(&mut self, color: Color) {
self.renderer.clear(color.to_linear());
}
pub fn draw(&mut self, width: f32, height: f32) {
let mut glyphs = Vec::new();
let mut paths = Vec::new();
for item in self.items.iter() {
match item {
DisplayItem::Glyphs(color, start, end) => {
glyphs.push((color, &self.glyphs[*start..*end]));
}
DisplayItem::FillPath(color, start, end) => {
paths.push((color, &self.paths[*start..*end]));
}
}
}
let mut path_verts: Vec<Vertex> = Vec::new();
let mut path_indices: Vec<u16> = Vec::new();
for (color, path) in paths {
let col = color.to_linear();
let mut col_alpha = col;
col_alpha[3] = 0.0;
let mut verts = Vec::new();
for (i, PathSegment(pos, segment)) in path.iter().enumerate() {
match segment {
SegmentType::Line => {
verts.push(*pos);
}
SegmentType::Arc(radius, start_angle, end_angle) => {
let PathSegment(next, _) = path[(i+1) % path.len()];
let segments: u16 = (((end_angle - start_angle).abs() / (1.0 - TOLERANCE / radius).acos()).ceil() as u16).max(4);
let arc = (end_angle - start_angle) / segments as f32;
let rotor = [arc.cos(), -arc.sin()];
let mut angle = [start_angle.cos(), -start_angle.sin()];
let center = [pos[0] - radius * angle[0], pos[1] - radius * angle[1]];
for _ in 0..segments {
verts.push([center[0] + radius * angle[0], center[1] + radius * angle[1]]);
angle = [rotor[0] * angle[0] - rotor[1] * angle[1], rotor[0] * angle[1] + rotor[1] * angle[0]];
}
}
}
}
let path_start = path_verts.len();
for i in 0..verts.len() {
let prev = verts[(i+verts.len()-1)%verts.len()];
let curr = verts[i];
let next = verts[(i+1)%verts.len()];
let prev_normal = normalized([prev[1] - curr[1], curr[0] - prev[0]]);
let next_normal = normalized([curr[1] - next[1], next[0] - curr[0]]);
let normal = normalized([(prev_normal[0] + next_normal[0]) / 2.0, (prev_normal[1] + next_normal[1]) / 2.0]);
let (inner_x, inner_y) = pixel_to_ndc(curr[0] - 0.5 * normal[0], curr[1] - 0.5 * normal[1], width, height);
let (outer_x, outer_y) = pixel_to_ndc(curr[0] + 0.5 * normal[0], curr[1] + 0.5 * normal[1], width, height);
path_verts.push(Vertex { pos: [inner_x, inner_y, 0.0], col });
path_verts.push(Vertex { pos: [outer_x, outer_y, 0.0], col: col_alpha });
}
for i in 1..verts.len().saturating_sub(1) {
path_indices.extend_from_slice(&[path_start as u16, (path_start + 2*i) as u16, (path_start + 2*i + 2) as u16]);
}
for i in 0..verts.len() {
path_indices.extend_from_slice(&[
(path_start + 2*i) as u16, (path_start + 2*i + 1) as u16, (path_start + 2*((i+1)%verts.len()) + 1) as u16,
(path_start + 2*i) as u16, (path_start + 2*((i+1)%verts.len()) + 1) as u16, (path_start + 2*((i+1)%verts.len())) as u16,
]);
}
}
self.renderer.draw(&path_verts, &path_indices);
let mut glyph_verts: Vec<VertexUV> = Vec::new();
let mut glyph_indices: Vec<u16> = Vec::new();
self.atlas.update_counter();
for (color, glyph_list) in glyphs {
let col = color.to_linear();
for glyph in glyph_list.iter() {
let rect = if let Some(rect) = self.atlas.get_cached(glyph.id) {
rect
} else {
let font = self.fonts.get(glyph.id.font).unwrap();
let bbox = font.get_bbox(glyph.id.glyph, glyph.id.scale).unwrap();
let rect = self.atlas.insert(glyph.id, bbox.width() as u32, bbox.height() as u32).unwrap();
let rendered = font.render_glyph(glyph.id.glyph, glyph.id.scale).unwrap();
self.renderer.update_tex(self.atlas_tex, rect.x as usize, rect.y as usize, rendered.width as usize, rendered.height as usize, &rendered.data);
rect
};
let i = glyph_verts.len() as u16;
let (u1, v1) = (rect.x as f32 / self.atlas.width as f32, (rect.y + rect.h) as f32 / self.atlas.height as f32);
let (u2, v2) = ((rect.x + rect.w) as f32 / self.atlas.width as f32, rect.y as f32 / self.atlas.height as f32);
let (x1, y1) = pixel_to_ndc(glyph.pos[0], glyph.pos[1], width, height);
let (x2, y2) = pixel_to_ndc(glyph.pos[0] + rect.w as f32, glyph.pos[1] + rect.h as f32, width, height);
glyph_verts.extend_from_slice(&[VertexUV {
pos: [x1, y1, 0.0],
col,
uv: [u1, v1],
}, VertexUV {
pos: [x2, y1, 0.0],
col,
uv: [u2, v1],
}, VertexUV {
pos: [x2, y2, 0.0],
col,
uv: [u2, v2],
}, VertexUV {
pos: [x1, y2, 0.0],
col,
uv: [u1, v2],
}]);
glyph_indices.extend_from_slice(&[i, i+1, i+2, i, i+2, i+3]);
}
}
self.renderer.draw_tex(&glyph_verts, &glyph_indices, self.atlas_tex);
self.layers = Vec::new();
self.stack = Vec::new();
self.items = Vec::new();
self.glyphs = Vec::new();
self.paths = Vec::new();
}
pub fn text_size(&self, text: &str, font_id: FontId, scale: u32) -> (f32, f32) {
let font = self.fonts.get(font_id).unwrap();
let mut width = 0.0;
for c in text.chars() {
let glyph = font.lookup_glyph_id(c as u32).unwrap();
let h_metrics = font.get_h_metrics(glyph, scale).unwrap();
width += h_metrics.advance_width;
}
let v_metrics = font.get_v_metrics(scale).unwrap();
(width, v_metrics.ascent - v_metrics.descent)
}
pub fn text(&mut self, pos: [f32; 2], text: &str, font_id: FontId, scale: u32, color: Color) {
let font = self.fonts.get(font_id).unwrap();
let mut pos = pos;
let start = self.glyphs.len();
self.glyphs.reserve(text.len());
for c in text.chars() {
let glyph = font.lookup_glyph_id(c as u32).unwrap();
let h_metrics = font.get_h_metrics(glyph, scale).unwrap();
let v_metrics = font.get_v_metrics(scale).unwrap();
if let Some(bbox) = font.get_bbox(glyph, scale) {
self.glyphs.push(Glyph {
id: GlyphId { font: font_id, scale, glyph },
pos: [pos[0] + bbox.l as f32, pos[1] + bbox.t as f32 + v_metrics.ascent as f32],
});
}
pos[0] += h_metrics.advance_width;
}
self.items.push(DisplayItem::Glyphs(color, start, self.glyphs.len()));
}
pub fn rect_fill(&mut self, pos: [f32; 2], size: [f32; 2], color: Color) {
let start = self.paths.len();
self.paths.extend_from_slice(&[
PathSegment([pos[0], pos[1]], SegmentType::Line),
PathSegment([pos[0], pos[1] + size[1]], SegmentType::Line),
PathSegment([pos[0] + size[0], pos[1] + size[1]], SegmentType::Line),
PathSegment([pos[0] + size[0], pos[1]], SegmentType::Line),
]);
self.items.push(DisplayItem::FillPath(color, start, self.paths.len()));
}
pub fn round_rect_fill(&mut self, pos: [f32; 2], size: [f32; 2], radius: f32, color: Color) {
let start = self.paths.len();
self.paths.extend_from_slice(&[
PathSegment([pos[0] + radius, pos[1]], SegmentType::Arc(radius, PI/2.0, PI)),
PathSegment([pos[0], pos[1] + radius], SegmentType::Line),
PathSegment([pos[0], pos[1] + size[1] - radius], SegmentType::Arc(radius, PI, 3.0*PI/2.0)),
PathSegment([pos[0] + radius, pos[1] + size[1]], SegmentType::Line),
PathSegment([pos[0] + size[0] - radius, pos[1] + size[1]], SegmentType::Arc(radius, 3.0*PI/2.0, 2.0*PI)),
PathSegment([pos[0] + size[0], pos[1] + size[1] - radius], SegmentType::Line),
PathSegment([pos[0] + size[0], pos[1] + radius], SegmentType::Arc(radius, 0.0, PI/2.0)),
PathSegment([pos[0] + size[0] - radius, pos[1]], SegmentType::Line),
]);
self.items.push(DisplayItem::FillPath(color, start, self.paths.len()));
}
pub fn circle_fill(&mut self, pos: [f32; 2], radius: f32, color: Color) {
let start = self.paths.len();
self.paths.extend_from_slice(&[
PathSegment([pos[0] + radius, pos[1]], SegmentType::Arc(radius, 0.0, 2.0*PI)),
]);
self.items.push(DisplayItem::FillPath(color, start, self.paths.len()));
}
}
#[inline]
fn pixel_to_ndc(x: f32, y: f32, screen_width: f32, screen_height: f32) -> (f32, f32) {
(2.0 * (x / screen_width as f32 - 0.5), 2.0 * (1.0 - y / screen_height as f32 - 0.5))
}
#[inline]
fn distance(p1: [f32; 2], p2: [f32; 2]) -> f32 {
((p2[0] - p1[0]) * (p2[0] - p1[0]) + (p2[1] - p1[1]) * (p2[1] - p1[1])).sqrt()
}
#[inline]
fn length(p: [f32; 2]) -> f32 {
(p[0] * p[0] + p[1] * p[1]).sqrt()
}
#[inline]
fn normalized(p: [f32; 2]) -> [f32; 2] {
let len = length(p);
[p[0] / len, p[1] / len]
}
#[derive(Copy, Clone)]
pub enum DisplayItem {
Glyphs(Color, usize, usize),
FillPath(Color, usize, usize),
}
#[derive(Copy, Clone)]
pub struct Color {
r: f32, g: f32, b: f32, a: f32
}
impl Color {
pub fn rgba(r: f32, g: f32, b: f32, a: f32) -> Color {
Color { r, g, b, a }
}
fn to_linear(&self) -> [f32; 4] {
[srgb_to_linear(self.r), srgb_to_linear(self.g), srgb_to_linear(self.b), self.a]
}
}
fn srgb_to_linear(x: f32) -> f32 {
if x < 0.04045 { x / 12.92 } else { ((x + 0.055)/1.055).powf(2.4) }
}
#[derive(Copy, Clone)]
pub struct Glyph {
id: GlyphId,
pos: [f32; 2],
}
#[derive(Copy, Clone)]
struct PathSegment([f32; 2], SegmentType);
#[derive(Copy, Clone)]
enum SegmentType {
Line,
Arc(f32, f32, f32),
}
pub type FontId = usize;
#[derive(Copy, Clone, PartialEq, Eq, Hash, Debug)]
pub struct GlyphId {
font: FontId,
scale: u32,
glyph: u16,
}
struct Atlas {
width: u32,
height: u32,
rows: Slab<Row>,
rows_by_height: Vec<usize>,
next_y: u32,
map: std::collections::HashMap<GlyphId, Entry>,
counter: usize,
}
struct Row {
y: u32,
height: u32,
glyphs: Slab<AtlasGlyph>,
next_x: u32,
last_used: usize,
}
impl Row {
fn new(y: u32, height: u32) -> Row {
Row { y, height, glyphs: Slab::new(), next_x: 0, last_used: 0 }
}
}
#[derive(Debug)]
struct AtlasGlyph {
x: u32,
width: u32,
height: u32,
glyph_id: GlyphId,
}
#[derive(Debug)]
struct Entry {
row: usize,
glyph: usize,
}
impl Atlas {
fn new(width: u32, height: u32) -> Atlas {
Atlas {
width,
height,
rows: Slab::new(),
rows_by_height: Vec::new(),
next_y: 0,
map: std::collections::HashMap::new(),
counter: 0,
}
}
fn update_counter(&mut self) {
self.counter += 1;
}
fn get_cached(&mut self, glyph_id: GlyphId) -> Option<Rect> {
if let Some(&Entry { row, glyph }) = self.map.get(&glyph_id) {
let row = self.rows.get_mut(row).unwrap();
row.last_used = self.counter;
let glyph = row.glyphs.get_mut(glyph).unwrap();
Some(Rect { x: glyph.x, y: row.y, w: glyph.width, h: glyph.height })
} else {
None
}
}
fn insert(&mut self, glyph_id: GlyphId, width: u32, height: u32) -> Option<Rect> {
if width > self.width || height > self.height { return None; }
let row_index = self.find_row(width, height);
if row_index.is_none() { return None; }
let row_index = row_index.unwrap();
let mut row = self.rows.get_mut(row_index).unwrap();
let x = row.next_x;
let glyph = row.glyphs.insert(AtlasGlyph {
x,
width,
height,
glyph_id,
});
row.next_x += width;
row.last_used = self.counter;
self.map.insert(glyph_id, Entry { row: row_index, glyph });
Some(Rect { x, y: row.y, w: width, h: height })
}
fn find_row(&mut self, width: u32, height: u32) -> Option<usize> {
let row_height = nearest_pow_2(height);
// this logic is to ensure that the search finds the first of a sequence of equal elements
let mut index = self.rows_by_height
.binary_search_by_key(&(2 * row_height - 1), |row| 2 * self.rows.get(*row).unwrap().height)
.unwrap_err();
// try to find an existing tightly sized row
while index < self.rows_by_height.len() && row_height == self.rows.get(self.rows_by_height[index]).unwrap().height {
if width <= self.width - self.rows.get(self.rows_by_height[index]).unwrap().next_x {
return Some(self.rows_by_height[index]);
}
index += 1;
}
// if there is no exact match, try to add a tightly sized row
if let Some(new_row_index) = self.try_add_row(index, row_height) {
return Some(new_row_index);
}
// search rows for room starting at tightest fit
for i in index..self.rows_by_height.len() {
if width <= self.width - self.rows.get(self.rows_by_height[i]).unwrap().next_x {
return Some(self.rows_by_height[i]);
}
}
// if we ran out of rows, try to add a new row
if let Some(row_index) = self.try_add_row(index, row_height) {
return Some(row_index);
}
// need to overwrite some rows
if let Some(row_index) = self.try_overwrite_rows(row_height) {
return Some(row_index);
}
None
}
fn try_add_row(&mut self, index: usize, row_height: u32) -> Option<usize> {
if row_height <= self.height - self.next_y {
let row_index = self.rows.insert(Row::new(self.next_y, row_height));
self.next_y += row_height;
self.rows_by_height.insert(index, row_index);
Some(row_index)
} else {
None
}
}
fn try_overwrite_rows(&mut self, row_height: u32) -> Option<usize> {
let mut rows_by_y = self.rows_by_height.clone();
rows_by_y.sort_by_key(|row| self.rows.get(*row).unwrap().y);
let mut best_i = 0;
let mut best_height = 0;
let mut best_num_rows = 0;
let mut best_last_used = self.counter as f32 + 1.0;
for i in 0..rows_by_y.len() {
let mut num_rows = 0;
let mut rows_height = 0;
let mut last_used_sum = 0;
while row_height > rows_height && i + num_rows < rows_by_y.len() {
let row = self.rows.get(rows_by_y[i]).unwrap();
if row.last_used == self.counter { continue; }
num_rows += 1;
rows_height += row.height;
last_used_sum += row.last_used;
}
if row_height <= rows_height {
let last_used_avg = last_used_sum as f32 / num_rows as f32;
if last_used_avg < best_last_used {
best_i = i;
best_height = rows_height;
best_num_rows = num_rows;
best_last_used = last_used_avg;
}
}
}
if best_height > 0 {
let y = self.rows.get(rows_by_y[best_i]).unwrap().y;
for row_index in &rows_by_y[best_i..(best_i + best_num_rows)] {
self.rows_by_height.remove(*row_index);
let row = self.rows.remove(*row_index).unwrap();
for glyph in row.glyphs.iter() {
self.map.remove(&glyph.glyph_id);
}
}
let row_index = self.add_row(Row::new(y, row_height));
if best_height > row_height {
self.add_row(Row::new(y + row_height, best_height - row_height));
}
Some(row_index)
} else {
None
}
}
fn add_row(&mut self, row: Row) -> usize {
let height = row.height;
let row_index = self.rows.insert(row);
let index = self.rows_by_height
.binary_search_by_key(&height, |row| self.rows.get(*row).unwrap().height)
.unwrap_or_else(|i| i);
self.rows_by_height.insert(index, row_index);
row_index
}
}
#[derive(Copy, Clone, Debug)]
struct Rect { x: u32, y: u32, w: u32, h: u32 }
fn nearest_pow_2(x: u32) -> u32 {
let mut x = x;
x -= 1;
x |= x >> 1;
x |= x >> 2;
x |= x >> 4;
x |= x >> 8;
x |= x >> 16;
x += 1;
x
}
|
#![allow(unused_variables, non_upper_case_globals, non_snake_case, unused_unsafe, non_camel_case_types, dead_code, clippy::all)]
#[cfg(feature = "ApplicationModel_Calls_Background")]
pub mod Background;
#[cfg(feature = "ApplicationModel_Calls_Provider")]
pub mod Provider;
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CallAnswerEventArgs(pub ::windows::core::IInspectable);
impl CallAnswerEventArgs {
pub fn AcceptedMedia(&self) -> ::windows::core::Result<VoipPhoneCallMedia> {
let this = self;
unsafe {
let mut result__: VoipPhoneCallMedia = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VoipPhoneCallMedia>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for CallAnswerEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.CallAnswerEventArgs;{fd789617-2dd7-4c8c-b2bd-95d17a5bb733})");
}
unsafe impl ::windows::core::Interface for CallAnswerEventArgs {
type Vtable = ICallAnswerEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfd789617_2dd7_4c8c_b2bd_95d17a5bb733);
}
impl ::windows::core::RuntimeName for CallAnswerEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.CallAnswerEventArgs";
}
impl ::core::convert::From<CallAnswerEventArgs> for ::windows::core::IUnknown {
fn from(value: CallAnswerEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&CallAnswerEventArgs> for ::windows::core::IUnknown {
fn from(value: &CallAnswerEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for CallAnswerEventArgs {
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 CallAnswerEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<CallAnswerEventArgs> for ::windows::core::IInspectable {
fn from(value: CallAnswerEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&CallAnswerEventArgs> for ::windows::core::IInspectable {
fn from(value: &CallAnswerEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for CallAnswerEventArgs {
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 CallAnswerEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for CallAnswerEventArgs {}
unsafe impl ::core::marker::Sync for CallAnswerEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CallRejectEventArgs(pub ::windows::core::IInspectable);
impl CallRejectEventArgs {
pub fn RejectReason(&self) -> ::windows::core::Result<VoipPhoneCallRejectReason> {
let this = self;
unsafe {
let mut result__: VoipPhoneCallRejectReason = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VoipPhoneCallRejectReason>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for CallRejectEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.CallRejectEventArgs;{da47fad7-13d4-4d92-a1c2-b77811ee37ec})");
}
unsafe impl ::windows::core::Interface for CallRejectEventArgs {
type Vtable = ICallRejectEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xda47fad7_13d4_4d92_a1c2_b77811ee37ec);
}
impl ::windows::core::RuntimeName for CallRejectEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.CallRejectEventArgs";
}
impl ::core::convert::From<CallRejectEventArgs> for ::windows::core::IUnknown {
fn from(value: CallRejectEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&CallRejectEventArgs> for ::windows::core::IUnknown {
fn from(value: &CallRejectEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for CallRejectEventArgs {
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 CallRejectEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<CallRejectEventArgs> for ::windows::core::IInspectable {
fn from(value: CallRejectEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&CallRejectEventArgs> for ::windows::core::IInspectable {
fn from(value: &CallRejectEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for CallRejectEventArgs {
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 CallRejectEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for CallRejectEventArgs {}
unsafe impl ::core::marker::Sync for CallRejectEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct CallStateChangeEventArgs(pub ::windows::core::IInspectable);
impl CallStateChangeEventArgs {
pub fn State(&self) -> ::windows::core::Result<VoipPhoneCallState> {
let this = self;
unsafe {
let mut result__: VoipPhoneCallState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VoipPhoneCallState>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for CallStateChangeEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.CallStateChangeEventArgs;{eab2349e-66f5-47f9-9fb5-459c5198c720})");
}
unsafe impl ::windows::core::Interface for CallStateChangeEventArgs {
type Vtable = ICallStateChangeEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xeab2349e_66f5_47f9_9fb5_459c5198c720);
}
impl ::windows::core::RuntimeName for CallStateChangeEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.CallStateChangeEventArgs";
}
impl ::core::convert::From<CallStateChangeEventArgs> for ::windows::core::IUnknown {
fn from(value: CallStateChangeEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&CallStateChangeEventArgs> for ::windows::core::IUnknown {
fn from(value: &CallStateChangeEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for CallStateChangeEventArgs {
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 CallStateChangeEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<CallStateChangeEventArgs> for ::windows::core::IInspectable {
fn from(value: CallStateChangeEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&CallStateChangeEventArgs> for ::windows::core::IInspectable {
fn from(value: &CallStateChangeEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for CallStateChangeEventArgs {
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 CallStateChangeEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for CallStateChangeEventArgs {}
unsafe impl ::core::marker::Sync for CallStateChangeEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct CellularDtmfMode(pub i32);
impl CellularDtmfMode {
pub const Continuous: CellularDtmfMode = CellularDtmfMode(0i32);
pub const Burst: CellularDtmfMode = CellularDtmfMode(1i32);
}
impl ::core::convert::From<i32> for CellularDtmfMode {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for CellularDtmfMode {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for CellularDtmfMode {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.CellularDtmfMode;i4)");
}
impl ::windows::core::DefaultType for CellularDtmfMode {
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 DtmfKey(pub i32);
impl DtmfKey {
pub const D0: DtmfKey = DtmfKey(0i32);
pub const D1: DtmfKey = DtmfKey(1i32);
pub const D2: DtmfKey = DtmfKey(2i32);
pub const D3: DtmfKey = DtmfKey(3i32);
pub const D4: DtmfKey = DtmfKey(4i32);
pub const D5: DtmfKey = DtmfKey(5i32);
pub const D6: DtmfKey = DtmfKey(6i32);
pub const D7: DtmfKey = DtmfKey(7i32);
pub const D8: DtmfKey = DtmfKey(8i32);
pub const D9: DtmfKey = DtmfKey(9i32);
pub const Star: DtmfKey = DtmfKey(10i32);
pub const Pound: DtmfKey = DtmfKey(11i32);
}
impl ::core::convert::From<i32> for DtmfKey {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for DtmfKey {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for DtmfKey {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.DtmfKey;i4)");
}
impl ::windows::core::DefaultType for DtmfKey {
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 DtmfToneAudioPlayback(pub i32);
impl DtmfToneAudioPlayback {
pub const Play: DtmfToneAudioPlayback = DtmfToneAudioPlayback(0i32);
pub const DoNotPlay: DtmfToneAudioPlayback = DtmfToneAudioPlayback(1i32);
}
impl ::core::convert::From<i32> for DtmfToneAudioPlayback {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for DtmfToneAudioPlayback {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for DtmfToneAudioPlayback {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.DtmfToneAudioPlayback;i4)");
}
impl ::windows::core::DefaultType for DtmfToneAudioPlayback {
type DefaultType = Self;
}
#[repr(transparent)]
#[doc(hidden)]
pub struct ICallAnswerEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICallAnswerEventArgs {
type Vtable = ICallAnswerEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfd789617_2dd7_4c8c_b2bd_95d17a5bb733);
}
#[repr(C)]
#[doc(hidden)]
pub struct ICallAnswerEventArgs_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 VoipPhoneCallMedia) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ICallRejectEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICallRejectEventArgs {
type Vtable = ICallRejectEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xda47fad7_13d4_4d92_a1c2_b77811ee37ec);
}
#[repr(C)]
#[doc(hidden)]
pub struct ICallRejectEventArgs_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 VoipPhoneCallRejectReason) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ICallStateChangeEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ICallStateChangeEventArgs {
type Vtable = ICallStateChangeEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xeab2349e_66f5_47f9_9fb5_459c5198c720);
}
#[repr(C)]
#[doc(hidden)]
pub struct ICallStateChangeEventArgs_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 VoipPhoneCallState) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILockScreenCallEndCallDeferral(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILockScreenCallEndCallDeferral {
type Vtable = ILockScreenCallEndCallDeferral_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2dd7ed0d_98ed_4041_9632_50ff812b773f);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILockScreenCallEndCallDeferral_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) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILockScreenCallEndRequestedEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILockScreenCallEndRequestedEventArgs {
type Vtable = ILockScreenCallEndRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8190a363_6f27_46e9_aeb6_c0ae83e47dc7);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILockScreenCallEndRequestedEventArgs_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct ILockScreenCallUI(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for ILockScreenCallUI {
type Vtable = ILockScreenCallUI_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc596fd8d_73c9_4a14_b021_ec1c50a3b727);
}
#[repr(C)]
#[doc(hidden)]
pub struct ILockScreenCallUI_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) -> ::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,
#[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 ::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 IMuteChangeEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IMuteChangeEventArgs {
type Vtable = IMuteChangeEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8585e159_0c41_432c_814d_c5f1fdf530be);
}
#[repr(C)]
#[doc(hidden)]
pub struct IMuteChangeEventArgs_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCall(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCall {
type Vtable = IPhoneCall_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc14ed0f8_c17d_59d2_9628_66e545b6cd21);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCall_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::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,
#[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,
#[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 ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::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 PhoneCallStatus) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallAudioDevice) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, key: DtmfKey, dtmftoneaudioplayback: DtmfToneAudioPlayback, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, key: DtmfKey, dtmftoneaudioplayback: DtmfToneAudioPlayback, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, endpoint: PhoneCallAudioDevice, result__: *mut PhoneCallOperationStatus) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, endpoint: PhoneCallAudioDevice, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallBlockingStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallBlockingStatics {
type Vtable = IPhoneCallBlockingStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x19646f84_2b79_26f1_a46f_694be043f313);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallBlockingStatics_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 bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: bool) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, phonenumberlist: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntry(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryEntry {
type Vtable = IPhoneCallHistoryEntry_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfab0e129_32a4_4b85_83d1_f90d8c23a857);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntry_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, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] 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,
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,
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,
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,
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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallHistoryEntryMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallHistoryEntryMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallHistoryEntryOtherAppReadAccess) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallHistoryEntryOtherAppReadAccess) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallHistorySourceIdKind) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallHistorySourceIdKind) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryAddress(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryEntryAddress {
type Vtable = IPhoneCallHistoryEntryAddress_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x30f159da_3955_4042_84e6_66eebf82e67f);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryAddress_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,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallHistoryEntryRawAddressKind) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallHistoryEntryRawAddressKind) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryAddressFactory(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryEntryAddressFactory {
type Vtable = IPhoneCallHistoryEntryAddressFactory_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfb0fadba_c7f0_4bb6_9f6b_ba5d73209aca);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryAddressFactory_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, rawaddress: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, rawaddresskind: PhoneCallHistoryEntryRawAddressKind, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryQueryOptions(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryEntryQueryOptions {
type Vtable = IPhoneCallHistoryEntryQueryOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9c5fe15c_8bed_40ca_b06e_c4ca8eae5c87);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryQueryOptions_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 PhoneCallHistoryEntryQueryDesiredMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallHistoryEntryQueryDesiredMedia) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryReader(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryEntryReader {
type Vtable = IPhoneCallHistoryEntryReader_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x61ece4be_8d86_479f_8404_a9846920fee6);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryEntryReader_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)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerForUser(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryManagerForUser {
type Vtable = IPhoneCallHistoryManagerForUser_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd925c523_f55f_4353_9db4_0205a5265a55);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerForUser_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, accesstype: PhoneCallHistoryStoreAccessType, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryManagerStatics {
type Vtable = IPhoneCallHistoryManagerStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf5a6da39_b31f_4f45_ac8e_1b08893c1b50);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerStatics_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, accesstype: PhoneCallHistoryStoreAccessType, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerStatics2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryManagerStatics2 {
type Vtable = IPhoneCallHistoryManagerStatics2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xefd474f0_a2db_4188_9e92_bc3cfa6813cf);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryManagerStatics2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, user: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallHistoryStore(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallHistoryStore {
type Vtable = IPhoneCallHistoryStore_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2f907db8_b40e_422b_8545_cb1910a61c52);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallHistoryStore_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, callhistoryentryid: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::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, queryoptions: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, callhistoryentry: ::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, callhistoryentry: ::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, callhistoryentries: ::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, callhistoryentry: ::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, callhistoryentries: ::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, 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, 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, sourceids: ::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 = "Foundation_Collections"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, sourceids: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Foundation", feature = "Foundation_Collections")))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallInfo(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallInfo {
type Vtable = IPhoneCallInfo_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x22b42577_3e4d_5dc6_89c2_469fe5ffc189);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallInfo_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] 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, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallDirection) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallManagerStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallManagerStatics {
type Vtable = IPhoneCallManagerStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x60edac78_78a6_4872_a3ef_98325ec8b843);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallManagerStatics_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, phonenumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, displayname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallManagerStatics2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallManagerStatics2 {
type Vtable = IPhoneCallManagerStatics2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc7e3c8bc_2370_431c_98fd_43be5f03086d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallManagerStatics2_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::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 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) -> ::windows::core::HRESULT,
#[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 IPhoneCallStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallStatics {
type Vtable = IPhoneCallStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2218eeab_f60b_53e7_ba13_5aeafbc22957);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallStatics_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, callid: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallStore(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallStore {
type Vtable = IPhoneCallStore_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5f610748_18a6_4173_86d1_28be9dc62dba);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallStore_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, number: ::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, result__: *mut ::windows::core::RawPtr) -> ::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,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallVideoCapabilities(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallVideoCapabilities {
type Vtable = IPhoneCallVideoCapabilities_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x02382786_b16a_4fdb_be3b_c4240e13ad0d);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallVideoCapabilities_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallVideoCapabilitiesManagerStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallVideoCapabilitiesManagerStatics {
type Vtable = IPhoneCallVideoCapabilitiesManagerStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf3c64b56_f00b_4a1c_a0c6_ee1910749ce7);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallVideoCapabilitiesManagerStatics_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, phonenumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneCallsResult(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneCallsResult {
type Vtable = IPhoneCallsResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1bfad365_57cf_57dd_986d_b057c91eac33);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneCallsResult_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 PhoneLineOperationStatus) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_Collections")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation_Collections"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneDialOptions(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneDialOptions {
type Vtable = IPhoneDialOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb639c4b8_f06f_36cb_a863_823742b5f2d4);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneDialOptions_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,
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 = "ApplicationModel_Contacts")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "ApplicationModel_Contacts"))] usize,
#[cfg(feature = "ApplicationModel_Contacts")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "ApplicationModel_Contacts"))] usize,
#[cfg(feature = "ApplicationModel_Contacts")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "ApplicationModel_Contacts"))] usize,
#[cfg(feature = "ApplicationModel_Contacts")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "ApplicationModel_Contacts"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneCallMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneCallMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneAudioRoutingEndpoint) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: PhoneAudioRoutingEndpoint) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLine(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLine {
type Vtable = IPhoneLine_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x27c66f30_6a69_34ca_a2ba_65302530c311);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLine_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::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::GUID) -> ::windows::core::HRESULT,
#[cfg(feature = "UI")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::UI::Color) -> ::windows::core::HRESULT,
#[cfg(not(feature = "UI"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneNetworkState) -> ::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, result__: *mut ::windows::core::RawPtr) -> ::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, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneLineTransport) -> ::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,
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")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, number: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, number: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, displayname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, options: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLine2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLine2 {
type Vtable = IPhoneLine2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0167f56a_5344_5d64_8af3_a31a950e916a);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLine2_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 ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLine3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLine3 {
type Vtable = IPhoneLine3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe2e33cf7_2406_57f3_826a_e5a5f40d6fb5);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLine3_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, number: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, displayname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, number: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, displayname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::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,
#[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 IPhoneLineCellularDetails(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineCellularDetails {
type Vtable = IPhoneLineCellularDetails_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x192601d5_147c_4769_b673_98a5ec8426cb);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineCellularDetails_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 PhoneSimState) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *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, result__: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, location: PhoneLineNetworkOperatorDisplayTextLocation, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLineConfiguration(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineConfiguration {
type Vtable = IPhoneLineConfiguration_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfe265862_f64f_4312_b2a8_4e257721aa95);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineConfiguration_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation_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 IPhoneLineDialResult(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineDialResult {
type Vtable = IPhoneLineDialResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe825a30a_5c7f_546f_b918_3ad2fe70fb34);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineDialResult_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 PhoneCallOperationStatus) -> ::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 IPhoneLineStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineStatics {
type Vtable = IPhoneLineStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xf38b5f23_ceb0_404f_bcf2_ba9f697d8adf);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineStatics_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, lineid: ::windows::core::GUID, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLineTransportDevice(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineTransportDevice {
type Vtable = IPhoneLineTransportDevice_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xefa8f889_cffa_59f4_97e4_74705b7dc490);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineTransportDevice_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, result__: *mut PhoneLineTransport) -> ::windows::core::HRESULT,
#[cfg(all(feature = "Devices_Enumeration", feature = "Foundation"))] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(all(feature = "Devices_Enumeration", feature = "Foundation")))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, user: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "System")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, user: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "System"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut bool) -> ::windows::core::HRESULT,
#[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 IPhoneLineTransportDevice2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineTransportDevice2 {
type Vtable = IPhoneLineTransportDevice2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x64c885f2_ecf4_5761_8c04_3c248ce61690);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineTransportDevice2_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 TransportDeviceAudioRoutingStatus) -> ::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, result__: *mut bool) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::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,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLineTransportDeviceStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineTransportDeviceStatics {
type Vtable = IPhoneLineTransportDeviceStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0f3121ac_d609_51a1_96f3_fb00d1819252);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineTransportDeviceStatics_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: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::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, transport: PhoneLineTransport, result__: *mut ::core::mem::ManuallyDrop<::windows::core::HSTRING>) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLineWatcher(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineWatcher {
type Vtable = IPhoneLineWatcher_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8a45cd0a_6323_44e0_a6f6_9f21f64dc90a);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineWatcher_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) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::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,
#[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,
#[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,
#[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,
#[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 PhoneLineWatcherStatus) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneLineWatcherEventArgs(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneLineWatcherEventArgs {
type Vtable = IPhoneLineWatcherEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd07c753e_9e12_4a37_82b7_ad535dad6a67);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneLineWatcherEventArgs_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IPhoneVoicemail(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IPhoneVoicemail {
type Vtable = IPhoneVoicemail_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc9ce77f6_6e9f_3a8b_b727_6e0cf6998224);
}
#[repr(C)]
#[doc(hidden)]
pub struct IPhoneVoicemail_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, result__: *mut i32) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut PhoneVoicemailType) -> ::windows::core::HRESULT,
#[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 IVoipCallCoordinator(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipCallCoordinator {
type Vtable = IVoipCallCoordinator_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4f118bcf_e8ef_4434_9c5f_a8d893fafe79);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipCallCoordinator_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, taskentrypoint: ::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, mutechangehandler: ::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,
#[cfg(feature = "Foundation")]
pub unsafe extern "system" fn(
this: ::windows::core::RawPtr,
context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactnumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactimage: ::windows::core::RawPtr,
servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
brandingimage: ::windows::core::RawPtr,
calldetails: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
ringtone: ::windows::core::RawPtr,
media: VoipPhoneCallMedia,
ringtimeout: super::super::Foundation::TimeSpan,
result__: *mut ::windows::core::RawPtr,
) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, media: VoipPhoneCallMedia, 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) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, callupgradeguid: ::windows::core::GUID, context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")]
pub unsafe extern "system" fn(
this: ::windows::core::RawPtr,
context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactnumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactimage: ::windows::core::RawPtr,
servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
brandingimage: ::windows::core::RawPtr,
calldetails: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
ringtone: ::windows::core::RawPtr,
ringtimeout: super::super::Foundation::TimeSpan,
result__: *mut ::windows::core::RawPtr,
) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, callupgradeguid: ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, callupgradeguid: ::windows::core::GUID) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipCallCoordinator2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipCallCoordinator2 {
type Vtable = IVoipCallCoordinator2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xbeb4a9f3_c704_4234_89ce_e88cc0d28fbe);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipCallCoordinator2_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, context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactnumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, media: VoipPhoneCallMedia, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipCallCoordinator3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipCallCoordinator3 {
type Vtable = IVoipCallCoordinator3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x338d0cbf_9b55_4021_87ca_e64b9bd666c7);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipCallCoordinator3_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, context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, contactnumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>, media: VoipPhoneCallMedia, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")]
pub unsafe extern "system" fn(
this: ::windows::core::RawPtr,
context: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactname: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactnumber: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
contactimage: ::windows::core::RawPtr,
servicename: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
brandingimage: ::windows::core::RawPtr,
calldetails: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
ringtone: ::windows::core::RawPtr,
media: VoipPhoneCallMedia,
ringtimeout: super::super::Foundation::TimeSpan,
contactremoteid: ::core::mem::ManuallyDrop<::windows::core::HSTRING>,
result__: *mut ::windows::core::RawPtr,
) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipCallCoordinator4(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipCallCoordinator4 {
type Vtable = IVoipCallCoordinator4_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x83737239_9311_468f_bb49_47e0dfb5d93e);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipCallCoordinator4_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipCallCoordinatorStatics(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipCallCoordinatorStatics {
type Vtable = IVoipCallCoordinatorStatics_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x7f5d1f2b_e04a_4d10_b31a_a55c922cc2fb);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipCallCoordinatorStatics_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 IVoipPhoneCall(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipPhoneCall {
type Vtable = IVoipPhoneCall_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6cf1f19a_7794_4a5a_8c68_ae87947a6990);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipPhoneCall_abi(
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, iid: &::windows::core::GUID, interface: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> u32,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, count: *mut u32, values: *mut *mut ::windows::core::GUID) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: *mut i32) -> ::windows::core::HRESULT,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, handler: ::windows::core::RawPtr, result__: *mut super::super::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,
#[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,
#[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,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, accepthandler: ::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,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, rejecthandler: ::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) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, 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")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
#[cfg(feature = "Foundation")] pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: super::super::Foundation::DateTime) -> ::windows::core::HRESULT,
#[cfg(not(feature = "Foundation"))] usize,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, result__: *mut VoipPhoneCallMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr, value: VoipPhoneCallMedia) -> ::windows::core::HRESULT,
pub unsafe extern "system" fn(this: ::windows::core::RawPtr) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipPhoneCall2(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipPhoneCall2 {
type Vtable = IVoipPhoneCall2_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x741b46e1_245f_41f3_9399_3141d25b52e3);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipPhoneCall2_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) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[doc(hidden)]
pub struct IVoipPhoneCall3(pub ::windows::core::IInspectable);
unsafe impl ::windows::core::Interface for IVoipPhoneCall3 {
type Vtable = IVoipPhoneCall3_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x0d891522_e258_4aa9_907a_1aa413c25523);
}
#[repr(C)]
#[doc(hidden)]
pub struct IVoipPhoneCall3_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, media: VoipPhoneCallMedia) -> ::windows::core::HRESULT,
);
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct LockScreenCallEndCallDeferral(pub ::windows::core::IInspectable);
impl LockScreenCallEndCallDeferral {
pub fn Complete(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this)).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for LockScreenCallEndCallDeferral {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.LockScreenCallEndCallDeferral;{2dd7ed0d-98ed-4041-9632-50ff812b773f})");
}
unsafe impl ::windows::core::Interface for LockScreenCallEndCallDeferral {
type Vtable = ILockScreenCallEndCallDeferral_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2dd7ed0d_98ed_4041_9632_50ff812b773f);
}
impl ::windows::core::RuntimeName for LockScreenCallEndCallDeferral {
const NAME: &'static str = "Windows.ApplicationModel.Calls.LockScreenCallEndCallDeferral";
}
impl ::core::convert::From<LockScreenCallEndCallDeferral> for ::windows::core::IUnknown {
fn from(value: LockScreenCallEndCallDeferral) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&LockScreenCallEndCallDeferral> for ::windows::core::IUnknown {
fn from(value: &LockScreenCallEndCallDeferral) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for LockScreenCallEndCallDeferral {
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 LockScreenCallEndCallDeferral {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<LockScreenCallEndCallDeferral> for ::windows::core::IInspectable {
fn from(value: LockScreenCallEndCallDeferral) -> Self {
value.0
}
}
impl ::core::convert::From<&LockScreenCallEndCallDeferral> for ::windows::core::IInspectable {
fn from(value: &LockScreenCallEndCallDeferral) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for LockScreenCallEndCallDeferral {
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 LockScreenCallEndCallDeferral {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for LockScreenCallEndCallDeferral {}
unsafe impl ::core::marker::Sync for LockScreenCallEndCallDeferral {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct LockScreenCallEndRequestedEventArgs(pub ::windows::core::IInspectable);
impl LockScreenCallEndRequestedEventArgs {
pub fn GetDeferral(&self) -> ::windows::core::Result<LockScreenCallEndCallDeferral> {
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::<LockScreenCallEndCallDeferral>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn Deadline(&self) -> ::windows::core::Result<super::super::Foundation::DateTime> {
let this = self;
unsafe {
let mut result__: super::super::Foundation::DateTime = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::DateTime>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for LockScreenCallEndRequestedEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.LockScreenCallEndRequestedEventArgs;{8190a363-6f27-46e9-aeb6-c0ae83e47dc7})");
}
unsafe impl ::windows::core::Interface for LockScreenCallEndRequestedEventArgs {
type Vtable = ILockScreenCallEndRequestedEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8190a363_6f27_46e9_aeb6_c0ae83e47dc7);
}
impl ::windows::core::RuntimeName for LockScreenCallEndRequestedEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.LockScreenCallEndRequestedEventArgs";
}
impl ::core::convert::From<LockScreenCallEndRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: LockScreenCallEndRequestedEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&LockScreenCallEndRequestedEventArgs> for ::windows::core::IUnknown {
fn from(value: &LockScreenCallEndRequestedEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for LockScreenCallEndRequestedEventArgs {
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 LockScreenCallEndRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<LockScreenCallEndRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: LockScreenCallEndRequestedEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&LockScreenCallEndRequestedEventArgs> for ::windows::core::IInspectable {
fn from(value: &LockScreenCallEndRequestedEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for LockScreenCallEndRequestedEventArgs {
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 LockScreenCallEndRequestedEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for LockScreenCallEndRequestedEventArgs {}
unsafe impl ::core::marker::Sync for LockScreenCallEndRequestedEventArgs {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct LockScreenCallUI(pub ::windows::core::IInspectable);
impl LockScreenCallUI {
pub fn Dismiss(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this)).ok() }
}
#[cfg(feature = "Foundation")]
pub fn EndRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<LockScreenCallUI, LockScreenCallEndRequestedEventArgs>>>(&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).7)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveEndRequested<'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).8)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn Closed<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<LockScreenCallUI, ::windows::core::IInspectable>>>(&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).9)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveClosed<'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).10)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn CallTitle(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetCallTitle<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for LockScreenCallUI {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.LockScreenCallUI;{c596fd8d-73c9-4a14-b021-ec1c50a3b727})");
}
unsafe impl ::windows::core::Interface for LockScreenCallUI {
type Vtable = ILockScreenCallUI_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc596fd8d_73c9_4a14_b021_ec1c50a3b727);
}
impl ::windows::core::RuntimeName for LockScreenCallUI {
const NAME: &'static str = "Windows.ApplicationModel.Calls.LockScreenCallUI";
}
impl ::core::convert::From<LockScreenCallUI> for ::windows::core::IUnknown {
fn from(value: LockScreenCallUI) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&LockScreenCallUI> for ::windows::core::IUnknown {
fn from(value: &LockScreenCallUI) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for LockScreenCallUI {
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 LockScreenCallUI {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<LockScreenCallUI> for ::windows::core::IInspectable {
fn from(value: LockScreenCallUI) -> Self {
value.0
}
}
impl ::core::convert::From<&LockScreenCallUI> for ::windows::core::IInspectable {
fn from(value: &LockScreenCallUI) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for LockScreenCallUI {
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 LockScreenCallUI {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for LockScreenCallUI {}
unsafe impl ::core::marker::Sync for LockScreenCallUI {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct MuteChangeEventArgs(pub ::windows::core::IInspectable);
impl MuteChangeEventArgs {
pub fn Muted(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for MuteChangeEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.MuteChangeEventArgs;{8585e159-0c41-432c-814d-c5f1fdf530be})");
}
unsafe impl ::windows::core::Interface for MuteChangeEventArgs {
type Vtable = IMuteChangeEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8585e159_0c41_432c_814d_c5f1fdf530be);
}
impl ::windows::core::RuntimeName for MuteChangeEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.MuteChangeEventArgs";
}
impl ::core::convert::From<MuteChangeEventArgs> for ::windows::core::IUnknown {
fn from(value: MuteChangeEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&MuteChangeEventArgs> for ::windows::core::IUnknown {
fn from(value: &MuteChangeEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for MuteChangeEventArgs {
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 MuteChangeEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<MuteChangeEventArgs> for ::windows::core::IInspectable {
fn from(value: MuteChangeEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&MuteChangeEventArgs> for ::windows::core::IInspectable {
fn from(value: &MuteChangeEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for MuteChangeEventArgs {
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 MuteChangeEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for MuteChangeEventArgs {}
unsafe impl ::core::marker::Sync for MuteChangeEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneAudioRoutingEndpoint(pub i32);
impl PhoneAudioRoutingEndpoint {
pub const Default: PhoneAudioRoutingEndpoint = PhoneAudioRoutingEndpoint(0i32);
pub const Bluetooth: PhoneAudioRoutingEndpoint = PhoneAudioRoutingEndpoint(1i32);
pub const Speakerphone: PhoneAudioRoutingEndpoint = PhoneAudioRoutingEndpoint(2i32);
}
impl ::core::convert::From<i32> for PhoneAudioRoutingEndpoint {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneAudioRoutingEndpoint {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneAudioRoutingEndpoint {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneAudioRoutingEndpoint;i4)");
}
impl ::windows::core::DefaultType for PhoneAudioRoutingEndpoint {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCall(pub ::windows::core::IInspectable);
impl PhoneCall {
#[cfg(feature = "Foundation")]
pub fn StatusChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneCall, ::windows::core::IInspectable>>>(&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).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveStatusChanged<'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).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn AudioDeviceChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneCall, ::windows::core::IInspectable>>>(&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).8)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveAudioDeviceChanged<'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).9)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn IsMutedChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneCall, ::windows::core::IInspectable>>>(&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).10)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveIsMutedChanged<'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).11)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn CallId(&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).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn IsMuted(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn Status(&self) -> ::windows::core::Result<PhoneCallStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallStatus>(result__)
}
}
pub fn AudioDevice(&self) -> ::windows::core::Result<PhoneCallAudioDevice> {
let this = self;
unsafe {
let mut result__: PhoneCallAudioDevice = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallAudioDevice>(result__)
}
}
pub fn GetPhoneCallInfo(&self) -> ::windows::core::Result<PhoneCallInfo> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallInfo>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn GetPhoneCallInfoAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallInfo>> {
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::<super::super::Foundation::IAsyncOperation<PhoneCallInfo>>(result__)
}
}
pub fn End(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn EndAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).19)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn SendDtmfKey(&self, key: DtmfKey, dtmftoneaudioplayback: DtmfToneAudioPlayback) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), key, dtmftoneaudioplayback, &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SendDtmfKeyAsync(&self, key: DtmfKey, dtmftoneaudioplayback: DtmfToneAudioPlayback) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this), key, dtmftoneaudioplayback, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn AcceptIncoming(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).22)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn AcceptIncomingAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).23)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn Hold(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).24)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn HoldAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).25)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn ResumeFromHold(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).26)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ResumeFromHoldAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).27)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn Mute(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).28)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn MuteAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).29)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn Unmute(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).30)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn UnmuteAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).31)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn RejectIncoming(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).32)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RejectIncomingAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).33)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn ChangeAudioDevice(&self, endpoint: PhoneCallAudioDevice) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).34)(::core::mem::transmute_copy(this), endpoint, &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ChangeAudioDeviceAsync(&self, endpoint: PhoneCallAudioDevice) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).35)(::core::mem::transmute_copy(this), endpoint, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallOperationStatus>>(result__)
}
}
pub fn GetFromId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(callid: Param0) -> ::windows::core::Result<PhoneCall> {
Self::IPhoneCallStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), callid.into_param().abi(), &mut result__).from_abi::<PhoneCall>(result__)
})
}
pub fn IPhoneCallStatics<R, F: FnOnce(&IPhoneCallStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCall, IPhoneCallStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCall {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCall;{c14ed0f8-c17d-59d2-9628-66e545b6cd21})");
}
unsafe impl ::windows::core::Interface for PhoneCall {
type Vtable = IPhoneCall_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc14ed0f8_c17d_59d2_9628_66e545b6cd21);
}
impl ::windows::core::RuntimeName for PhoneCall {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCall";
}
impl ::core::convert::From<PhoneCall> for ::windows::core::IUnknown {
fn from(value: PhoneCall) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCall> for ::windows::core::IUnknown {
fn from(value: &PhoneCall) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCall {
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 PhoneCall {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCall> for ::windows::core::IInspectable {
fn from(value: PhoneCall) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCall> for ::windows::core::IInspectable {
fn from(value: &PhoneCall) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCall {
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 PhoneCall {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCall {}
unsafe impl ::core::marker::Sync for PhoneCall {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallAudioDevice(pub i32);
impl PhoneCallAudioDevice {
pub const Unknown: PhoneCallAudioDevice = PhoneCallAudioDevice(0i32);
pub const LocalDevice: PhoneCallAudioDevice = PhoneCallAudioDevice(1i32);
pub const RemoteDevice: PhoneCallAudioDevice = PhoneCallAudioDevice(2i32);
}
impl ::core::convert::From<i32> for PhoneCallAudioDevice {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallAudioDevice {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallAudioDevice {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallAudioDevice;i4)");
}
impl ::windows::core::DefaultType for PhoneCallAudioDevice {
type DefaultType = Self;
}
pub struct PhoneCallBlocking {}
impl PhoneCallBlocking {
pub fn BlockUnknownNumbers() -> ::windows::core::Result<bool> {
Self::IPhoneCallBlockingStatics(|this| unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
})
}
pub fn SetBlockUnknownNumbers(value: bool) -> ::windows::core::Result<()> {
Self::IPhoneCallBlockingStatics(|this| unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() })
}
pub fn BlockPrivateNumbers() -> ::windows::core::Result<bool> {
Self::IPhoneCallBlockingStatics(|this| 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 SetBlockPrivateNumbers(value: bool) -> ::windows::core::Result<()> {
Self::IPhoneCallBlockingStatics(|this| unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value).ok() })
}
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn SetCallBlockingListAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<::windows::core::HSTRING>>>(phonenumberlist: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<bool>> {
Self::IPhoneCallBlockingStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), phonenumberlist.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<bool>>(result__)
})
}
pub fn IPhoneCallBlockingStatics<R, F: FnOnce(&IPhoneCallBlockingStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallBlocking, IPhoneCallBlockingStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
impl ::windows::core::RuntimeName for PhoneCallBlocking {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallBlocking";
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallDirection(pub i32);
impl PhoneCallDirection {
pub const Unknown: PhoneCallDirection = PhoneCallDirection(0i32);
pub const Incoming: PhoneCallDirection = PhoneCallDirection(1i32);
pub const Outgoing: PhoneCallDirection = PhoneCallDirection(2i32);
}
impl ::core::convert::From<i32> for PhoneCallDirection {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallDirection {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallDirection {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallDirection;i4)");
}
impl ::windows::core::DefaultType for PhoneCallDirection {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallHistoryEntry(pub ::windows::core::IInspectable);
impl PhoneCallHistoryEntry {
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<PhoneCallHistoryEntry, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Id(&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 Address(&self) -> ::windows::core::Result<PhoneCallHistoryEntryAddress> {
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::<PhoneCallHistoryEntryAddress>(result__)
}
}
pub fn SetAddress<'a, Param0: ::windows::core::IntoParam<'a, PhoneCallHistoryEntryAddress>>(&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 Duration(&self) -> ::windows::core::Result<super::super::Foundation::IReference<super::super::Foundation::TimeSpan>> {
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::IReference<super::super::Foundation::TimeSpan>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetDuration<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::IReference<super::super::Foundation::TimeSpan>>>(&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 IsCallerIdBlocked(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsCallerIdBlocked(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsEmergency(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsEmergency(&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 IsIncoming(&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__)
}
}
pub fn SetIsIncoming(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsMissed(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsMissed(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsRinging(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).19)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsRinging(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsSeen(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsSeen(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).22)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsSuppressed(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).23)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsSuppressed(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).24)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn IsVoicemail(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).25)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SetIsVoicemail(&self, value: bool) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).26)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Media(&self) -> ::windows::core::Result<PhoneCallHistoryEntryMedia> {
let this = self;
unsafe {
let mut result__: PhoneCallHistoryEntryMedia = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).27)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallHistoryEntryMedia>(result__)
}
}
pub fn SetMedia(&self, value: PhoneCallHistoryEntryMedia) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).28)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn OtherAppReadAccess(&self) -> ::windows::core::Result<PhoneCallHistoryEntryOtherAppReadAccess> {
let this = self;
unsafe {
let mut result__: PhoneCallHistoryEntryOtherAppReadAccess = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).29)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallHistoryEntryOtherAppReadAccess>(result__)
}
}
pub fn SetOtherAppReadAccess(&self, value: PhoneCallHistoryEntryOtherAppReadAccess) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).30)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn RemoteId(&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).31)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetRemoteId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).32)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn SourceDisplayName(&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).33)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SourceId(&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).34)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetSourceId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).35)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn SourceIdKind(&self) -> ::windows::core::Result<PhoneCallHistorySourceIdKind> {
let this = self;
unsafe {
let mut result__: PhoneCallHistorySourceIdKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).36)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallHistorySourceIdKind>(result__)
}
}
pub fn SetSourceIdKind(&self, value: PhoneCallHistorySourceIdKind) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).37)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation")]
pub fn StartTime(&self) -> ::windows::core::Result<super::super::Foundation::DateTime> {
let this = self;
unsafe {
let mut result__: super::super::Foundation::DateTime = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).38)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::DateTime>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetStartTime<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::DateTime>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).39)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntry {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryEntry;{fab0e129-32a4-4b85-83d1-f90d8c23a857})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryEntry {
type Vtable = IPhoneCallHistoryEntry_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfab0e129_32a4_4b85_83d1_f90d8c23a857);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryEntry {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryEntry";
}
impl ::core::convert::From<PhoneCallHistoryEntry> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryEntry) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntry> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryEntry) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryEntry {
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 PhoneCallHistoryEntry {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryEntry> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryEntry) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntry> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryEntry) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryEntry {
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 PhoneCallHistoryEntry {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryEntry {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryEntry {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallHistoryEntryAddress(pub ::windows::core::IInspectable);
impl PhoneCallHistoryEntryAddress {
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<PhoneCallHistoryEntryAddress, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn ContactId(&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 SetContactId<'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() }
}
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).8)(::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 = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn RawAddress(&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 SetRawAddress<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn RawAddressKind(&self) -> ::windows::core::Result<PhoneCallHistoryEntryRawAddressKind> {
let this = self;
unsafe {
let mut result__: PhoneCallHistoryEntryRawAddressKind = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallHistoryEntryRawAddressKind>(result__)
}
}
pub fn SetRawAddressKind(&self, value: PhoneCallHistoryEntryRawAddressKind) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn Create<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(rawaddress: Param0, rawaddresskind: PhoneCallHistoryEntryRawAddressKind) -> ::windows::core::Result<PhoneCallHistoryEntryAddress> {
Self::IPhoneCallHistoryEntryAddressFactory(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), rawaddress.into_param().abi(), rawaddresskind, &mut result__).from_abi::<PhoneCallHistoryEntryAddress>(result__)
})
}
pub fn IPhoneCallHistoryEntryAddressFactory<R, F: FnOnce(&IPhoneCallHistoryEntryAddressFactory) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallHistoryEntryAddress, IPhoneCallHistoryEntryAddressFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryAddress {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryAddress;{30f159da-3955-4042-84e6-66eebf82e67f})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryEntryAddress {
type Vtable = IPhoneCallHistoryEntryAddress_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x30f159da_3955_4042_84e6_66eebf82e67f);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryEntryAddress {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryEntryAddress";
}
impl ::core::convert::From<PhoneCallHistoryEntryAddress> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryEntryAddress) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryAddress> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryEntryAddress) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryEntryAddress {
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 PhoneCallHistoryEntryAddress {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryEntryAddress> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryEntryAddress) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryAddress> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryEntryAddress) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryEntryAddress {
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 PhoneCallHistoryEntryAddress {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryEntryAddress {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryEntryAddress {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallHistoryEntryMedia(pub i32);
impl PhoneCallHistoryEntryMedia {
pub const Audio: PhoneCallHistoryEntryMedia = PhoneCallHistoryEntryMedia(0i32);
pub const Video: PhoneCallHistoryEntryMedia = PhoneCallHistoryEntryMedia(1i32);
}
impl ::core::convert::From<i32> for PhoneCallHistoryEntryMedia {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistoryEntryMedia {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryMedia {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryMedia;i4)");
}
impl ::windows::core::DefaultType for PhoneCallHistoryEntryMedia {
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 PhoneCallHistoryEntryOtherAppReadAccess(pub i32);
impl PhoneCallHistoryEntryOtherAppReadAccess {
pub const Full: PhoneCallHistoryEntryOtherAppReadAccess = PhoneCallHistoryEntryOtherAppReadAccess(0i32);
pub const SystemOnly: PhoneCallHistoryEntryOtherAppReadAccess = PhoneCallHistoryEntryOtherAppReadAccess(1i32);
}
impl ::core::convert::From<i32> for PhoneCallHistoryEntryOtherAppReadAccess {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistoryEntryOtherAppReadAccess {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryOtherAppReadAccess {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryOtherAppReadAccess;i4)");
}
impl ::windows::core::DefaultType for PhoneCallHistoryEntryOtherAppReadAccess {
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 PhoneCallHistoryEntryQueryDesiredMedia(pub u32);
impl PhoneCallHistoryEntryQueryDesiredMedia {
pub const None: PhoneCallHistoryEntryQueryDesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia(0u32);
pub const Audio: PhoneCallHistoryEntryQueryDesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia(1u32);
pub const Video: PhoneCallHistoryEntryQueryDesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia(2u32);
pub const All: PhoneCallHistoryEntryQueryDesiredMedia = PhoneCallHistoryEntryQueryDesiredMedia(4294967295u32);
}
impl ::core::convert::From<u32> for PhoneCallHistoryEntryQueryDesiredMedia {
fn from(value: u32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistoryEntryQueryDesiredMedia {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryQueryDesiredMedia {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryQueryDesiredMedia;u4)");
}
impl ::windows::core::DefaultType for PhoneCallHistoryEntryQueryDesiredMedia {
type DefaultType = Self;
}
impl ::core::ops::BitOr for PhoneCallHistoryEntryQueryDesiredMedia {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ::core::ops::BitAnd for PhoneCallHistoryEntryQueryDesiredMedia {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl ::core::ops::BitOrAssign for PhoneCallHistoryEntryQueryDesiredMedia {
fn bitor_assign(&mut self, rhs: Self) {
self.0.bitor_assign(rhs.0)
}
}
impl ::core::ops::BitAndAssign for PhoneCallHistoryEntryQueryDesiredMedia {
fn bitand_assign(&mut self, rhs: Self) {
self.0.bitand_assign(rhs.0)
}
}
impl ::core::ops::Not for PhoneCallHistoryEntryQueryDesiredMedia {
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 PhoneCallHistoryEntryQueryOptions(pub ::windows::core::IInspectable);
impl PhoneCallHistoryEntryQueryOptions {
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<PhoneCallHistoryEntryQueryOptions, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn DesiredMedia(&self) -> ::windows::core::Result<PhoneCallHistoryEntryQueryDesiredMedia> {
let this = self;
unsafe {
let mut result__: PhoneCallHistoryEntryQueryDesiredMedia = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallHistoryEntryQueryDesiredMedia>(result__)
}
}
pub fn SetDesiredMedia(&self, value: PhoneCallHistoryEntryQueryDesiredMedia) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), value).ok() }
}
#[cfg(feature = "Foundation_Collections")]
pub fn SourceIds(&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__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryQueryOptions {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryQueryOptions;{9c5fe15c-8bed-40ca-b06e-c4ca8eae5c87})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryEntryQueryOptions {
type Vtable = IPhoneCallHistoryEntryQueryOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x9c5fe15c_8bed_40ca_b06e_c4ca8eae5c87);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryEntryQueryOptions {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryEntryQueryOptions";
}
impl ::core::convert::From<PhoneCallHistoryEntryQueryOptions> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryEntryQueryOptions) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryQueryOptions> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryEntryQueryOptions) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryEntryQueryOptions {
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 PhoneCallHistoryEntryQueryOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryEntryQueryOptions> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryEntryQueryOptions) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryQueryOptions> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryEntryQueryOptions) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryEntryQueryOptions {
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 PhoneCallHistoryEntryQueryOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryEntryQueryOptions {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryEntryQueryOptions {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallHistoryEntryRawAddressKind(pub i32);
impl PhoneCallHistoryEntryRawAddressKind {
pub const PhoneNumber: PhoneCallHistoryEntryRawAddressKind = PhoneCallHistoryEntryRawAddressKind(0i32);
pub const Custom: PhoneCallHistoryEntryRawAddressKind = PhoneCallHistoryEntryRawAddressKind(1i32);
}
impl ::core::convert::From<i32> for PhoneCallHistoryEntryRawAddressKind {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistoryEntryRawAddressKind {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryRawAddressKind {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryRawAddressKind;i4)");
}
impl ::windows::core::DefaultType for PhoneCallHistoryEntryRawAddressKind {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallHistoryEntryReader(pub ::windows::core::IInspectable);
impl PhoneCallHistoryEntryReader {
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn ReadBatchAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Foundation::Collections::IVectorView<PhoneCallHistoryEntry>>> {
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::IAsyncOperation<super::super::Foundation::Collections::IVectorView<PhoneCallHistoryEntry>>>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryEntryReader {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryEntryReader;{61ece4be-8d86-479f-8404-a9846920fee6})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryEntryReader {
type Vtable = IPhoneCallHistoryEntryReader_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x61ece4be_8d86_479f_8404_a9846920fee6);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryEntryReader {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryEntryReader";
}
impl ::core::convert::From<PhoneCallHistoryEntryReader> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryEntryReader) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryReader> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryEntryReader) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryEntryReader {
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 PhoneCallHistoryEntryReader {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryEntryReader> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryEntryReader) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryEntryReader> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryEntryReader) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryEntryReader {
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 PhoneCallHistoryEntryReader {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryEntryReader {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryEntryReader {}
pub struct PhoneCallHistoryManager {}
impl PhoneCallHistoryManager {
#[cfg(feature = "Foundation")]
pub fn RequestStoreAsync(accesstype: PhoneCallHistoryStoreAccessType) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallHistoryStore>> {
Self::IPhoneCallHistoryManagerStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), accesstype, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallHistoryStore>>(result__)
})
}
#[cfg(feature = "System")]
pub fn GetForUser<'a, Param0: ::windows::core::IntoParam<'a, super::super::System::User>>(user: Param0) -> ::windows::core::Result<PhoneCallHistoryManagerForUser> {
Self::IPhoneCallHistoryManagerStatics2(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), user.into_param().abi(), &mut result__).from_abi::<PhoneCallHistoryManagerForUser>(result__)
})
}
pub fn IPhoneCallHistoryManagerStatics<R, F: FnOnce(&IPhoneCallHistoryManagerStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallHistoryManager, IPhoneCallHistoryManagerStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IPhoneCallHistoryManagerStatics2<R, F: FnOnce(&IPhoneCallHistoryManagerStatics2) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallHistoryManager, IPhoneCallHistoryManagerStatics2> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
impl ::windows::core::RuntimeName for PhoneCallHistoryManager {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryManager";
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallHistoryManagerForUser(pub ::windows::core::IInspectable);
impl PhoneCallHistoryManagerForUser {
#[cfg(feature = "Foundation")]
pub fn RequestStoreAsync(&self, accesstype: PhoneCallHistoryStoreAccessType) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallHistoryStore>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), accesstype, &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallHistoryStore>>(result__)
}
}
#[cfg(feature = "System")]
pub fn User(&self) -> ::windows::core::Result<super::super::System::User> {
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::System::User>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryManagerForUser {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryManagerForUser;{d925c523-f55f-4353-9db4-0205a5265a55})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryManagerForUser {
type Vtable = IPhoneCallHistoryManagerForUser_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd925c523_f55f_4353_9db4_0205a5265a55);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryManagerForUser {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryManagerForUser";
}
impl ::core::convert::From<PhoneCallHistoryManagerForUser> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryManagerForUser) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryManagerForUser> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryManagerForUser) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryManagerForUser {
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 PhoneCallHistoryManagerForUser {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryManagerForUser> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryManagerForUser) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryManagerForUser> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryManagerForUser) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryManagerForUser {
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 PhoneCallHistoryManagerForUser {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryManagerForUser {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryManagerForUser {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallHistorySourceIdKind(pub i32);
impl PhoneCallHistorySourceIdKind {
pub const CellularPhoneLineId: PhoneCallHistorySourceIdKind = PhoneCallHistorySourceIdKind(0i32);
pub const PackageFamilyName: PhoneCallHistorySourceIdKind = PhoneCallHistorySourceIdKind(1i32);
}
impl ::core::convert::From<i32> for PhoneCallHistorySourceIdKind {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistorySourceIdKind {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistorySourceIdKind {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistorySourceIdKind;i4)");
}
impl ::windows::core::DefaultType for PhoneCallHistorySourceIdKind {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallHistoryStore(pub ::windows::core::IInspectable);
impl PhoneCallHistoryStore {
#[cfg(feature = "Foundation")]
pub fn GetEntryAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, callhistoryentryid: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallHistoryEntry>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), callhistoryentryid.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallHistoryEntry>>(result__)
}
}
pub fn GetEntryReader(&self) -> ::windows::core::Result<PhoneCallHistoryEntryReader> {
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::<PhoneCallHistoryEntryReader>(result__)
}
}
pub fn GetEntryReaderWithOptions<'a, Param0: ::windows::core::IntoParam<'a, PhoneCallHistoryEntryQueryOptions>>(&self, queryoptions: Param0) -> ::windows::core::Result<PhoneCallHistoryEntryReader> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), queryoptions.into_param().abi(), &mut result__).from_abi::<PhoneCallHistoryEntryReader>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SaveEntryAsync<'a, Param0: ::windows::core::IntoParam<'a, PhoneCallHistoryEntry>>(&self, callhistoryentry: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), callhistoryentry.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn DeleteEntryAsync<'a, Param0: ::windows::core::IntoParam<'a, PhoneCallHistoryEntry>>(&self, callhistoryentry: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), callhistoryentry.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn DeleteEntriesAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<PhoneCallHistoryEntry>>>(&self, callhistoryentries: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), callhistoryentries.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn MarkEntryAsSeenAsync<'a, Param0: ::windows::core::IntoParam<'a, PhoneCallHistoryEntry>>(&self, callhistoryentry: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), callhistoryentry.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn MarkEntriesAsSeenAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<PhoneCallHistoryEntry>>>(&self, callhistoryentries: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), callhistoryentries.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn GetUnseenCountAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<u32>> {
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::IAsyncOperation<u32>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn MarkAllAsSeenAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn GetSourcesUnseenCountAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<::windows::core::HSTRING>>>(&self, sourceids: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<u32>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), sourceids.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<u32>>(result__)
}
}
#[cfg(all(feature = "Foundation", feature = "Foundation_Collections"))]
pub fn MarkSourcesAsSeenAsync<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::Collections::IIterable<::windows::core::HSTRING>>>(&self, sourceids: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), sourceids.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncAction>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryStore {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallHistoryStore;{2f907db8-b40e-422b-8545-cb1910a61c52})");
}
unsafe impl ::windows::core::Interface for PhoneCallHistoryStore {
type Vtable = IPhoneCallHistoryStore_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x2f907db8_b40e_422b_8545_cb1910a61c52);
}
impl ::windows::core::RuntimeName for PhoneCallHistoryStore {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallHistoryStore";
}
impl ::core::convert::From<PhoneCallHistoryStore> for ::windows::core::IUnknown {
fn from(value: PhoneCallHistoryStore) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallHistoryStore> for ::windows::core::IUnknown {
fn from(value: &PhoneCallHistoryStore) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallHistoryStore {
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 PhoneCallHistoryStore {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallHistoryStore> for ::windows::core::IInspectable {
fn from(value: PhoneCallHistoryStore) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallHistoryStore> for ::windows::core::IInspectable {
fn from(value: &PhoneCallHistoryStore) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallHistoryStore {
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 PhoneCallHistoryStore {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallHistoryStore {}
unsafe impl ::core::marker::Sync for PhoneCallHistoryStore {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallHistoryStoreAccessType(pub i32);
impl PhoneCallHistoryStoreAccessType {
pub const AppEntriesReadWrite: PhoneCallHistoryStoreAccessType = PhoneCallHistoryStoreAccessType(0i32);
pub const AllEntriesLimitedReadWrite: PhoneCallHistoryStoreAccessType = PhoneCallHistoryStoreAccessType(1i32);
pub const AllEntriesReadWrite: PhoneCallHistoryStoreAccessType = PhoneCallHistoryStoreAccessType(2i32);
}
impl ::core::convert::From<i32> for PhoneCallHistoryStoreAccessType {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallHistoryStoreAccessType {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallHistoryStoreAccessType {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallHistoryStoreAccessType;i4)");
}
impl ::windows::core::DefaultType for PhoneCallHistoryStoreAccessType {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallInfo(pub ::windows::core::IInspectable);
impl PhoneCallInfo {
pub fn LineId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = self;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
pub fn IsHoldSupported(&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__)
}
}
#[cfg(feature = "Foundation")]
pub fn StartTime(&self) -> ::windows::core::Result<super::super::Foundation::DateTime> {
let this = self;
unsafe {
let mut result__: super::super::Foundation::DateTime = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::DateTime>(result__)
}
}
pub fn PhoneNumber(&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 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).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn CallDirection(&self) -> ::windows::core::Result<PhoneCallDirection> {
let this = self;
unsafe {
let mut result__: PhoneCallDirection = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallDirection>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallInfo {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallInfo;{22b42577-3e4d-5dc6-89c2-469fe5ffc189})");
}
unsafe impl ::windows::core::Interface for PhoneCallInfo {
type Vtable = IPhoneCallInfo_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x22b42577_3e4d_5dc6_89c2_469fe5ffc189);
}
impl ::windows::core::RuntimeName for PhoneCallInfo {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallInfo";
}
impl ::core::convert::From<PhoneCallInfo> for ::windows::core::IUnknown {
fn from(value: PhoneCallInfo) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallInfo> for ::windows::core::IUnknown {
fn from(value: &PhoneCallInfo) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallInfo {
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 PhoneCallInfo {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallInfo> for ::windows::core::IInspectable {
fn from(value: PhoneCallInfo) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallInfo> for ::windows::core::IInspectable {
fn from(value: &PhoneCallInfo) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallInfo {
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 PhoneCallInfo {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallInfo {}
unsafe impl ::core::marker::Sync for PhoneCallInfo {}
pub struct PhoneCallManager {}
impl PhoneCallManager {
pub fn ShowPhoneCallUI<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(phonenumber: Param0, displayname: Param1) -> ::windows::core::Result<()> {
Self::IPhoneCallManagerStatics(|this| unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), phonenumber.into_param().abi(), displayname.into_param().abi()).ok() })
}
#[cfg(feature = "Foundation")]
pub fn CallStateChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::EventHandler<::windows::core::IInspectable>>>(handler: Param0) -> ::windows::core::Result<super::super::Foundation::EventRegistrationToken> {
Self::IPhoneCallManagerStatics2(|this| unsafe {
let mut result__: super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
})
}
#[cfg(feature = "Foundation")]
pub fn RemoveCallStateChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::EventRegistrationToken>>(token: Param0) -> ::windows::core::Result<()> {
Self::IPhoneCallManagerStatics2(|this| unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() })
}
pub fn IsCallActive() -> ::windows::core::Result<bool> {
Self::IPhoneCallManagerStatics2(|this| 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 IsCallIncoming() -> ::windows::core::Result<bool> {
Self::IPhoneCallManagerStatics2(|this| 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 ShowPhoneCallSettingsUI() -> ::windows::core::Result<()> {
Self::IPhoneCallManagerStatics2(|this| unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this)).ok() })
}
#[cfg(feature = "Foundation")]
pub fn RequestStoreAsync() -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallStore>> {
Self::IPhoneCallManagerStatics2(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallStore>>(result__)
})
}
pub fn IPhoneCallManagerStatics<R, F: FnOnce(&IPhoneCallManagerStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallManager, IPhoneCallManagerStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn IPhoneCallManagerStatics2<R, F: FnOnce(&IPhoneCallManagerStatics2) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallManager, IPhoneCallManagerStatics2> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
impl ::windows::core::RuntimeName for PhoneCallManager {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallManager";
}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneCallMedia(pub i32);
impl PhoneCallMedia {
pub const Audio: PhoneCallMedia = PhoneCallMedia(0i32);
pub const AudioAndVideo: PhoneCallMedia = PhoneCallMedia(1i32);
pub const AudioAndRealTimeText: PhoneCallMedia = PhoneCallMedia(2i32);
}
impl ::core::convert::From<i32> for PhoneCallMedia {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallMedia {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallMedia {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallMedia;i4)");
}
impl ::windows::core::DefaultType for PhoneCallMedia {
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 PhoneCallOperationStatus(pub i32);
impl PhoneCallOperationStatus {
pub const Succeeded: PhoneCallOperationStatus = PhoneCallOperationStatus(0i32);
pub const OtherFailure: PhoneCallOperationStatus = PhoneCallOperationStatus(1i32);
pub const TimedOut: PhoneCallOperationStatus = PhoneCallOperationStatus(2i32);
pub const ConnectionLost: PhoneCallOperationStatus = PhoneCallOperationStatus(3i32);
pub const InvalidCallState: PhoneCallOperationStatus = PhoneCallOperationStatus(4i32);
}
impl ::core::convert::From<i32> for PhoneCallOperationStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallOperationStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallOperationStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallOperationStatus;i4)");
}
impl ::windows::core::DefaultType for PhoneCallOperationStatus {
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 PhoneCallStatus(pub i32);
impl PhoneCallStatus {
pub const Lost: PhoneCallStatus = PhoneCallStatus(0i32);
pub const Incoming: PhoneCallStatus = PhoneCallStatus(1i32);
pub const Dialing: PhoneCallStatus = PhoneCallStatus(2i32);
pub const Talking: PhoneCallStatus = PhoneCallStatus(3i32);
pub const Held: PhoneCallStatus = PhoneCallStatus(4i32);
pub const Ended: PhoneCallStatus = PhoneCallStatus(5i32);
}
impl ::core::convert::From<i32> for PhoneCallStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneCallStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneCallStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneCallStatus;i4)");
}
impl ::windows::core::DefaultType for PhoneCallStatus {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallStore(pub ::windows::core::IInspectable);
impl PhoneCallStore {
#[cfg(feature = "Foundation")]
pub fn IsEmergencyPhoneNumberAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, number: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<bool>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), number.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<bool>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn GetDefaultLineAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<::windows::core::GUID>> {
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::IAsyncOperation<::windows::core::GUID>>(result__)
}
}
pub fn RequestLineWatcher(&self) -> ::windows::core::Result<PhoneLineWatcher> {
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::<PhoneLineWatcher>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallStore {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallStore;{5f610748-18a6-4173-86d1-28be9dc62dba})");
}
unsafe impl ::windows::core::Interface for PhoneCallStore {
type Vtable = IPhoneCallStore_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x5f610748_18a6_4173_86d1_28be9dc62dba);
}
impl ::windows::core::RuntimeName for PhoneCallStore {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallStore";
}
impl ::core::convert::From<PhoneCallStore> for ::windows::core::IUnknown {
fn from(value: PhoneCallStore) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallStore> for ::windows::core::IUnknown {
fn from(value: &PhoneCallStore) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallStore {
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 PhoneCallStore {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallStore> for ::windows::core::IInspectable {
fn from(value: PhoneCallStore) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallStore> for ::windows::core::IInspectable {
fn from(value: &PhoneCallStore) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallStore {
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 PhoneCallStore {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallStore {}
unsafe impl ::core::marker::Sync for PhoneCallStore {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallVideoCapabilities(pub ::windows::core::IInspectable);
impl PhoneCallVideoCapabilities {
pub fn IsVideoCallingCapable(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallVideoCapabilities {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallVideoCapabilities;{02382786-b16a-4fdb-be3b-c4240e13ad0d})");
}
unsafe impl ::windows::core::Interface for PhoneCallVideoCapabilities {
type Vtable = IPhoneCallVideoCapabilities_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x02382786_b16a_4fdb_be3b_c4240e13ad0d);
}
impl ::windows::core::RuntimeName for PhoneCallVideoCapabilities {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallVideoCapabilities";
}
impl ::core::convert::From<PhoneCallVideoCapabilities> for ::windows::core::IUnknown {
fn from(value: PhoneCallVideoCapabilities) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallVideoCapabilities> for ::windows::core::IUnknown {
fn from(value: &PhoneCallVideoCapabilities) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallVideoCapabilities {
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 PhoneCallVideoCapabilities {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallVideoCapabilities> for ::windows::core::IInspectable {
fn from(value: PhoneCallVideoCapabilities) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallVideoCapabilities> for ::windows::core::IInspectable {
fn from(value: &PhoneCallVideoCapabilities) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallVideoCapabilities {
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 PhoneCallVideoCapabilities {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallVideoCapabilities {}
unsafe impl ::core::marker::Sync for PhoneCallVideoCapabilities {}
pub struct PhoneCallVideoCapabilitiesManager {}
impl PhoneCallVideoCapabilitiesManager {
#[cfg(feature = "Foundation")]
pub fn GetCapabilitiesAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(phonenumber: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallVideoCapabilities>> {
Self::IPhoneCallVideoCapabilitiesManagerStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), phonenumber.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneCallVideoCapabilities>>(result__)
})
}
pub fn IPhoneCallVideoCapabilitiesManagerStatics<R, F: FnOnce(&IPhoneCallVideoCapabilitiesManagerStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneCallVideoCapabilitiesManager, IPhoneCallVideoCapabilitiesManagerStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
impl ::windows::core::RuntimeName for PhoneCallVideoCapabilitiesManager {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallVideoCapabilitiesManager";
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneCallsResult(pub ::windows::core::IInspectable);
impl PhoneCallsResult {
pub fn OperationStatus(&self) -> ::windows::core::Result<PhoneLineOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneLineOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneLineOperationStatus>(result__)
}
}
#[cfg(feature = "Foundation_Collections")]
pub fn AllActivePhoneCalls(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IVectorView<PhoneCall>> {
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<PhoneCall>>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneCallsResult {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneCallsResult;{1bfad365-57cf-57dd-986d-b057c91eac33})");
}
unsafe impl ::windows::core::Interface for PhoneCallsResult {
type Vtable = IPhoneCallsResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x1bfad365_57cf_57dd_986d_b057c91eac33);
}
impl ::windows::core::RuntimeName for PhoneCallsResult {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneCallsResult";
}
impl ::core::convert::From<PhoneCallsResult> for ::windows::core::IUnknown {
fn from(value: PhoneCallsResult) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneCallsResult> for ::windows::core::IUnknown {
fn from(value: &PhoneCallsResult) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneCallsResult {
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 PhoneCallsResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneCallsResult> for ::windows::core::IInspectable {
fn from(value: PhoneCallsResult) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneCallsResult> for ::windows::core::IInspectable {
fn from(value: &PhoneCallsResult) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneCallsResult {
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 PhoneCallsResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneCallsResult {}
unsafe impl ::core::marker::Sync for PhoneCallsResult {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneDialOptions(pub ::windows::core::IInspectable);
impl PhoneDialOptions {
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<PhoneDialOptions, ::windows::core::IActivationFactory> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
pub fn Number(&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 SetNumber<'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() }
}
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).8)(::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 = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "ApplicationModel_Contacts")]
pub fn Contact(&self) -> ::windows::core::Result<super::Contacts::Contact> {
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::Contacts::Contact>(result__)
}
}
#[cfg(feature = "ApplicationModel_Contacts")]
pub fn SetContact<'a, Param0: ::windows::core::IntoParam<'a, super::Contacts::Contact>>(&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 = "ApplicationModel_Contacts")]
pub fn ContactPhone(&self) -> ::windows::core::Result<super::Contacts::ContactPhone> {
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::Contacts::ContactPhone>(result__)
}
}
#[cfg(feature = "ApplicationModel_Contacts")]
pub fn SetContactPhone<'a, Param0: ::windows::core::IntoParam<'a, super::Contacts::ContactPhone>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn Media(&self) -> ::windows::core::Result<PhoneCallMedia> {
let this = self;
unsafe {
let mut result__: PhoneCallMedia = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallMedia>(result__)
}
}
pub fn SetMedia(&self, value: PhoneCallMedia) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn AudioEndpoint(&self) -> ::windows::core::Result<PhoneAudioRoutingEndpoint> {
let this = self;
unsafe {
let mut result__: PhoneAudioRoutingEndpoint = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneAudioRoutingEndpoint>(result__)
}
}
pub fn SetAudioEndpoint(&self, value: PhoneAudioRoutingEndpoint) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), value).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneDialOptions {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneDialOptions;{b639c4b8-f06f-36cb-a863-823742b5f2d4})");
}
unsafe impl ::windows::core::Interface for PhoneDialOptions {
type Vtable = IPhoneDialOptions_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xb639c4b8_f06f_36cb_a863_823742b5f2d4);
}
impl ::windows::core::RuntimeName for PhoneDialOptions {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneDialOptions";
}
impl ::core::convert::From<PhoneDialOptions> for ::windows::core::IUnknown {
fn from(value: PhoneDialOptions) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneDialOptions> for ::windows::core::IUnknown {
fn from(value: &PhoneDialOptions) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneDialOptions {
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 PhoneDialOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneDialOptions> for ::windows::core::IInspectable {
fn from(value: PhoneDialOptions) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneDialOptions> for ::windows::core::IInspectable {
fn from(value: &PhoneDialOptions) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneDialOptions {
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 PhoneDialOptions {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneDialOptions {}
unsafe impl ::core::marker::Sync for PhoneDialOptions {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLine(pub ::windows::core::IInspectable);
impl PhoneLine {
#[cfg(feature = "Foundation")]
pub fn LineChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLine, ::windows::core::IInspectable>>>(&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).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveLineChanged<'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).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn Id(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = self;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
#[cfg(feature = "UI")]
pub fn DisplayColor(&self) -> ::windows::core::Result<super::super::UI::Color> {
let this = self;
unsafe {
let mut result__: super::super::UI::Color = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::UI::Color>(result__)
}
}
pub fn NetworkState(&self) -> ::windows::core::Result<PhoneNetworkState> {
let this = self;
unsafe {
let mut result__: PhoneNetworkState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneNetworkState>(result__)
}
}
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).11)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn Voicemail(&self) -> ::windows::core::Result<PhoneVoicemail> {
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::<PhoneVoicemail>(result__)
}
}
pub fn NetworkName(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = self;
unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn CellularDetails(&self) -> ::windows::core::Result<PhoneLineCellularDetails> {
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::<PhoneLineCellularDetails>(result__)
}
}
pub fn Transport(&self) -> ::windows::core::Result<PhoneLineTransport> {
let this = self;
unsafe {
let mut result__: PhoneLineTransport = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneLineTransport>(result__)
}
}
pub fn CanDial(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn SupportsTile(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn VideoCallingCapabilities(&self) -> ::windows::core::Result<PhoneCallVideoCapabilities> {
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::<PhoneCallVideoCapabilities>(result__)
}
}
pub fn LineConfiguration(&self) -> ::windows::core::Result<PhoneLineConfiguration> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).19)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneLineConfiguration>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn IsImmediateDialNumberAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, number: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<bool>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), number.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<bool>>(result__)
}
}
pub fn Dial<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, number: Param0, displayname: Param1) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this), number.into_param().abi(), displayname.into_param().abi()).ok() }
}
pub fn DialWithOptions<'a, Param0: ::windows::core::IntoParam<'a, PhoneDialOptions>>(&self, options: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).22)(::core::mem::transmute_copy(this), options.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn FromIdAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::GUID>>(lineid: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneLine>> {
Self::IPhoneLineStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), lineid.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneLine>>(result__)
})
}
pub fn EnableTextReply(&self, value: bool) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IPhoneLine2>(self)?;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn TransportDeviceId(&self) -> ::windows::core::Result<::windows::core::HSTRING> {
let this = &::windows::core::Interface::cast::<IPhoneLine2>(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 DialWithResult<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, number: Param0, displayname: Param1) -> ::windows::core::Result<PhoneLineDialResult> {
let this = &::windows::core::Interface::cast::<IPhoneLine3>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), number.into_param().abi(), displayname.into_param().abi(), &mut result__).from_abi::<PhoneLineDialResult>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn DialWithResultAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, number: Param0, displayname: Param1) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneLineDialResult>> {
let this = &::windows::core::Interface::cast::<IPhoneLine3>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), number.into_param().abi(), displayname.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<PhoneLineDialResult>>(result__)
}
}
pub fn GetAllActivePhoneCalls(&self) -> ::windows::core::Result<PhoneCallsResult> {
let this = &::windows::core::Interface::cast::<IPhoneLine3>(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::<PhoneCallsResult>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn GetAllActivePhoneCallsAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<PhoneCallsResult>> {
let this = &::windows::core::Interface::cast::<IPhoneLine3>(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::IAsyncOperation<PhoneCallsResult>>(result__)
}
}
pub fn IPhoneLineStatics<R, F: FnOnce(&IPhoneLineStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneLine, IPhoneLineStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLine {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLine;{27c66f30-6a69-34ca-a2ba-65302530c311})");
}
unsafe impl ::windows::core::Interface for PhoneLine {
type Vtable = IPhoneLine_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x27c66f30_6a69_34ca_a2ba_65302530c311);
}
impl ::windows::core::RuntimeName for PhoneLine {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLine";
}
impl ::core::convert::From<PhoneLine> for ::windows::core::IUnknown {
fn from(value: PhoneLine) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLine> for ::windows::core::IUnknown {
fn from(value: &PhoneLine) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLine {
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 PhoneLine {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLine> for ::windows::core::IInspectable {
fn from(value: PhoneLine) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLine> for ::windows::core::IInspectable {
fn from(value: &PhoneLine) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLine {
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 PhoneLine {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLine {}
unsafe impl ::core::marker::Sync for PhoneLine {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineCellularDetails(pub ::windows::core::IInspectable);
impl PhoneLineCellularDetails {
pub fn SimState(&self) -> ::windows::core::Result<PhoneSimState> {
let this = self;
unsafe {
let mut result__: PhoneSimState = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneSimState>(result__)
}
}
pub fn SimSlotIndex(&self) -> ::windows::core::Result<i32> {
let this = self;
unsafe {
let mut result__: i32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<i32>(result__)
}
}
pub fn IsModemOn(&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 RegistrationRejectCode(&self) -> ::windows::core::Result<i32> {
let this = self;
unsafe {
let mut result__: i32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this), &mut result__).from_abi::<i32>(result__)
}
}
pub fn GetNetworkOperatorDisplayText(&self, location: PhoneLineNetworkOperatorDisplayTextLocation) -> ::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), location, &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineCellularDetails {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineCellularDetails;{192601d5-147c-4769-b673-98a5ec8426cb})");
}
unsafe impl ::windows::core::Interface for PhoneLineCellularDetails {
type Vtable = IPhoneLineCellularDetails_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x192601d5_147c_4769_b673_98a5ec8426cb);
}
impl ::windows::core::RuntimeName for PhoneLineCellularDetails {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineCellularDetails";
}
impl ::core::convert::From<PhoneLineCellularDetails> for ::windows::core::IUnknown {
fn from(value: PhoneLineCellularDetails) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineCellularDetails> for ::windows::core::IUnknown {
fn from(value: &PhoneLineCellularDetails) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineCellularDetails {
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 PhoneLineCellularDetails {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineCellularDetails> for ::windows::core::IInspectable {
fn from(value: PhoneLineCellularDetails) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineCellularDetails> for ::windows::core::IInspectable {
fn from(value: &PhoneLineCellularDetails) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineCellularDetails {
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 PhoneLineCellularDetails {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineCellularDetails {}
unsafe impl ::core::marker::Sync for PhoneLineCellularDetails {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineConfiguration(pub ::windows::core::IInspectable);
impl PhoneLineConfiguration {
pub fn IsVideoCallingEnabled(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
#[cfg(feature = "Foundation_Collections")]
pub fn ExtendedProperties(&self) -> ::windows::core::Result<super::super::Foundation::Collections::IMapView<::windows::core::HSTRING, ::windows::core::IInspectable>> {
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::IMapView<::windows::core::HSTRING, ::windows::core::IInspectable>>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineConfiguration {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineConfiguration;{fe265862-f64f-4312-b2a8-4e257721aa95})");
}
unsafe impl ::windows::core::Interface for PhoneLineConfiguration {
type Vtable = IPhoneLineConfiguration_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xfe265862_f64f_4312_b2a8_4e257721aa95);
}
impl ::windows::core::RuntimeName for PhoneLineConfiguration {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineConfiguration";
}
impl ::core::convert::From<PhoneLineConfiguration> for ::windows::core::IUnknown {
fn from(value: PhoneLineConfiguration) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineConfiguration> for ::windows::core::IUnknown {
fn from(value: &PhoneLineConfiguration) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineConfiguration {
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 PhoneLineConfiguration {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineConfiguration> for ::windows::core::IInspectable {
fn from(value: PhoneLineConfiguration) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineConfiguration> for ::windows::core::IInspectable {
fn from(value: &PhoneLineConfiguration) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineConfiguration {
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 PhoneLineConfiguration {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineConfiguration {}
unsafe impl ::core::marker::Sync for PhoneLineConfiguration {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineDialResult(pub ::windows::core::IInspectable);
impl PhoneLineDialResult {
pub fn DialCallStatus(&self) -> ::windows::core::Result<PhoneCallOperationStatus> {
let this = self;
unsafe {
let mut result__: PhoneCallOperationStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneCallOperationStatus>(result__)
}
}
pub fn DialedCall(&self) -> ::windows::core::Result<PhoneCall> {
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::<PhoneCall>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineDialResult {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineDialResult;{e825a30a-5c7f-546f-b918-3ad2fe70fb34})");
}
unsafe impl ::windows::core::Interface for PhoneLineDialResult {
type Vtable = IPhoneLineDialResult_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xe825a30a_5c7f_546f_b918_3ad2fe70fb34);
}
impl ::windows::core::RuntimeName for PhoneLineDialResult {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineDialResult";
}
impl ::core::convert::From<PhoneLineDialResult> for ::windows::core::IUnknown {
fn from(value: PhoneLineDialResult) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineDialResult> for ::windows::core::IUnknown {
fn from(value: &PhoneLineDialResult) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineDialResult {
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 PhoneLineDialResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineDialResult> for ::windows::core::IInspectable {
fn from(value: PhoneLineDialResult) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineDialResult> for ::windows::core::IInspectable {
fn from(value: &PhoneLineDialResult) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineDialResult {
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 PhoneLineDialResult {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineDialResult {}
unsafe impl ::core::marker::Sync for PhoneLineDialResult {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneLineNetworkOperatorDisplayTextLocation(pub i32);
impl PhoneLineNetworkOperatorDisplayTextLocation {
pub const Default: PhoneLineNetworkOperatorDisplayTextLocation = PhoneLineNetworkOperatorDisplayTextLocation(0i32);
pub const Tile: PhoneLineNetworkOperatorDisplayTextLocation = PhoneLineNetworkOperatorDisplayTextLocation(1i32);
pub const Dialer: PhoneLineNetworkOperatorDisplayTextLocation = PhoneLineNetworkOperatorDisplayTextLocation(2i32);
pub const InCallUI: PhoneLineNetworkOperatorDisplayTextLocation = PhoneLineNetworkOperatorDisplayTextLocation(3i32);
}
impl ::core::convert::From<i32> for PhoneLineNetworkOperatorDisplayTextLocation {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneLineNetworkOperatorDisplayTextLocation {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneLineNetworkOperatorDisplayTextLocation {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneLineNetworkOperatorDisplayTextLocation;i4)");
}
impl ::windows::core::DefaultType for PhoneLineNetworkOperatorDisplayTextLocation {
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 PhoneLineOperationStatus(pub i32);
impl PhoneLineOperationStatus {
pub const Succeeded: PhoneLineOperationStatus = PhoneLineOperationStatus(0i32);
pub const OtherFailure: PhoneLineOperationStatus = PhoneLineOperationStatus(1i32);
pub const TimedOut: PhoneLineOperationStatus = PhoneLineOperationStatus(2i32);
pub const ConnectionLost: PhoneLineOperationStatus = PhoneLineOperationStatus(3i32);
pub const InvalidCallState: PhoneLineOperationStatus = PhoneLineOperationStatus(4i32);
}
impl ::core::convert::From<i32> for PhoneLineOperationStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneLineOperationStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneLineOperationStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneLineOperationStatus;i4)");
}
impl ::windows::core::DefaultType for PhoneLineOperationStatus {
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 PhoneLineTransport(pub i32);
impl PhoneLineTransport {
pub const Cellular: PhoneLineTransport = PhoneLineTransport(0i32);
pub const VoipApp: PhoneLineTransport = PhoneLineTransport(1i32);
pub const Bluetooth: PhoneLineTransport = PhoneLineTransport(2i32);
}
impl ::core::convert::From<i32> for PhoneLineTransport {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneLineTransport {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneLineTransport {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneLineTransport;i4)");
}
impl ::windows::core::DefaultType for PhoneLineTransport {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineTransportDevice(pub ::windows::core::IInspectable);
impl PhoneLineTransportDevice {
pub fn DeviceId(&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 Transport(&self) -> ::windows::core::Result<PhoneLineTransport> {
let this = self;
unsafe {
let mut result__: PhoneLineTransport = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneLineTransport>(result__)
}
}
#[cfg(all(feature = "Devices_Enumeration", feature = "Foundation"))]
pub fn RequestAccessAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<super::super::Devices::Enumeration::DeviceAccessStatus>> {
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::IAsyncOperation<super::super::Devices::Enumeration::DeviceAccessStatus>>(result__)
}
}
pub fn RegisterApp(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).9)(::core::mem::transmute_copy(this)).ok() }
}
#[cfg(feature = "System")]
pub fn RegisterAppForUser<'a, Param0: ::windows::core::IntoParam<'a, super::super::System::User>>(&self, user: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), user.into_param().abi()).ok() }
}
pub fn UnregisterApp(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this)).ok() }
}
#[cfg(feature = "System")]
pub fn UnregisterAppForUser<'a, Param0: ::windows::core::IntoParam<'a, super::super::System::User>>(&self, user: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this), user.into_param().abi()).ok() }
}
pub fn IsRegistered(&self) -> ::windows::core::Result<bool> {
let this = self;
unsafe {
let mut result__: bool = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), &mut result__).from_abi::<bool>(result__)
}
}
pub fn Connect(&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__)
}
}
#[cfg(feature = "Foundation")]
pub fn ConnectAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<bool>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<bool>>(result__)
}
}
pub fn FromId<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(id: Param0) -> ::windows::core::Result<PhoneLineTransportDevice> {
Self::IPhoneLineTransportDeviceStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), id.into_param().abi(), &mut result__).from_abi::<PhoneLineTransportDevice>(result__)
})
}
pub fn GetDeviceSelector() -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IPhoneLineTransportDeviceStatics(|this| 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 GetDeviceSelectorForPhoneLineTransport(transport: PhoneLineTransport) -> ::windows::core::Result<::windows::core::HSTRING> {
Self::IPhoneLineTransportDeviceStatics(|this| unsafe {
let mut result__: ::core::mem::ManuallyDrop<::windows::core::HSTRING> = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), transport, &mut result__).from_abi::<::windows::core::HSTRING>(result__)
})
}
pub fn AudioRoutingStatus(&self) -> ::windows::core::Result<TransportDeviceAudioRoutingStatus> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(self)?;
unsafe {
let mut result__: TransportDeviceAudioRoutingStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<TransportDeviceAudioRoutingStatus>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn AudioRoutingStatusChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineTransportDevice, ::windows::core::IInspectable>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::Foundation::EventRegistrationToken> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(self)?;
unsafe {
let mut result__: super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveAudioRoutingStatusChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(self)?;
unsafe { (::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn InBandRingingEnabled(&self) -> ::windows::core::Result<bool> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(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__)
}
}
#[cfg(feature = "Foundation")]
pub fn InBandRingingEnabledChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineTransportDevice, ::windows::core::IInspectable>>>(&self, handler: Param0) -> ::windows::core::Result<super::super::Foundation::EventRegistrationToken> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(self)?;
unsafe {
let mut result__: super::super::Foundation::EventRegistrationToken = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveInBandRingingEnabledChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::EventRegistrationToken>>(&self, token: Param0) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IPhoneLineTransportDevice2>(self)?;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn IPhoneLineTransportDeviceStatics<R, F: FnOnce(&IPhoneLineTransportDeviceStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<PhoneLineTransportDevice, IPhoneLineTransportDeviceStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineTransportDevice {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineTransportDevice;{efa8f889-cffa-59f4-97e4-74705b7dc490})");
}
unsafe impl ::windows::core::Interface for PhoneLineTransportDevice {
type Vtable = IPhoneLineTransportDevice_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xefa8f889_cffa_59f4_97e4_74705b7dc490);
}
impl ::windows::core::RuntimeName for PhoneLineTransportDevice {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineTransportDevice";
}
impl ::core::convert::From<PhoneLineTransportDevice> for ::windows::core::IUnknown {
fn from(value: PhoneLineTransportDevice) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineTransportDevice> for ::windows::core::IUnknown {
fn from(value: &PhoneLineTransportDevice) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineTransportDevice {
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 PhoneLineTransportDevice {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineTransportDevice> for ::windows::core::IInspectable {
fn from(value: PhoneLineTransportDevice) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineTransportDevice> for ::windows::core::IInspectable {
fn from(value: &PhoneLineTransportDevice) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineTransportDevice {
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 PhoneLineTransportDevice {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineTransportDevice {}
unsafe impl ::core::marker::Sync for PhoneLineTransportDevice {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineWatcher(pub ::windows::core::IInspectable);
impl PhoneLineWatcher {
pub fn Start(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this)).ok() }
}
pub fn Stop(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this)).ok() }
}
#[cfg(feature = "Foundation")]
pub fn LineAdded<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineWatcher, PhoneLineWatcherEventArgs>>>(&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).8)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveLineAdded<'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).9)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn LineRemoved<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineWatcher, PhoneLineWatcherEventArgs>>>(&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).10)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveLineRemoved<'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).11)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn LineUpdated<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineWatcher, PhoneLineWatcherEventArgs>>>(&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).12)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveLineUpdated<'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).13)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn EnumerationCompleted<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineWatcher, ::windows::core::IInspectable>>>(&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 RemoveEnumerationCompleted<'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() }
}
#[cfg(feature = "Foundation")]
pub fn Stopped<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<PhoneLineWatcher, ::windows::core::IInspectable>>>(&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).16)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveStopped<'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).17)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
pub fn Status(&self) -> ::windows::core::Result<PhoneLineWatcherStatus> {
let this = self;
unsafe {
let mut result__: PhoneLineWatcherStatus = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneLineWatcherStatus>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineWatcher {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineWatcher;{8a45cd0a-6323-44e0-a6f6-9f21f64dc90a})");
}
unsafe impl ::windows::core::Interface for PhoneLineWatcher {
type Vtable = IPhoneLineWatcher_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x8a45cd0a_6323_44e0_a6f6_9f21f64dc90a);
}
impl ::windows::core::RuntimeName for PhoneLineWatcher {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineWatcher";
}
impl ::core::convert::From<PhoneLineWatcher> for ::windows::core::IUnknown {
fn from(value: PhoneLineWatcher) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineWatcher> for ::windows::core::IUnknown {
fn from(value: &PhoneLineWatcher) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineWatcher {
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 PhoneLineWatcher {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineWatcher> for ::windows::core::IInspectable {
fn from(value: PhoneLineWatcher) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineWatcher> for ::windows::core::IInspectable {
fn from(value: &PhoneLineWatcher) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineWatcher {
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 PhoneLineWatcher {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineWatcher {}
unsafe impl ::core::marker::Sync for PhoneLineWatcher {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneLineWatcherEventArgs(pub ::windows::core::IInspectable);
impl PhoneLineWatcherEventArgs {
pub fn LineId(&self) -> ::windows::core::Result<::windows::core::GUID> {
let this = self;
unsafe {
let mut result__: ::windows::core::GUID = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::GUID>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneLineWatcherEventArgs {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneLineWatcherEventArgs;{d07c753e-9e12-4a37-82b7-ad535dad6a67})");
}
unsafe impl ::windows::core::Interface for PhoneLineWatcherEventArgs {
type Vtable = IPhoneLineWatcherEventArgs_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xd07c753e_9e12_4a37_82b7_ad535dad6a67);
}
impl ::windows::core::RuntimeName for PhoneLineWatcherEventArgs {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneLineWatcherEventArgs";
}
impl ::core::convert::From<PhoneLineWatcherEventArgs> for ::windows::core::IUnknown {
fn from(value: PhoneLineWatcherEventArgs) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneLineWatcherEventArgs> for ::windows::core::IUnknown {
fn from(value: &PhoneLineWatcherEventArgs) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneLineWatcherEventArgs {
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 PhoneLineWatcherEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneLineWatcherEventArgs> for ::windows::core::IInspectable {
fn from(value: PhoneLineWatcherEventArgs) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneLineWatcherEventArgs> for ::windows::core::IInspectable {
fn from(value: &PhoneLineWatcherEventArgs) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneLineWatcherEventArgs {
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 PhoneLineWatcherEventArgs {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneLineWatcherEventArgs {}
unsafe impl ::core::marker::Sync for PhoneLineWatcherEventArgs {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneLineWatcherStatus(pub i32);
impl PhoneLineWatcherStatus {
pub const Created: PhoneLineWatcherStatus = PhoneLineWatcherStatus(0i32);
pub const Started: PhoneLineWatcherStatus = PhoneLineWatcherStatus(1i32);
pub const EnumerationCompleted: PhoneLineWatcherStatus = PhoneLineWatcherStatus(2i32);
pub const Stopped: PhoneLineWatcherStatus = PhoneLineWatcherStatus(3i32);
}
impl ::core::convert::From<i32> for PhoneLineWatcherStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneLineWatcherStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneLineWatcherStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneLineWatcherStatus;i4)");
}
impl ::windows::core::DefaultType for PhoneLineWatcherStatus {
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 PhoneNetworkState(pub i32);
impl PhoneNetworkState {
pub const Unknown: PhoneNetworkState = PhoneNetworkState(0i32);
pub const NoSignal: PhoneNetworkState = PhoneNetworkState(1i32);
pub const Deregistered: PhoneNetworkState = PhoneNetworkState(2i32);
pub const Denied: PhoneNetworkState = PhoneNetworkState(3i32);
pub const Searching: PhoneNetworkState = PhoneNetworkState(4i32);
pub const Home: PhoneNetworkState = PhoneNetworkState(5i32);
pub const RoamingInternational: PhoneNetworkState = PhoneNetworkState(6i32);
pub const RoamingDomestic: PhoneNetworkState = PhoneNetworkState(7i32);
}
impl ::core::convert::From<i32> for PhoneNetworkState {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneNetworkState {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneNetworkState {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneNetworkState;i4)");
}
impl ::windows::core::DefaultType for PhoneNetworkState {
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 PhoneSimState(pub i32);
impl PhoneSimState {
pub const Unknown: PhoneSimState = PhoneSimState(0i32);
pub const PinNotRequired: PhoneSimState = PhoneSimState(1i32);
pub const PinUnlocked: PhoneSimState = PhoneSimState(2i32);
pub const PinLocked: PhoneSimState = PhoneSimState(3i32);
pub const PukLocked: PhoneSimState = PhoneSimState(4i32);
pub const NotInserted: PhoneSimState = PhoneSimState(5i32);
pub const Invalid: PhoneSimState = PhoneSimState(6i32);
pub const Disabled: PhoneSimState = PhoneSimState(7i32);
}
impl ::core::convert::From<i32> for PhoneSimState {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneSimState {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneSimState {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneSimState;i4)");
}
impl ::windows::core::DefaultType for PhoneSimState {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct PhoneVoicemail(pub ::windows::core::IInspectable);
impl PhoneVoicemail {
pub fn Number(&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 MessageCount(&self) -> ::windows::core::Result<i32> {
let this = self;
unsafe {
let mut result__: i32 = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(::core::mem::transmute_copy(this), &mut result__).from_abi::<i32>(result__)
}
}
pub fn Type(&self) -> ::windows::core::Result<PhoneVoicemailType> {
let this = self;
unsafe {
let mut result__: PhoneVoicemailType = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).8)(::core::mem::transmute_copy(this), &mut result__).from_abi::<PhoneVoicemailType>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn DialVoicemailAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncAction> {
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::IAsyncAction>(result__)
}
}
}
unsafe impl ::windows::core::RuntimeType for PhoneVoicemail {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.PhoneVoicemail;{c9ce77f6-6e9f-3a8b-b727-6e0cf6998224})");
}
unsafe impl ::windows::core::Interface for PhoneVoicemail {
type Vtable = IPhoneVoicemail_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0xc9ce77f6_6e9f_3a8b_b727_6e0cf6998224);
}
impl ::windows::core::RuntimeName for PhoneVoicemail {
const NAME: &'static str = "Windows.ApplicationModel.Calls.PhoneVoicemail";
}
impl ::core::convert::From<PhoneVoicemail> for ::windows::core::IUnknown {
fn from(value: PhoneVoicemail) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&PhoneVoicemail> for ::windows::core::IUnknown {
fn from(value: &PhoneVoicemail) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for PhoneVoicemail {
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 PhoneVoicemail {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<PhoneVoicemail> for ::windows::core::IInspectable {
fn from(value: PhoneVoicemail) -> Self {
value.0
}
}
impl ::core::convert::From<&PhoneVoicemail> for ::windows::core::IInspectable {
fn from(value: &PhoneVoicemail) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for PhoneVoicemail {
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 PhoneVoicemail {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for PhoneVoicemail {}
unsafe impl ::core::marker::Sync for PhoneVoicemail {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct PhoneVoicemailType(pub i32);
impl PhoneVoicemailType {
pub const None: PhoneVoicemailType = PhoneVoicemailType(0i32);
pub const Traditional: PhoneVoicemailType = PhoneVoicemailType(1i32);
pub const Visual: PhoneVoicemailType = PhoneVoicemailType(2i32);
}
impl ::core::convert::From<i32> for PhoneVoicemailType {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for PhoneVoicemailType {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for PhoneVoicemailType {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.PhoneVoicemailType;i4)");
}
impl ::windows::core::DefaultType for PhoneVoicemailType {
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 TransportDeviceAudioRoutingStatus(pub i32);
impl TransportDeviceAudioRoutingStatus {
pub const Unknown: TransportDeviceAudioRoutingStatus = TransportDeviceAudioRoutingStatus(0i32);
pub const CanRouteToLocalDevice: TransportDeviceAudioRoutingStatus = TransportDeviceAudioRoutingStatus(1i32);
pub const CannotRouteToLocalDevice: TransportDeviceAudioRoutingStatus = TransportDeviceAudioRoutingStatus(2i32);
}
impl ::core::convert::From<i32> for TransportDeviceAudioRoutingStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for TransportDeviceAudioRoutingStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for TransportDeviceAudioRoutingStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.TransportDeviceAudioRoutingStatus;i4)");
}
impl ::windows::core::DefaultType for TransportDeviceAudioRoutingStatus {
type DefaultType = Self;
}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct VoipCallCoordinator(pub ::windows::core::IInspectable);
impl VoipCallCoordinator {
#[cfg(feature = "Foundation")]
pub fn ReserveCallResourcesAsync<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, taskentrypoint: Param0) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VoipPhoneCallResourceReservationStatus>> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), taskentrypoint.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::IAsyncOperation<VoipPhoneCallResourceReservationStatus>>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn MuteStateChanged<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipCallCoordinator, MuteChangeEventArgs>>>(&self, mutechangehandler: 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).7)(::core::mem::transmute_copy(this), mutechangehandler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveMuteStateChanged<'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).8)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn RequestNewIncomingCall<
'a,
Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param3: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param4: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param5: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param6: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param7: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param9: ::windows::core::IntoParam<'a, super::super::Foundation::TimeSpan>,
>(
&self,
context: Param0,
contactname: Param1,
contactnumber: Param2,
contactimage: Param3,
servicename: Param4,
brandingimage: Param5,
calldetails: Param6,
ringtone: Param7,
media: VoipPhoneCallMedia,
ringtimeout: Param9,
) -> ::windows::core::Result<VoipPhoneCall> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).9)(
::core::mem::transmute_copy(this),
context.into_param().abi(),
contactname.into_param().abi(),
contactnumber.into_param().abi(),
contactimage.into_param().abi(),
servicename.into_param().abi(),
brandingimage.into_param().abi(),
calldetails.into_param().abi(),
ringtone.into_param().abi(),
media,
ringtimeout.into_param().abi(),
&mut result__,
)
.from_abi::<VoipPhoneCall>(result__)
}
}
pub fn RequestNewOutgoingCall<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, context: Param0, contactname: Param1, servicename: Param2, media: VoipPhoneCallMedia) -> ::windows::core::Result<VoipPhoneCall> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).10)(::core::mem::transmute_copy(this), context.into_param().abi(), contactname.into_param().abi(), servicename.into_param().abi(), media, &mut result__).from_abi::<VoipPhoneCall>(result__)
}
}
pub fn NotifyMuted(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).11)(::core::mem::transmute_copy(this)).ok() }
}
pub fn NotifyUnmuted(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).12)(::core::mem::transmute_copy(this)).ok() }
}
pub fn RequestOutgoingUpgradeToVideoCall<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::GUID>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param3: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, callupgradeguid: Param0, context: Param1, contactname: Param2, servicename: Param3) -> ::windows::core::Result<VoipPhoneCall> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).13)(::core::mem::transmute_copy(this), callupgradeguid.into_param().abi(), context.into_param().abi(), contactname.into_param().abi(), servicename.into_param().abi(), &mut result__).from_abi::<VoipPhoneCall>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RequestIncomingUpgradeToVideoCall<
'a,
Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param3: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param4: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param5: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param6: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param7: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param8: ::windows::core::IntoParam<'a, super::super::Foundation::TimeSpan>,
>(
&self,
context: Param0,
contactname: Param1,
contactnumber: Param2,
contactimage: Param3,
servicename: Param4,
brandingimage: Param5,
calldetails: Param6,
ringtone: Param7,
ringtimeout: Param8,
) -> ::windows::core::Result<VoipPhoneCall> {
let this = self;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).14)(
::core::mem::transmute_copy(this),
context.into_param().abi(),
contactname.into_param().abi(),
contactnumber.into_param().abi(),
contactimage.into_param().abi(),
servicename.into_param().abi(),
brandingimage.into_param().abi(),
calldetails.into_param().abi(),
ringtone.into_param().abi(),
ringtimeout.into_param().abi(),
&mut result__,
)
.from_abi::<VoipPhoneCall>(result__)
}
}
pub fn TerminateCellularCall<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::GUID>>(&self, callupgradeguid: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).15)(::core::mem::transmute_copy(this), callupgradeguid.into_param().abi()).ok() }
}
pub fn CancelUpgrade<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::GUID>>(&self, callupgradeguid: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this), callupgradeguid.into_param().abi()).ok() }
}
pub fn GetDefault() -> ::windows::core::Result<VoipCallCoordinator> {
Self::IVoipCallCoordinatorStatics(|this| unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VoipCallCoordinator>(result__)
})
}
pub fn SetupNewAcceptedCall<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param3: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, context: Param0, contactname: Param1, contactnumber: Param2, servicename: Param3, media: VoipPhoneCallMedia) -> ::windows::core::Result<VoipPhoneCall> {
let this = &::windows::core::Interface::cast::<IVoipCallCoordinator2>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), context.into_param().abi(), contactname.into_param().abi(), contactnumber.into_param().abi(), servicename.into_param().abi(), media, &mut result__).from_abi::<VoipPhoneCall>(result__)
}
}
pub fn RequestNewAppInitiatedCall<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>, Param3: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, context: Param0, contactname: Param1, contactnumber: Param2, servicename: Param3, media: VoipPhoneCallMedia) -> ::windows::core::Result<VoipPhoneCall> {
let this = &::windows::core::Interface::cast::<IVoipCallCoordinator3>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), context.into_param().abi(), contactname.into_param().abi(), contactnumber.into_param().abi(), servicename.into_param().abi(), media, &mut result__).from_abi::<VoipPhoneCall>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RequestNewIncomingCallWithContactRemoteId<
'a,
Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param1: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param2: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param3: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param4: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param5: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param6: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
Param7: ::windows::core::IntoParam<'a, super::super::Foundation::Uri>,
Param9: ::windows::core::IntoParam<'a, super::super::Foundation::TimeSpan>,
Param10: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>,
>(
&self,
context: Param0,
contactname: Param1,
contactnumber: Param2,
contactimage: Param3,
servicename: Param4,
brandingimage: Param5,
calldetails: Param6,
ringtone: Param7,
media: VoipPhoneCallMedia,
ringtimeout: Param9,
contactremoteid: Param10,
) -> ::windows::core::Result<VoipPhoneCall> {
let this = &::windows::core::Interface::cast::<IVoipCallCoordinator3>(self)?;
unsafe {
let mut result__: ::windows::core::RawPtr = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).7)(
::core::mem::transmute_copy(this),
context.into_param().abi(),
contactname.into_param().abi(),
contactnumber.into_param().abi(),
contactimage.into_param().abi(),
servicename.into_param().abi(),
brandingimage.into_param().abi(),
calldetails.into_param().abi(),
ringtone.into_param().abi(),
media,
ringtimeout.into_param().abi(),
contactremoteid.into_param().abi(),
&mut result__,
)
.from_abi::<VoipPhoneCall>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn ReserveOneProcessCallResourcesAsync(&self) -> ::windows::core::Result<super::super::Foundation::IAsyncOperation<VoipPhoneCallResourceReservationStatus>> {
let this = &::windows::core::Interface::cast::<IVoipCallCoordinator4>(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::IAsyncOperation<VoipPhoneCallResourceReservationStatus>>(result__)
}
}
pub fn IVoipCallCoordinatorStatics<R, F: FnOnce(&IVoipCallCoordinatorStatics) -> ::windows::core::Result<R>>(callback: F) -> ::windows::core::Result<R> {
static mut SHARED: ::windows::core::FactoryCache<VoipCallCoordinator, IVoipCallCoordinatorStatics> = ::windows::core::FactoryCache::new();
unsafe { SHARED.call(callback) }
}
}
unsafe impl ::windows::core::RuntimeType for VoipCallCoordinator {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.VoipCallCoordinator;{4f118bcf-e8ef-4434-9c5f-a8d893fafe79})");
}
unsafe impl ::windows::core::Interface for VoipCallCoordinator {
type Vtable = IVoipCallCoordinator_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x4f118bcf_e8ef_4434_9c5f_a8d893fafe79);
}
impl ::windows::core::RuntimeName for VoipCallCoordinator {
const NAME: &'static str = "Windows.ApplicationModel.Calls.VoipCallCoordinator";
}
impl ::core::convert::From<VoipCallCoordinator> for ::windows::core::IUnknown {
fn from(value: VoipCallCoordinator) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&VoipCallCoordinator> for ::windows::core::IUnknown {
fn from(value: &VoipCallCoordinator) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VoipCallCoordinator {
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 VoipCallCoordinator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<VoipCallCoordinator> for ::windows::core::IInspectable {
fn from(value: VoipCallCoordinator) -> Self {
value.0
}
}
impl ::core::convert::From<&VoipCallCoordinator> for ::windows::core::IInspectable {
fn from(value: &VoipCallCoordinator) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VoipCallCoordinator {
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 VoipCallCoordinator {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for VoipCallCoordinator {}
unsafe impl ::core::marker::Sync for VoipCallCoordinator {}
#[repr(transparent)]
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: clone :: Clone, :: core :: fmt :: Debug)]
pub struct VoipPhoneCall(pub ::windows::core::IInspectable);
impl VoipPhoneCall {
#[cfg(feature = "Foundation")]
pub fn EndRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipPhoneCall, CallStateChangeEventArgs>>>(&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).6)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveEndRequested<'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).7)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn HoldRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipPhoneCall, CallStateChangeEventArgs>>>(&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).8)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveHoldRequested<'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).9)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn ResumeRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipPhoneCall, CallStateChangeEventArgs>>>(&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).10)(::core::mem::transmute_copy(this), handler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveResumeRequested<'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).11)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn AnswerRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipPhoneCall, CallAnswerEventArgs>>>(&self, accepthandler: 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).12)(::core::mem::transmute_copy(this), accepthandler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveAnswerRequested<'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).13)(::core::mem::transmute_copy(this), token.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn RejectRequested<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::TypedEventHandler<VoipPhoneCall, CallRejectEventArgs>>>(&self, rejecthandler: 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), rejecthandler.into_param().abi(), &mut result__).from_abi::<super::super::Foundation::EventRegistrationToken>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn RemoveRejectRequested<'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 NotifyCallHeld(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).16)(::core::mem::transmute_copy(this)).ok() }
}
pub fn NotifyCallActive(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).17)(::core::mem::transmute_copy(this)).ok() }
}
pub fn NotifyCallEnded(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).18)(::core::mem::transmute_copy(this)).ok() }
}
pub fn ContactName(&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).19)(::core::mem::transmute_copy(this), &mut result__).from_abi::<::windows::core::HSTRING>(result__)
}
}
pub fn SetContactName<'a, Param0: ::windows::core::IntoParam<'a, ::windows::core::HSTRING>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).20)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
#[cfg(feature = "Foundation")]
pub fn StartTime(&self) -> ::windows::core::Result<super::super::Foundation::DateTime> {
let this = self;
unsafe {
let mut result__: super::super::Foundation::DateTime = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).21)(::core::mem::transmute_copy(this), &mut result__).from_abi::<super::super::Foundation::DateTime>(result__)
}
}
#[cfg(feature = "Foundation")]
pub fn SetStartTime<'a, Param0: ::windows::core::IntoParam<'a, super::super::Foundation::DateTime>>(&self, value: Param0) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).22)(::core::mem::transmute_copy(this), value.into_param().abi()).ok() }
}
pub fn CallMedia(&self) -> ::windows::core::Result<VoipPhoneCallMedia> {
let this = self;
unsafe {
let mut result__: VoipPhoneCallMedia = ::core::mem::zeroed();
(::windows::core::Interface::vtable(this).23)(::core::mem::transmute_copy(this), &mut result__).from_abi::<VoipPhoneCallMedia>(result__)
}
}
pub fn SetCallMedia(&self, value: VoipPhoneCallMedia) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).24)(::core::mem::transmute_copy(this), value).ok() }
}
pub fn NotifyCallReady(&self) -> ::windows::core::Result<()> {
let this = self;
unsafe { (::windows::core::Interface::vtable(this).25)(::core::mem::transmute_copy(this)).ok() }
}
pub fn TryShowAppUI(&self) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IVoipPhoneCall2>(self)?;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this)).ok() }
}
pub fn NotifyCallAccepted(&self, media: VoipPhoneCallMedia) -> ::windows::core::Result<()> {
let this = &::windows::core::Interface::cast::<IVoipPhoneCall3>(self)?;
unsafe { (::windows::core::Interface::vtable(this).6)(::core::mem::transmute_copy(this), media).ok() }
}
}
unsafe impl ::windows::core::RuntimeType for VoipPhoneCall {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"rc(Windows.ApplicationModel.Calls.VoipPhoneCall;{6cf1f19a-7794-4a5a-8c68-ae87947a6990})");
}
unsafe impl ::windows::core::Interface for VoipPhoneCall {
type Vtable = IVoipPhoneCall_abi;
const IID: ::windows::core::GUID = ::windows::core::GUID::from_u128(0x6cf1f19a_7794_4a5a_8c68_ae87947a6990);
}
impl ::windows::core::RuntimeName for VoipPhoneCall {
const NAME: &'static str = "Windows.ApplicationModel.Calls.VoipPhoneCall";
}
impl ::core::convert::From<VoipPhoneCall> for ::windows::core::IUnknown {
fn from(value: VoipPhoneCall) -> Self {
value.0 .0
}
}
impl ::core::convert::From<&VoipPhoneCall> for ::windows::core::IUnknown {
fn from(value: &VoipPhoneCall) -> Self {
value.0 .0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IUnknown> for VoipPhoneCall {
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 VoipPhoneCall {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IUnknown> {
::windows::core::Param::Borrowed(&self.0 .0)
}
}
impl ::core::convert::From<VoipPhoneCall> for ::windows::core::IInspectable {
fn from(value: VoipPhoneCall) -> Self {
value.0
}
}
impl ::core::convert::From<&VoipPhoneCall> for ::windows::core::IInspectable {
fn from(value: &VoipPhoneCall) -> Self {
value.0.clone()
}
}
impl<'a> ::windows::core::IntoParam<'a, ::windows::core::IInspectable> for VoipPhoneCall {
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 VoipPhoneCall {
fn into_param(self) -> ::windows::core::Param<'a, ::windows::core::IInspectable> {
::windows::core::Param::Borrowed(&self.0)
}
}
unsafe impl ::core::marker::Send for VoipPhoneCall {}
unsafe impl ::core::marker::Sync for VoipPhoneCall {}
#[derive(:: core :: cmp :: PartialEq, :: core :: cmp :: Eq, :: core :: marker :: Copy, :: core :: clone :: Clone, :: core :: default :: Default, :: core :: fmt :: Debug)]
#[repr(transparent)]
pub struct VoipPhoneCallMedia(pub u32);
impl VoipPhoneCallMedia {
pub const None: VoipPhoneCallMedia = VoipPhoneCallMedia(0u32);
pub const Audio: VoipPhoneCallMedia = VoipPhoneCallMedia(1u32);
pub const Video: VoipPhoneCallMedia = VoipPhoneCallMedia(2u32);
}
impl ::core::convert::From<u32> for VoipPhoneCallMedia {
fn from(value: u32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for VoipPhoneCallMedia {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for VoipPhoneCallMedia {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.VoipPhoneCallMedia;u4)");
}
impl ::windows::core::DefaultType for VoipPhoneCallMedia {
type DefaultType = Self;
}
impl ::core::ops::BitOr for VoipPhoneCallMedia {
type Output = Self;
fn bitor(self, rhs: Self) -> Self {
Self(self.0 | rhs.0)
}
}
impl ::core::ops::BitAnd for VoipPhoneCallMedia {
type Output = Self;
fn bitand(self, rhs: Self) -> Self {
Self(self.0 & rhs.0)
}
}
impl ::core::ops::BitOrAssign for VoipPhoneCallMedia {
fn bitor_assign(&mut self, rhs: Self) {
self.0.bitor_assign(rhs.0)
}
}
impl ::core::ops::BitAndAssign for VoipPhoneCallMedia {
fn bitand_assign(&mut self, rhs: Self) {
self.0.bitand_assign(rhs.0)
}
}
impl ::core::ops::Not for VoipPhoneCallMedia {
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 VoipPhoneCallRejectReason(pub i32);
impl VoipPhoneCallRejectReason {
pub const UserIgnored: VoipPhoneCallRejectReason = VoipPhoneCallRejectReason(0i32);
pub const TimedOut: VoipPhoneCallRejectReason = VoipPhoneCallRejectReason(1i32);
pub const OtherIncomingCall: VoipPhoneCallRejectReason = VoipPhoneCallRejectReason(2i32);
pub const EmergencyCallExists: VoipPhoneCallRejectReason = VoipPhoneCallRejectReason(3i32);
pub const InvalidCallState: VoipPhoneCallRejectReason = VoipPhoneCallRejectReason(4i32);
}
impl ::core::convert::From<i32> for VoipPhoneCallRejectReason {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for VoipPhoneCallRejectReason {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for VoipPhoneCallRejectReason {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.VoipPhoneCallRejectReason;i4)");
}
impl ::windows::core::DefaultType for VoipPhoneCallRejectReason {
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 VoipPhoneCallResourceReservationStatus(pub i32);
impl VoipPhoneCallResourceReservationStatus {
pub const Success: VoipPhoneCallResourceReservationStatus = VoipPhoneCallResourceReservationStatus(0i32);
pub const ResourcesNotAvailable: VoipPhoneCallResourceReservationStatus = VoipPhoneCallResourceReservationStatus(1i32);
}
impl ::core::convert::From<i32> for VoipPhoneCallResourceReservationStatus {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for VoipPhoneCallResourceReservationStatus {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for VoipPhoneCallResourceReservationStatus {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.VoipPhoneCallResourceReservationStatus;i4)");
}
impl ::windows::core::DefaultType for VoipPhoneCallResourceReservationStatus {
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 VoipPhoneCallState(pub i32);
impl VoipPhoneCallState {
pub const Ended: VoipPhoneCallState = VoipPhoneCallState(0i32);
pub const Held: VoipPhoneCallState = VoipPhoneCallState(1i32);
pub const Active: VoipPhoneCallState = VoipPhoneCallState(2i32);
pub const Incoming: VoipPhoneCallState = VoipPhoneCallState(3i32);
pub const Outgoing: VoipPhoneCallState = VoipPhoneCallState(4i32);
}
impl ::core::convert::From<i32> for VoipPhoneCallState {
fn from(value: i32) -> Self {
Self(value)
}
}
unsafe impl ::windows::core::Abi for VoipPhoneCallState {
type Abi = Self;
}
unsafe impl ::windows::core::RuntimeType for VoipPhoneCallState {
const SIGNATURE: ::windows::core::ConstBuffer = ::windows::core::ConstBuffer::from_slice(b"enum(Windows.ApplicationModel.Calls.VoipPhoneCallState;i4)");
}
impl ::windows::core::DefaultType for VoipPhoneCallState {
type DefaultType = Self;
}
|
mod helpers;
// Don't forget to add all the modules, so that the UTs are run.
//
pub mod d2_1_bubble_sort;
pub mod d2_2_merge_sort;
pub mod d2_2_merge_sort_source;
pub mod d2_3_quicksort;
pub mod d2_4_dynamic_programming;
pub mod d3_1_linked_list;
pub mod d3_2_doubly_linked_list;
pub mod d3_3_binary_tree;
pub mod d3_4_balanced_binary_tree;
pub mod d3_5_skip_list;
pub mod d3_6_skip_list_with_height;
pub mod d3_7_huffman_coding;
pub mod d4_1_graph_representations;
pub mod d4_2_filling_the_graph;
pub mod d5_2_hashmap_from_scratch;
pub mod d5_3_bucket_list;
pub mod d5_4_finishing_hashmap;
pub mod d6_39_id_generator;
pub mod d6_40_data_store;
pub mod d6_41_ecs_system;
pub mod d7_44_blob_data_file;
pub mod d7_45_convert_any_data_to_bytes;
pub mod d7_46_create_blob_store;
|
use needletail::{parse_fastx_stdin, Sequence};
fn main() -> Result<(), Box<dyn std::error::Error>> {
let mut n_bases = 0;
let mut n_valid_kmers = 0;
let mut reader = parse_fastx_stdin().expect("valid path/file");
while let Some(record) = reader.next() {
let seqrec = record.expect("invalid record");
// keep track of the total number of bases
n_bases += seqrec.num_bases();
// normalize to make sure all the bases are consistently capitalized and
// that we remove the newlines since this is FASTA
let norm_seq = seqrec.normalize(false);
// we make a reverse complemented copy of the sequence first for
// `canonical_kmers` to draw the complemented sequences from.
let rc = norm_seq.reverse_complement();
// now we keep track of the number of AAAAs (or TTTTs via
// canonicalization) in the file; note we also get the position (i.0;
// in the event there were `N`-containing kmers that were skipped)
// and whether the sequence was complemented (i.2) in addition to
// the canonical kmer (i.1)
for (_, kmer, _) in norm_seq.canonical_kmers(4, &rc) {
if kmer == b"AAAA" {
n_valid_kmers += 1;
}
}
}
println!("There are {} bases in your file.", n_bases);
println!("There are {} AAAAs in your file.", n_valid_kmers);
Ok(())
}
|
use git_version::{git_hash, git_hash_short, run_command};
#[test]
fn git_hash() {
assert!(git_hash!().len() == 40);
}
#[test]
fn git_hash_short_default() {
assert!(git_hash_short!().len() == 7);
}
#[test]
fn git_hash_short_custom() {
assert!(git_hash_short!(0).len() == 4); // minimum output length is 4
assert!(git_hash_short!(1).len() == 4);
assert!(git_hash_short!(2).len() == 4);
assert!(git_hash_short!(3).len() == 4);
assert!(git_hash_short!(4).len() == 4);
assert!(git_hash_short!(5).len() == 5);
assert!(git_hash_short!(6).len() == 6);
assert!(git_hash_short!(7).len() == 7);
assert!(git_hash_short!(8).len() == 8);
assert!(git_hash_short!(9).len() == 9);
assert!(git_hash_short!(10).len() == 10);
assert!(git_hash_short!(11).len() == 11);
assert!(git_hash_short!(12).len() == 12);
assert!(git_hash_short!(13).len() == 13);
assert!(git_hash_short!(14).len() == 14);
assert!(git_hash_short!(15).len() == 15);
}
#[test]
fn run_command() {
assert!(run_command!("git", "rev-parse" "--abbrev-ref" "HEAD") == "master")
}
|
//! Linux `mount`.
use crate::backend::mount::types::{
InternalMountFlags, MountFlags, MountFlagsArg, MountPropagationFlags, UnmountFlags,
};
use crate::{backend, io, path};
/// `mount(source, target, filesystemtype, mountflags, data)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
pub fn mount<Source: path::Arg, Target: path::Arg, Fs: path::Arg, Data: path::Arg>(
source: Source,
target: Target,
file_system_type: Fs,
flags: MountFlags,
data: Data,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
file_system_type.into_with_c_str(|file_system_type| {
data.into_with_c_str(|data| {
backend::mount::syscalls::mount(
Some(source),
target,
Some(file_system_type),
MountFlagsArg(flags.bits()),
Some(data),
)
})
})
})
})
}
/// `mount(NULL, target, NULL, MS_REMOUNT | mountflags, data)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
#[doc(alias = "MS_REMOUNT")]
pub fn mount_remount<Target: path::Arg, Data: path::Arg>(
target: Target,
flags: MountFlags,
data: Data,
) -> io::Result<()> {
target.into_with_c_str(|target| {
data.into_with_c_str(|data| {
backend::mount::syscalls::mount(
None,
target,
None,
MountFlagsArg(InternalMountFlags::REMOUNT.bits() | flags.bits()),
Some(data),
)
})
})
}
/// `mount(source, target, NULL, MS_BIND, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
#[doc(alias = "MS_BIND")]
pub fn mount_bind<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::mount::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(MountFlags::BIND.bits()),
None,
)
})
})
}
/// `mount(source, target, NULL, MS_BIND | MS_REC, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
#[doc(alias = "MS_REC")]
pub fn mount_recursive_bind<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::mount::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(MountFlags::BIND.bits() | MountPropagationFlags::REC.bits()),
None,
)
})
})
}
/// `mount(NULL, target, NULL, mountflags, NULL)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
pub fn mount_change<Target: path::Arg>(
target: Target,
flags: MountPropagationFlags,
) -> io::Result<()> {
target.into_with_c_str(|target| {
backend::mount::syscalls::mount(None, target, None, MountFlagsArg(flags.bits()), None)
})
}
/// `mount(source, target, NULL, MS_MOVE, NULL)`
///
/// This is not the same as the `move_mount` syscall. If you want to use that,
/// use [`move_mount`] instead.
///
/// # References
/// - [Linux]
///
/// [`move_mount`]: crate::mount::move_mount
/// [Linux]: https://man7.org/linux/man-pages/man2/mount.2.html
#[inline]
#[doc(alias = "mount")]
#[doc(alias = "MS_MOVE")]
pub fn mount_move<Source: path::Arg, Target: path::Arg>(
source: Source,
target: Target,
) -> io::Result<()> {
source.into_with_c_str(|source| {
target.into_with_c_str(|target| {
backend::mount::syscalls::mount(
Some(source),
target,
None,
MountFlagsArg(InternalMountFlags::MOVE.bits()),
None,
)
})
})
}
/// `umount2(target, flags)`
///
/// # References
/// - [Linux]
///
/// [Linux]: https://man7.org/linux/man-pages/man2/umount.2.html
#[inline]
#[doc(alias = "umount", alias = "umount2")]
pub fn unmount<Target: path::Arg>(target: Target, flags: UnmountFlags) -> io::Result<()> {
target.into_with_c_str(|target| backend::mount::syscalls::unmount(target, flags))
}
|
use super::skill_description::SkillDescription;
use crate::models::skill::Skill;
use yew::prelude::*;
use yew::{html, Html};
#[derive(Clone, Debug, Eq, PartialEq, Properties)]
pub struct Props {
pub skills: Vec<Skill>,
}
pub struct SkillsPanel {
skills: Vec<Skill>,
}
impl Component for SkillsPanel {
type Message = ();
type Properties = Props;
fn create(_props: Self::Properties, _link: ComponentLink<Self>) -> Self {
Self {
skills: _props.skills.to_vec(),
}
}
fn update(&mut self, _msg: Self::Message) -> ShouldRender {
unimplemented!()
}
fn change(&mut self, _props: Self::Properties) -> ShouldRender {
false
}
fn view(&self) -> Html {
let Self { skills } = self;
html! {
<ul class="item-list">
{ for skills.iter().map(|skill| html! {
<SkillDescription skill=skill.clone()/>
})}
</ul>
}
}
}
|
use core::marker::PhantomData;
pub use crate::make_anon_typeid_owner as new_anon;
pub use crate::make_typeid as make;
#[macro_export]
macro_rules! make_anon_typeid_owner {
() => {
unsafe { $crate::Owner::new($crate::typeid::Type::new_unchecked(|| ())) }
};
}
#[macro_export]
macro_rules! make_typeid {
($($v:vis type $name:ident);* $(;)?) => {$(
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
$v struct $name($crate::typeid::macros::UnsafeCreate);
const _: () = {
static __make_typeid_FLAG: $crate::typeid::macros::Flag = $crate::typeid::macros::Flag::new();
impl $name {
pub fn owner() -> $crate::typeid::Owner<Self> {
Self::try_owner().expect(concat!(
"attempted a reentrant acquire of a `Type<",
stringify!($name),
">`"
))
}
pub fn try_owner() -> Option<$crate::typeid::Owner<Self>> {
use $crate::typeid::{macros::UnsafeCreate, Type};
unsafe {
__make_typeid_FLAG.init();
if __make_typeid_FLAG.acquire() {
Some($crate::typeid::Owner::new(Type::new_unchecked(Self(UnsafeCreate::new()))))
} else {
None
}
}
}
}
impl Drop for $name {
fn drop(&mut self) {
unsafe {
__make_typeid_FLAG.release();
}
}
}
};
)*};
}
#[doc(hidden)]
pub mod macros {
pub use core::cell::Cell;
pub use flag::Flag;
#[cfg(feature = "std")]
pub use std::thread_local;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct UnsafeCreate(());
impl UnsafeCreate {
#[doc(hidden)]
pub unsafe fn new() -> Self {
Self(())
}
}
#[cfg(feature = "std")]
mod flag {
use core::sync::atomic::{
AtomicBool, AtomicUsize,
Ordering::{Acquire, Relaxed},
};
use std::cell::UnsafeCell;
use std::mem::MaybeUninit;
use std::sync::{Condvar, Mutex, Once};
thread_local! {
static THREAD_ID: MaybeUninit<u8> = MaybeUninit::uninit();
}
fn get_thread_id() -> usize {
THREAD_ID.with(|id| id.as_ptr() as usize)
}
pub struct Flag(
Once,
AtomicBool,
AtomicUsize,
UnsafeCell<MaybeUninit<Condvar>>,
UnsafeCell<MaybeUninit<Mutex<()>>>,
);
unsafe impl Send for Flag {}
unsafe impl Sync for Flag {}
impl Flag {
pub const fn new() -> Self {
Self(
Once::new(),
AtomicBool::new(false),
AtomicUsize::new(0),
UnsafeCell::new(MaybeUninit::uninit()),
UnsafeCell::new(MaybeUninit::uninit()),
)
}
pub fn init(&self) {
let Self(once, _, _, cv, mx) = self;
once.call_once(|| unsafe {
cv.get().write(MaybeUninit::new(Condvar::new()));
mx.get().write(MaybeUninit::new(Mutex::new(())));
});
}
#[doc(hidden)]
pub unsafe fn acquire(&self) -> bool {
let Self(_, st, thread_id, _, _) = self;
if st.compare_and_swap(false, true, Acquire) && !self.acquire_slow() {
return false;
}
thread_id.store(get_thread_id(), Relaxed);
true
}
#[cold]
#[doc(hidden)]
pub unsafe fn acquire_slow(&self) -> bool {
let Self(_, st, thread_id, cv, mx) = self;
let cv = &*cv.get().cast::<Condvar>();
let mx = &*mx.get().cast::<Mutex<()>>();
if thread_id.load(Relaxed) == get_thread_id() {
// reentrant acquire, we can't make an owner if there is already
// an owner on the current thread, we also shouldn't block
// because we can never acquire an owner, so we must return false
false
} else {
let _ = cv
.wait_while(mx.lock().unwrap(), |()| {
st.compare_and_swap(false, true, Relaxed)
})
.unwrap();
true
}
}
#[doc(hidden)]
#[allow(unused)]
pub unsafe fn release(&self) {
let Self(_, st, thread_id, cv, _) = self;
let cv = &*cv.get().cast::<Condvar>();
thread_id.store(0, Relaxed);
st.store(false, Relaxed);
// if we are running miri, we are single threaded, so we don't need to notify
// also miri doesn't handle notify at all
#[cfg(not(miri))]
cv.notify_one();
}
}
}
#[cfg(not(feature = "std"))]
mod flag {
use core::sync::atomic::{AtomicBool, Ordering};
pub struct Flag(AtomicBool);
unsafe impl Send for Flag {}
unsafe impl Sync for Flag {}
impl Flag {
pub const fn new() -> Self {
Self(AtomicBool::new(false))
}
pub fn init(&self) {}
#[doc(hidden)]
pub fn acquire(&self) -> bool {
const SPIN_LIMIT: u32 = 6;
let mut backoff = 0;
while self
.0
.compare_exchange_weak(false, true, Ordering::Acquire, Ordering::Relaxed)
.is_err()
{
for _ in 0..1 << backoff.min(SPIN_LIMIT) {
core::sync::atomic::spin_loop_hint();
}
if backoff <= SPIN_LIMIT {
backoff += 1;
}
}
true
}
#[doc(hidden)]
pub fn release(&self) {
self.0.store(false, Ordering::Release)
}
}
}
}
struct Invariant<T>(fn() -> *mut T);
pub type Owner<Id> = crate::Owner<Type<Id>>;
pub type ICell<Id, T> = crate::ICell<TypeId<Id>, T>;
pub struct TypeId<T>(PhantomData<Invariant<T>>);
pub struct Type<T>(T, TypeId<T>);
impl<T> TypeId<T> {
#[inline(always)]
pub const fn new() -> Self {
Self(PhantomData)
}
}
impl<T> Type<T> {
/// # Safety
///
/// There must be at most 1 instance of `Type<T>` for any given `T`
/// on the current process
#[inline(always)]
pub const unsafe fn new_unchecked(value: T) -> Self {
Self(value, TypeId::new())
}
}
unsafe impl<T> crate::Transparent for TypeId<T> {}
unsafe impl<T> crate::Identifier for Type<T> {
type Id = TypeId<T>;
fn id(&self) -> Self::Id {
self.1
}
fn check_id(&self, _id: &Self::Id) -> bool {
true
}
}
impl<T> Default for TypeId<T> {
fn default() -> Self {
Self::new()
}
}
impl<T> Copy for TypeId<T> {}
impl<T> Clone for TypeId<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> core::fmt::Debug for TypeId<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("TypeId")
.field(&core::any::type_name::<T>())
.finish()
}
}
impl<T> core::fmt::Debug for Type<T> {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
f.debug_tuple("Type")
.field(&core::any::type_name::<T>())
.finish()
}
}
impl<T> Eq for TypeId<T> {}
impl<T> PartialEq for TypeId<T> {
fn eq(&self, _: &Self) -> bool {
true
}
}
impl<T> PartialOrd for TypeId<T> {
fn partial_cmp(&self, _: &Self) -> Option<core::cmp::Ordering> {
Some(core::cmp::Ordering::Equal)
}
}
impl<T> Ord for TypeId<T> {
fn cmp(&self, _: &Self) -> core::cmp::Ordering {
core::cmp::Ordering::Equal
}
}
impl<T> core::hash::Hash for TypeId<T> {
fn hash<H: core::hash::Hasher>(&self, _: &mut H) {}
}
impl<T> Eq for Type<T> {}
impl<T> PartialEq for Type<T> {
fn eq(&self, _: &Self) -> bool {
true
}
}
impl<T> PartialOrd for Type<T> {
fn partial_cmp(&self, _: &Self) -> Option<core::cmp::Ordering> {
Some(core::cmp::Ordering::Equal)
}
}
impl<T> Ord for Type<T> {
fn cmp(&self, _: &Self) -> core::cmp::Ordering {
core::cmp::Ordering::Equal
}
}
impl<T> core::hash::Hash for Type<T> {
fn hash<H: core::hash::Hasher>(&self, _: &mut H) {}
}
|
// Copyright 2016 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
use rustc::ty::TyCtxt;
use rustc::mir::*;
use rustc_data_structures::indexed_vec::Idx;
use transform::{MirPass, MirSource};
pub struct Deaggregator;
impl MirPass for Deaggregator {
fn run_pass<'a, 'tcx>(&self,
tcx: TyCtxt<'a, 'tcx, 'tcx>,
_source: MirSource,
mir: &mut Mir<'tcx>) {
let (basic_blocks, local_decls) = mir.basic_blocks_and_local_decls_mut();
let local_decls = &*local_decls;
for bb in basic_blocks {
bb.expand_statements(|stmt| {
// FIXME(eddyb) don't match twice on `stmt.kind` (post-NLL).
if let StatementKind::Assign(_, ref rhs) = stmt.kind {
if let Rvalue::Aggregate(ref kind, _) = *rhs {
// FIXME(#48193) Deaggregate arrays when it's cheaper to do so.
if let AggregateKind::Array(_) = **kind {
return None;
}
} else {
return None;
}
} else {
return None;
}
let stmt = stmt.replace_nop();
let source_info = stmt.source_info;
let (mut lhs, kind, operands) = match stmt.kind {
StatementKind::Assign(lhs, Rvalue::Aggregate(kind, operands))
=> (lhs, kind, operands),
_ => bug!()
};
let mut set_discriminant = None;
let active_field_index = match *kind {
AggregateKind::Adt(adt_def, variant_index, _, active_field_index) => {
if adt_def.is_enum() {
set_discriminant = Some(Statement {
kind: StatementKind::SetDiscriminant {
place: lhs.clone(),
variant_index,
},
source_info,
});
lhs = lhs.downcast(adt_def, variant_index);
}
active_field_index
}
_ => None
};
Some(operands.into_iter().enumerate().map(move |(i, op)| {
let lhs_field = if let AggregateKind::Array(_) = *kind {
// FIXME(eddyb) `offset` should be u64.
let offset = i as u32;
assert_eq!(offset as usize, i);
lhs.clone().elem(ProjectionElem::ConstantIndex {
offset,
// FIXME(eddyb) `min_length` doesn't appear to be used.
min_length: offset + 1,
from_end: false
})
} else {
let ty = op.ty(local_decls, tcx);
let field = Field::new(active_field_index.unwrap_or(i));
lhs.clone().field(field, ty)
};
Statement {
source_info,
kind: StatementKind::Assign(lhs_field, Rvalue::Use(op)),
}
}).chain(set_discriminant))
});
}
}
}
|
pub mod status;
use super::Apply;
use super::QueryActor;
use crate::sim::{SimState, SimTime};
use bevy_ecs::prelude::Entity;
use delegate::delegate;
use status::{Status, StatusFlag};
// TODO: Maybe a time ordered heap would be faster. Benchmark when we have more functionality.
#[derive(Default)]
pub struct StatusEffects(Vec<StatusEffect>);
impl StatusEffects {
delegate! {
to self.0 {
#[call(push)]
pub fn add(&mut self, status_effect: StatusEffect);
pub fn len(&self) -> usize;
pub fn iter(&self) -> std::slice::Iter<StatusEffect>;
}
}
pub fn remove_expired(&mut self, sim_time: SimTime) {
self.0.retain(|effect| !effect.is_expired(sim_time));
}
pub fn expire_with_flag(&mut self, flag: StatusFlag) {
for effect in self.0.iter_mut() {
if effect.has_flag(&flag) {
effect.expire();
}
}
}
}
#[derive(Clone, Debug)]
// Represents an applied status with an expiration
pub struct StatusEffect {
// expiration is the simulation timestamp when this status effect should be removed.
pub expiration: SimTime,
pub status: Status,
pub source: Entity,
// expired can be set to true to force an effect to expire without the expiration time passing.
pub force_expired: bool,
}
impl StatusEffect {
pub fn new(status: Status, source: Entity, sim_time: SimTime) -> StatusEffect {
return StatusEffect {
expiration: sim_time + status.duration,
status: status,
source: source,
force_expired: false,
};
}
pub fn is_expired(&self, sim_time: SimTime) -> bool {
self.force_expired || sim_time >= self.expiration
}
pub fn expire(&mut self) {
self.force_expired = true;
}
delegate! {
to self.status {
pub fn has_flag(&self, flag: &StatusFlag) -> bool;
}
}
}
impl Apply for StatusEffect {
fn apply(&self, sim: &SimState, query: &mut QueryActor, source: Entity, target: Entity) {
for effect in &self.status.effects {
effect.apply(sim, query, source, target);
}
}
}
#[cfg(test)]
mod tests {
use super::*;
use status::StatusFlags;
use std::collections::HashSet;
#[test]
fn status_effect_new() {
let status_effect = StatusEffect::new(Status::default(), Entity::new(1), 10);
assert_eq!(10, status_effect.expiration);
}
#[test]
fn status_effect_new2() {
let status_effect = StatusEffect::new(
Status {
duration: 1000,
..Status::default()
},
Entity::new(1),
10,
);
assert_eq!(1010, status_effect.expiration);
}
#[test]
fn receive_status_effect() -> std::result::Result<(), String> {
let mut effects = StatusEffects::default();
let status_effect = StatusEffect::new(Status::default(), Entity::new(1), 10);
assert_eq!(0, effects.len());
effects.add(status_effect);
assert_eq!(1, effects.len());
Ok(())
}
#[test]
fn remove_expired() {
let mut effects = StatusEffects::default();
let should_expire = Status {
name: "Should Expire".into(),
..Default::default()
};
let should_not_expire = Status {
name: "Should Not Expire".into(),
..Default::default()
};
effects.add(StatusEffect::new(should_expire.clone(), Entity::new(1), 10));
effects.add(StatusEffect::new(
should_not_expire.clone(),
Entity::new(2),
12,
));
effects.add(StatusEffect::new(should_expire.clone(), Entity::new(1), 10));
effects.add(StatusEffect::new(
should_not_expire.clone(),
Entity::new(2),
12,
));
effects.add(StatusEffect::new(should_expire.clone(), Entity::new(1), 10));
assert_eq!(5, effects.len());
effects.remove_expired(11);
assert_eq!(2, effects.len());
for effect in effects.iter() {
assert_eq!(should_not_expire.name, effect.status.name);
}
}
#[test]
fn expire_with_flag() {
let mut effects = StatusEffects::default();
let should_expire = Status {
name: "Should Expire".into(),
flags: StatusFlags::new(&[StatusFlag::ExpireOnDirectDamage]),
..Default::default()
};
let should_not_expire = Status {
name: "Should Not Expire".into(),
..Default::default()
};
effects.add(StatusEffect::new(should_expire.clone(), Entity::new(1), 12));
effects.add(StatusEffect::new(
should_not_expire.clone(),
Entity::new(1),
12,
));
effects.remove_expired(11);
assert_eq!(2, effects.len());
effects.expire_with_flag(StatusFlag::ExpireOnDirectDamage);
effects.remove_expired(11);
assert_eq!(1, effects.len());
for effect in effects.iter() {
assert_eq!(should_not_expire.name, effect.status.name);
}
}
#[test]
fn is_expired() {
let effect = StatusEffect::new(Status::default(), Entity::new(1), 10);
assert_eq!(false, effect.is_expired(9));
assert_eq!(true, effect.is_expired(10));
assert_eq!(true, effect.is_expired(11));
}
#[test]
fn expire() {
let mut effect = StatusEffect::new(Status::default(), Entity::new(1), 10);
assert_eq!(false, effect.is_expired(9));
effect.expire();
assert_eq!(true, effect.is_expired(9));
}
#[test]
fn has_flag() {
let mut flags = HashSet::<StatusFlag>::new();
flags.insert(StatusFlag::ExpireOnDirectDamage);
let effect = StatusEffect::new(
Status {
flags: StatusFlags::new(&[StatusFlag::ExpireOnDirectDamage]),
..Default::default()
},
Entity::new(1),
10,
);
assert_eq!(true, effect.has_flag(&StatusFlag::ExpireOnDirectDamage));
}
#[test]
fn has_flag2() {
let effect = StatusEffect::new(Status::default(), Entity::new(1), 10);
assert_eq!(false, effect.has_flag(&StatusFlag::ExpireOnDirectDamage));
}
}
|
#[doc = "Reader of register FDCAN_TTOCN"]
pub type R = crate::R<u32, super::FDCAN_TTOCN>;
#[doc = "Writer for register FDCAN_TTOCN"]
pub type W = crate::W<u32, super::FDCAN_TTOCN>;
#[doc = "Register FDCAN_TTOCN `reset()`'s with value 0"]
impl crate::ResetValue for super::FDCAN_TTOCN {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `SGT`"]
pub type SGT_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SGT`"]
pub struct SGT_W<'a> {
w: &'a mut W,
}
impl<'a> SGT_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 `ECS`"]
pub type ECS_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `ECS`"]
pub struct ECS_W<'a> {
w: &'a mut W,
}
impl<'a> ECS_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 `SWP`"]
pub type SWP_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `SWP`"]
pub struct SWP_W<'a> {
w: &'a mut W,
}
impl<'a> SWP_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 2)) | (((value as u32) & 0x01) << 2);
self.w
}
}
#[doc = "Reader of field `SWS`"]
pub type SWS_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `SWS`"]
pub struct SWS_W<'a> {
w: &'a mut W,
}
impl<'a> SWS_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 3)) | (((value as u32) & 0x03) << 3);
self.w
}
}
#[doc = "Reader of field `RTIE`"]
pub type RTIE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `RTIE`"]
pub struct RTIE_W<'a> {
w: &'a mut W,
}
impl<'a> RTIE_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 5)) | (((value as u32) & 0x01) << 5);
self.w
}
}
#[doc = "Reader of field `TMC`"]
pub type TMC_R = crate::R<u8, u8>;
#[doc = "Write proxy for field `TMC`"]
pub struct TMC_W<'a> {
w: &'a mut W,
}
impl<'a> TMC_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u8) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x03 << 6)) | (((value as u32) & 0x03) << 6);
self.w
}
}
#[doc = "Reader of field `TTIE`"]
pub type TTIE_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `TTIE`"]
pub struct TTIE_W<'a> {
w: &'a mut W,
}
impl<'a> TTIE_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 8)) | (((value as u32) & 0x01) << 8);
self.w
}
}
#[doc = "Reader of field `GCS`"]
pub type GCS_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `GCS`"]
pub struct GCS_W<'a> {
w: &'a mut W,
}
impl<'a> GCS_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 9)) | (((value as u32) & 0x01) << 9);
self.w
}
}
#[doc = "Reader of field `FGP`"]
pub type FGP_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `FGP`"]
pub struct FGP_W<'a> {
w: &'a mut W,
}
impl<'a> FGP_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 `TMG`"]
pub type TMG_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `TMG`"]
pub struct TMG_W<'a> {
w: &'a mut W,
}
impl<'a> TMG_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 `NIG`"]
pub type NIG_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `NIG`"]
pub struct NIG_W<'a> {
w: &'a mut W,
}
impl<'a> NIG_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 12)) | (((value as u32) & 0x01) << 12);
self.w
}
}
#[doc = "Reader of field `ESCN`"]
pub type ESCN_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `ESCN`"]
pub struct ESCN_W<'a> {
w: &'a mut W,
}
impl<'a> ESCN_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 13)) | (((value as u32) & 0x01) << 13);
self.w
}
}
#[doc = "Reader of field `LCKC`"]
pub type LCKC_R = crate::R<bool, bool>;
#[doc = "Write proxy for field `LCKC`"]
pub struct LCKC_W<'a> {
w: &'a mut W,
}
impl<'a> LCKC_W<'a> {
#[doc = r"Sets the field bit"]
#[inline(always)]
pub fn set_bit(self) -> &'a mut W {
self.bit(true)
}
#[doc = r"Clears the field bit"]
#[inline(always)]
pub fn clear_bit(self) -> &'a mut W {
self.bit(false)
}
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub fn bit(self, value: bool) -> &'a mut W {
self.w.bits = (self.w.bits & !(0x01 << 15)) | (((value as u32) & 0x01) << 15);
self.w
}
}
impl R {
#[doc = "Bit 0 - Set Global time"]
#[inline(always)]
pub fn sgt(&self) -> SGT_R {
SGT_R::new((self.bits & 0x01) != 0)
}
#[doc = "Bit 1 - External Clock Synchronization"]
#[inline(always)]
pub fn ecs(&self) -> ECS_R {
ECS_R::new(((self.bits >> 1) & 0x01) != 0)
}
#[doc = "Bit 2 - Stop Watch Polarity"]
#[inline(always)]
pub fn swp(&self) -> SWP_R {
SWP_R::new(((self.bits >> 2) & 0x01) != 0)
}
#[doc = "Bits 3:4 - Stop Watch Source."]
#[inline(always)]
pub fn sws(&self) -> SWS_R {
SWS_R::new(((self.bits >> 3) & 0x03) as u8)
}
#[doc = "Bit 5 - Register Time Mark Interrupt Pulse Enable"]
#[inline(always)]
pub fn rtie(&self) -> RTIE_R {
RTIE_R::new(((self.bits >> 5) & 0x01) != 0)
}
#[doc = "Bits 6:7 - Register Time Mark Compare"]
#[inline(always)]
pub fn tmc(&self) -> TMC_R {
TMC_R::new(((self.bits >> 6) & 0x03) as u8)
}
#[doc = "Bit 8 - Trigger Time Mark Interrupt Pulse Enable"]
#[inline(always)]
pub fn ttie(&self) -> TTIE_R {
TTIE_R::new(((self.bits >> 8) & 0x01) != 0)
}
#[doc = "Bit 9 - Gap Control Select"]
#[inline(always)]
pub fn gcs(&self) -> GCS_R {
GCS_R::new(((self.bits >> 9) & 0x01) != 0)
}
#[doc = "Bit 10 - Finish Gap."]
#[inline(always)]
pub fn fgp(&self) -> FGP_R {
FGP_R::new(((self.bits >> 10) & 0x01) != 0)
}
#[doc = "Bit 11 - Time Mark Gap"]
#[inline(always)]
pub fn tmg(&self) -> TMG_R {
TMG_R::new(((self.bits >> 11) & 0x01) != 0)
}
#[doc = "Bit 12 - Next is Gap"]
#[inline(always)]
pub fn nig(&self) -> NIG_R {
NIG_R::new(((self.bits >> 12) & 0x01) != 0)
}
#[doc = "Bit 13 - External Synchronization Control"]
#[inline(always)]
pub fn escn(&self) -> ESCN_R {
ESCN_R::new(((self.bits >> 13) & 0x01) != 0)
}
#[doc = "Bit 15 - TT Operation Control Register Locked"]
#[inline(always)]
pub fn lckc(&self) -> LCKC_R {
LCKC_R::new(((self.bits >> 15) & 0x01) != 0)
}
}
impl W {
#[doc = "Bit 0 - Set Global time"]
#[inline(always)]
pub fn sgt(&mut self) -> SGT_W {
SGT_W { w: self }
}
#[doc = "Bit 1 - External Clock Synchronization"]
#[inline(always)]
pub fn ecs(&mut self) -> ECS_W {
ECS_W { w: self }
}
#[doc = "Bit 2 - Stop Watch Polarity"]
#[inline(always)]
pub fn swp(&mut self) -> SWP_W {
SWP_W { w: self }
}
#[doc = "Bits 3:4 - Stop Watch Source."]
#[inline(always)]
pub fn sws(&mut self) -> SWS_W {
SWS_W { w: self }
}
#[doc = "Bit 5 - Register Time Mark Interrupt Pulse Enable"]
#[inline(always)]
pub fn rtie(&mut self) -> RTIE_W {
RTIE_W { w: self }
}
#[doc = "Bits 6:7 - Register Time Mark Compare"]
#[inline(always)]
pub fn tmc(&mut self) -> TMC_W {
TMC_W { w: self }
}
#[doc = "Bit 8 - Trigger Time Mark Interrupt Pulse Enable"]
#[inline(always)]
pub fn ttie(&mut self) -> TTIE_W {
TTIE_W { w: self }
}
#[doc = "Bit 9 - Gap Control Select"]
#[inline(always)]
pub fn gcs(&mut self) -> GCS_W {
GCS_W { w: self }
}
#[doc = "Bit 10 - Finish Gap."]
#[inline(always)]
pub fn fgp(&mut self) -> FGP_W {
FGP_W { w: self }
}
#[doc = "Bit 11 - Time Mark Gap"]
#[inline(always)]
pub fn tmg(&mut self) -> TMG_W {
TMG_W { w: self }
}
#[doc = "Bit 12 - Next is Gap"]
#[inline(always)]
pub fn nig(&mut self) -> NIG_W {
NIG_W { w: self }
}
#[doc = "Bit 13 - External Synchronization Control"]
#[inline(always)]
pub fn escn(&mut self) -> ESCN_W {
ESCN_W { w: self }
}
#[doc = "Bit 15 - TT Operation Control Register Locked"]
#[inline(always)]
pub fn lckc(&mut self) -> LCKC_W {
LCKC_W { w: self }
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.