text stringlengths 8 4.13M |
|---|
// Puzzle 1 (p.31 of the book)
const TOP_EDGE: u32 = 10000;
use arsak_zhak_programmirovanie_igr_i_golovolomok::*;
use std::env;
use std::str::FromStr;
// Run as puz1 [initial_value]
fn main() {
let args: Vec<String> = env::args().collect();
let mut p = if args.len() == 1 {
0
} else {
match u32::from_str(&args[1]) {
Ok(res) => res,
_ => 0,
}
};
let fn_random = |seed:u32| {
(TOP_EDGE as f32 * random(seed as f32 / TOP_EDGE as f32)).trunc() as u32
};
for _ in 0..TOP_EDGE { p = fn_random(p); }
let fix_p = p;
let mut period = 1;
loop {
p = fn_random(p);
if p == fix_p { break; } else { period += 1; };
}
println!("Period found == {}", period);
for _ in 0..=period { p = fn_random(p); print!("{} ", p) }
}
|
///! SpinLock implemented using AtomicBool
///! Just like Mutex except:
///!
///! 1. It uses CAS for locking, more efficient in low contention
///! 2. Use `.lock()` instead of `.lock().unwrap()` to retrieve the guard.
///! 3. It doesn't handle poison so data is still available on thread panic.
use std::cell::UnsafeCell;
use std::ops::Deref;
use std::ops::DerefMut;
use std::sync::atomic::AtomicBool;
use std::sync::atomic::Ordering;
pub struct SpinLock<T: ?Sized> {
locked: AtomicBool,
data: UnsafeCell<T>,
}
unsafe impl<T: ?Sized + Send> Send for SpinLock<T> {}
unsafe impl<T: ?Sized + Send> Sync for SpinLock<T> {}
pub struct SpinLockGuard<'a, T: ?Sized + 'a> {
// funny underscores due to how Deref/DerefMut currently work (they
// disregard field privacy).
__lock: &'a SpinLock<T>,
}
impl<'a, T: ?Sized + 'a> SpinLockGuard<'a, T> {
pub fn new(pool: &'a SpinLock<T>) -> SpinLockGuard<'a, T> {
Self { __lock: pool }
}
}
unsafe impl<'a, T: ?Sized + Sync> Sync for SpinLockGuard<'a, T> {}
impl<T> SpinLock<T> {
pub fn new(t: T) -> SpinLock<T> {
Self {
locked: AtomicBool::new(false),
data: UnsafeCell::new(t),
}
}
}
impl<T: ?Sized> SpinLock<T> {
pub fn lock(&self) -> SpinLockGuard<T> {
while self
.locked
.compare_exchange(false, true, Ordering::SeqCst, Ordering::SeqCst)
.is_err()
{}
SpinLockGuard::new(self)
}
}
impl<'mutex, T: ?Sized> Deref for SpinLockGuard<'mutex, T> {
type Target = T;
fn deref(&self) -> &T {
unsafe { &*self.__lock.data.get() }
}
}
impl<'mutex, T: ?Sized> DerefMut for SpinLockGuard<'mutex, T> {
fn deref_mut(&mut self) -> &mut T {
unsafe { &mut *self.__lock.data.get() }
}
}
impl<'a, T: ?Sized> Drop for SpinLockGuard<'a, T> {
#[inline]
fn drop(&mut self) {
while self
.__lock
.locked
.compare_exchange(true, false, Ordering::SeqCst, Ordering::SeqCst)
.is_err()
{}
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::sync::mpsc::channel;
use std::sync::Arc;
use std::thread;
#[derive(Eq, PartialEq, Debug)]
struct NonCopy(i32);
#[test]
fn smoke() {
let m = SpinLock::new(());
drop(m.lock());
drop(m.lock());
}
#[test]
fn lots_and_lots() {
const J: u32 = 1000;
const K: u32 = 3;
let m = Arc::new(SpinLock::new(0));
fn inc(m: &SpinLock<u32>) {
for _ in 0..J {
*m.lock() += 1;
}
}
let (tx, rx) = channel();
for _ in 0..K {
let tx2 = tx.clone();
let m2 = m.clone();
thread::spawn(move || {
inc(&m2);
tx2.send(()).unwrap();
});
let tx2 = tx.clone();
let m2 = m.clone();
thread::spawn(move || {
inc(&m2);
tx2.send(()).unwrap();
});
}
drop(tx);
for _ in 0..2 * K {
rx.recv().unwrap();
}
assert_eq!(*m.lock(), J * K * 2);
}
#[test]
fn test_mutex_unsized() {
let mutex: &SpinLock<[i32]> = &SpinLock::new([1, 2, 3]);
{
let b = &mut *mutex.lock();
b[0] = 4;
b[2] = 5;
}
let comp: &[i32] = &[4, 2, 5];
assert_eq!(&*mutex.lock(), comp);
}
}
|
fn main() {
let a = [0];
let i = 0;
println!("{}", a[i]);
}
|
extern crate wasm_bindgen;
use myna::crypto::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
pub fn verify(cert: Box<[u8]>, sig: Box<[u8]>, hash: Box<[u8]>) -> Result<bool, JsValue> {
let pubkey = extract_pubkey(&cert).map_err(|_| "Certificate is not DER format")?;
myna::crypto::verify(pubkey, &hash, &sig).map_err(|_| "Failed to verify signature")?;
Ok(true)
} |
// Determine the depth of each board by retrospective analysis.
//
// Input: 1-enum's output
//
// Output:
// board depth
// ...
//
// board: hex representation of bit-board
// depth: the depth of the board
// odd: black will win
// even: white will win
// -1: draw
#[macro_use]
extern crate precomp;
use precomp::{In, Out};
use precomp::board::{Board, Result};
use precomp::board_collection::BoardSet;
#[derive(Default)]
struct State {
prev_boards: Vec<Board>, // board list of depth-{N-1}
next_boards: Vec<Board>, // board list of depth-N
fixed: BoardSet, // boards whose depth is already fixed
unfixed: BoardSet, // boards whose depth is not fixed yet
}
// load all possible boards
fn load() -> State {
fn log(msg: &str, fixed: usize, unfixed: usize) {
log!("{} (unfixed: {}, fixed: {}, total: {})",
msg, unfixed, fixed, unfixed + fixed);
}
let mut s = State::default();
In::each(|b, depth, _| {
if depth == 0 {
// a depth-0 board is fixed
s.fixed.insert(b);
s.prev_boards.push(b);
}
else {
// a board whose depth is more than 0 is unfixed
s.unfixed.insert(b);
if depth == 1 { s.next_boards.push(b); }
}
if (s.fixed.len() + s.unfixed.len()) % 10000000 == 0 {
log("loading...", s.fixed.len(), s.unfixed.len());
}
});
log("loaded!", s.fixed.len(), s.unfixed.len());
s
}
// identify all depth-N boards
fn enumerate_next_boards(s: &mut State, depth: i32) {
// We can determine a board B is depth-N, only if:
// (1) N is odd (white's turn) and any B's next board is depth-{N-1}, or
// (2) N is even (black's turn) and all B's next boards are depth-{N-1}
//
// We call "a depth-N board candidate" if any next of the board is depth-{N-1}.
// Check if a depth-N board candidate satisfies the conditions above
#[inline]
fn check(fixed: &BoardSet, b: Board, depth: i32, next_boards: &mut Vec<Board>) {
if depth % 2 != 0 {
if let Result::Unknown(bs) = b.next() {
for b in bs {
if !fixed.contains(b) { return }
}
}
}
next_boards.push(b)
}
let prev_boards = &s.prev_boards;
let fixed = &s.fixed;
let unfixed = &s.unfixed;
let mut next_boards = &mut s.next_boards;
// There are two approaches to enumerate depth-N board candidates:
// 1) calculate back the depth-N candidates from all depth-{N-1} boards
// 2) filter the depth-N candidates that can proceed to any depth-N board
if prev_boards.len() * 4 < unfixed.len() {
// approach 1
let mut visited = BoardSet::new();
for b in prev_boards { // depth-{N-1} boards
for b in b.prev() { // calculate candidates
if unfixed.contains(b) { // skip unreachable board
if !visited.contains(b) { // avoid duplication
visited.insert(b);
// candidate found
check(fixed, b, depth, &mut next_boards);
}
}
}
}
}
else {
// approach 2
unfixed.each(|b| {
// candidate found
check(fixed, b, depth, &mut next_boards);
});
}
}
fn main() {
log!("Step 2: perform retrospective analysis");
let mut out = Out::new();
let mut s = load();
let init_board = Board::init().normalize();
let mut board_counts = vec![0, 0];
let mut init_depth = 0;
let mut depth = 0;
for b in &s.prev_boards { out!(out, "{:015x} 0\n", b.0); }
// retrospective analysis
while s.prev_boards.len() > 0 {
board_counts[depth % 2] += s.prev_boards.len();
log!("analyzing... (depth-{} boards: {}, unfixed boards: {})",
depth, s.prev_boards.len(), s.unfixed.len());
// identify all depth-N boards from depth-{N-1} boards
enumerate_next_boards(&mut s, depth as i32);
for &b in &s.next_boards {
s.fixed.insert(b);
s.unfixed.delete(b);
out!(out, "{:015x} {}\n", b.0, depth + 1);
if b == init_board { init_depth = depth; }
}
s.prev_boards = s.next_boards;
s.next_boards = vec![];
let len = s.unfixed.len();
s.unfixed.resize(len);
depth += 1;
}
s.unfixed.each(|b| { out!(out, "{:015x} -1\n", b.0); }); // draw
log!("Step 2: result");
log!(" black-winning boards: {:9}", board_counts[0]);
log!(" white-winning boards: {:9}", board_counts[1]);
log!(" draw : {:9}", s.unfixed.len());
log!(" max depth : {:3}", depth - 1);
log!(" init depth: {:3}", init_depth);
log!("Step 2: done!");
}
|
use std::collections::HashSet;
#[aoc_generator(day1)]
pub fn input_generator(input: &str) -> Vec<i32> {
input.lines().map(|l| l.parse().unwrap()).collect()
}
#[aoc(day1, part1)]
pub fn solve_part1(input: &[i32]) -> i32 {
input.iter().sum()
}
#[aoc(day1, part2)]
pub fn solve_part2(input: &[i32]) -> i32 {
let mut seen: HashSet<i32> = vec![0].into_iter().collect();
let mut current: i32 = 0;
for i in input.iter().cycle() {
current += i;
if !seen.insert(current) {
return current;
}
}
panic!("Never reached");
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn example1_1() {
assert_eq!(solve_part1(&[1, 1, 1]), 3);
}
#[test]
fn example1_2() {
assert_eq!(solve_part1(&[1, 1, -2]), 0);
}
#[test]
fn example1_3() {
assert_eq!(solve_part1(&[-1, -2, -3]), -6);
}
#[test]
fn example2_1() {
assert_eq!(solve_part2(&[1, -1]), 0);
}
#[test]
fn example2_2() {
assert_eq!(solve_part2(&[3, 3, 4, -2, -4]), 10);
}
#[test]
fn example2_3() {
assert_eq!(solve_part2(&vec![-6, 3, 8, 5, -6]), 5);
}
#[test]
fn example2_4() {
assert_eq!(solve_part2(&vec![7, 7, -2, -7, -4]), 14);
}
}
|
use std::time;
use crate::{client::Endpoint, core::MAX_CONNS, http::Http, Config, Error, Info, Random, Result};
// State of each endpoint. An endpoint is booted and subsequently
// used to watch/get future rounds of random-ness.
#[derive(Clone)]
pub(crate) struct State {
pub(crate) info: Info,
pub(crate) check_point: Option<Random>,
pub(crate) determinism: bool,
pub(crate) secure: bool,
pub(crate) max_conns: usize,
}
impl Default for State {
fn default() -> Self {
State {
info: Info::default(),
check_point: None,
determinism: bool::default(),
secure: bool::default(),
max_conns: MAX_CONNS,
}
}
}
impl From<Config> for State {
fn from(mut cfg: Config) -> Self {
State {
info: Info::default(),
check_point: cfg.check_point.take(),
determinism: cfg.determinism,
secure: cfg.secure,
max_conns: cfg.max_conns,
}
}
}
// Endpoints is an enumeration of several known http endpoint from
// main-net.
pub(crate) struct Endpoints {
name: String,
state: State,
endpoints: Vec<Inner>,
}
impl Endpoints {
pub(crate) fn from_config(name: &str, config: Config) -> Self {
Endpoints {
name: name.to_string(),
state: config.into(),
endpoints: Vec::default(),
}
}
pub(crate) fn add_endpoint(&mut self, endp: Endpoint) -> &mut Self {
let name = self.name.to_string();
let endp = match endp {
Endpoint::HttpDrandApi => {
let endp = Http::new_drand_api();
Inner::Http { name, endp }
}
Endpoint::HttpDrandApi2 => {
let endp = Http::new_drand_api();
Inner::Http { name, endp }
}
Endpoint::HttpDrandApi3 => {
let endp = Http::new_drand_api();
Inner::Http { name, endp }
}
Endpoint::HttpCloudflare => {
let endp = Http::new_drand_api();
Inner::Http { name, endp }
}
};
self.endpoints.push(endp);
self
}
pub(crate) fn to_info(&self) -> Info {
self.state.info.clone()
}
pub(crate) async fn boot(&mut self, chain_hash: Option<Vec<u8>>) -> Result<()> {
let agent = self.user_agent();
// root of trust.
let rot = chain_hash.as_ref().map(|x| x.as_slice());
let (info, latest) = match self.endpoints.len() {
0 => err_at!(Invalid, msg: format!("initialize endpoint"))?,
1 => self.endpoints[0].boot_phase1(rot, agent.clone()).await?,
_ => {
let (info, latest) = {
let endp = &mut self.endpoints[0];
endp.boot_phase1(rot, agent.clone()).await?
};
let mut tail = vec![];
for mut endp in self.endpoints[1..].to_vec() {
let (info1, latest1) = (info.clone(), latest.clone());
tail.push(async {
let (info2, _) = {
let agent = agent.clone();
endp.boot_phase1(rot, agent).await?
};
Self::boot_validate_info(info1, info2)?;
let s = {
let mut s = State::default();
s.check_point = None;
s.secure = false;
s
};
let (_, r) = {
let round = Some(latest1.round);
endp.get(s, round, agent.clone()).await?
};
Self::boot_validate_latest(latest1, r)?;
Ok::<Inner, Error>(endp)
})
}
futures::future::join_all(tail).await;
(info, latest)
}
};
self.state.info = info;
self.state = {
let s = self.state.clone();
self.endpoints[0]
.boot_phase2(s, latest, agent.clone())
.await?
};
Ok(())
}
pub(crate) async fn get(&mut self, round: Option<u128>) -> Result<Random> {
let agent = self.user_agent();
let (state, r) = loop {
match self.get_endpoint_pair() {
(Some(mut e1), Some(mut e2)) => {
let (res1, res2) = futures::join!(
e1.get(self.state.clone(), round, agent.clone()),
e2.get(self.state.clone(), round, agent.clone()),
);
match (res1, res2) {
(Ok((s1, r1)), Ok((s2, r2))) => {
if r1.round > r2.round {
break (s1, r1);
} else {
break (s2, r2);
};
}
(Ok((s1, r1)), Err(_)) => break (s1, r1),
(Err(_), Ok((s2, r2))) => break (s2, r2),
(Err(_), Err(_)) => (),
};
}
(Some(mut e1), None) => {
let state = self.state.clone();
let (state, r) = e1.get(state, round, agent).await?;
break (state, r);
}
(None, _) => {
let msg = format!("missing/exhausted endpoint");
err_at!(IOError, msg: msg)?
}
}
};
self.state = state;
Ok(r)
}
}
impl Endpoints {
fn boot_validate_info(this: Info, other: Info) -> Result<()> {
if this.public_key != other.public_key {
let x = hex::encode(&this.public_key);
let y = hex::encode(&other.public_key);
err_at!(NotSecure, msg: format!("public-key {} ! {}", x, y))
} else if this.hash != other.hash {
let x = hex::encode(&this.hash);
let y = hex::encode(&other.hash);
err_at!(NotSecure, msg: format!("hash {} != {}", x, y))
} else {
Ok(())
}
}
fn boot_validate_latest(this: Random, other: Random) -> Result<()> {
if this.round != other.round {
err_at!(
NotSecure,
msg: format!("round {} != {}", this.round, other.round)
)
} else if this.randomness != other.randomness {
let x = hex::encode(&this.randomness);
let y = hex::encode(&other.randomness);
err_at!(NotSecure, msg: format!("randomness {} != {} ", x, y))
} else if this.signature != other.signature {
let x = hex::encode(&this.signature);
let y = hex::encode(&other.signature);
err_at!(NotSecure, msg: format!("signature {} != {}", x, y))
} else if this.previous_signature != other.previous_signature {
let x = hex::encode(&this.previous_signature);
let y = hex::encode(&other.previous_signature);
err_at!(NotSecure, msg: format!("previous_signature {} != {}", x, y))
} else {
Ok(())
}
}
fn get_endpoint_pair(&self) -> (Option<Inner>, Option<Inner>) {
use crate::http::MAX_ELAPSED;
let mut endpoints = vec![];
for (i, endp) in self.endpoints.iter().enumerate() {
if endp.to_elapsed() < MAX_ELAPSED {
endpoints.push((i, endp.to_elapsed()));
}
}
endpoints.sort_by(|x, y| x.1.cmp(&y.1));
let mut iter = endpoints.iter();
match (iter.next(), iter.next()) {
(Some((i, _)), Some((j, _))) => {
let x = Some(self.endpoints[*i].clone());
let y = Some(self.endpoints[*j].clone());
(x, y)
}
(Some((i, _)), None) => {
let x = Some(self.endpoints[*i].clone());
let y = None;
(x, y)
}
(None, _) => (None, None),
}
}
fn user_agent(&self) -> Option<reqwest::header::HeaderValue> {
use reqwest::header::HeaderValue;
let agent = format!("drand-rs-{}", self.name);
HeaderValue::from_str(&agent).ok()
}
}
#[derive(Clone)]
enum Inner {
Http { name: String, endp: Http },
}
impl Inner {
async fn boot_phase1(
&mut self,
rot: Option<&[u8]>,
agent: Option<reqwest::header::HeaderValue>,
) -> Result<(Info, Random)> {
match self {
Inner::Http { endp, .. } => endp.boot_phase1(rot, agent).await,
}
}
async fn boot_phase2(
&mut self,
state: State,
latest: Random,
agent: Option<reqwest::header::HeaderValue>,
) -> Result<State> {
match self {
Inner::Http { endp, .. } => endp.boot_phase2(state, latest, agent).await,
}
}
async fn get(
&mut self,
state: State,
round: Option<u128>,
agent: Option<reqwest::header::HeaderValue>,
) -> Result<(State, Random)> {
match self {
Inner::Http { endp, .. } => endp.get(state, round, agent).await,
}
}
fn to_elapsed(&self) -> time::Duration {
match self {
Inner::Http { endp, .. } => endp.to_elapsed(),
}
}
}
|
#[macro_use(mem_info)]
extern crate arrayfire as af;
extern crate time;
use time::PreciseTime;
use af::*;
#[allow(unused_must_use)]
#[allow(unused_variables)]
fn main() {
set_device(0);
info();
let samples = 20_000_000;
let dims = Dim4::new(&[samples, 1, 1, 1]);
let x = &randu::<f32>(dims).unwrap();
let y = &randu::<f32>(dims).unwrap();
let start = PreciseTime::now();
mem_info!("Before benchmark");
for bench_iter in 0..100 {
let pi_val = add(&mul(x, x, false).unwrap(), &mul(y, y, false).unwrap(), false)
.and_then( |z| sqrt(&z) )
.and_then( |z| le(&z, &constant(1, dims).unwrap(), false) )
.and_then( |z| sum_all(&z) )
.map( |z| z.0 * 4.0/(samples as f64) )
.unwrap();
}
let end = PreciseTime::now();
println!("Estimated Pi Value in {} seconds", start.to(end) / 100);
mem_info!("After benchmark");
}
|
use itertools::Itertools;
use lazy_static::lazy_static;
use std::collections::HashMap;
struct Step {
name: &'static str,
prereqs: String,
}
impl Step {
fn new(name: &'static str) -> Self {
Step {
name,
prereqs: String::new(),
}
}
fn is_ready(&self, started: &str, completed: &str) -> bool {
!started.contains(&self.name)
&& self
.prereqs
.chars()
.all(|prereq| completed.contains(prereq))
}
}
lazy_static! {
static ref STEPS: Vec<Step> = {
let mut map = HashMap::new();
let constraints = include_str!("input.txt")
.lines()
.map(|line| (&line[5..6], &line[36..37]));
for (prereq, step) in constraints {
map.entry(step)
.or_insert_with(|| Step::new(step))
.prereqs
.push_str(prereq);
map.entry(prereq).or_insert_with(|| Step::new(prereq));
}
map.drain()
.map(|(_, step)| step)
.sorted_by_key(|step| step.name)
};
}
fn part1() {
let mut order = String::new();
while let Some(next_step) = STEPS
.iter()
.find(|step| step.is_ready(&order, &order))
.map(|step| step.name)
{
order.push_str(next_step);
}
println!("{}", order);
}
fn part2() {
let mut worked_on = String::new();
let mut completed = String::new();
let mut time = 0;
let mut workers = vec![Worker::default(); 5];
while completed.len() < 26 {
for worker in &mut workers {
if let Some(step) = worker.step {
if worker.elapsed >= time_needed(step) {
completed.push_str(step);
worker.step = None;
worker.elapsed = 0;
}
}
}
for worker in &mut workers {
if worker.step.is_none() {
worker.step = STEPS
.iter()
.find(|step| step.is_ready(&worked_on, &completed))
.map(|step| step.name);
}
if let Some(step) = worker.step {
if !worked_on.contains(step) {
worked_on.push_str(step);
}
worker.elapsed += 1;
}
}
time += 1;
}
println!("{}", time - 1);
#[derive(Clone, Default)]
struct Worker {
step: Option<&'static str>,
elapsed: u8,
}
fn time_needed(step: &str) -> u8 {
step.as_bytes()[0] - b'A' + 61
}
}
fn main() {
part1();
part2();
}
|
use crate::proxy::{Router, RouterTrait};
use hyper::service::Service;
use hyper::{Body, Request, Response};
use std::future::Future;
use std::pin::Pin;
use std::task::{Context, Poll};
pub struct Svc {
router: Router,
}
impl Service<Request<Body>> for Svc {
type Response = Response<Body>;
type Error = hyper::Error;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
fn poll_ready(&mut self, _cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, req: Request<Body>) -> Self::Future {
let router_clone = self.router.clone();
Box::pin(async move { router_clone.route(req).await })
}
}
pub struct MakeSvc {
pub router: Router,
}
impl<T> Service<T> for MakeSvc {
type Response = Svc;
type Error = hyper::Error;
type Future = Pin<Box<dyn Future<Output = Result<Self::Response, Self::Error>> + Send>>;
fn poll_ready(&mut self, _: &mut Context) -> Poll<Result<(), Self::Error>> {
Poll::Ready(Ok(()))
}
fn call(&mut self, _: T) -> Self::Future {
let router = self.router.clone();
let future = async move { Ok(Svc { router }) };
Box::pin(future)
}
}
|
/// Trait describing frame rates.
pub trait FrameRate {
const FPS: u32;
const DROP_FRAME: bool;
#[doc(hidden)]
const MAX_FRAMES: u32;
#[doc(hidden)]
const FRAMES_PER_MINUTE: u32 = Self::FPS * 60;
#[doc(hidden)]
const FRAMES_PER_HOUR: u32 = Self::FRAMES_PER_MINUTE * 60;
#[doc(hidden)]
const DROP_FRAME_COUNT: u32 = Self::FPS / 15;
/// Given the elements of a timecode, calculate the frame offset from zero.
#[doc(hidden)]
fn calculate_frame_number(
hour: u32,
minute: u32,
second: u32,
frame: u32,
) -> Option<u32> {
if hour > 23 || minute > 59 || second > 59 || frame > Self::FPS
|| (Self::DROP_FRAME && second == 0 && minute % 10 != 0
&& frame < Self::DROP_FRAME_COUNT)
{
return None;
}
let frame_number_before_drop_frames =
(Self::FRAMES_PER_HOUR * hour as u32)
+ (Self::FRAMES_PER_MINUTE * minute as u32)
+ (Self::FPS * second as u32) + frame as u32;
let frame_number = if Self::DROP_FRAME {
let tens = hour * 6 + minute / 10;
let minutes_without_tens = minute % 10;
let drop_frame_minutes_without_tens = if minutes_without_tens > 1 {
minutes_without_tens
} else {
0
};
let drop_frames_per_ten = Self::DROP_FRAME_COUNT * 9;
frame_number_before_drop_frames - (tens * drop_frames_per_ten)
- drop_frame_minutes_without_tens * Self::DROP_FRAME_COUNT
} else {
frame_number_before_drop_frames
};
Some(frame_number)
}
/// Given a frame number, calculate the fields for a time code.
#[doc(hidden)]
fn calculate_time_code(frame_number: u32) -> (u8, u8, u8, u8) {
if frame_number > Self::MAX_FRAMES {
panic!(
"Frame rate only supports up to {:?} frames.",
Self::MAX_FRAMES
);
}
let (hour, minute, second, frame) = if Self::DROP_FRAME {
let frames_per_drop_minute =
Self::FRAMES_PER_MINUTE - Self::DROP_FRAME_COUNT;
let frames_per_ten =
Self::FRAMES_PER_MINUTE + (frames_per_drop_minute * 9);
let frames_per_hour = frames_per_ten * 6;
let hour = frame_number / frames_per_hour;
let frame_number_without_hours = frame_number % frames_per_hour;
let tens = frame_number_without_hours / frames_per_ten;
let frame_number_without_tens =
frame_number_without_hours % frames_per_ten;
let (minute, second, frame) = if frame_number_without_tens
< Self::FRAMES_PER_MINUTE
{
let minute = tens * 10;
let frame_number_without_minutes = frame_number_without_tens;
let second = frame_number_without_minutes / Self::FPS;
let frame = frame_number_without_minutes % Self::FPS;
(minute, second, frame)
} else {
let frame_number_without_first_minute =
frame_number_without_tens - Self::FRAMES_PER_MINUTE;
let minute = 1
+ (frame_number_without_first_minute
/ frames_per_drop_minute);
let frame_number_without_minutes =
(frame_number_without_first_minute % frames_per_drop_minute)
+ Self::DROP_FRAME_COUNT;
let second = frame_number_without_minutes / Self::FPS;
let frame = frame_number_without_minutes % Self::FPS;
(tens * 10 + minute, second, frame)
};
(hour, minute, second, frame)
} else {
let total_seconds = frame_number / Self::FPS;
let total_minutes = total_seconds / 60;
let hour = total_minutes / 60;
let minute = total_minutes % 60;
let second = total_seconds % 60;
let frame = frame_number % Self::FPS;
(hour, minute, second, frame)
};
(hour as u8, minute as u8, second as u8, frame as u8)
}
}
macro_rules! create_frame_rate {
($frame_rate_name:ident, $frame_rate:expr, false) => (
#[derive(Debug, PartialEq)]
pub struct $frame_rate_name;
impl FrameRate for $frame_rate_name {
const FPS: u32 = $frame_rate;
const DROP_FRAME: bool = false;
const MAX_FRAMES: u32 = 86400 * Self::FPS;
}
);
($frame_rate_name:ident, $frame_rate:expr, true) => (
#[derive(Debug, PartialEq)]
pub struct $frame_rate_name;
impl FrameRate for $frame_rate_name {
const FPS: u32 = $frame_rate;
const DROP_FRAME: bool = true;
const MAX_FRAMES: u32 = 86400 * Self::FPS
- 144 * (18 * (Self::FPS / 30));
}
);
}
create_frame_rate!(FrameRate24, 24, false);
create_frame_rate!(FrameRate25, 25, false);
create_frame_rate!(FrameRate30, 30, false);
create_frame_rate!(FrameRate50, 50, false);
create_frame_rate!(FrameRate60, 60, false);
create_frame_rate!(FrameRate2398, 24, false);
create_frame_rate!(FrameRate2997, 30, true);
create_frame_rate!(FrameRate5994, 60, true);
pub trait NormalizeFrameNumber<T> {
fn normalize(self, max_frames: T) -> u32;
}
macro_rules! impl_int_unsigned {
($($t:ty)*) => ($(
impl NormalizeFrameNumber<$t> for $t {
fn normalize(self, max_frames: $t) -> u32 {
(self % max_frames) as u32
}
}
)*)
}
impl_int_unsigned! { usize u8 u16 u32 u64 }
macro_rules! impl_int_signed {
($($t:ty)*) => ($(
impl NormalizeFrameNumber<$t> for $t {
fn normalize(self, max_frames: $t) -> u32 {
let remainder = self % max_frames;
let result = if remainder < 0 {
remainder + max_frames
} else {
remainder
};
result as u32
}
}
)*)
}
impl_int_signed! { isize i8 i16 i32 i64 }
|
use perseus::{ErrorPages, GenericNode};
use std::rc::Rc;
use sycamore::template;
// This site will be exported statically, so we only have control over 404 pages for broken links in the site itself
pub fn get_error_pages<G: GenericNode>() -> ErrorPages<G> {
let mut error_pages = ErrorPages::new(Rc::new(|url, status, err, _| {
template! {
p { (format!("An error with HTTP code {} occurred at '{}': '{}'.", status, url, err)) }
}
}));
error_pages.add_page(
404,
Rc::new(|_, _, _, _| {
template! {
p { "Page not found." }
}
}),
);
error_pages
}
|
fn ground_lifetime<'a>(x: &'a u64) -> &'a u64
{
x
}
struct Ref<'a, T: 'a>(&'a T);
trait Red { }
struct Ball<'a> {
diameter: &'a i32,
}
impl<'a> Red for Ball<'a> { }
static num: i32 = 5;
struct Context<'s>(&'s mut String);
impl<'s> Context<'s>
{
fn mutate<'c>(&mut self, cs: &'c mut String) -> &'c mut String
{
let swap_a = self.0.pop().unwrap();
let swap_b = cs.pop().unwrap();
self.0.push(swap_b);
cs.push(swap_a);
cs
}
}
fn main()
{
let x = 3;
ground_lifetime(&x);
let obj = Box::new(Ball { diameter: &num }) as Box<Red + 'static>;
let mut s = "outside string context abc".to_string();
{
//temporary context
let mut c = Context(&mut s);
{
//further temporary context
let mut s2 = "inside string context def".to_string();
c.mutate(&mut s2);
println!("s2 {}", s2);
}
}
println!("s {}", s);
}
|
#[doc = "Register `DDRCTRL_ADDRMAP1` reader"]
pub type R = crate::R<DDRCTRL_ADDRMAP1_SPEC>;
#[doc = "Register `DDRCTRL_ADDRMAP1` writer"]
pub type W = crate::W<DDRCTRL_ADDRMAP1_SPEC>;
#[doc = "Field `ADDRMAP_BANK_B0` reader - ADDRMAP_BANK_B0"]
pub type ADDRMAP_BANK_B0_R = crate::FieldReader;
#[doc = "Field `ADDRMAP_BANK_B0` writer - ADDRMAP_BANK_B0"]
pub type ADDRMAP_BANK_B0_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 6, O>;
#[doc = "Field `ADDRMAP_BANK_B1` reader - ADDRMAP_BANK_B1"]
pub type ADDRMAP_BANK_B1_R = crate::FieldReader;
#[doc = "Field `ADDRMAP_BANK_B1` writer - ADDRMAP_BANK_B1"]
pub type ADDRMAP_BANK_B1_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 6, O>;
#[doc = "Field `ADDRMAP_BANK_B2` reader - ADDRMAP_BANK_B2"]
pub type ADDRMAP_BANK_B2_R = crate::FieldReader;
#[doc = "Field `ADDRMAP_BANK_B2` writer - ADDRMAP_BANK_B2"]
pub type ADDRMAP_BANK_B2_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 6, O>;
impl R {
#[doc = "Bits 0:5 - ADDRMAP_BANK_B0"]
#[inline(always)]
pub fn addrmap_bank_b0(&self) -> ADDRMAP_BANK_B0_R {
ADDRMAP_BANK_B0_R::new((self.bits & 0x3f) as u8)
}
#[doc = "Bits 8:13 - ADDRMAP_BANK_B1"]
#[inline(always)]
pub fn addrmap_bank_b1(&self) -> ADDRMAP_BANK_B1_R {
ADDRMAP_BANK_B1_R::new(((self.bits >> 8) & 0x3f) as u8)
}
#[doc = "Bits 16:21 - ADDRMAP_BANK_B2"]
#[inline(always)]
pub fn addrmap_bank_b2(&self) -> ADDRMAP_BANK_B2_R {
ADDRMAP_BANK_B2_R::new(((self.bits >> 16) & 0x3f) as u8)
}
}
impl W {
#[doc = "Bits 0:5 - ADDRMAP_BANK_B0"]
#[inline(always)]
#[must_use]
pub fn addrmap_bank_b0(&mut self) -> ADDRMAP_BANK_B0_W<DDRCTRL_ADDRMAP1_SPEC, 0> {
ADDRMAP_BANK_B0_W::new(self)
}
#[doc = "Bits 8:13 - ADDRMAP_BANK_B1"]
#[inline(always)]
#[must_use]
pub fn addrmap_bank_b1(&mut self) -> ADDRMAP_BANK_B1_W<DDRCTRL_ADDRMAP1_SPEC, 8> {
ADDRMAP_BANK_B1_W::new(self)
}
#[doc = "Bits 16:21 - ADDRMAP_BANK_B2"]
#[inline(always)]
#[must_use]
pub fn addrmap_bank_b2(&mut self) -> ADDRMAP_BANK_B2_W<DDRCTRL_ADDRMAP1_SPEC, 16> {
ADDRMAP_BANK_B2_W::new(self)
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
}
#[doc = "DDRCTRL address map register 1\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`ddrctrl_addrmap1::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`ddrctrl_addrmap1::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct DDRCTRL_ADDRMAP1_SPEC;
impl crate::RegisterSpec for DDRCTRL_ADDRMAP1_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`ddrctrl_addrmap1::R`](R) reader structure"]
impl crate::Readable for DDRCTRL_ADDRMAP1_SPEC {}
#[doc = "`write(|w| ..)` method takes [`ddrctrl_addrmap1::W`](W) writer structure"]
impl crate::Writable for DDRCTRL_ADDRMAP1_SPEC {
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets DDRCTRL_ADDRMAP1 to value 0"]
impl crate::Resettable for DDRCTRL_ADDRMAP1_SPEC {
const RESET_VALUE: Self::Ux = 0;
}
|
extern crate cc;
use std::env;
static ARCH_FLAGS: &[&str] = &["-mthumb-interwork", "-mcpu=arm946e-s", "-msoft-float"];
fn gcc_config() -> cc::Build {
let mut config = cc::Build::new();
for flag in ARCH_FLAGS {
config.flag(flag);
}
config
.flag("-fno-strict-aliasing")
.flag("-std=c11");
config
}
fn main() {
println!("cargo:rerun-if-env-changed=C9_PROG_TYPE");
// Make sure the requested program actually exists
let prog = env::var("C9_PROG_TYPE").unwrap();
let modfile = include_str!("src/programs/mod.rs");
let start = modfile.find("define_programs!(").unwrap();
let end = modfile[start..].find(");").unwrap() + start;
modfile[start..end].find(&format!("\"{}\"", prog))
.expect(&format!("Could not find program `{}`!", prog));
println!("cargo:rerun-if-changed=src/start.s");
println!("cargo:rerun-if-changed=src/interrupts.s");
println!("cargo:rerun-if-changed=src/caches.s");
gcc_config()
.file("src/start.s")
.file("src/interrupts.s")
.file("src/caches.s")
.compile("libstart.a");
println!("cargo:rerun-if-changed=src/armwrestler.s");
println!("cargo:rerun-if-changed=src/cache_benchers.s");
gcc_config()
.flag("-w")
.file("src/programs/armwrestler.s")
.file("src/programs/thumbwrestler.s")
.file("src/programs/cache_benchers.s")
.compile("libtestasm.a");
println!("cargo:rerun-if-changed=src/programs/os/entry.s");
gcc_config()
.flag("-w")
.file("src/programs/os/entry.s")
.compile("libosasm.a");
gcc_config()
.flag("-w")
.include("Decrypt9WIP/source/fatfs")
.include("Decrypt9WIP/source")
.file("Decrypt9WIP/source/fatfs/ff.c")
.file("Decrypt9WIP/source/fatfs/delay.s")
.file("Decrypt9WIP/source/fatfs/sdmmc.c")
.file("Decrypt9WIP/source/fatfs/diskio.c")
.file("Decrypt9WIP/source/fs.c")
.compile("libd9fs.a");
}
|
fn main() {
let r1 = Rect {
width: 12,
height: 12,
};
println!("area is: {}", r1.area());
}
struct Rect {
width: u32,
height: u32,
}
// 这里实现方法
impl Rect {
// 实现 area 方法
// &self 来替代 rect: &Rect
// 这里是借用 &self
// 也可以是可变的借用 &mut self
// 也可以获取所有权 self, 这种非常少, 这种技术通常用在当方法将 self 转换成别的实例的时候,这时我们想要防止调用者在转换之后使用原始的实例
fn area(&self) -> u32 {
self.width * self.height
}
}
|
extern crate clap;
mod index;
mod info;
mod stat;
mod util;
use clap::{App, Arg, SubCommand};
use info::Info;
use stat::Stat;
fn main() {
let matches = App::new("Tutor")
.version("0.1")
.about("Command line tutorials")
.author("Abdun Nihaal")
.subcommand(
SubCommand::with_name("list")
.alias("ls")
.about("Lists the sections and excercises")
.arg(
Arg::with_name("section")
.help("section that you want to list")
.index(1),
),
)
.subcommand(
SubCommand::with_name("instruction")
.alias("i")
.about("Gives introductary instructions about the tutorial"),
)
.subcommand(
SubCommand::with_name("check")
.alias("c")
.about("Checks if the solution is correct")
.arg(
Arg::with_name("file")
.help("The solution file to check")
.required(true)
.index(1),
),
)
.subcommand(
SubCommand::with_name("lesson")
.alias("l")
.about("Prints the current lesson")
.arg(
Arg::with_name("lesson_index")
.help("The lesson whose text is to be printed")
.index(1),
),
)
.subcommand(
SubCommand::with_name("task")
.alias("t")
.about("Prints the current task")
.arg(
Arg::with_name("lesson_index")
.help("The lesson whose task is to be printed")
.index(1),
),
)
.subcommand(
SubCommand::with_name("hint")
.alias("h")
.about("Prints a hint if provided in the lesson")
.arg(
Arg::with_name("next")
.help("Opens the next hidden hint")
.index(1),
),
)
.get_matches();
let info: Info = info::read_tutorinfo();
let mut stat: Stat;
let read_option = stat::read_tutorstat();
if read_option.is_none() {
stat = stat::new(
info.get_tutorial_version(),
"1.1".to_string(),
info.get_total_lessons(),
);
println!("{}", info.get_instructions());
} else {
stat = read_option.unwrap();
}
let current_file: String;
let lesson_file_result = info.get_lesson_file(stat.get_current_lesson());
if lesson_file_result.is_ok() {
current_file = lesson_file_result.unwrap();
} else {
println!("{}", lesson_file_result.err().unwrap());
return;
}
if let Some(cmd_matches) = matches.subcommand_matches("list") {
let section_str = cmd_matches.value_of("section").unwrap_or("");
}
if let Some(cmd_matches) = matches.subcommand_matches("instruction") {
println!("{}", info.get_instructions());
}
if let Some(cmd_matches) = matches.subcommand_matches("check") {
let file = cmd_matches.value_of("file").unwrap();
if let Ok(shell_script) = util::get_section(¤t_file, "check") {
if util::check(shell_script, file) {
println!("Correct");
print!(
"{}",
util::get_section(¤t_file, "solution")
.unwrap_or("No solution text for this lesson".to_string())
);
//TODO Add to finished tasks in the stat structure
if let Some(next_lesson) =
info.get_next_lesson(index::new_from_string(stat.get_current_lesson()).unwrap())
{
stat.set_current_lesson(next_lesson);
} else {
// TODO Check for unfinished tasks before congratulating
println!("Congratulations! you have completed the tutorial");
}
} else {
println!("Incorrect. Try again");
}
}
}
if let Some(cmd_matches) = matches.subcommand_matches("lesson") {
let lesson_index = cmd_matches.value_of("lesson_index").unwrap_or("");
print!(
"{}",
util::get_section(¤t_file, "lesson")
.unwrap_or("No help text for this lesson".to_string())
);
}
if let Some(cmd_matches) = matches.subcommand_matches("task") {
let lesson_index = cmd_matches.value_of("lesson_index").unwrap_or("");
print!(
"{}",
util::get_section(¤t_file, "task")
.unwrap_or("No task for this lesson".to_string())
);
}
if let Some(cmd_matches) = matches.subcommand_matches("hint") {
let next = cmd_matches.value_of("section").is_some();
//TODO get the number of hints used from tutorstats
//Also update when next is set
let num_hints = 5;
if let Ok(hints) = util::get_section(¤t_file, "hint") {
let (text, hints_read) =
util::get_n_hints(hints, num_hints).unwrap_or(("".to_string(), 0));
print!("{}", text);
if hints_read < num_hints {
println!("Only {} hints available for this task", hints_read);
}
} else {
println!("No hints for this task");
}
}
stat::write_tutorstat(stat);
}
|
#![macro_use]
use core::cell::UnsafeCell;
use core::marker::PhantomData;
use core::sync::atomic::{compiler_fence, Ordering};
use embassy::util::Unborrow;
use embassy_extras::unborrow;
use crate::gpio::sealed::Pin as _;
use crate::gpio::OptionalPin as GpioOptionalPin;
use crate::interrupt::Interrupt;
use crate::pac;
#[derive(Debug, Eq, PartialEq, Clone, Copy)]
pub enum Prescaler {
Div1,
Div2,
Div4,
Div8,
Div16,
Div32,
Div64,
Div128,
}
/// Interface to the UARTE peripheral
pub struct Pwm<'d, T: Instance> {
phantom: PhantomData<&'d mut T>,
}
impl<'d, T: Instance> Pwm<'d, T> {
/// Creates the interface to a UARTE instance.
/// Sets the baud rate, parity and assigns the pins to the UARTE peripheral.
///
/// # Safety
///
/// The returned API is safe unless you use `mem::forget` (or similar safe mechanisms)
/// on stack allocated buffers which which have been passed to [`send()`](Pwm::send)
/// or [`receive`](Pwm::receive).
#[allow(unused_unsafe)]
pub fn new(
_pwm: impl Unborrow<Target = T> + 'd,
ch0: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
ch1: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
ch2: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
ch3: impl Unborrow<Target = impl GpioOptionalPin> + 'd,
) -> Self {
unborrow!(ch0, ch1, ch2, ch3);
let r = T::regs();
let s = T::state();
if let Some(pin) = ch0.pin_mut() {
pin.set_low();
pin.conf().write(|w| w.dir().output());
}
if let Some(pin) = ch1.pin_mut() {
pin.set_low();
pin.conf().write(|w| w.dir().output());
}
if let Some(pin) = ch2.pin_mut() {
pin.set_low();
pin.conf().write(|w| w.dir().output());
}
if let Some(pin) = ch3.pin_mut() {
pin.set_low();
pin.conf().write(|w| w.dir().output());
}
r.psel.out[0].write(|w| unsafe { w.bits(ch0.psel_bits()) });
r.psel.out[1].write(|w| unsafe { w.bits(ch1.psel_bits()) });
r.psel.out[2].write(|w| unsafe { w.bits(ch2.psel_bits()) });
r.psel.out[3].write(|w| unsafe { w.bits(ch3.psel_bits()) });
// Disable all interrupts
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
// Enable
r.enable.write(|w| w.enable().enabled());
r.seq0
.ptr
.write(|w| unsafe { w.bits(&s.duty as *const _ as u32) });
r.seq0.cnt.write(|w| unsafe { w.bits(4) });
r.seq0.refresh.write(|w| unsafe { w.bits(32) });
r.seq0.enddelay.write(|w| unsafe { w.bits(0) });
r.decoder.write(|w| {
w.load().individual();
w.mode().refresh_count()
});
r.mode.write(|w| w.updown().up());
r.prescaler.write(|w| w.prescaler().div_1());
r.countertop
.write(|w| unsafe { w.countertop().bits(32767) });
r.loop_.write(|w| w.cnt().disabled());
Self {
phantom: PhantomData,
}
}
/// Enables the PWM generator.
#[inline(always)]
pub fn enable(&self) {
let r = T::regs();
r.enable.write(|w| w.enable().enabled());
}
/// Disables the PWM generator.
#[inline(always)]
pub fn disable(&self) {
let r = T::regs();
r.enable.write(|w| w.enable().disabled());
}
/// Sets duty cycle (15 bit) for a PWM channel.
pub fn set_duty(&self, channel: usize, duty: u16) {
let s = T::state();
unsafe { (*s.duty.get())[channel] = duty & 0x7FFF };
compiler_fence(Ordering::SeqCst);
T::regs().tasks_seqstart[0].write(|w| unsafe { w.bits(1) });
}
/// Sets the PWM clock prescaler.
#[inline(always)]
pub fn set_prescaler(&self, div: Prescaler) {
T::regs().prescaler.write(|w| w.prescaler().bits(div as u8));
}
/// Sets the PWM clock prescaler.
#[inline(always)]
pub fn prescaler(&self) -> Prescaler {
match T::regs().prescaler.read().prescaler().bits() {
0 => Prescaler::Div1,
1 => Prescaler::Div2,
2 => Prescaler::Div4,
3 => Prescaler::Div8,
4 => Prescaler::Div16,
5 => Prescaler::Div32,
6 => Prescaler::Div64,
7 => Prescaler::Div128,
_ => unreachable!(),
}
}
/// Sets the maximum duty cycle value.
#[inline(always)]
pub fn set_max_duty(&self, duty: u16) {
T::regs()
.countertop
.write(|w| unsafe { w.countertop().bits(duty.min(32767u16)) });
}
/// Returns the maximum duty cycle value.
#[inline(always)]
pub fn max_duty(&self) -> u16 {
T::regs().countertop.read().countertop().bits()
}
/// Sets the PWM output frequency.
#[inline(always)]
pub fn set_period(&self, freq: u32) {
let clk = 16_000_000u32 >> (self.prescaler() as u8);
let duty = clk / freq;
self.set_max_duty(duty.min(32767) as u16);
}
/// Returns the PWM output frequency.
#[inline(always)]
pub fn period(&self) -> u32 {
let clk = 16_000_000u32 >> (self.prescaler() as u8);
let max_duty = self.max_duty() as u32;
clk / max_duty
}
}
impl<'a, T: Instance> Drop for Pwm<'a, T> {
fn drop(&mut self) {
let r = T::regs();
r.enable.write(|w| w.enable().disabled());
info!("pwm drop: done");
// TODO: disable pins
}
}
pub(crate) mod sealed {
use super::*;
pub struct State {
pub duty: UnsafeCell<[u16; 4]>,
}
unsafe impl Sync for State {}
impl State {
pub const fn new() -> Self {
Self {
duty: UnsafeCell::new([0; 4]),
}
}
}
pub trait Instance {
fn regs() -> &'static pac::pwm0::RegisterBlock;
fn state() -> &'static State;
}
}
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}
macro_rules! impl_pwm {
($type:ident, $pac_type:ident, $irq:ident) => {
impl crate::pwm::sealed::Instance for peripherals::$type {
fn regs() -> &'static pac::pwm0::RegisterBlock {
unsafe { &*pac::$pac_type::ptr() }
}
fn state() -> &'static crate::pwm::sealed::State {
static STATE: crate::pwm::sealed::State = crate::pwm::sealed::State::new();
&STATE
}
}
impl crate::pwm::Instance for peripherals::$type {
type Interrupt = crate::interrupt::$irq;
}
};
}
|
pub use self::pattern::Pattern;
pub use self::track::Track;
mod track;
mod pattern; |
use crate::config::cache::Cache;
use crate::lib::error::{BuildError, DfxError, DfxResult};
use anyhow::{anyhow, bail};
use std::process::Command;
/// Package arguments for moc or mo-ide as returned by
/// a package tool like https://github.com/kritzcreek/vessel
/// or, if there is no package tool, the base library.
pub type PackageArguments = Vec<String>;
pub fn load(cache: &dyn Cache, packtool: &Option<String>) -> DfxResult<PackageArguments> {
if packtool.is_none() {
let stdlib_path = cache
.get_binary_command_path("base")?
.into_os_string()
.into_string()
.map_err(|_| anyhow!("Path contains invalid Unicode data."))?;
let base = vec![String::from("--package"), String::from("base"), stdlib_path];
return Ok(base);
}
let commandline: Vec<String> = packtool
.as_ref()
.unwrap()
.split_ascii_whitespace()
.map(String::from)
.collect();
let mut cmd = Command::new(commandline[0].clone());
for arg in commandline.iter().skip(1) {
cmd.arg(arg);
}
let output = match cmd.output() {
Ok(output) => output,
Err(err) => bail!(
"Failed to invoke the package tool {:?}\n the error was: {}",
cmd,
err
),
};
if !output.status.success() {
return Err(DfxError::new(BuildError::CommandError(
format!("{:?}", cmd),
output.status,
String::from_utf8_lossy(&output.stdout).to_string(),
String::from_utf8_lossy(&output.stderr).to_string(),
)));
}
let package_arguments = String::from_utf8_lossy(&output.stdout)
.split_ascii_whitespace()
.map(String::from)
.collect();
Ok(package_arguments)
}
|
use std::panic;
use rocket::{self, http::{ContentType, Header, Status}, local::Client};
use diesel::connection::SimpleConnection;
use horus_server::{self, routes::manage::*};
use test::{run_test, sql::*};
#[test]
fn my_pastes()
{
run(|| {
let client = get_client();
let req = client.get("/manage/pastes/0").header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
// TODO: Make sure its truncated (it's not currently.)
assert!(response.body_string().unwrap().contains(PASTE_DATA));
});
}
#[test]
fn my_images()
{
run(|| {
let client = get_client();
let req = client.get("/manage/images/0").header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(IMAGE_ID));
});
}
#[test]
fn my_videos()
{
run(|| {
let client = get_client();
let req = client.get("/manage/videos/0").header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(VIDEO_ID));
});
}
#[test]
fn my_files()
{
run(|| {
let client = get_client();
let req = client.get("/manage/files/0").header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(FILE_ID));
});
}
#[test]
fn image()
{
run(|| {
let client = get_client();
let req = client
.get("/manage/image/".to_string() + IMAGE_ID)
.header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(IMAGE_ID));
});
}
#[test]
fn video()
{
run(|| {
let client = get_client();
let req = client
.get("/manage/video/".to_string() + VIDEO_ID)
.header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(VIDEO_ID));
});
}
#[test]
fn paste()
{
run(|| {
let client = get_client();
let req = client
.get("/manage/paste/".to_string() + PASTE_ID)
.header(auth_header());
let mut response = req.dispatch();
assert_eq!(response.status(), Status::Ok);
assert!(response.body_string().unwrap().contains(PASTE_ID));
});
}
fn run<T>(test: T) -> ()
where
T: FnOnce() -> () + panic::UnwindSafe,
{
run_test(test, setup_db, unsetup_db);
}
fn setup_db()
{
let conn = horus_server::dbtools::get_db_conn_requestless().unwrap();
let mut setup_sql = String::new();
setup_sql.push_str(sql_insert_user().as_str());
setup_sql.push_str(sql_insert_license().as_str());
setup_sql.push_str(sql_insert_paste().as_str());
setup_sql.push_str(sql_insert_image().as_str());
setup_sql.push_str(sql_insert_video().as_str());
setup_sql.push_str(sql_insert_file().as_str());
conn.batch_execute(&setup_sql).unwrap();
}
fn unsetup_db()
{
let conn = horus_server::dbtools::get_db_conn_requestless().unwrap();
// No need to delete everything, a user delete cascades.
let unsetup_sql = sql_delete_user();
conn.batch_execute(&unsetup_sql).unwrap();
}
fn get_client() -> Client
{
use rocket_contrib::Template;
let rocket = rocket::ignite()
.attach(Template::fairing())
.mount(
"/manage",
routes![
my_images, my_files, my_videos, my_pastes, video, image, paste
],
)
.manage(horus_server::dbtools::init_pool());
Client::new(rocket).expect("valid rocket instance")
}
|
mod bounds;
pub use self::bounds::*;
mod morton_index;
pub use self::morton_index::*;
mod bitmanip;
pub use self::bitmanip::*;
mod arithmetic;
pub use self::arithmetic::*;
mod minmax;
pub use self::minmax::*;
|
// Copyright (c) The Starcoin Core Contributors
// SPDX-License-Identifier: Apache-2.0
use libra_crypto::HashValue;
#[derive(Clone, Copy, Eq, Hash, PartialEq, PartialOrd, Ord)]
pub struct HtlcPayment {
hash_lock: HashValue,
amount: u64,
timeout: u64,
}
impl HtlcPayment {
pub fn new(hash_lock: HashValue, amount: u64, timeout: u64) -> Self {
Self {
hash_lock,
amount,
timeout,
}
}
pub fn hash_lock(&self) -> &HashValue {
&self.hash_lock
}
pub fn amount(&self) -> u64 {
self.amount
}
pub fn timeout(&self) -> u64 {
self.timeout
}
}
|
use std::boxed::Box;
use std::cmp::{max, min};
use std::convert::TryInto;
use std::fmt;
use std::iter::{empty, Peekable};
use std::ops::Range;
use chrono::{Duration, NaiveDate, NaiveDateTime, NaiveTime};
use once_cell::sync::Lazy;
use crate::day_selector::{DateFilter, DaySelector};
use crate::extended_time::ExtendedTime;
use crate::schedule::{Schedule, TimeRange};
use crate::time_selector::TimeSelector;
static DATE_LIMIT: Lazy<NaiveDateTime> = Lazy::new(|| {
NaiveDateTime::new(
NaiveDate::from_ymd(10_000, 1, 1),
NaiveTime::from_hms(0, 0, 0),
)
});
// DateTimeRange
#[non_exhaustive]
#[derive(Clone, Eq, PartialEq)]
pub struct DateTimeRange<'c> {
pub range: Range<NaiveDateTime>,
pub kind: RuleKind,
pub comments: Vec<&'c str>,
}
impl fmt::Debug for DateTimeRange<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("DateTimeRange")
.field("range", &self.range)
.field("kind", &self.kind)
.field("comments", &self.comments)
.finish()
}
}
impl<'c> DateTimeRange<'c> {
fn new_with_sorted_comments(
range: Range<NaiveDateTime>,
kind: RuleKind,
comments: Vec<&'c str>,
) -> Self {
Self {
range,
kind,
comments,
}
}
}
// TimeDomain
#[derive(Clone, Debug)]
pub struct TimeDomain {
pub rules: Vec<RuleSequence>,
}
impl TimeDomain {
// Low level implementations.
//
// Following functions are used to build the TimeDomainIterator which is
// used to implement all other functions.
//
// This means that performances matters a lot for these functions and it
// would be relevant to focus on optimisatons to this regard.
pub fn schedule_at(&self, date: NaiveDate) -> Schedule {
let mut prev_match = false;
let mut prev_eval = None;
for rules_seq in &self.rules {
let curr_match = rules_seq.day_selector.filter(date);
let curr_eval = rules_seq.schedule_at(date);
let (new_match, new_eval) = match rules_seq.operator {
RuleOperator::Normal => (
curr_match || prev_match,
if curr_match {
curr_eval
} else {
prev_eval.or(curr_eval)
},
),
RuleOperator::Additional => (
prev_match || curr_match,
match (prev_eval, curr_eval) {
(Some(prev), Some(curr)) => Some(prev.addition(curr)),
(prev, curr) => prev.or(curr),
},
),
RuleOperator::Fallback => {
if prev_match {
(prev_match, prev_eval)
} else {
(curr_match, curr_eval)
}
}
};
prev_match = new_match;
prev_eval = new_eval;
}
prev_eval.unwrap_or_else(Schedule::empty)
}
pub fn iter_from(&self, from: NaiveDateTime) -> impl Iterator<Item = DateTimeRange> + '_ {
self.iter_range(from, *DATE_LIMIT)
}
pub fn iter_range(
&self,
from: NaiveDateTime,
to: NaiveDateTime,
) -> impl Iterator<Item = DateTimeRange> + '_ {
assert!(to <= *DATE_LIMIT);
TimeDomainIterator::new(&self, from, to)
.take_while(move |dtr| dtr.range.start < to)
.map(move |dtr| {
let start = max(dtr.range.start, from);
let end = min(dtr.range.end, to);
DateTimeRange::new_with_sorted_comments(start..end, dtr.kind, dtr.comments)
})
}
// High level implementations
pub fn next_change(&self, current_time: NaiveDateTime) -> NaiveDateTime {
self.iter_from(current_time)
.next()
.map(|dtr| dtr.range.end)
.unwrap_or(current_time)
}
pub fn state(&self, current_time: NaiveDateTime) -> RuleKind {
self.iter_range(current_time, current_time + Duration::minutes(1))
.next()
.map(|dtr| dtr.kind)
.unwrap_or(RuleKind::Unknown)
}
pub fn is_open(&self, current_time: NaiveDateTime) -> bool {
self.state(current_time) == RuleKind::Open
}
pub fn is_closed(&self, current_time: NaiveDateTime) -> bool {
self.state(current_time) == RuleKind::Closed
}
pub fn is_unknown(&self, current_time: NaiveDateTime) -> bool {
self.state(current_time) == RuleKind::Unknown
}
}
// TimeDomainIterator
pub struct TimeDomainIterator<'d> {
time_domain: &'d TimeDomain,
curr_date: NaiveDate,
curr_schedule: Peekable<Box<dyn Iterator<Item = TimeRange<'d>> + 'd>>,
end_datetime: NaiveDateTime,
}
impl<'d> TimeDomainIterator<'d> {
pub fn new(
time_domain: &'d TimeDomain,
start_datetime: NaiveDateTime,
end_datetime: NaiveDateTime,
) -> Self {
let start_date = start_datetime.date();
let start_time = start_datetime.time().into();
let mut curr_schedule = {
if start_datetime < end_datetime {
time_domain.schedule_at(start_date).into_iter_filled()
} else {
Box::new(empty())
}
}
.peekable();
while curr_schedule
.peek()
.map(|tr| !tr.range.contains(&start_time))
.unwrap_or(false)
{
curr_schedule.next();
}
Self {
time_domain,
curr_date: start_date,
curr_schedule,
end_datetime,
}
}
fn consume_until_next_kind(&mut self, curr_kind: RuleKind) {
while self.curr_schedule.peek().map(|tr| tr.kind) == Some(curr_kind) {
self.curr_schedule.next();
if self.curr_schedule.peek().is_none() {
self.curr_date += Duration::days(1);
if self.curr_date <= self.end_datetime.date() {
self.curr_schedule = self
.time_domain
.schedule_at(self.curr_date)
.into_iter_filled()
.peekable()
}
}
}
}
}
impl<'d> Iterator for TimeDomainIterator<'d> {
type Item = DateTimeRange<'d>;
fn next(&mut self) -> Option<Self::Item> {
if let Some(curr_tr) = self.curr_schedule.peek().cloned() {
let start = NaiveDateTime::new(
self.curr_date,
curr_tr
.range
.start
.try_into()
.expect("got invalid time from schedule"),
);
self.consume_until_next_kind(curr_tr.kind);
let end_date = self.curr_date;
let end_time = self
.curr_schedule
.peek()
.map(|tr| tr.range.start)
.unwrap_or_else(|| ExtendedTime::new(0, 0));
let end = std::cmp::min(
self.end_datetime,
NaiveDateTime::new(
end_date,
end_time.try_into().expect("got invalid time from schedule"),
),
);
Some(DateTimeRange::new_with_sorted_comments(
start..end,
curr_tr.kind,
curr_tr.comments,
))
} else {
None
}
}
}
// RuleSequence
#[non_exhaustive]
#[derive(Clone, Debug)]
pub struct RuleSequence {
pub day_selector: DaySelector,
pub time_selector: TimeSelector,
pub kind: RuleKind,
pub operator: RuleOperator,
pub comments: Vec<String>,
}
impl RuleSequence {
pub fn new(
day_selector: DaySelector,
time_selector: TimeSelector,
kind: RuleKind,
operator: RuleOperator,
mut comments: Vec<String>,
) -> Self {
comments.sort_unstable();
Self {
day_selector,
time_selector,
kind,
operator,
comments,
}
}
}
impl RuleSequence {
pub fn schedule_at(&self, date: NaiveDate) -> Option<Schedule> {
let today = {
if self.day_selector.filter(date) {
let ranges = self.time_selector.intervals_at(date);
Some(Schedule::from_ranges_with_sorted_comments(
ranges,
self.kind,
self.get_comments(),
))
} else {
None
}
};
let yesterday = {
let date = date - Duration::days(1);
if self.day_selector.filter(date) {
let ranges = self.time_selector.intervals_at_next_day(date);
Some(Schedule::from_ranges_with_sorted_comments(
ranges,
self.kind,
self.get_comments(),
))
} else {
None
}
};
match (today, yesterday) {
(Some(sched_1), Some(sched_2)) => Some(sched_1.addition(sched_2)),
(today, yesterday) => today.or(yesterday),
}
}
pub fn get_comments(&self) -> Vec<&str> {
self.comments.iter().map(|x| x.as_str()).collect()
}
}
// RuleKind
#[derive(Copy, Clone, Debug, Eq, Ord, PartialEq, PartialOrd)]
pub enum RuleKind {
Open,
Closed,
Unknown,
}
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum RuleOperator {
Normal,
Additional,
Fallback,
}
|
use pgx::{FromRow, queryx};
use super::super::types::{Field, Type, Status};
use postgres::rows::Row;
use postgres::Connection;
use postgres::error::Error;
use postgres_array::Array;
use std::str::FromStr;
use user::UserInfo;
use pgtypes::requirements::{FieldType, RequirementType};
#[derive(Debug)]
pub struct RequirementModel {
pub id: i32,
pub name: String,
pub field_type: Field,
pub req_type: Type,
}
impl RequirementModel {
pub fn get_all_requirements<'a>(conn: &'a Connection) -> Result<Vec<RequirementModel>, Error> {
let stmt = try!(conn.prepare("select id, name, field,req_type, req_args from \
requirements;"));
let iter = try!(queryx::<RequirementModel>(&stmt, &[]));
Ok(iter.collect::<Vec<_>>())
}
}
impl FromRow for RequirementModel {
fn from_row(row: &Row) -> RequirementModel {
let req_args: Array<String> = row.get(4);
let req_type_enum: RequirementType = row.get(3);
let field_enum: FieldType = row.get(2);
let mut req_iter = req_args.into_iter();
let req_type = match req_type_enum {
RequirementType::Boolean => {
let value = bool::from_str(&req_iter.next().expect("No bool arg"))
.ok()
.unwrap_or(false);
Type::Boolean(value)
}
RequirementType::IntRange => {
let start = u32::from_str(&req_iter.next().expect("No start arg"))
.ok()
.unwrap_or(0);
let end = u32::from_str(&req_iter.next().expect("No end arg")).ok().unwrap_or(0);
Type::IntRange(start, end)
}
RequirementType::IntEquals => {
let value = u32::from_str(&req_iter.next().expect("No int arg")).ok().unwrap_or(0);
Type::IntEquals(value)
}
RequirementType::StringEquals => {
Type::StringEquals(req_iter.next().expect("No string arg").clone())
}
};
let req_name: String = row.get(1);
RequirementModel::new(row.get(0), &req_name, Field::from(field_enum), req_type)
}
}
fn check_int_range(val: &Option<u32>, start: u32, end: u32) -> Status {
if let Some(x) = *val {
if x >= start && x <= end {
Status::Met
} else {
Status::NotMet
}
} else {
Status::Unknown
}
}
fn check_int_equals(val: &Option<u32>, other: u32) -> Status {
if let Some(i) = *val {
if other == i {
Status::Met
} else {
Status::NotMet
}
} else {
Status::Unknown
}
}
fn check_boolean(val: &Option<bool>, other: bool) -> Status {
if let Some(b) = *val {
if other == b {
Status::Met
} else {
Status::NotMet
}
} else {
Status::Unknown
}
}
fn check_string_equals(val: &Option<String>, other: &str) -> Status {
if let Some(ref s) = *val {
if other == s {
Status::Met
} else {
Status::NotMet
}
} else {
Status::Unknown
}
}
impl RequirementModel {
pub fn new(id: i32, name: &str, field: Field, req_type: Type) -> RequirementModel {
RequirementModel {
id: id,
name: String::from(name),
field_type: field,
req_type: req_type,
}
}
pub fn check(&self, info: &UserInfo) -> Status {
match self.field_type {
Field::Age => {
match self.req_type {
Type::IntRange(start, end) => check_int_range(&info.age, start, end),
_ => unimplemented!(),
}
}
Field::County => {
match self.req_type {
Type::StringEquals(ref s) => check_string_equals(&info.county, s),
_ => unimplemented!(),
}
}
Field::ChildrenCount => {
match self.req_type {
Type::IntEquals(i) => check_int_equals(&info.child_count, i),
Type::IntRange(start, end) => check_int_range(&info.child_count, start, end),
_ => unimplemented!(),
}
}
Field::Income => {
match self.req_type {
Type::IntRange(start, end) => check_int_range(&info.annual_income, start, end),
_ => unimplemented!(),
}
}
Field::SingleParent => {
match self.req_type {
Type::Boolean(b) => check_boolean(&info.single_parent, b),
_ => unimplemented!(),
}
}
}
}
}
|
#![allow(dead_code)]
use glium::{
glutin::{event, event_loop},
Display,
};
use conrod_winit;
pub enum Request<'a, 'b: 'a> {
Event {
event: &'a event::Event<'b, ()>,
should_update_ui: &'a mut bool,
should_exit: &'a mut bool,
},
SetUi {
needs_redraw: &'a mut bool,
},
Redraw,
}
/// In most of the examples the `glutin` crate is used for providing the window context and
/// events while the `glium` crate is used for displaying `conrod_core::render::Primitives` to the
/// screen.
///
/// This function simplifies some of the boilerplate involved in limiting the redraw rate in the
/// glutin+glium event loop.
pub fn run_loop<F>(display: Display, event_loop: glium::glutin::event_loop::EventLoop<()>, mut callback: F) -> !
where
F: 'static + FnMut(Request, &Display),
{
let sixteen_ms = std::time::Duration::from_millis(16);
let mut next_update = None;
let mut ui_update_needed = false;
event_loop.run(move |event, _, control_flow| {
{
let mut should_update_ui = false;
let mut should_exit = false;
callback(
Request::Event {
event: &event,
should_update_ui: &mut should_update_ui,
should_exit: &mut should_exit,
},
&display,
);
ui_update_needed |= should_update_ui;
if should_exit {
*control_flow = event_loop::ControlFlow::Exit;
return;
}
}
// We don't want to draw any faster than 60 FPS, so set the UI only on every 16ms, unless:
// - this is the very first event, or
// - we didn't request update on the last event and new events have arrived since then.
let should_set_ui_on_main_events_cleared = next_update.is_none() && ui_update_needed;
match (&event, should_set_ui_on_main_events_cleared) {
(event::Event::NewEvents(event::StartCause::Init { .. }), _)
| (event::Event::NewEvents(event::StartCause::ResumeTimeReached { .. }), _)
| (event::Event::MainEventsCleared, true) => {
next_update = Some(std::time::Instant::now() + sixteen_ms);
ui_update_needed = false;
let mut needs_redraw = false;
callback(
Request::SetUi {
needs_redraw: &mut needs_redraw,
},
&display,
);
if needs_redraw {
display.gl_window().window().request_redraw();
} else {
// We don't need to redraw anymore until more events arrives.
next_update = None;
}
}
_ => {}
}
if let Some(next_update) = next_update {
*control_flow = event_loop::ControlFlow::WaitUntil(next_update);
} else {
*control_flow = event_loop::ControlFlow::Wait;
}
// Request redraw if needed.
match &event {
event::Event::RedrawRequested(_) => {
callback(Request::Redraw, &display);
}
_ => {}
}
})
}
// Conversion functions for converting between types from glium's version of `winit` and
// `conrod_core`.
conrod_winit::v023_conversion_fns!();
|
use itertools::Itertools;
pub fn part1(input: &str) -> Result<usize, String> {
Ok(input
.split("\n\n")
.map(|x| x.replace("\n", "").chars().unique().count())
.sum())
}
pub fn part2(input: &str) -> Result<usize, String> {
Ok(input.split("\n\n").fold(0, |acc, x| {
let answers = x.replace("\n", "");
let people = x.matches("\n").count() + 1;
let mut count = 0;
for char in answers.chars().unique() {
if x.matches(char).count() == people {
count += 1;
}
}
acc + count
}))
}
#[cfg(test)]
mod tests {
use super::*;
const INPUT: &str = "abc\n\na\nb\nc\n\nab\nac\n\na\na\na\na\n\nb";
#[test]
fn test_part1() {
assert_eq!(part1(INPUT).unwrap(), 11);
}
#[test]
fn test_part2() {
assert_eq!(part2(INPUT).unwrap(), 6);
}
}
|
use log::{info, warn};
use num_bigint_dig::*;
use rsa::{hash, PaddingScheme, PublicKey, RSAPublicKey};
use sha2::*;
pub fn verify_signature(data: &[u8], signature: &[u8], public_key: &[u8]) -> bool {
let mut hasher = Sha256::new();
hasher.input(&data);
let hash = hasher.result();
let public_key = match RSAPublicKey::new(BigUint::from_bytes_be(&public_key), 0x10001u32.into())
{
Ok(public_key) => public_key,
Err(e) => {
warn!("RSA public key error: {}", e);
return false;
}
};
match public_key.verify(
PaddingScheme::PKCS1v15,
Some(&hash::Hashes::SHA2_256),
&hash,
&signature,
) {
Ok(()) => true,
Err(e) => {
info!("RSA verification failure: {}", e);
false
}
}
}
|
use std::thread;
use std::sync::{Arc, Mutex};
use std::time::Duration;
use std::old_io::timer;
fn main() {
let buf = Arc::new(Mutex::new(Vec::<String>::new()));
let res = test(buf);
println!("{:?}", *res.lock().unwrap());
}
fn test(buf: Arc<Mutex<Vec<String>>>) -> Arc<Mutex<Vec<String>>> {
let guards: Vec<_> = (0..3).map( |i| {
let mtx = buf.clone();
thread::scoped(|| {
println!("Thread: {}", i);
let mut res = mtx.lock().unwrap();
timer::sleep(Duration::seconds(5));
res.push(format!("thread {}", i));
});
}).collect();
buf
}
|
use serenity::{
framework::standard::{macros::command, CommandResult},
model::channel::Message,
prelude::*,
};
#[command]
#[description = "Bot willk reply with pretty embed containing links to other projects by the author."]
fn projects(ctx: &mut Context, msg: &Message) -> CommandResult {
let msg = msg.channel_id.send_message(&ctx.http, |m| {
m.embed(|e| {
e.title("Other Projects Created/Co-Created by The Author");
e.fields(vec![
("cfg", "https://github.com/Phate6660/cfg", false),
("gzdoom-discordrpc", "https://github.com/Phate6660/gzdoom-discordrpc", false),
("musinfo", "https://github.com/Phate6660/musinfo", false),
("nixinfo", "https://github.com/Phate6660/rsnixinfo", false),
("p6nc-overlay", "https://github.com/p6nc/overlay", false),
("pkg", "https://github.com/Phate6660/pkg", false),
("rsfetch", "https://github.com/Phate6660/rsfetch", false),
("rsmpc", "https://github.com/Phate6660/rsmpc", false),
("rsmpv", "https://github.com/Phate6660/rsmpv", false),
("undeprecated-overlay", "https://github.com/Phate6660/undeprecated", false),
("WBMPFMPD", "https://github.com/Phate6660/WBMPFMPD", false),
]);
e
});
m
});
if let Err(why) = msg {
println!("Error sending message: {:?}", why);
}
Ok(())
}
|
pub mod modules {
//MODULE_JSON
pub const UNITY_2022_1_0_A_13:&str = include_str!("2022.1.0a13_modules.json");
pub const UNITY_2022_2_6_F_1:&str = include_str!("2022.2.6f1_modules.json");
}
pub mod manifests {
//MANIFEST_INI
pub const UNITY_2022_1_0_A_13:&str = include_str!("2022.1.0a13_manifest.ini");
pub const UNITY_2022_2_6_F_1:&str = include_str!("2022.2.6f1_manifest.ini");
}
|
//! Utilities for working on GHC's prof JSON dumps (`+RTS -pj`)
//!
//! For now just compares allocations.
use serde::Deserialize;
use std::collections::HashMap;
#[derive(Debug, Deserialize)]
struct ProfFile {
program: String,
arguments: Vec<String>,
rts_arguments: Vec<String>,
end_time: String,
initial_capabilities: u8,
total_time: f64,
total_ticks: u64,
tick_interval: u64,
total_alloc: u64,
cost_centres: Vec<CostCentre>,
profile: Profile,
}
#[derive(Debug, Deserialize)]
struct CostCentre {
id: u64,
label: String,
module: String,
src_loc: String,
is_caf: bool,
}
#[derive(Debug, Deserialize)]
struct Profile {
id: u64,
entries: u64,
alloc: u64,
ticks: u64,
children: Vec<Profile>,
}
fn parse_prof_file(path: &str) -> ProfFile {
let file = std::fs::File::open(path).unwrap();
let reader = std::io::BufReader::new(file);
serde_json::from_reader(reader).unwrap()
}
/// Maps cost centres to allocations
fn make_alloc_map(f: &ProfFile) -> HashMap<String, u64> {
let cost_centre_map = {
let mut map: HashMap<u64, String> = HashMap::new();
for cc in &f.cost_centres {
map.insert(cc.id, format!("{}.{}", cc.module, cc.label));
}
map
};
let mut alloc_map = HashMap::new();
add_profile(&mut alloc_map, &f.profile, &cost_centre_map);
alloc_map
}
fn add_profile(alloc_map: &mut HashMap<String, u64>, p: &Profile, cc_map: &HashMap<u64, String>) {
alloc_map.insert(cc_map.get(&p.id).unwrap().clone(), p.alloc);
for p in &p.children {
add_profile(alloc_map, p, cc_map);
}
}
fn compare(f1: &str, f2: &str) {
let allocs1 = make_alloc_map(&parse_prof_file(f1));
let mut allocs2 = make_alloc_map(&parse_prof_file(f2));
let mut diffs: Vec<(String, i64)> = vec![];
for (cc, alloc1) in allocs1.into_iter() {
let diff = match allocs2.remove(&cc) {
None => -(alloc1 as i64),
Some(alloc2) => (alloc2 as i64) - (alloc1 as i64),
};
if diff != 0 {
diffs.push((cc, diff));
}
}
for (cc, alloc2) in allocs2.into_iter() {
if alloc2 != 0 {
diffs.push((cc, alloc2 as i64));
}
}
diffs.sort_by_key(|&(_, v)| std::cmp::Reverse(v));
let mut total = 0;
for (k, v) in diffs {
println!("{}: {}", k, v);
total += v;
}
println!();
println!("TOTAL: {}", total);
}
fn show_allocs(f: &str) {
let allocs = make_alloc_map(&parse_prof_file(f));
let mut allocs = allocs.into_iter().collect::<Vec<(String, u64)>>();
allocs.sort_by_key(|&(_, v)| std::cmp::Reverse(v));
let total: u64 = allocs.iter().map(|&(_, v)| v).sum();
let total_f: f64 = total as f64;
for (cc, alloc) in allocs.iter() {
if *alloc != 0 {
println!(
"{}: {} ({:.2}%)",
cc,
alloc,
((*alloc as f64) / total_f) * 100.0f64
);
}
}
println!("TOTAL: {}", total);
}
fn main() {
let args = std::env::args().collect::<Vec<_>>();
match args.len() {
3 => {
compare(&args[1], &args[2]);
}
2 => {
show_allocs(&args[1]);
}
_ => {
println!("USAGE:");
println!("(1) ghc-prof-compare <file1> <file2> # to compare two files for allocations");
println!("(2) ghc-prof-compare <file> # to show allocations, sorted");
std::process::exit(1);
}
}
}
|
// cargo test -- --nocapture
#[test]
fn test() {
println!("test...あああああああああああああ");
let list = vec!["あ", "い", "う", "え", "お"];
// 長さはないんね...
for v in list {
println!("v:{}", v);
}
}
|
/// An enum to represent all characters in the Hiragana block.
#[derive(Debug, Clone, Copy, Hash, PartialEq, Eq)]
pub enum Hiragana {
/// \u{3041}: 'ぁ'
LetterSmallA,
/// \u{3042}: 'あ'
LetterA,
/// \u{3043}: 'ぃ'
LetterSmallI,
/// \u{3044}: 'い'
LetterI,
/// \u{3045}: 'ぅ'
LetterSmallU,
/// \u{3046}: 'う'
LetterU,
/// \u{3047}: 'ぇ'
LetterSmallE,
/// \u{3048}: 'え'
LetterE,
/// \u{3049}: 'ぉ'
LetterSmallO,
/// \u{304a}: 'お'
LetterO,
/// \u{304b}: 'か'
LetterKa,
/// \u{304c}: 'が'
LetterGa,
/// \u{304d}: 'き'
LetterKi,
/// \u{304e}: 'ぎ'
LetterGi,
/// \u{304f}: 'く'
LetterKu,
/// \u{3050}: 'ぐ'
LetterGu,
/// \u{3051}: 'け'
LetterKe,
/// \u{3052}: 'げ'
LetterGe,
/// \u{3053}: 'こ'
LetterKo,
/// \u{3054}: 'ご'
LetterGo,
/// \u{3055}: 'さ'
LetterSa,
/// \u{3056}: 'ざ'
LetterZa,
/// \u{3057}: 'し'
LetterSi,
/// \u{3058}: 'じ'
LetterZi,
/// \u{3059}: 'す'
LetterSu,
/// \u{305a}: 'ず'
LetterZu,
/// \u{305b}: 'せ'
LetterSe,
/// \u{305c}: 'ぜ'
LetterZe,
/// \u{305d}: 'そ'
LetterSo,
/// \u{305e}: 'ぞ'
LetterZo,
/// \u{305f}: 'た'
LetterTa,
/// \u{3060}: 'だ'
LetterDa,
/// \u{3061}: 'ち'
LetterTi,
/// \u{3062}: 'ぢ'
LetterDi,
/// \u{3063}: 'っ'
LetterSmallTu,
/// \u{3064}: 'つ'
LetterTu,
/// \u{3065}: 'づ'
LetterDu,
/// \u{3066}: 'て'
LetterTe,
/// \u{3067}: 'で'
LetterDe,
/// \u{3068}: 'と'
LetterTo,
/// \u{3069}: 'ど'
LetterDo,
/// \u{306a}: 'な'
LetterNa,
/// \u{306b}: 'に'
LetterNi,
/// \u{306c}: 'ぬ'
LetterNu,
/// \u{306d}: 'ね'
LetterNe,
/// \u{306e}: 'の'
LetterNo,
/// \u{306f}: 'は'
LetterHa,
/// \u{3070}: 'ば'
LetterBa,
/// \u{3071}: 'ぱ'
LetterPa,
/// \u{3072}: 'ひ'
LetterHi,
/// \u{3073}: 'び'
LetterBi,
/// \u{3074}: 'ぴ'
LetterPi,
/// \u{3075}: 'ふ'
LetterHu,
/// \u{3076}: 'ぶ'
LetterBu,
/// \u{3077}: 'ぷ'
LetterPu,
/// \u{3078}: 'へ'
LetterHe,
/// \u{3079}: 'べ'
LetterBe,
/// \u{307a}: 'ぺ'
LetterPe,
/// \u{307b}: 'ほ'
LetterHo,
/// \u{307c}: 'ぼ'
LetterBo,
/// \u{307d}: 'ぽ'
LetterPo,
/// \u{307e}: 'ま'
LetterMa,
/// \u{307f}: 'み'
LetterMi,
/// \u{3080}: 'む'
LetterMu,
/// \u{3081}: 'め'
LetterMe,
/// \u{3082}: 'も'
LetterMo,
/// \u{3083}: 'ゃ'
LetterSmallYa,
/// \u{3084}: 'や'
LetterYa,
/// \u{3085}: 'ゅ'
LetterSmallYu,
/// \u{3086}: 'ゆ'
LetterYu,
/// \u{3087}: 'ょ'
LetterSmallYo,
/// \u{3088}: 'よ'
LetterYo,
/// \u{3089}: 'ら'
LetterRa,
/// \u{308a}: 'り'
LetterRi,
/// \u{308b}: 'る'
LetterRu,
/// \u{308c}: 'れ'
LetterRe,
/// \u{308d}: 'ろ'
LetterRo,
/// \u{308e}: 'ゎ'
LetterSmallWa,
/// \u{308f}: 'わ'
LetterWa,
/// \u{3090}: 'ゐ'
LetterWi,
/// \u{3091}: 'ゑ'
LetterWe,
/// \u{3092}: 'を'
LetterWo,
/// \u{3093}: 'ん'
LetterN,
/// \u{3094}: 'ゔ'
LetterVu,
/// \u{3095}: 'ゕ'
LetterSmallKa,
/// \u{3096}: 'ゖ'
LetterSmallKe,
/// \u{3099}: '゙'
CombiningKatakanaDashVoicedSoundMark,
/// \u{309a}: '゚'
CombiningKatakanaDashSemiDashVoicedSoundMark,
/// \u{309b}: '゛'
KatakanaDashVoicedSoundMark,
/// \u{309c}: '゜'
KatakanaDashSemiDashVoicedSoundMark,
/// \u{309d}: 'ゝ'
IterationMark,
/// \u{309e}: 'ゞ'
VoicedIterationMark,
}
impl Into<char> for Hiragana {
fn into(self) -> char {
match self {
Hiragana::LetterSmallA => 'ぁ',
Hiragana::LetterA => 'あ',
Hiragana::LetterSmallI => 'ぃ',
Hiragana::LetterI => 'い',
Hiragana::LetterSmallU => 'ぅ',
Hiragana::LetterU => 'う',
Hiragana::LetterSmallE => 'ぇ',
Hiragana::LetterE => 'え',
Hiragana::LetterSmallO => 'ぉ',
Hiragana::LetterO => 'お',
Hiragana::LetterKa => 'か',
Hiragana::LetterGa => 'が',
Hiragana::LetterKi => 'き',
Hiragana::LetterGi => 'ぎ',
Hiragana::LetterKu => 'く',
Hiragana::LetterGu => 'ぐ',
Hiragana::LetterKe => 'け',
Hiragana::LetterGe => 'げ',
Hiragana::LetterKo => 'こ',
Hiragana::LetterGo => 'ご',
Hiragana::LetterSa => 'さ',
Hiragana::LetterZa => 'ざ',
Hiragana::LetterSi => 'し',
Hiragana::LetterZi => 'じ',
Hiragana::LetterSu => 'す',
Hiragana::LetterZu => 'ず',
Hiragana::LetterSe => 'せ',
Hiragana::LetterZe => 'ぜ',
Hiragana::LetterSo => 'そ',
Hiragana::LetterZo => 'ぞ',
Hiragana::LetterTa => 'た',
Hiragana::LetterDa => 'だ',
Hiragana::LetterTi => 'ち',
Hiragana::LetterDi => 'ぢ',
Hiragana::LetterSmallTu => 'っ',
Hiragana::LetterTu => 'つ',
Hiragana::LetterDu => 'づ',
Hiragana::LetterTe => 'て',
Hiragana::LetterDe => 'で',
Hiragana::LetterTo => 'と',
Hiragana::LetterDo => 'ど',
Hiragana::LetterNa => 'な',
Hiragana::LetterNi => 'に',
Hiragana::LetterNu => 'ぬ',
Hiragana::LetterNe => 'ね',
Hiragana::LetterNo => 'の',
Hiragana::LetterHa => 'は',
Hiragana::LetterBa => 'ば',
Hiragana::LetterPa => 'ぱ',
Hiragana::LetterHi => 'ひ',
Hiragana::LetterBi => 'び',
Hiragana::LetterPi => 'ぴ',
Hiragana::LetterHu => 'ふ',
Hiragana::LetterBu => 'ぶ',
Hiragana::LetterPu => 'ぷ',
Hiragana::LetterHe => 'へ',
Hiragana::LetterBe => 'べ',
Hiragana::LetterPe => 'ぺ',
Hiragana::LetterHo => 'ほ',
Hiragana::LetterBo => 'ぼ',
Hiragana::LetterPo => 'ぽ',
Hiragana::LetterMa => 'ま',
Hiragana::LetterMi => 'み',
Hiragana::LetterMu => 'む',
Hiragana::LetterMe => 'め',
Hiragana::LetterMo => 'も',
Hiragana::LetterSmallYa => 'ゃ',
Hiragana::LetterYa => 'や',
Hiragana::LetterSmallYu => 'ゅ',
Hiragana::LetterYu => 'ゆ',
Hiragana::LetterSmallYo => 'ょ',
Hiragana::LetterYo => 'よ',
Hiragana::LetterRa => 'ら',
Hiragana::LetterRi => 'り',
Hiragana::LetterRu => 'る',
Hiragana::LetterRe => 'れ',
Hiragana::LetterRo => 'ろ',
Hiragana::LetterSmallWa => 'ゎ',
Hiragana::LetterWa => 'わ',
Hiragana::LetterWi => 'ゐ',
Hiragana::LetterWe => 'ゑ',
Hiragana::LetterWo => 'を',
Hiragana::LetterN => 'ん',
Hiragana::LetterVu => 'ゔ',
Hiragana::LetterSmallKa => 'ゕ',
Hiragana::LetterSmallKe => 'ゖ',
Hiragana::CombiningKatakanaDashVoicedSoundMark => '゙',
Hiragana::CombiningKatakanaDashSemiDashVoicedSoundMark => '゚',
Hiragana::KatakanaDashVoicedSoundMark => '゛',
Hiragana::KatakanaDashSemiDashVoicedSoundMark => '゜',
Hiragana::IterationMark => 'ゝ',
Hiragana::VoicedIterationMark => 'ゞ',
}
}
}
impl std::convert::TryFrom<char> for Hiragana {
type Error = ();
fn try_from(c: char) -> Result<Self, Self::Error> {
match c {
'ぁ' => Ok(Hiragana::LetterSmallA),
'あ' => Ok(Hiragana::LetterA),
'ぃ' => Ok(Hiragana::LetterSmallI),
'い' => Ok(Hiragana::LetterI),
'ぅ' => Ok(Hiragana::LetterSmallU),
'う' => Ok(Hiragana::LetterU),
'ぇ' => Ok(Hiragana::LetterSmallE),
'え' => Ok(Hiragana::LetterE),
'ぉ' => Ok(Hiragana::LetterSmallO),
'お' => Ok(Hiragana::LetterO),
'か' => Ok(Hiragana::LetterKa),
'が' => Ok(Hiragana::LetterGa),
'き' => Ok(Hiragana::LetterKi),
'ぎ' => Ok(Hiragana::LetterGi),
'く' => Ok(Hiragana::LetterKu),
'ぐ' => Ok(Hiragana::LetterGu),
'け' => Ok(Hiragana::LetterKe),
'げ' => Ok(Hiragana::LetterGe),
'こ' => Ok(Hiragana::LetterKo),
'ご' => Ok(Hiragana::LetterGo),
'さ' => Ok(Hiragana::LetterSa),
'ざ' => Ok(Hiragana::LetterZa),
'し' => Ok(Hiragana::LetterSi),
'じ' => Ok(Hiragana::LetterZi),
'す' => Ok(Hiragana::LetterSu),
'ず' => Ok(Hiragana::LetterZu),
'せ' => Ok(Hiragana::LetterSe),
'ぜ' => Ok(Hiragana::LetterZe),
'そ' => Ok(Hiragana::LetterSo),
'ぞ' => Ok(Hiragana::LetterZo),
'た' => Ok(Hiragana::LetterTa),
'だ' => Ok(Hiragana::LetterDa),
'ち' => Ok(Hiragana::LetterTi),
'ぢ' => Ok(Hiragana::LetterDi),
'っ' => Ok(Hiragana::LetterSmallTu),
'つ' => Ok(Hiragana::LetterTu),
'づ' => Ok(Hiragana::LetterDu),
'て' => Ok(Hiragana::LetterTe),
'で' => Ok(Hiragana::LetterDe),
'と' => Ok(Hiragana::LetterTo),
'ど' => Ok(Hiragana::LetterDo),
'な' => Ok(Hiragana::LetterNa),
'に' => Ok(Hiragana::LetterNi),
'ぬ' => Ok(Hiragana::LetterNu),
'ね' => Ok(Hiragana::LetterNe),
'の' => Ok(Hiragana::LetterNo),
'は' => Ok(Hiragana::LetterHa),
'ば' => Ok(Hiragana::LetterBa),
'ぱ' => Ok(Hiragana::LetterPa),
'ひ' => Ok(Hiragana::LetterHi),
'び' => Ok(Hiragana::LetterBi),
'ぴ' => Ok(Hiragana::LetterPi),
'ふ' => Ok(Hiragana::LetterHu),
'ぶ' => Ok(Hiragana::LetterBu),
'ぷ' => Ok(Hiragana::LetterPu),
'へ' => Ok(Hiragana::LetterHe),
'べ' => Ok(Hiragana::LetterBe),
'ぺ' => Ok(Hiragana::LetterPe),
'ほ' => Ok(Hiragana::LetterHo),
'ぼ' => Ok(Hiragana::LetterBo),
'ぽ' => Ok(Hiragana::LetterPo),
'ま' => Ok(Hiragana::LetterMa),
'み' => Ok(Hiragana::LetterMi),
'む' => Ok(Hiragana::LetterMu),
'め' => Ok(Hiragana::LetterMe),
'も' => Ok(Hiragana::LetterMo),
'ゃ' => Ok(Hiragana::LetterSmallYa),
'や' => Ok(Hiragana::LetterYa),
'ゅ' => Ok(Hiragana::LetterSmallYu),
'ゆ' => Ok(Hiragana::LetterYu),
'ょ' => Ok(Hiragana::LetterSmallYo),
'よ' => Ok(Hiragana::LetterYo),
'ら' => Ok(Hiragana::LetterRa),
'り' => Ok(Hiragana::LetterRi),
'る' => Ok(Hiragana::LetterRu),
'れ' => Ok(Hiragana::LetterRe),
'ろ' => Ok(Hiragana::LetterRo),
'ゎ' => Ok(Hiragana::LetterSmallWa),
'わ' => Ok(Hiragana::LetterWa),
'ゐ' => Ok(Hiragana::LetterWi),
'ゑ' => Ok(Hiragana::LetterWe),
'を' => Ok(Hiragana::LetterWo),
'ん' => Ok(Hiragana::LetterN),
'ゔ' => Ok(Hiragana::LetterVu),
'ゕ' => Ok(Hiragana::LetterSmallKa),
'ゖ' => Ok(Hiragana::LetterSmallKe),
'゙' => Ok(Hiragana::CombiningKatakanaDashVoicedSoundMark),
'゚' => Ok(Hiragana::CombiningKatakanaDashSemiDashVoicedSoundMark),
'゛' => Ok(Hiragana::KatakanaDashVoicedSoundMark),
'゜' => Ok(Hiragana::KatakanaDashSemiDashVoicedSoundMark),
'ゝ' => Ok(Hiragana::IterationMark),
'ゞ' => Ok(Hiragana::VoicedIterationMark),
_ => Err(()),
}
}
}
impl Into<u32> for Hiragana {
fn into(self) -> u32 {
let c: char = self.into();
let hex = c
.escape_unicode()
.to_string()
.replace("\\u{", "")
.replace("}", "");
u32::from_str_radix(&hex, 16).unwrap()
}
}
impl std::convert::TryFrom<u32> for Hiragana {
type Error = ();
fn try_from(u: u32) -> Result<Self, Self::Error> {
if let Ok(c) = char::try_from(u) {
Self::try_from(c)
} else {
Err(())
}
}
}
impl Iterator for Hiragana {
type Item = Self;
fn next(&mut self) -> Option<Self> {
let index: u32 = (*self).into();
use std::convert::TryFrom;
Self::try_from(index + 1).ok()
}
}
impl Hiragana {
/// The character with the lowest index in this unicode block
pub fn new() -> Self {
Hiragana::LetterSmallA
}
/// The character's name, in sentence case
pub fn name(&self) -> String {
let s = std::format!("Hiragana{:#?}", self);
string_morph::to_sentence_case(&s)
}
}
|
use crate::z3::ast;
use ast::Ast;
use std::convert::TryInto;
use std::ffi::CStr;
use std::fmt;
use z3_sys::*;
use crate::z3::{Context, FuncDecl, Sort, Symbol, Z3_MUTEX};
impl<'ctx> FuncDecl<'ctx> {
pub fn new<S: Into<Symbol>>(
ctx: &'ctx Context,
name: S,
domain: &[&Sort<'ctx>],
range: &Sort<'ctx>,
) -> Self {
assert!(domain.iter().all(|s| s.ctx.z3_ctx == ctx.z3_ctx));
assert_eq!(ctx.z3_ctx, range.ctx.z3_ctx);
let domain: Vec<_> = domain.iter().map(|s| s.z3_sort).collect();
unsafe {
Self::from_raw(
ctx,
Z3_mk_func_decl(
ctx.z3_ctx,
name.into().as_z3_symbol(ctx),
domain.len().try_into().unwrap(),
domain.as_ptr(),
range.z3_sort,
),
)
}
}
pub unsafe fn from_raw(ctx: &'ctx Context, z3_func_decl: Z3_func_decl) -> Self {
let guard = Z3_MUTEX.lock().unwrap();
Z3_inc_ref(ctx.z3_ctx, Z3_func_decl_to_ast(ctx.z3_ctx, z3_func_decl));
Self { ctx, z3_func_decl }
}
/// Return the number of arguments of a function declaration.
///
/// If the function declaration is a constant, then the arity is `0`.
///
/// ```
/// # use z3::{Config, Context, FuncDecl, Solver, Sort, Symbol};
/// # let cfg = Config::new();
/// # let ctx = Context::new(&cfg);
/// let f = FuncDecl::new(
/// &ctx,
/// "f",
/// &[&Sort::int(&ctx), &Sort::real(&ctx)],
/// &Sort::int(&ctx));
/// assert_eq!(f.arity(), 2);
/// ```
pub fn arity(&self) -> usize {
unsafe { Z3_get_arity(self.ctx.z3_ctx, self.z3_func_decl) as usize }
}
/// Create a constant (if `args` has length 0) or function application (otherwise).
///
/// Note that `args` should have the types corresponding to the `domain` of the `FuncDecl`.
pub fn apply(&self, args: &[&ast::Dynamic<'ctx>]) -> ast::Dynamic<'ctx> {
assert!(args.iter().all(|s| s.get_ctx().z3_ctx == self.ctx.z3_ctx));
let args: Vec<_> = args.iter().map(|a| a.get_z3_ast()).collect();
ast::Dynamic::new(self.ctx, unsafe {
let guard = Z3_MUTEX.lock().unwrap();
Z3_mk_app(
self.ctx.z3_ctx,
self.z3_func_decl,
args.len().try_into().unwrap(),
args.as_ptr(),
)
})
}
}
impl<'ctx> fmt::Display for FuncDecl<'ctx> {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
let p = unsafe { Z3_func_decl_to_string(self.ctx.z3_ctx, self.z3_func_decl) };
if p.is_null() {
return Result::Err(fmt::Error);
}
match unsafe { CStr::from_ptr(p) }.to_str() {
Ok(s) => write!(f, "{}", s),
Err(_) => Result::Err(fmt::Error),
}
}
}
impl<'ctx> Drop for FuncDecl<'ctx> {
fn drop(&mut self) {
unsafe {
Z3_dec_ref(
self.ctx.z3_ctx,
Z3_func_decl_to_ast(self.ctx.z3_ctx, self.z3_func_decl),
);
}
}
}
|
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct UiLayout {
pub name: String,
pub flex_childs: Vec<FlexChild>
}
impl Default for UiLayout {
fn default() -> Self {
UiLayout {
name: "".to_string(),
flex_childs: vec![]
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FlexChild {
pub flex: Flex,
pub cells: Vec<FlexCell>
}
impl Default for FlexChild {
fn default() -> Self {
FlexChild {
flex: Flex::ROW,
cells: vec![]
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct FlexCell {
pub component_name: String,
pub parameters: Vec<String>,
pub normal_info: String
}
impl Default for FlexCell {
fn default() -> Self {
FlexCell {
component_name: "".to_string(),
parameters: vec![],
normal_info: "".to_string()
}
}
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum Flex {
ROW,
COLUMN
}
|
use error_chain::error_chain;
error_chain! {
foreign_links {
Fmt(::std::fmt::Error);
Io(::std::io::Error);
NetworkError(::reqwest::Error);
ZipError(::zip::result::ZipError);
VersionError(::uvm_core::unity::VersionError);
}
errors {
ChecksumVerificationFailed {
description("checksum verification failed")
}
ManifestLoadFailed
UnknownInstallerType(provided: String, expected: String) {
description("unknown installer"),
display("unknown installer {}. Expect {}", provided, expected),
}
MissingDestination(installer: String) {
description("missing destination"),
display("missing destination for {}", installer),
}
MissingCommand(installer: String) {
description("missing cmd"),
display("missing command for {}", installer),
}
InstallerCreationFailed {
description("unable to create installer"),
}
}
}
|
fn main() {
vectors();
strings();
hash_maps();
}
#[derive(Debug)]
enum SpreadsheetCell {
Int(i32),
Float(f64),
Text(String),
}
fn vectors() {
let v: Vec<i32> = Vec::new(); // empty vector
println!("v: {:?}", v);
let v = vec![1, 2, 3]; // using the macro
println!("v: {:?}", v);
let mut v = Vec::new();
v.push(5);
v.push(6);
v.push(7);
v.push(8);
println!("v: {:?}", v);
let third: &i32 = &v[2];
println!("third element of v: {}", third);
match v.get(2) {
Some(x) => println!("x: {}", x),
None => println!("nothing found at v.get(2)"),
}
for i in &v {
println!("{}", i);
}
for i in &mut v {
// Need to dereference i to get to its value
//
*i += 50;
}
for i in &v {
println!("{}", i);
}
// This will panic
// let does_not_exist = &v[100];
// This will return None instead
let does_not_exist = v.get(100);
println!("does_not_exist: {:?}", does_not_exist);
// The following code is invalid, since there is a mix
// of mutable and immutable references. Since vectors
// can be resized and possibly reallocated, having an
// immutable reference before the vector is changed
// could mean that the previous reference points to
// deallocated memory. The borrow checker will find
// issues like this upon compilation.
//
/*
{
let mut v = vec![1, 2, 3];
let first = &v[0]; // immutable borrow occurs here
v.push(6); // mutable borrow later used here
println!("The first element is: {}", first); // immutable borrow later used here, and is invalid
}
*/
// Vectors can only store values of the same type. However,
// an enum can be used to wrap underlying types
//
let row = vec![
SpreadsheetCell::Int(3),
SpreadsheetCell::Text(String::from("blue")),
SpreadsheetCell::Float(10.12),
];
println!("row: {:?}", row);
}
// - Strings and string slices are UTF-8 encoded
// - Rust does not support indexing into strings
// - String slices could result in runtime panics
// - Some UTF-8 characters are multi-byte
// - Best approach is to iterate over chars()
//
fn strings() {
let mut s = String::new(); // new, blank string
// Ways to create a string from a string literal
//
let data = "initial contents";
let s = data.to_string();
println!("s: {}", s);
let s = "other contents".to_string();
println!("s: {}", s);
// Strings can grow
//
let mut s = "my content".to_string();
s.push_str(" appended with more content");
println!("s: {}", s);
s.push('!');
println!("s: {}", s);
let s1 = String::from("hello ");
let s2 = String::from("world");
let s = s1 + &s2; // NOTE: s1 has been moved here and is now invalid
//
// The above implements
// add(self, s: &str) -> String
//
println!("s: {}", s);
// Using the format macro to concatenate strings
//
let s1 = String::from("tic");
let s2 = String::from("tac");
let s3 = String::from("toe");
let s = format!("{}-{}-{}", s1, s2, s3);
println!("s: {}", s);
// Iterate over each scalar unicode character
//
for c in s.chars() {
println!("c: {}", c)
}
// Iterate over bytes
//
for b in s.bytes() {
println!("b: {}", b)
}
}
use std::collections::HashMap;
// - For types that implement the Copy trait, values are copied into the HashMap
// - For owned values like String, the values will be moved and the HashMap
// will be the owner of those values
// - Uses SipHash by default
//
fn hash_maps() {
let mut scores = HashMap::new();
scores.insert(String::from("Blue"), 10);
scores.insert(String::from("Yellow"), 50);
println!("scores: {:?}", scores);
let teams = vec![String::from("Blue"), String::from("Yellow")];
let initial_scores = vec![10, 50];
let mut scores: HashMap<_, _> = teams.into_iter().zip(initial_scores.into_iter()).collect();
println!("scores: {:?}", scores);
let score = scores.get("Blue");
println!("score for Blue: {:?}", score);
match score {
Some(x) => println!("score for Blue: {}", x),
None => println!("no score found for Blue")
}
scores.insert(String::from("Blue"), 0);
if let Some(score) = scores.get("Blue") {
println!("updated score for Blue: {}", score);
}
scores.entry(String::from("Red")).or_insert(100); // added
scores.entry(String::from("Blue")).or_insert(90); // unchanged
println!("updated scores: {:?}", scores);
for (k, v) in &scores {
println!("key: {}, value: {}", k, v);
}
let n = String::from("fav color");
let v = String::from("blue");
let mut map = HashMap::new();
map.insert(n, v); // n, v have been moved and are no longer valid
println!("map: {:?}", map);
let text = "hello world wonderful world";
let mut word_count_map = HashMap::new();
for word in text.split_whitespace() {
let count = word_count_map.entry(word).or_insert(0);
*count += 1;
}
println!("word count: {:?}", word_count_map);
}
|
use std::sync::mpsc;
use std::collections::BinaryHeap;
const N_SHARDS: usize = 4;
pub struct Transaction;
impl Transaction {
fn get_shard(&self) -> usize {
3
}
}
#[derive(PartialEq)]
pub struct MempoolItem {
id: [u8; 32],
tx: Transaction,
package_fee: u32
};
impl From<Transaction> for MempoolItem {
fn from(tx: Transaction) -> MempoolItem {
MempoolItem {
id: [0; 32],
tx,
package_fee: 0
}
}
}
fn main() {
let (tx_send, tx_recv) = mpsc::unbounded();
}
fn coordinator(tx_recv: mpsc::Receiver<Transaction>, shard_send: [mpsc::Sender<Transaction>; N_SHARDS]) {
tx_recv.for_each(|tx|
shard_send[tx.get_shard()].send(tx)
)
}
pub struct Shard {
tx_recv: mpsc::Receciver<Transaction>,
queue: BinaryHeap<MempoolItem>
}
impl Shard {
pub fn create() -> (Shard, mpsc::Sender<Transaction>) {
// Create shard channel
let (tx_send, tx_recv) = mpsc::unbounded();
// Create shard
let shard = Shard {
tx_recv,
queue: BinaryHeap::default()
};
(shard, tx_send)
}
pub fn run(self) {
self.tx_recv.for_each(|tx| {
let item = MempoolItem::from(tx);
})
queue
}
} |
use std::os::raw::{c_char, c_int, c_long, c_void};
extern "C" {
pub fn luaL_newstate() -> *mut c_void;
pub fn luaL_openlibs(state: *mut c_void);
pub fn lua_getfield(state: *mut c_void, index: c_int, k: *const c_char);
pub fn lua_tolstring(state: *mut c_void, index: c_int, len: *mut c_long) -> *const c_char;
pub fn luaL_loadstring(state: *mut c_void, s: *const c_char) -> c_int;
#[cfg(any(feature = "lua52", feature = "lua53", feature = "lua54"))]
pub fn lua_getglobal(state: *mut c_void, k: *const c_char);
}
#[cfg(feature = "lua51")]
pub unsafe fn lua_getglobal(state: *mut c_void, k: *const c_char) {
lua_getfield(state, -10002 /* LUA_GLOBALSINDEX */, k);
}
#[test]
fn lua_works() {
use std::{ptr, slice};
unsafe {
let state = luaL_newstate();
assert!(state != ptr::null_mut());
luaL_openlibs(state);
let version = {
lua_getglobal(state, "_VERSION\0".as_ptr().cast());
let mut len: c_long = 0;
let version_ptr = lua_tolstring(state, -1, &mut len);
slice::from_raw_parts(version_ptr as *const u8, len as usize)
};
#[cfg(feature = "lua51")]
assert_eq!(version, "Lua 5.1".as_bytes());
#[cfg(feature = "lua52")]
assert_eq!(version, "Lua 5.2".as_bytes());
#[cfg(feature = "lua53")]
assert_eq!(version, "Lua 5.3".as_bytes());
#[cfg(feature = "lua54")]
assert_eq!(version, "Lua 5.4".as_bytes());
}
}
#[test]
fn unicode_identifiers() {
unsafe {
let state = luaL_newstate();
let code = "local 😀 = 0\0";
let ret = luaL_loadstring(state, code.as_ptr().cast());
#[cfg(feature = "lua54")]
assert_eq!(0, ret);
#[cfg(not(feature = "lua54"))]
assert_ne!(0, ret);
}
}
|
use std::collections::HashMap;
use itertools::Itertools;
type RxnMap = HashMap<String, (SIZE, Vec<(String, SIZE)>)>;
type SIZE = u128;
#[aoc_generator(day14)]
fn gen(input: &str) -> RxnMap {
input.lines()
.map(|line| {
let mut iter = line.split("=>");
let ingreds = iter.next().unwrap()
.split(",")
.map(|ingred| {
let mut iter = ingred.split_ascii_whitespace();
let num = iter.next().unwrap().parse().unwrap();
let name = iter.next().unwrap().to_string();
(name, num)
})
.collect();
let mut product = iter.next().unwrap().split_ascii_whitespace();
let num = product.next().unwrap().parse().unwrap();
let name = product.next().unwrap().to_string();
(name, (num, ingreds))
})
.collect()
}
const FACTOR: SIZE = 2540160;
#[aoc(day14, part1)]
fn part1(recipes: &RxnMap) -> SIZE {
let mut store = HashMap::new();
// let recipes = recipes.iter()
// .map(|(prod, (prod_qty, ingreds))| {
// let ingreds = ingreds.iter()
// .map(|(name, qty)| (name.clone(), *qty * FACTOR))
// .collect();
// (prod.clone(), (prod_qty * FACTOR, ingreds))
// })
// .collect();
make("FUEL", 1, &mut store, &recipes)
}
#[allow(mutable_borrow_reservation_conflict)]
fn make(goal: &str, goal_num: SIZE, store: &mut HashMap<String, SIZE>, recipes: &RxnMap) -> SIZE {
if goal == "ORE" {
store.insert(goal.to_string(), goal_num);
return goal_num;
}
let mut ore_used = 0;
while *store.get(goal).unwrap_or(&0) < goal_num {
let tmp = recipes.get(goal).unwrap();
let ingreds = &tmp.1;
let num_produced = tmp.0;
for ingred in ingreds {
ore_used += make(&ingred.0, ingred.1, store, recipes);
let curr = store.get(&ingred.0).unwrap();
store.insert(ingred.0.clone(), curr - ingred.1);
}
let curr = *store.get(goal).unwrap_or(&0);
store.insert(goal.to_string(), curr + num_produced);
}
ore_used
}
const TRILLION: SIZE = 1_000_000_000_000;
#[aoc(day14, part2)]
fn part2(recipes: &RxnMap) -> SIZE {
let mut scaled_recipes = RxnMap::new();
scale("FUEL", recipes, &mut scaled_recipes);
// for scaled in &scaled_recipes {
// println!("{}: {:?}", scaled.0, scaled.1);
// }
let mut ore = HashMap::new();
ore.insert("ORE".to_string(), (1, 1));
collapse_to_ore("FUEL", &scaled_recipes, &mut ore);
// println!("{:?}", ore);
let &(fuel_made, ore_used) = ore.get("FUEL").unwrap();
println!("made {}, used {}", fuel_made, ore_used);
// if TRILLION * fuel_made % ore_used != 0 {
// panic!();
// }
TRILLION * fuel_made / ore_used
}
/// recursively replace every
fn collapse_to_ore(goal: &str, scaled: &RxnMap, ore: &mut HashMap<String, (SIZE, SIZE)>) {
let (qty, ingreds) = scaled.get(goal).unwrap();
for (ingr_name, _) in ingreds {
if !ore.contains_key(ingr_name) {
collapse_to_ore(ingr_name, scaled, ore);
}
}
let total_ore = ingreds.iter()
.map(|(name, qty)| {
// println!("{} {} takes {} ORE", ore.get(name).unwrap().0, name, ore.get(name).unwrap().1);
(qty, ore.get(name).unwrap())
})
.map(|(&needed_qty, &(prod_qty, ore_qty))| {
if needed_qty % prod_qty != 0 {
panic!()
}
needed_qty / prod_qty * ore_qty
})
.sum();
ore.insert(goal.to_string(), (*qty as SIZE, total_ore));
}
fn scale(goal: &str, recipes: &RxnMap, scaled_recipes: &mut RxnMap) {
let tmp = recipes.get(goal).unwrap();
let orig_goal_qty = tmp.0;
let ingreds = &tmp.1;
let mut lcm = Vec::new();
for (ingred, qty) in ingreds {
if ingred == "ORE" {
// ex: 157 ORE => 5 N
// ingred = ORE, qty = 157, goal = N
scaled_recipes.insert(goal.to_string(), (orig_goal_qty, vec![("ORE".to_string(), *qty)]));
} else {
if !scaled_recipes.contains_key(ingred) {
scale(ingred, recipes, scaled_recipes);
}
let recipe = scaled_recipes.get(ingred).unwrap();
lcm.push(recipe.0)
// ex: 12 H, 1 G, 8 P => 9 Q
// ingred = H, qty = 12, goal = Q, ogq = 9
// recipe = (5, [177 ORE])
}
}
// ex: 12 H, 1 G, 8 P => 9 Q
// ORE => 5 H, => 2 G, => 7 P
// LCM = 70
// scaled recipe = Q = (630, [H 840, G 70, P 560])
// println!("lcmvec={:?}", &lcm);
let lcm = lcm.into_iter()
.fold1(|a, b| lcm2(a, b)).unwrap_or(1);
let scaled_ingreds = ingreds.iter()
.map(|(name, qty)| (name.clone(), *qty * lcm))
// .map(|(name, qty)| (name.clone(), lcm2(*qty, lcm)))
.collect();
let scaled_output = orig_goal_qty * lcm;
// let scaled_output = lcm2(orig_goal_qty, lcm);
// println!("{} {}: {:?}", scaled_output, goal, scaled_ingreds);
let scaled_recipe = (scaled_output, scaled_ingreds);
scaled_recipes.insert(goal.to_string(), scaled_recipe);
}
fn lcm2(a: SIZE, b: SIZE) -> SIZE {
if (a * b) % gcd2(a, b) != 0 {
panic!();
}
(a * b) / gcd2(a, b)
}
fn gcd2(mut a: SIZE, mut b: SIZE) -> SIZE {
while b > 0 {
a %= b;
std::mem::swap(&mut a, &mut b);
}
a
} |
use crate::q2b::grid::Grid;
use crate::q2b::cluster_finder::ClusterFinder;
mod grid;
mod cluster_finder;
pub fn main() {
let lx = 6;
let ly = 4;
let n = 10;
let p_super = 0.1;
let mut r: Vec<bool> = Vec::with_capacity(100);
for _ in 0..100 {
let g1 = Grid::new(lx, ly, n, p_super);
let mut cf = ClusterFinder::new(&g1);
cf.search();
println!("{}", cf);
r.push(cf.did_form_path());
}
let success = r.iter()
.filter(|b| **b)
.count();
println!("Found path fraction = {}", (success as f64) / (r.len() as f64))
}
|
use crate::println;
use core::panic::PanicInfo;
#[panic_handler]
fn panic(info: &PanicInfo) -> ! {
println!("{}", info);
loop {}
}
|
use criterion::*;
#[path = "../src/mining.rs"]
mod mining;
pub fn criterion_benchmark(c: &mut Criterion) {
c.bench_function("onetime_rank", |b| {
b.iter(|| {
mining::ontime_rank(
// "/Desktop/Functional and Parallel Programing/mining",
"C:/Users/Admin/Desktop/mining/2008.csv",
)
})
});
}
criterion_group!(benches, criterion_benchmark);
criterion_main!(benches); |
use simplelog::Level::Info;
use std::thread;
use errors::*;
use format::*;
use ndarray::Axis;
use profile::ProfileData;
use rusage::{Duration, Instant};
use tfdeploy::streaming::*;
use tfdeploy::Tensor;
use utils::random_tensor;
use {OutputParameters, Parameters, ProfilingMode};
fn build_streaming_model(params: &Parameters) -> Result<(StreamingModel, Tensor)> {
let start = Instant::now();
info!("Initializing the StreamingModelState.");
let input = params
.input
.as_ref()
.ok_or("Exactly one of <size> or <data> must be specified.")?;
let inputs = params
.input_node_ids
.iter()
.map(|&s| {
(
s,
StreamingInput::Streamed(input.datatype, input.shape.clone()),
)
})
.collect::<Vec<_>>();
let model = StreamingModel::new(
params.tfd_model.clone(),
inputs.clone(),
Some(params.output_node_id),
)?;
let measure = Duration::since(&start, 1);
info!(
"Initialized the StreamingModelState in: {}",
dur_avg_oneline(measure)
);
let input = params
.input
.as_ref()
.ok_or("Exactly one of <size> or <data> must be specified.")?;
let chunk_shape = input
.shape
.iter()
.map(|d| d.unwrap_or(1))
.collect::<Vec<_>>();
let chunk = random_tensor(chunk_shape, input.datatype);
Ok((model, chunk))
}
// feed the network until it outputs something
fn bufferize(state: &mut StreamingModelState, chunk: &Tensor) -> Result<()> {
let buffering = Instant::now();
info!("Buffering...");
let mut buffered = 0;
loop {
let result = state.step(0, chunk.clone())?;
if result.len() != 0 {
break;
}
buffered += 1;
}
info!(
"Buffered {} chunks in {}",
buffered,
dur_avg_oneline(Duration::since(&buffering, 1))
);
Ok(())
}
pub fn handle_bench(
params: Parameters,
profiling: ProfilingMode,
_output_params: OutputParameters,
) -> Result<()> {
let (max_iters, max_time) = if let ProfilingMode::StreamBenching {
max_iters,
max_time,
} = profiling
{
(max_iters, max_time)
} else {
bail!("Expecting bench profile mode")
};
let (model, chunk) = build_streaming_model(¶ms)?;
let mut state = model.state();
bufferize(&mut state, &chunk)?;
info!("Starting bench itself");
let start = Instant::now();
let mut fed = 0;
let mut read = 0;
while fed < max_iters && start.elapsed_real() < (max_time as f64 * 1e-3) {
let result = state.step(0, chunk.clone())?;
read += result.len();
fed += 1;
}
println!(
"Fed {} chunks, obtained {}. {}",
fed,
read,
dur_avg_oneline(Duration::since(&start, fed))
);
Ok(())
}
pub fn handle_cruise(params: Parameters, output_params: OutputParameters) -> Result<()> {
let (model, chunk) = build_streaming_model(¶ms)?;
let mut state = model.state();
bufferize(&mut state, &chunk)?;
let mut profile = ProfileData::new(state.streaming_model().inner_model());
for _ in 0..100 {
let _result = state.step_wrapping_ops(
params.input_node_ids[0],
chunk.clone(),
|node, input, buffer| {
let start = Instant::now();
let r = node.op.step(input, buffer)?;
profile.add(node, Duration::since(&start, 1))?;
Ok(r)
},
);
}
profile.print_most_consuming_nodes(&model.inner_model(), ¶ms.graph, &output_params)?;
println!();
profile.print_most_consuming_ops(&model.inner_model())?;
Ok(())
}
/// Handles the `profile` subcommand when there are streaming dimensions.
pub fn handle_buffering(params: Parameters, output_params: OutputParameters) -> Result<()> {
let start = Instant::now();
info!("Initializing the StreamingModelState.");
let (streaming_model, _chunk) = build_streaming_model(¶ms)?;
let measure = Duration::since(&start, 1);
info!(
"Initialized the StreamingModelState in: {}",
dur_avg_oneline(measure)
);
let mut input = params
.input
.ok_or("Exactly one of <size> or <data> must be specified.")?;
let axis = input.shape.iter().position(|&d| d == None).unwrap(); // checked above
let mut states = (0..100)
.map(|_| streaming_model.state())
.collect::<Vec<_>>();
if log_enabled!(Info) {
println!();
print_header(format!("Streaming profiling for {}:", params.name), "white");
}
let shape = input
.shape
.iter()
.map(|d| d.unwrap_or(20))
.collect::<Vec<_>>();
let data = input
.data
.take()
.unwrap_or_else(|| random_tensor(shape, input.datatype));
// Split the input data into chunks along the streaming axis.
macro_rules! split_inner {
($constr:path, $array:expr) => {{
$array
.axis_iter(Axis(axis))
.map(|v| $constr(v.insert_axis(Axis(axis)).to_owned()))
.collect::<Vec<_>>()
}};
}
let chunks = match data {
Tensor::F64(m) => split_inner!(Tensor::F64, m),
Tensor::F32(m) => split_inner!(Tensor::F32, m),
Tensor::I32(m) => split_inner!(Tensor::I32, m),
Tensor::I8(m) => split_inner!(Tensor::I8, m),
Tensor::U8(m) => split_inner!(Tensor::U8, m),
Tensor::String(m) => split_inner!(Tensor::String, m),
};
let mut profile = ProfileData::new(&streaming_model.inner_model());
for (step, chunk) in chunks.into_iter().enumerate() {
for &input in ¶ms.input_node_ids {
trace!("Starting step {:?} with input {:?}.", step, chunk);
let mut input_chunks = vec![Some(chunk.clone()); 100];
let mut outputs = Vec::with_capacity(100);
let start = Instant::now();
for i in 0..100 {
outputs.push(states[i].step_wrapping_ops(
input,
input_chunks[i].take().unwrap(),
|node, input, buffer| {
let start = Instant::now();
let r = node.op.step(input, buffer)?;
profile.add(node, Duration::since(&start, 1))?;
Ok(r)
},
));
}
let measure = Duration::since(&start, 100);
println!(
"Completed step {:2} with output {:?} in: {}",
step,
outputs[0],
dur_avg_oneline(measure)
);
thread::sleep(::std::time::Duration::from_secs(1));
}
}
println!();
print_header(format!("Summary for {}:", params.name), "white");
profile.print_most_consuming_nodes(
&streaming_model.inner_model(),
¶ms.graph,
&output_params,
)?;
println!();
profile.print_most_consuming_ops(&streaming_model.inner_model())?;
Ok(())
}
|
//! Everting needed to track a position in a [source](`super::source::Source`)
//! file.
use std::fmt;
use std::ops::{Deref, Index};
// COPYRIGHT by Rust project contributors
// <https://github.com/rust-lang/rust/graphs/contributors>
//
// Copied from <https://github.com/rust-lang/rust/blob/362e0f55eb1f36d279e5c4a58fb0fe5f9a2c579d/compiler/rustc_span/src/lib.rs#L1768>.
/// A general position which allows conversion from and to [`usize`] and [`u32`].
pub trait Pos {
/// Creates a new position from `value`.
fn from_usize(value: usize) -> Self;
/// Creates a new position from `value`.
fn from_u32(value: u32) -> Self;
/// Interprets the position as a `usize`.
fn as_usize(&self) -> usize;
/// Interprets the position as a `u32`.
fn as_u32(&self) -> u32;
}
// COPYRIGHT by Rust project contributors
// <https://github.com/rust-lang/rust/graphs/contributors>
//
// Copied from <https://github.com/rust-lang/rust/blob/362e0f55eb1f36d279e5c4a58fb0fe5f9a2c579d/compiler/rustc_span/src/lib.rs#L1775> with slight adaptations.
/// Generates a basic structure/functions for a position type.
macro_rules! pos {
(
$(
$(#[$attr:meta])*
$vis:vis struct $ident:ident($inner_vis:vis $inner_ty:ty);
)*
) => {
$(
$(#[$attr])*
$vis struct $ident($inner_vis $inner_ty);
impl $ident {
/// Creates a new instance with `value`.
pub const fn new(value: $inner_ty) -> Self {
Self(value)
}
}
impl Pos for $ident {
fn from_usize(value: usize) -> Self {
Self(value as $inner_ty)
}
fn from_u32(value: u32) -> Self {
Self(value)
}
fn as_usize(&self) -> usize {
self.0 as usize
}
fn as_u32(&self) -> u32 {
self.0
}
}
impl ::std::convert::From<usize> for $ident {
fn from(value: usize) -> Self {
Self::from_usize(value)
}
}
impl ::std::convert::From<u32> for $ident {
fn from(value: u32) -> Self {
Self::from_u32(value)
}
}
impl ::std::fmt::Display for $ident {
fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
::std::fmt::Display::fmt(&self.0, f)
}
}
)*
}
}
pos! {
/// A position of a byte.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct BytePos(pub u32);
/// A position of a character.
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct CharPos(pub u32);
}
// COPYRIGHT by Rust project contributors
// <https://github.com/rust-lang/rust/graphs/contributors>
//
// Inspired by <https://github.com/rust-lang/rust/blob/362e0f55eb1f36d279e5c4a58fb0fe5f9a2c579d/compiler/rustc_span/src/lib.rs#L419>.
/// A span with a [start position](`ByteSpan::low`) and an [end position](`ByteSpan::high`).
#[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct ByteSpan {
/// Start position of the span.
pub low: BytePos,
/// End position of the span.
pub high: BytePos,
}
impl ByteSpan {
/// Creates a new span from `low` and `high`.
///
/// # Note
///
/// If `high` is smaller than `low` the values are switched.
pub fn new<L: Into<BytePos>, H: Into<BytePos>>(low: L, high: H) -> Self {
let mut low = low.into();
let mut high = high.into();
if low > high {
std::mem::swap(&mut low, &mut high);
}
Self { low, high }
}
/// Associates the span with the given `value`.
pub const fn span<T>(self, value: T) -> Spanned<T> {
Spanned::new(self, value)
}
/// Creates a new span with `low` while `high` is taken from this span.
pub fn with_low<L: Into<BytePos>>(&self, low: L) -> Self {
let mut copy = *self;
copy.low = low.into();
copy
}
/// Creates a new span with `low` taken from this span and `high`.
pub fn with_high<H: Into<BytePos>>(&self, high: H) -> Self {
let mut copy = *self;
copy.high = high.into();
copy
}
/// Creates a new span containing both `self` and `other`.
pub fn union(&self, other: &Self) -> Self {
let low = std::cmp::min(self.low, other.low);
let high = std::cmp::max(self.high, other.high);
Self { low, high }
}
/// Creates a new span with `low` offset by `amount`.
pub fn offset_low<A: Into<i32>>(&self, amount: A) -> Self {
let amount = amount.into();
let mut copy = *self;
copy.low.0 = (copy.low.0 as i32 + amount) as u32;
copy
}
/// Creates a new span with `high` offset by `amount`.
pub fn offset_high<A: Into<i32>>(&self, amount: A) -> Self {
let amount = amount.into();
let mut copy = *self;
copy.high.0 = (copy.high.0 as i32 + amount) as u32;
copy
}
/// Creates a new span with both `low` and `high` offset by `amount`.
pub fn offset<A: Into<i32>>(&self, amount: A) -> Self {
let amount = amount.into();
let mut copy = *self;
copy.low.0 = (copy.low.0 as i32 + amount) as u32;
copy.high.0 = (copy.high.0 as i32 + amount) as u32;
copy
}
/// Returns the start of the span.
pub const fn low(&self) -> &BytePos {
&self.low
}
/// Returns the end of the span.
pub const fn high(&self) -> &BytePos {
&self.high
}
}
impl fmt::Display for ByteSpan {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(f, "{}..{}", self.low, self.high)
}
}
impl Index<ByteSpan> for str {
type Output = Self;
fn index(&self, index: ByteSpan) -> &Self::Output {
&self[index.low.as_usize()..index.high.as_usize()]
}
}
impl Index<&ByteSpan> for str {
type Output = Self;
fn index(&self, index: &ByteSpan) -> &Self::Output {
&self[index.low.as_usize()..index.high.as_usize()]
}
}
/// Associates a [`ByteSpan`] with a generic `value`.
pub struct Spanned<T> {
/// A span.
pub span: ByteSpan,
/// The value associated with the span.
pub value: T,
}
impl<T> Spanned<T> {
/// Creates a new instance.
pub const fn new(span: ByteSpan, value: T) -> Self {
Self { span, value }
}
/// Returns the `span` associated with this struct.
pub const fn span(&self) -> &ByteSpan {
&self.span
}
/// Returns the `value` associated with this struct.
pub const fn value(&self) -> &T {
&self.value
}
/// Consumes self and returns the `span` associated with it.
// Destructors can not be run at compile time.
#[allow(clippy::missing_const_for_fn)]
pub fn into_span(self) -> ByteSpan {
self.span
}
/// Consumes self and returns the `value` associated with it.
// Destructors can not be run at compile time.
#[allow(clippy::missing_const_for_fn)]
pub fn into_value(self) -> T {
self.value
}
/// Consumes self and returns both `span` and `value`.
// Destructors can not be run at compile time.
#[allow(clippy::missing_const_for_fn)]
pub fn into_inner(self) -> (ByteSpan, T) {
(self.span, self.value)
}
}
impl<T> fmt::Debug for Spanned<T>
where
T: fmt::Debug,
{
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Spanned")
.field("span", &self.span)
.field("value", &self.value)
.finish()
}
}
impl<T> Clone for Spanned<T>
where
T: Clone,
{
fn clone(&self) -> Self {
Self {
span: self.span,
value: self.value.clone(),
}
}
}
impl<T> Copy for Spanned<T> where T: Copy {}
impl<T> PartialEq for Spanned<T>
where
T: PartialEq,
{
fn eq(&self, other: &Self) -> bool {
self.span.eq(&other.span) && self.value.eq(&other.value)
}
}
impl<T> Eq for Spanned<T> where T: Eq {}
impl<T> Deref for Spanned<T> {
type Target = T;
fn deref(&self) -> &Self::Target {
&self.value
}
}
|
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
use super::{FieldElement, StarkField};
use core::{
convert::TryFrom,
fmt::{Debug, Display, Formatter},
ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign},
slice,
};
use utils::{
collections::Vec,
string::{String, ToString},
AsBytes, ByteReader, ByteWriter, Deserializable, DeserializationError, Serializable,
};
// QUADRATIC EXTENSION FIELD
// ================================================================================================
/// Represents an element in a quadratic extensions field defined as F\[x\]/(x^2-x-1).
///
/// The extension element is α + β * φ, where φ is a root of the polynomial x^2 - x - 1, and α
/// and β are base field elements.
#[repr(C)]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
pub struct QuadExtensionA<B: StarkField>(B, B);
impl<B: StarkField> QuadExtensionA<B> {
/// Converts a vector of base elements into a vector of elements in a quadratic extension
/// field by fusing two adjacent base elements together. The output vector is half the length
/// of the source vector.
fn base_to_quad_vector(source: Vec<B>) -> Vec<Self> {
debug_assert!(
source.len() % 2 == 0,
"source vector length must be divisible by two, but was {}",
source.len()
);
let mut v = core::mem::ManuallyDrop::new(source);
let p = v.as_mut_ptr();
let len = v.len() / 2;
let cap = v.capacity() / 2;
unsafe { Vec::from_raw_parts(p as *mut Self, len, cap) }
}
}
impl<B: StarkField> FieldElement for QuadExtensionA<B> {
type PositiveInteger = B::PositiveInteger;
type BaseField = B;
const ELEMENT_BYTES: usize = B::ELEMENT_BYTES * 2;
const IS_MALLEABLE: bool = B::IS_MALLEABLE;
const ZERO: Self = Self(B::ZERO, B::ZERO);
const ONE: Self = Self(B::ONE, B::ZERO);
fn inv(self) -> Self {
if self == Self::ZERO {
return Self::ZERO;
}
#[allow(clippy::suspicious_operation_groupings)]
let denom = (self.0 * self.0) + (self.0 * self.1) - (self.1 * self.1);
let denom_inv = denom.inv();
Self((self.0 + self.1) * denom_inv, self.1.neg() * denom_inv)
}
fn conjugate(&self) -> Self {
Self(self.0 + self.1, B::ZERO - self.1)
}
#[cfg(feature = "std")]
fn rand() -> Self {
Self(B::rand(), B::rand())
}
fn from_random_bytes(bytes: &[u8]) -> Option<Self> {
Self::try_from(&bytes[..Self::ELEMENT_BYTES as usize]).ok()
}
fn elements_into_bytes(elements: Vec<Self>) -> Vec<u8> {
let mut v = core::mem::ManuallyDrop::new(elements);
let p = v.as_mut_ptr();
let len = v.len() * Self::ELEMENT_BYTES;
let cap = v.capacity() * Self::ELEMENT_BYTES;
unsafe { Vec::from_raw_parts(p as *mut u8, len, cap) }
}
fn elements_as_bytes(elements: &[Self]) -> &[u8] {
unsafe {
slice::from_raw_parts(
elements.as_ptr() as *const u8,
elements.len() * Self::ELEMENT_BYTES,
)
}
}
unsafe fn bytes_as_elements(bytes: &[u8]) -> Result<&[Self], DeserializationError> {
if bytes.len() % Self::ELEMENT_BYTES != 0 {
return Err(DeserializationError::InvalidValue(format!(
"number of bytes ({}) does not divide into whole number of field elements",
bytes.len(),
)));
}
let p = bytes.as_ptr();
let len = bytes.len() / Self::ELEMENT_BYTES;
// make sure the bytes are aligned on the boundary consistent with base element alignment
if (p as usize) % Self::BaseField::ELEMENT_BYTES != 0 {
return Err(DeserializationError::InvalidValue(
"slice memory alignment is not valid for this field element type".to_string(),
));
}
Ok(slice::from_raw_parts(p as *const Self, len))
}
fn zeroed_vector(n: usize) -> Vec<Self> {
// get twice the number of base elements, and re-interpret them as quad field elements
let result = B::zeroed_vector(n * 2);
Self::base_to_quad_vector(result)
}
#[cfg(feature = "std")]
fn prng_vector(seed: [u8; 32], n: usize) -> Vec<Self> {
// get twice the number of base elements, and re-interpret them as quad field elements
let result = B::prng_vector(seed, n * 2);
Self::base_to_quad_vector(result)
}
fn normalize(&mut self) {
self.0.normalize();
self.1.normalize();
}
}
impl<B: StarkField> Display for QuadExtensionA<B> {
fn fmt(&self, f: &mut Formatter) -> core::fmt::Result {
write!(f, "({}, {})", self.0, self.1)
}
}
// OVERLOADED OPERATORS
// ------------------------------------------------------------------------------------------------
impl<B: StarkField> Add for QuadExtensionA<B> {
type Output = Self;
fn add(self, rhs: Self) -> Self {
Self(self.0 + rhs.0, self.1 + rhs.1)
}
}
impl<B: StarkField> AddAssign for QuadExtensionA<B> {
fn add_assign(&mut self, rhs: Self) {
*self = *self + rhs
}
}
impl<B: StarkField> Sub for QuadExtensionA<B> {
type Output = Self;
fn sub(self, rhs: Self) -> Self {
Self(self.0 - rhs.0, self.1 - rhs.1)
}
}
impl<B: StarkField> SubAssign for QuadExtensionA<B> {
fn sub_assign(&mut self, rhs: Self) {
*self = *self - rhs;
}
}
impl<B: StarkField> Mul for QuadExtensionA<B> {
type Output = Self;
fn mul(self, rhs: Self) -> Self {
let coef0_mul = self.0 * rhs.0;
Self(
coef0_mul + self.1 * rhs.1,
(self.0 + self.1) * (rhs.0 + rhs.1) - coef0_mul,
)
}
}
impl<B: StarkField> MulAssign for QuadExtensionA<B> {
fn mul_assign(&mut self, rhs: Self) {
*self = *self * rhs
}
}
impl<B: StarkField> Div for QuadExtensionA<B> {
type Output = Self;
#[allow(clippy::suspicious_arithmetic_impl)]
fn div(self, rhs: Self) -> Self {
self * rhs.inv()
}
}
impl<B: StarkField> DivAssign for QuadExtensionA<B> {
fn div_assign(&mut self, rhs: Self) {
*self = *self / rhs
}
}
impl<B: StarkField> Neg for QuadExtensionA<B> {
type Output = Self;
fn neg(self) -> Self {
Self(B::ZERO - self.0, B::ZERO - self.1)
}
}
// TYPE CONVERSIONS
// ------------------------------------------------------------------------------------------------
impl<B: StarkField> From<B> for QuadExtensionA<B> {
fn from(e: B) -> Self {
Self(e, B::ZERO)
}
}
impl<B: StarkField> From<u128> for QuadExtensionA<B> {
fn from(value: u128) -> Self {
Self(B::from(value), B::ZERO)
}
}
impl<B: StarkField> From<u64> for QuadExtensionA<B> {
fn from(value: u64) -> Self {
Self(B::from(value), B::ZERO)
}
}
impl<B: StarkField> From<u32> for QuadExtensionA<B> {
fn from(value: u32) -> Self {
Self(B::from(value), B::ZERO)
}
}
impl<B: StarkField> From<u16> for QuadExtensionA<B> {
fn from(value: u16) -> Self {
Self(B::from(value), B::ZERO)
}
}
impl<B: StarkField> From<u8> for QuadExtensionA<B> {
fn from(value: u8) -> Self {
Self(B::from(value), B::ZERO)
}
}
impl<'a, B: StarkField> TryFrom<&'a [u8]> for QuadExtensionA<B> {
type Error = String;
/// Converts a slice of bytes into a field element; returns error if the value encoded in bytes
/// is not a valid field element. The bytes are assumed to be in little-endian byte order.
fn try_from(bytes: &[u8]) -> Result<Self, Self::Error> {
if bytes.len() < Self::ELEMENT_BYTES {
return Err(
"need more bytes in order to convert into extension field element".to_string(),
);
}
let value0 = match B::try_from(&bytes[..B::ELEMENT_BYTES]) {
Ok(val) => val,
Err(_) => {
return Err("could not convert into field element".to_string());
}
};
let value1 = match B::try_from(&bytes[B::ELEMENT_BYTES..]) {
Ok(val) => val,
Err(_) => {
return Err("could not convert into field element".to_string());
}
};
Ok(Self(value0, value1))
}
}
impl<B: StarkField> AsBytes for QuadExtensionA<B> {
fn as_bytes(&self) -> &[u8] {
// TODO: take endianness into account
let self_ptr: *const Self = self;
unsafe { slice::from_raw_parts(self_ptr as *const u8, Self::ELEMENT_BYTES) }
}
}
// SERIALIZATION / DESERIALIZATION
// ------------------------------------------------------------------------------------------------
impl<B: StarkField> Serializable for QuadExtensionA<B> {
fn write_into<W: ByteWriter>(&self, target: &mut W) {
self.0.write_into(target);
self.1.write_into(target);
}
}
impl<B: StarkField> Deserializable for QuadExtensionA<B> {
fn read_from<R: ByteReader>(source: &mut R) -> Result<Self, DeserializationError> {
let value0 = B::read_from(source)?;
let value1 = B::read_from(source)?;
Ok(Self(value0, value1))
}
}
// TESTS
// ================================================================================================
#[cfg(test)]
mod tests {
use super::{AsBytes, DeserializationError, FieldElement, QuadExtensionA, Vec};
use crate::field::f128::BaseElement;
// BASIC ALGEBRA
// --------------------------------------------------------------------------------------------
#[test]
fn add() {
// identity
let r = QuadExtensionA::<BaseElement>::rand();
assert_eq!(r, r + QuadExtensionA::<BaseElement>::ZERO);
// test random values
let r1 = QuadExtensionA::<BaseElement>::rand();
let r2 = QuadExtensionA::<BaseElement>::rand();
let expected = QuadExtensionA(r1.0 + r2.0, r1.1 + r2.1);
assert_eq!(expected, r1 + r2);
}
#[test]
fn sub() {
// identity
let r = QuadExtensionA::<BaseElement>::rand();
assert_eq!(r, r - QuadExtensionA::<BaseElement>::ZERO);
// test random values
let r1 = QuadExtensionA::<BaseElement>::rand();
let r2 = QuadExtensionA::<BaseElement>::rand();
let expected = QuadExtensionA(r1.0 - r2.0, r1.1 - r2.1);
assert_eq!(expected, r1 - r2);
}
#[test]
fn mul() {
// identity
let r = QuadExtensionA::<BaseElement>::rand();
assert_eq!(
QuadExtensionA::<BaseElement>::ZERO,
r * QuadExtensionA::<BaseElement>::ZERO
);
assert_eq!(r, r * QuadExtensionA::<BaseElement>::ONE);
// test random values
let r1 = QuadExtensionA::<BaseElement>::rand();
let r2 = QuadExtensionA::<BaseElement>::rand();
let expected = QuadExtensionA(
r1.0 * r2.0 + r1.1 * r2.1,
(r1.0 + r1.1) * (r2.0 + r2.1) - r1.0 * r2.0,
);
assert_eq!(expected, r1 * r2);
}
#[test]
fn inv() {
// identity
assert_eq!(
QuadExtensionA::<BaseElement>::ONE,
QuadExtensionA::<BaseElement>::inv(QuadExtensionA::<BaseElement>::ONE)
);
assert_eq!(
QuadExtensionA::<BaseElement>::ZERO,
QuadExtensionA::<BaseElement>::inv(QuadExtensionA::<BaseElement>::ZERO)
);
// test random values
let x = QuadExtensionA::<BaseElement>::prng_vector(build_seed(), 1000);
for i in 0..x.len() {
let y = QuadExtensionA::<BaseElement>::inv(x[i]);
assert_eq!(QuadExtensionA::<BaseElement>::ONE, x[i] * y);
}
}
#[test]
fn conjugate() {
let a = QuadExtensionA::<BaseElement>::rand();
let b = a.conjugate();
let expected = QuadExtensionA(a.0 + a.1, -a.1);
assert_eq!(expected, b);
}
// INITIALIZATION
// --------------------------------------------------------------------------------------------
#[test]
fn zeroed_vector() {
let result = QuadExtensionA::<BaseElement>::zeroed_vector(4);
assert_eq!(4, result.len());
for element in result.into_iter() {
assert_eq!(QuadExtensionA::<BaseElement>::ZERO, element);
}
}
#[test]
fn prng_vector() {
let a = QuadExtensionA::<BaseElement>::prng_vector([0; 32], 4);
assert_eq!(4, a.len());
let b = QuadExtensionA::<BaseElement>::prng_vector([0; 32], 8);
assert_eq!(8, b.len());
for (&a, &b) in a.iter().zip(b.iter()) {
assert_eq!(a, b);
}
let c = QuadExtensionA::<BaseElement>::prng_vector([1; 32], 4);
for (&a, &c) in a.iter().zip(c.iter()) {
assert_ne!(a, c);
}
}
// SERIALIZATION / DESERIALIZATION
// --------------------------------------------------------------------------------------------
#[test]
fn elements_into_bytes() {
let source = vec![
QuadExtensionA(BaseElement::new(1), BaseElement::new(2)),
QuadExtensionA(BaseElement::new(3), BaseElement::new(4)),
];
let expected: Vec<u8> = vec![
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
];
assert_eq!(
expected,
QuadExtensionA::<BaseElement>::elements_into_bytes(source)
);
}
#[test]
fn elements_as_bytes() {
let source = vec![
QuadExtensionA(BaseElement::new(1), BaseElement::new(2)),
QuadExtensionA(BaseElement::new(3), BaseElement::new(4)),
];
let expected: Vec<u8> = vec![
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0,
];
assert_eq!(
expected,
QuadExtensionA::<BaseElement>::elements_as_bytes(&source)
);
}
#[test]
fn bytes_as_elements() {
let bytes: Vec<u8> = vec![
1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 3, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 5,
];
let expected = vec![
QuadExtensionA(BaseElement::new(1), BaseElement::new(2)),
QuadExtensionA(BaseElement::new(3), BaseElement::new(4)),
];
let result = unsafe { QuadExtensionA::<BaseElement>::bytes_as_elements(&bytes[..64]) };
assert!(result.is_ok());
assert_eq!(expected, result.unwrap());
let result = unsafe { QuadExtensionA::<BaseElement>::bytes_as_elements(&bytes) };
assert!(matches!(result, Err(DeserializationError::InvalidValue(_))));
let result = unsafe { QuadExtensionA::<BaseElement>::bytes_as_elements(&bytes[1..]) };
assert!(matches!(result, Err(DeserializationError::InvalidValue(_))));
}
// HELPER FUNCTIONS
// --------------------------------------------------------------------------------------------
fn build_seed() -> [u8; 32] {
let mut result = [0; 32];
let seed = QuadExtensionA::<BaseElement>::rand().as_bytes().to_vec();
result.copy_from_slice(&seed);
result
}
}
|
use crate::neuron::{get_quality, Neuron, NeuronicInput, NeuronicSensor, Neuronic, ChargeCycle};
use std::rc::Rc;
/// Utility method that compares f32 to
/// three decimal places
fn cmp_f32(f1: f32, f2: f32) {
assert_eq!(
(f1 * 1000.).floor(),
(f2 * 1000.).floor(),
"{} does not equal {}",
f1,
f2
);
}
#[test]
fn test_basic_neuron() {
let s1_value = 0.5;
let s1 = Rc::new(NeuronicSensor::new_custom_start(s1_value));
let s2_value = 0.6;
let s2 = Rc::new(NeuronicSensor::new_custom_start(s2_value));
let s2_w1 = 1.;
let s1_w2 = 1.;
let weights_vec = vec![vec![s1_w2], vec![s2_w1]];
let input_vec = vec![
Rc::clone(&s1) as Rc<dyn NeuronicInput>,
Rc::clone(&s2) as Rc<dyn NeuronicInput>,
];
let learning_rate = 0.01;
let n = Neuron::new(learning_rate, get_quality);
n.add_synapses(input_vec, weights_vec);
let cycle = ChargeCycle::Even;
n.run_cycle(cycle);
let prediction_weights = n.prediction_weights.borrow();
cmp_f32(
*prediction_weights.get(0).unwrap().get(0).unwrap(),
s2_w1 - s2_value * learning_rate
);
cmp_f32(
*prediction_weights.get(1).unwrap().get(0).unwrap(),
s1_w2 + s1_value * learning_rate
)
}
|
use crate::data::component::components::*;
use crate::{map, set};
use super::*;
use crate::data::component::statefuls::{SRFlipFlop, Constant};
use std::cell::Cell;
macro_rules! edge {
($subnet:expr, $component:expr, $port:expr, 0) => {
Edge {
subnet: $subnet,
component: $component,
port: $port,
direction: EdgeDirection::ToComponent,
}
};
($subnet:expr, $component:expr, $port:expr, 1) => {
Edge {
subnet: $subnet,
component: $component,
port: $port,
direction: EdgeDirection::Bidirectional,
}
};
($subnet:expr, $component:expr, $port:expr, 2) => {
Edge {
subnet: $subnet,
component: $component,
port: $port,
direction: EdgeDirection::ToSubnet,
}
};
}
macro_rules! subnet {
($state:expr) => {
{
let mut s = Subnet::new();
s.update($state);
s
}
};
}
#[test]
fn test_adding_components() {
let mut data = Data::new();
data.add_subnet(0);
assert!(data.add_component(Box::new(OutputGate {}), vec![Some(0)]).is_ok());
data.add_subnet(1);
data.add_subnet(5);
assert!(data.add_component(Box::new(AND {}), vec![Some(1), Some(5), Some(0)]).is_ok());
assert!(data.add_component(Box::new(OutputGate {}), vec![Some(0)]).is_ok());
assert_eq!(data.component_edges, map!(
1 => set!(edge!(0, 1, 0, 0)),
2 => set!(edge!(0, 2, 2, 2), edge!(1, 2, 0, 0), edge!(5, 2, 1, 0)),
3 => set!(edge!(0, 3, 0, 0))
));
assert_eq!(data.subnet_edges, map!(
0 => set!(edge!(0, 1, 0, 0), edge!(0, 2, 2, 2), edge!(0, 3, 0, 0)),
1 => set!(edge!(1, 2, 0, 0)),
5 => set!(edge!(5, 2, 1, 0))
));
assert!(data.add_component(Box::new(AND {}), vec![]).is_err());
}
#[test]
fn test_removing_subnets() {
let mut data = Data::new();
data.add_subnet(0);
data.add_subnet(1);
assert_eq!(data.component_edges, map!());
assert_eq!(data.subnet_edges, map!());
assert!(data.add_component(Box::new(OutputGate {}), vec![Some(0)]).is_ok());
assert_eq!(data.component_edges, map!(
1 => set!(edge!(0, 1, 0, 0))
));
assert_eq!(data.subnet_edges, map!(
0 => set!(edge!(0, 1, 0, 0))
));
assert!(data.remove_subnet(0));
assert_eq!(data.component_edges, map!());
assert_eq!(data.subnet_edges, map!());
assert!(data.remove_subnet(1));
assert_eq!(data.component_edges, map!());
assert_eq!(data.subnet_edges, map!());
assert!(!data.remove_subnet(0));
assert!(!data.remove_subnet(3));
}
#[test]
fn test_simulation() {
let mut data = Data::new();
data.add_subnet(0);
data.add_subnet(1);
assert!(data.add_component(Box::new(NOT {}), vec![Some(0), Some(1)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(false) }), vec![Some(0)]).is_ok());
assert_eq!(data.simulation.dirty_subnets, VecDeque::from(vec![]));
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::Off),
1 => subnet!(SubnetState::On)
));
}
#[test]
fn test_simulation_2() {
let mut data = Data::new();
data.add_subnet(1);
data.add_subnet(2);
data.add_subnet(5);
data.add_subnet(7);
assert!(data.add_component(Box::new(Constant { state: Cell::new(false) }), vec![Some(7)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(true) }), vec![Some(2)]).is_ok());
assert!(data.add_component(Box::new(AND {}), vec![Some(1), Some(2), Some(5)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(7), Some(1)]).is_ok());
assert_eq!(data.simulation.dirty_subnets, VecDeque::from(vec![]));
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::On),
2 => subnet!(SubnetState::On),
5 => subnet!(SubnetState::On),
7 => subnet!(SubnetState::Off)
));
}
#[test]
fn test_simulation_3() {
let mut data = Data::new();
data.add_subnet(1);
data.add_subnet(2);
data.add_subnet(3);
data.add_subnet(4);
data.add_subnet(5);
data.add_subnet(6);
assert!(data.add_component(Box::new(AND {}), vec![Some(3), Some(3), Some(4)]).is_ok());
assert!(data.add_component(Box::new(AND {}), vec![Some(1), Some(2), Some(3)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(5), Some(1)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(6), Some(2)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(false) }), vec![Some(5)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(false) }), vec![Some(6)]).is_ok());
assert_eq!(data.simulation.dirty_subnets, VecDeque::from(vec![]));
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::On),
2 => subnet!(SubnetState::On),
3 => subnet!(SubnetState::On),
4 => subnet!(SubnetState::On),
5 => subnet!(SubnetState::Off),
6 => subnet!(SubnetState::Off)
));
}
// probably easiest to implement with buttons and such
//#[test]
fn test_sr_latch() {
let mut data = Data::new();
data.add_subnet(0);
data.add_subnet(1);
data.add_subnet(2);
data.add_subnet(3);
data.add_subnet(4);
data.add_subnet(5);
assert!(data.add_component(Box::new( SRFlipFlop { state: Cell::new(false) }),
vec![Some(0), Some(1), Some(2), Some(3), Some(4), Some(5)]).is_ok());
assert!(data.add_component(Box::new( Constant { state: Cell::new(true) }), vec![Some(0)]).is_ok());
assert!(data.add_component(Box::new( Constant { state: Cell::new(false) }), vec![Some(2)]).is_ok());
data.update_subnet(0, SubnetState::On);
data.update_subnet(2, SubnetState::Off);
data.advance_time();
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::On),
1 => subnet!(SubnetState::Floating),
2 => subnet!(SubnetState::Off),
3 => subnet!(SubnetState::Floating),
4 => subnet!(SubnetState::Off),
5 => subnet!(SubnetState::On)
));
data.update_subnet(2, SubnetState::On);
data.advance_time();
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::On),
1 => subnet!(SubnetState::Floating),
2 => subnet!(SubnetState::On),
3 => subnet!(SubnetState::Floating),
4 => subnet!(SubnetState::On),
5 => subnet!(SubnetState::Off)
));
data.update_subnet(0, SubnetState::Off);
data.update_subnet(1, SubnetState::On);
data.update_subnet(2, SubnetState::Off);
data.advance_time();
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::Off),
1 => subnet!(SubnetState::On),
2 => subnet!(SubnetState::Off),
3 => subnet!(SubnetState::Floating),
4 => subnet!(SubnetState::On),
5 => subnet!(SubnetState::Off)
));
data.update_subnet(2, SubnetState::On);
data.advance_time();
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::Off),
1 => subnet!(SubnetState::On),
2 => subnet!(SubnetState::On),
3 => subnet!(SubnetState::Floating),
4 => subnet!(SubnetState::Off),
5 => subnet!(SubnetState::On)
));
}
#[test]
fn test_error_driving() {
let mut data = Data::new();
data.add_subnet(0);
data.add_subnet(1);
data.add_subnet(2);
assert!(data.add_component(Box::new(Constant { state: Cell::new(false) }), vec![Some(0)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(true) }), vec![Some(1)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(0), Some(2)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(1), Some(2)]).is_ok());
assert_eq!(data.subnets, map!(
0 => subnet!(SubnetState::Off),
1 => subnet!(SubnetState::On),
2 => subnet!(SubnetState::Error)
));
}
#[test]
fn test_linking() {
let mut data = Data::new();
data.add_subnet(0);
data.add_subnet(1);
data.add_subnet(2);
assert!(data.add_component(Box::new(AND {}), vec![Some(0), Some(1), Some(2)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(true) }), vec![Some(0)]).is_ok());
assert!(data.add_component(Box::new(Constant { state: Cell::new(true) }), vec![Some(1)]).is_ok());
assert_eq!(data.simulation.dirty_subnets, VecDeque::from(vec![]));
assert_eq!(data.subnets.get(&2).unwrap().val(), SubnetState::On);
}
#[test]
fn test_simulating_loop() {
let mut data = Data::new();
data.add_subnet(1);
assert!(data.add_component(Box::new(Constant::new()), vec![Some(1)]).is_ok());
assert!(data.add_component(Box::new(NOT {}), vec![Some(1), Some(1)]).is_ok());
assert_eq!(data.simulation.dirty_subnets, VecDeque::from(vec![]));
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::Error)
));
}
#[test]
fn test_relinking() {
let mut data = Data::new();
data.add_subnet(1);
data.add_subnet(2);
assert!(data.add_component(Box::new(Constant::new()), vec![None]).is_ok());
data.link(1, 0, 1);
assert_eq!(data.component_edges, map!(
1 => set!(edge!(1, 1, 0, 2))
));
assert_eq!(data.subnet_edges, map!(
1 => set!(edge!(1, 1, 0, 2))
));
data.link(1, 0, 2);
assert_eq!(data.component_edges, map!(
1 => set!(edge!(2, 1, 0, 2))
));
assert_eq!(data.subnet_edges, map!(
2 => set!(edge!(2, 1, 0, 2))
));
}
#[test]
fn test_unlinking_last() {
let mut data = Data::new();
data.add_subnet(1);
data.add_component(Box::new(Constant::new()), vec![None]).unwrap();
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::Floating)
));
assert!(data.link(1, 0, 1));
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::Off)
));
assert!(data.unlink(1, 0, 1));
assert_eq!(data.subnets, map!(
1 => subnet!(SubnetState::Floating)
));
} |
fn main() {
println!("cargo:rerun-if-changed=src/callback.c");
cc::Build::new()
.opt_level(0)
.debug(false)
.flag("-g1")
.file("src/callback.c")
.compile("libcallback.a");
}
|
mod rbf;
mod utils;
use std::slice::{from_raw_parts};
use std::os::raw::c_char;
use std::ffi::CString;
use rand::Rng;
use nalgebra::*;
use crate::rbf::RBF;
//////////////////////////////////////////////////LINEAR MODEL///////////////////////////////////////////////////////////
#[no_mangle]
pub extern fn create_linear_model(input_size: usize) -> *mut Vec<f64> {
//Initialisation du model lineaire avec une taille défini + un biais
let mut weights = Vec::with_capacity(input_size + 1);
//Initialisation des poids
for i in 0..input_size {
weights.push(rand::thread_rng().gen_range(-1.0, 1.0));
}
//Initialisation du poids du biais
weights.push(rand::thread_rng().gen_range(-1.0, 1.0));
//Fuite mémoire volontaire afin de pouvoir renvoyer un pointeur
let boxed_weights = Box::new(weights);
let boxed_ref = Box::leak(boxed_weights);
boxed_ref
}
#[no_mangle]
pub extern fn predict_linear_model(model: *mut Vec<f64>, inputs: *mut f64, inputs_size: usize, is_classification: bool) -> f64
{
let boxed_model;
let inputs_slice;
unsafe {
//Récupération des contenus des pointeurs
boxed_model = model.as_ref().unwrap();
inputs_slice = from_raw_parts(inputs, inputs_size);
}
let mut sum = 0.0;
//prédictions
for i in 0..inputs_slice.len() {
sum += inputs_slice[i] * boxed_model[i];
}
//Sachant que le biais = 1.0
sum += boxed_model[inputs_slice.len()];
if is_classification
{
return utils::sign(sum);
}
sum
}
#[no_mangle]
pub extern fn train_linear_model_class(model: *mut Vec<f64>, inputs: *mut f64, input_size: usize, input_sample_size: usize,
output: *mut f64, output_size: usize, output_sample_size: usize, learning_rate: f64, is_classification: bool, epochs: i32)
{
let mut boxed_model;
let mut input_slice;
let mut output_slice;
unsafe {
boxed_model = &mut *model;
input_slice = from_raw_parts(inputs, input_size);
output_slice = from_raw_parts(output, output_size);
}
let dataset_size = output_size/output_sample_size;
for it in 0..epochs
{
if is_classification
{
let biais = 1.0;
let mut k = rand::thread_rng().gen_range(0, dataset_size);
let mut sampled_input: Vec<f64> = Vec::new();
let mut sampled_output: Vec<f64> = Vec::new();
for i in input_sample_size * k..input_sample_size * (k + 1)
{
sampled_input.push(input_slice[i]);
}
sampled_input.push(1.0);
for i in output_sample_size * k..output_sample_size * (k + 1)
{
sampled_output.push(output_slice[i]);
}
let result = utils::_predict_linear_model(model, &sampled_input, input_size, is_classification);
//Mise a jour des poids
// W[i] = W[i] + r * error * Input[i]
for l in 0..input_sample_size + 1
{
for z in 0..output_sample_size
{
boxed_model[l] = boxed_model[l] + learning_rate * (sampled_output[z] - result) * sampled_input[l];
}
}
} else {
let X: DMatrix<f64> = DMatrix::<f64>::from_column_slice(input_size / input_sample_size, input_sample_size, input_slice);
let Y: DMatrix<f64> = DMatrix::<f64>::from_column_slice(output_size / output_sample_size, output_sample_size, output_slice);
let mut W: DMatrix<f64> = ((X.transpose() * &X).try_inverse().unwrap().clone());
W = (W * X.transpose()) * &Y;
for i in 0..W.len()
{
boxed_model[i] = W.get(i).unwrap().clone();
}
}
}
}
//////////////////////////////////////////////////MLP MODEL///////////////////////////////////////////////////////////
#[no_mangle]
pub extern fn create_mlp_model(number_layer: usize, neurones_count: *mut i32) -> *mut Vec<f64> {
//Initialisation du model lineaire avec une taille défini + un biais
//Nombre de neurones par couche cachées
let mut npl;
unsafe {
npl = from_raw_parts(neurones_count, number_layer);
}
let mut weights = vec![0.0; 0];
//Ajout de toutes les neurones et des biais
//Initialisation des poids
for l in 0..(npl.len())
{
if l==0
{
// pour la couche d'entrée 100.0 étant pour nous l'équivalent de NONE
weights.push(100.0);
continue
}
for i in 0..(npl[l-1]+1)
{
for j in 0..(npl[l] + 1)
{
weights.push(rand::thread_rng().gen_range(-1.0, 1.0))
}
}
}
//Fuite mémoire volontaire afin de pouvoir renvoyer un pointeur
let boxed_weights = Box::new(weights);
let boxed_ref = Box::leak(boxed_weights);
boxed_ref
}
#[no_mangle]
pub extern fn predict_mlp_model(model: *mut Vec<f64>,
inputs: *mut f64, inputs_size: usize, number_layer: usize, neurones_count: *mut i32, is_classification: bool) -> *mut c_char
{
let boxed_model;
let inputs_slice;
let neurones_count_slice;
let L = number_layer - 1;
unsafe {
//Récupération des contenus des pointeurs
boxed_model = &mut *model;
inputs_slice = from_raw_parts(inputs, inputs_size);
neurones_count_slice = from_raw_parts(neurones_count, number_layer);
}
let mut vec_boxed_model = utils::weight_array_1dto3d(boxed_model, neurones_count_slice);
let mut neurones_values = vec![vec![0.0; 0]; number_layer];
neurones_values[0].push(1.0);
for i in 0..inputs_size
{
neurones_values[0].push(inputs_slice[i])
}
for i in 1..neurones_count_slice.len(){
neurones_values[i].push(1.0);
for j in 0..neurones_count_slice[i]
{
neurones_values[i].push(0.0)
}
}
for l in 1..(L + 1)
{
for j in 1..(neurones_count_slice[l] + 1)
{
let mut sum:f64 = 0.0;
for i in 0..(neurones_count_slice[l - 1] + 1)
{
sum += neurones_values[l - 1][i as usize] * vec_boxed_model[l][i as usize][j as usize];
}
if l == L && !is_classification {
neurones_values[l][j as usize] = sum;
}
else {
neurones_values[l][j as usize] = sum.tanh();
}
}
}
let mut result_string = "".to_string();
for i in 1..neurones_values[L].len()
{
let tmp = neurones_values[L][i].to_string()+";";
result_string.push_str(&tmp);
}
let pntr = CString::new(result_string).unwrap().into_raw();
pntr
}
#[no_mangle]
pub extern fn train_mlp_model_class(model: *mut Vec<f64>, number_layer: usize, dataset_size: usize, neurones_count: *mut i32, inputs: *mut f64, input_size: usize, input_sample_size: usize,
output: *mut f64, output_size: usize, output_sample_size: usize, epochs: i32, learning_rate: f64, is_classification: bool)
{
let mut boxed_model;
let input_slice;
let output_slice;
let neurones_count_slice;
let L = number_layer - 1;
unsafe {
boxed_model = &mut *model;
input_slice = from_raw_parts(inputs, input_size);
output_slice = from_raw_parts(output, output_size);
neurones_count_slice = from_raw_parts(neurones_count, number_layer);
}
let mut vec_boxed_model = utils::weight_array_1dto3d(boxed_model, neurones_count_slice);
let mut deltas:Vec<Vec<f64>> = Vec::new();
let mut neurones_values = vec![vec![0.0; 0]; number_layer];
neurones_values[0].push(1.0);
for i in 0..input_sample_size
{
neurones_values[0].push(0.0);
}
for i in 1..neurones_count_slice.len(){
neurones_values[i].push(1.0);
for j in 0..neurones_count_slice[i]
{
neurones_values[i].push(0.0)
}
}
for i in 0..number_layer
{
let mut tmp:Vec<f64> = Vec::new();
for j in 0..neurones_count_slice[i]+1
{
if j == 0{
tmp.push(1.0);
}
else {
tmp.push(0.0);
}
}
deltas.push(tmp);
}
for it in 0..epochs
{
let mut k = rand::thread_rng().gen_range(0, dataset_size);
let mut sampled_input:Vec<f64> = Vec::new();
let mut sampled_output:Vec<f64> = Vec::new();
for i in input_sample_size * k..input_sample_size * (k + 1)
{
sampled_input.push(input_slice[i]);
}
for j in 0..sampled_input.len()
{
neurones_values[0][j+1] = sampled_input[j];
}
for i in output_sample_size * k..output_sample_size * (k + 1)
{
sampled_output.push(output_slice[i]);
}
///////////////////////PREDICTIONS///////////////////////////////////////
for l in 1..(L + 1)
{
for j in 1..(neurones_count_slice[l] + 1)
{
let mut sum:f64 = 0.0;
for i in 0..(neurones_count_slice[l - 1] + 1)
{
sum += neurones_values[l - 1][i as usize] * vec_boxed_model[l][i as usize][j as usize];
}
if l == L && !is_classification {
neurones_values[l][j as usize] = sum;
}
else {
neurones_values[l][j as usize] = sum.tanh();
}
}
}
////////////////////////////////////////////////////////////////////////
for j in 1..neurones_count_slice[L] + 1
{
deltas[L][j as usize] = neurones_values[L][j as usize] - sampled_output[j as usize - 1];
if is_classification
{
deltas[L][j as usize] = deltas[L][j as usize] * (1.0 - utils::power(neurones_values[L][j as usize], 2));
}
}
for l in (2..L + 1).rev()
{
for i in 0..neurones_count_slice[l - 1]+1
{
let mut sum = 0.0;
for j in 1..neurones_count_slice[l] + 1
{
sum += vec_boxed_model[l][i as usize][j as usize] * deltas[l][j as usize]
}
deltas[l as usize - 1][i as usize] = (1.0 - utils::power(neurones_values[l as usize - 1][i as usize], 2)) * sum;
}
}
for l in 1..L + 1
{
for i in 0..neurones_count_slice[l - 1] + 1
{
for j in 1..neurones_count_slice[l] + 1
{
vec_boxed_model[l][i as usize][j as usize] -= learning_rate * neurones_values[l - 1][i as usize] * deltas[l][j as usize];
}
}
}
}
utils::weight_array_3dto1d(boxed_model, &vec_boxed_model, &neurones_count_slice);
}
////////////////////////////////////////////////////////RBF////////////////////////////////////////////////////////////////////////////
#[no_mangle]
pub extern fn init_RBF(inputs: *mut f64, input_size: usize, input_sample_size: usize,
output: *mut f64, output_size: usize, output_sample_size: usize, k: i32,) //->*mut RBF
{
let mut input_vec;
let mut trainning_output;
unsafe {
input_vec = from_raw_parts(inputs, input_size).to_vec();
trainning_output = from_raw_parts(output, output_size).to_vec();
}
let trainning_input = utils::_1dto2dVec(&input_vec, input_size/input_sample_size, input_sample_size);
let mut test_input: Vec<Vec<f64>> = Vec::new();
let mut test_output: Vec<f64> = Vec::new();
for i in (trainning_input.len()*0.8 as usize)..trainning_input.len()
{
test_input.push(trainning_input[i].clone());
}
for i in (trainning_output.len()*0.8 as usize)..trainning_output.len()
{
test_output.push(trainning_output[i]);
}
let mut RBF = RBF::init(trainning_input, trainning_output, test_input, test_output, output_sample_size as i32, k);
RBF.fit();
/*let boxed_RBF = Box::new(RBF);
let boxed_ref = Box::leak(boxed_RBF);
boxed_ref*/
}
#[no_mangle]
pub extern fn predict_RBF(RBF_model: *mut RBF, input_X: *mut f64, input_size: i32) -> i32
{
let mut tst;
let mut boxed_ref;
unsafe {
tst = Box::from_raw(RBF_model);
boxed_ref = Box::leak(tst);
}
let resulted_index = boxed_ref.predict(input_X, input_size as usize);
resulted_index
}
#[no_mangle]
pub extern fn delete_linear_model(model: *mut Vec<f64>)
{
unsafe {
let boxed_model = Box::from_raw(model);
};
}
|
use ring::digest::{digest, SHA256};
pub fn hash(input: &[u8]) -> Vec<u8> {
digest(&SHA256, input).as_ref().to_vec()
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_hashing() {
let input = b"lorem ipsum";
let output = hash(input.as_ref());
let output_bytes = output.as_ref();
let expected_bytes = [
0x5e, 0x2b, 0xf5, 0x7d, 0x3f, 0x40, 0xc4, 0xb6, 0xdf, 0x69, 0xda, 0xf1, 0x93, 0x6c,
0xb7, 0x66, 0xf8, 0x32, 0x37, 0x4b, 0x4f, 0xc0, 0x25, 0x9a, 0x7c, 0xbf, 0xf0, 0x6e,
0x2f, 0x70, 0xf2, 0x69,
];
assert_eq!(expected_bytes, output_bytes);
}
}
|
use serde::Deserialize;
use std::cell::RefCell;
use std::collections::HashMap;
use std::error::Error;
use std::fs::read_dir;
use std::path::Path;
use std::rc::Rc;
use crate::json;
#[derive(Clone, Debug, Deserialize)]
pub enum NodeType {
CollectionType,
DocumentType,
}
#[derive(Clone, Debug, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Metadata {
deleted: bool,
last_modified: String,
last_opened_page: Option<i32>,
metadatamodified: bool,
modified: bool,
parent: String,
pinned: bool,
r#type: NodeType,
synced: bool,
version: i32,
pub visible_name: String,
}
#[derive(Default)]
pub struct Node {
pub id: String,
pub metadata: Option<Metadata>,
pub children: RefCell<Vec<Rc<Node>>>,
}
impl Node {
pub const ROOT_ID: &'static str = "root";
pub fn name(&self) -> &str {
match &self.metadata {
Some(metadata) => &metadata.visible_name,
None => "",
}
}
pub fn is_notebook(&self) -> bool {
match &self.metadata {
Some(metadata) => match &metadata.r#type {
NodeType::DocumentType => true,
_ => false,
},
None => false,
}
}
pub fn get_descendant_by_name(&self, path: &Path) -> Option<Rc<Node>> {
let mut parts = path.components();
let name = parts.next()?;
let child = self.get_child_by_name(name.as_os_str().to_str()?)?;
let rest_of_path = parts.as_path();
if rest_of_path.eq(Path::new("")) {
Some(child)
} else {
child.get_descendant_by_name(rest_of_path)
}
}
pub fn walk<F: Fn(&Self, &Vec<Rc<Node>>)>(&self, f: &F) {
let mut ancestors = vec![];
self.walk_with_ancestors(&mut ancestors, f);
}
fn walk_with_ancestors<F: Fn(&Self, &Vec<Rc<Node>>)>(
&self,
ancestors: &mut Vec<Rc<Node>>,
f: &F,
) {
f(self, ancestors);
let children = self.children.borrow();
for child in children.iter() {
ancestors.push(child.clone());
child.walk_with_ancestors(ancestors, f);
ancestors.pop();
}
}
fn parent_id(&self) -> Option<&str> {
if let Some(metadata) = &self.metadata {
if !metadata.parent.is_empty() {
return Some(&metadata.parent);
}
}
None
}
fn get_child_by_name(&self, name: &str) -> Option<Rc<Node>> {
for child in self.children.borrow().iter() {
if child.name() == name {
return Some(child.clone());
}
}
None
}
}
pub fn parse_nodes(path: &str) -> Result<Node, Box<dyn Error>> {
let directory = read_dir(path)?;
let mut graph = GraphBuilder::new();
for entry in directory {
let entry = entry?;
let path = entry.path();
if let Some(extension) = path.extension() {
if extension == "metadata" {
if let Some(node_id) = path.file_stem() {
let metadata: Metadata = json::parse(&path)?;
if let Some(id) = node_id.to_str() {
graph.add(Rc::new(Node {
id: id.to_owned(),
metadata: Some(metadata),
children: RefCell::new(vec![]),
}));
}
}
}
}
}
let root_nodes = graph.get_root_nodes();
Ok(Node {
id: Node::ROOT_ID.to_owned(),
metadata: None,
children: RefCell::new(root_nodes),
})
}
pub struct GraphBuilder {
map: HashMap<String, Rc<Node>>,
}
impl GraphBuilder {
fn new() -> Self {
Self {
map: HashMap::new(),
}
}
fn add(&mut self, node: Rc<Node>) {
if let Some(placeholder) = self.map.remove(&node.id) {
// There was a node holding children. Transfer the children.
let mut target = node.children.borrow_mut();
target.clear();
for node in placeholder.children.borrow().iter() {
target.push(node.clone());
}
}
self.map.insert(node.id.clone(), node.clone());
// Insert as child of parent
if let Some(parent_id) = node.parent_id() {
let parent = self
.map
.entry(parent_id.to_owned())
.or_insert(Rc::new(Node {
id: parent_id.to_owned(),
metadata: None,
children: RefCell::new(vec![]),
}));
parent.children.borrow_mut().push(node.clone());
}
}
fn get_root_nodes(&self) -> Vec<Rc<Node>> {
self.map
.values()
.filter(|node| node.parent_id().is_none())
.map(|node| node.clone())
.collect()
}
}
|
use std::fs;
use std::path::Path;
use toml;
use std::io::{Read, Write};
use errors::*;
// Serialization made with serde
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct Config {
#[serde(skip_serializing_if="Option::is_none")]
pub http: Option<HttpConfig>,
pub locations: Vec<LocationConfig>,
#[serde(skip_serializing_if="Option::is_none")]
pub default: Option<AuthConfig>,
pub hosts: Vec<HostConfig>,
pub slack: Option<SlackConfig>,
// Seconds between two refresh rates
#[serde(skip_serializing_if="Option::is_none")]
pub refresh_delay: Option<u64>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct SlackConfig {
pub channel: String,
pub hook: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct LocationConfig {
pub name: String,
pub ips: String,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct HttpConfig {
pub port: u16,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct HostConfig {
pub name: String,
pub address: String,
pub iface: String,
#[serde(skip_serializing_if="Option::is_none")]
pub ignored_disks: Option<Vec<String>>,
#[serde(skip_serializing_if="Option::is_none")]
pub auth: Option<AuthConfig>,
#[serde(skip_serializing_if="Option::is_none")]
pub location: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Default, Clone)]
pub struct AuthConfig {
pub login: String,
#[serde(skip_serializing_if="Option::is_none")]
pub keypair: Option<String>,
#[serde(skip_serializing_if="Option::is_none")]
pub password: Option<String>,
}
pub fn read_config<P: AsRef<Path>>(filename: P) -> Result<Config> {
let mut file = fs::File::open(filename).chain_err(|| "could not open config file")?;
let mut buffer = String::new();
file.read_to_string(&mut buffer).chain_err(|| "could not read config")?;
toml::de::from_str(&buffer).chain_err(|| "could not parse config")
}
pub fn write_config<P: AsRef<Path>>(filename: P,
config: &Config)
-> Result<()> {
let buffer = toml::ser::to_vec(config).chain_err(|| "could not serialize config")?;
let mut file = fs::File::create(filename).chain_err(|| "could not create config file")?;
file.write_all(&buffer).chain_err(|| "could not write config")?;
Ok(())
}
|
#![no_std]
#![feature(asm)]
#![feature(global_asm)]
#[macro_use]
mod io; // IO库; 宏`println`和`print`
mod context; // 上下文; 中断帧
mod init; // 系统初始化; 系统入口
mod interrupt; // 中断库; 中断初始化程序, 中断处理程序
mod lang_items; // RUST所需的语义项
mod sbi; // 封装SBI
mod timer; // 时钟中断
|
use std::env;
use std::fs;
use std::path::Path;
use std::collections::HashMap;
fn read_instructions(filename:&str) -> String{
let fpath = Path::new(filename);
let abspath = env::current_dir()
.unwrap()
.into_boxed_path()
.join(fpath);
let replaced = fs::read_to_string(abspath)
.expect("Error reading instructions!");
let instructions = replaced.replace(",", "");
return instructions;
}
fn parse_instructions(instructions_list:&str, is_overriden:bool){
let mut registers:HashMap<&str,u32> = HashMap::new();
let mut instructions:Vec<Vec<&str>> = Vec::new();
for instruction in instructions_list.lines(){
let ops = instruction
.split_whitespace()
.collect::<Vec<&str>>();
instructions.push(ops);
}
if is_overriden{
registers.insert("a", 1);
}
let mut i = 0;
loop {
if i >= instructions.len(){
break;
}
match instructions[i][0]{
"hlf" => {
if !registers.contains_key(&instructions[i][1]){
registers.insert(instructions[i][1], 0);
}
let r = *registers.get(&instructions[i][1]).unwrap();
*registers.get_mut(&instructions[i][1]).unwrap() = r/2;
i+=1;
},
"tpl" => {
if !registers.contains_key(&instructions[i][1]){
registers.insert(instructions[i][1], 0);
}
*registers.get_mut(&instructions[i][1]).unwrap() *= 3;
i+=1;
},
"inc" => {
if !registers.contains_key(&instructions[i][1]){
registers.insert(instructions[i][1], 0);
}
*registers.get_mut(&instructions[i][1]).unwrap() += 1;
i+=1;
},
"jmp" => {
let inc:i32 =instructions[i][1].parse().unwrap();
if inc < 0{
i -= (inc * -1) as usize;
continue;
}
i += inc as usize;
},
"jie" => {
if !registers.contains_key(&instructions[i][1]){
registers.insert(instructions[i][1], 0);
}
let r = *registers.get(&instructions[i][1]).unwrap();
if r % 2 == 0{
let inc:i32 =instructions[i][2].parse().unwrap();
if inc < 0{
i -= (inc * -1) as usize;
continue;
}
i += inc as usize;
continue;
}
i+=1;
},
"jio" => {
if !registers.contains_key(&instructions[i][1]){
registers.insert(instructions[i][1], 0);
}
let r = *registers.get(&instructions[i][1]).unwrap();
if r == 1{
let inc:i32 =instructions[i][2].parse().unwrap();
if inc < 0{
i -= (inc * -1) as usize;
continue;
}
i += inc as usize;
continue;
}
i+=1;
},
_=> {
break;
}
}
}
println!("{:?}", registers);
}
pub fn run(){
let instructions = read_instructions("inputs/day-23.txt");
parse_instructions(&instructions, false);
parse_instructions(&instructions, true);
} |
use serde::{Deserialize, Serialize};
/// Message from the server to the client.
#[derive(Serialize, Deserialize)]
pub struct ServerMessage {
pub id: usize,
pub text: String,
}
/// Message from the client to the server.
#[derive(Serialize, Deserialize)]
pub struct ClientMessage {
pub text: String,
}
/// Message from the client to the server.
#[derive(Serialize, Deserialize)]
pub struct ClientMessageGQLInit {
pub r#type: String,
pub payload: PayloadEmp,
}
#[derive(Serialize, Deserialize)]
pub struct PayloadEmp {}
/// Message from the client to the server.
#[derive(Serialize, Deserialize)]
pub struct ClientMessageGQLPay {
pub id: String,
pub r#type: String,
pub payload: Payload,
}
#[derive(Serialize, Deserialize)]
pub struct Payload {
pub query: String,
}
pub struct Clock {
hours: i64,
minutes: i64,
seconds: i64,
}
impl Clock {
///
/// Create a new clock.
///
pub fn new() -> Clock {
Clock {
hours: 0,
minutes: 0,
seconds: 0,
}
}
///
/// Set the clock time in milliseconds.
///
/// * `ms` - Milliseconds to set time from.
pub fn set_time_ms(&mut self, ms: i64) {
self.seconds = (ms / 1000) % 60;
self.minutes = (ms / (1000 * 60)) % 60;
self.hours = (ms / (1000 * 60 * 60)) % 24;
}
///
/// Set the clock time in seconds.
///
/// * `seconds` - Seconds to set time from.
pub fn set_time_secs(&mut self, seconds: i64) {
self.set_time_ms(seconds * 1000);
}
///
/// Get the clock time in hh:mm:ss notation.
///
pub fn get_time(&self) -> String {
format!("{:02}:{:02}:{:02}", self.hours, self.minutes, self.seconds)
}
}
|
use openssl::rsa::{Rsa};
use openssl::pkey::PKey;
use openssl::sign::{Signer};
use openssl::hash::MessageDigest;
use std::fs;
use crate::data;
pub fn generate_keys(){
let rsa = Rsa::generate(1024).unwrap();
let private_key: Vec<u8> = rsa.private_key_to_pem().unwrap();
let public_key: Vec<u8> = rsa.public_key_to_pem().unwrap();
let private_key_string = String::from_utf8(private_key).unwrap();
let public_key_string = String::from_utf8(public_key).unwrap();
println!("{}", private_key_string);
println!("{}", public_key_string);
// Write to file
fs::write("./priv.pem", private_key_string).expect("Unable to write public key file");
fs::write("./pub.pem", public_key_string).expect("Unable to write private key file");
}
pub fn sign(transaction: &mut data::Transaction) {
// To String
let priv_data = fs::read_to_string("./priv.pem").expect("Unable to read private key file");
// To rsa
let priv_rsa = Rsa::private_key_from_pem(&priv_data.as_bytes()).expect("Error pem to private key");
let keypair = PKey::from_rsa(priv_rsa).unwrap();
// Sign the data
let data = format!("{}", transaction);
let mut signer = Signer::new(MessageDigest::sha256(), &keypair).unwrap();
signer.update(data.as_bytes()).unwrap();
let signature = signer.sign_to_vec().unwrap();
//println!("{}", String::from_utf8_lossy(&signature));
transaction.signature = signature;
}
pub fn get_public_key() -> String {
// To String
let pub_data = fs::read_to_string("./pub.pem").expect("Unable to read public key file");
return pub_data;
}
pub fn get_private_key() -> String {
// To String
let priv_data = fs::read_to_string("./priv.pem").expect("Unable to read private key file");
return priv_data;
} |
/*
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT license.
*/
use half::{bf16, f16};
use std::env;
use std::fs::{File, OpenOptions};
use std::io::{self, Read, Write, BufReader, BufWriter};
enum F16OrBF16 {
F16(f16),
BF16(bf16),
}
fn main() -> io::Result<()> {
// Retrieve command-line arguments
let args: Vec<String> = env::args().collect();
match args.len() {
3|4|5|6=> {},
_ => {
print_usage();
std::process::exit(1);
}
}
// Retrieve the input and output file paths from the arguments
let input_file_path = &args[1];
let output_file_path = &args[2];
let use_f16 = args.len() >= 4 && args[3] == "f16";
let save_as_float = args.len() >= 5 && args[4] == "save_as_float";
let batch_size = if args.len() >= 6 { args[5].parse::<i32>().unwrap() } else { 100000 };
println!("use_f16: {}", use_f16);
println!("save_as_float: {}", save_as_float);
println!("batch_size: {}", batch_size);
// Open the input file for reading
let mut input_file = BufReader::new(File::open(input_file_path)?);
// Open the output file for writing
let mut output_file = BufWriter::new(OpenOptions::new().write(true).create(true).open(output_file_path)?);
// Read the first 8 bytes as metadata
let mut metadata = [0; 8];
input_file.read_exact(&mut metadata)?;
// Write the metadata to the output file
output_file.write_all(&metadata)?;
// Extract the number of points and dimension from the metadata
let num_points = i32::from_le_bytes(metadata[..4].try_into().unwrap());
let dimension = i32::from_le_bytes(metadata[4..].try_into().unwrap());
let num_batches = num_points / batch_size;
// Calculate the size of one data point in bytes
let data_point_size = (dimension * 4 * batch_size) as usize;
let mut batches_processed = 0;
let numbers_to_print = 2;
let mut numbers_printed = 0;
let mut num_fb16_wins = 0;
let mut num_f16_wins = 0;
let mut bf16_overflow = 0;
let mut f16_overflow = 0;
// Process each data point
for _ in 0..num_batches {
// Read one data point from the input file
let mut buffer = vec![0; data_point_size];
match input_file.read_exact(&mut buffer){
Ok(()) => {
// Convert the float32 data to bf16
let half_data: Vec<F16OrBF16> = buffer
.chunks_exact(4)
.map(|chunk| {
let value = f32::from_le_bytes([chunk[0], chunk[1], chunk[2], chunk[3]]);
let converted_bf16 = bf16::from_f32(value);
let converted_f16 = f16::from_f32(value);
let distance_f16 = (converted_f16.to_f32() - value).abs();
let distance_bf16 = (converted_bf16.to_f32() - value).abs();
if distance_f16 < distance_bf16 {
num_f16_wins += 1;
} else {
num_fb16_wins += 1;
}
if (converted_bf16 == bf16::INFINITY) || (converted_bf16 == bf16::NEG_INFINITY) {
bf16_overflow += 1;
}
if (converted_f16 == f16::INFINITY) || (converted_f16 == f16::NEG_INFINITY) {
f16_overflow += 1;
}
if numbers_printed < numbers_to_print {
numbers_printed += 1;
println!("f32 value: {} f16 value: {} | distance {}, bf16 value: {} | distance {},",
value, converted_f16, converted_f16.to_f32() - value, converted_bf16, converted_bf16.to_f32() - value);
}
if use_f16 {
F16OrBF16::F16(converted_f16)
} else {
F16OrBF16::BF16(converted_bf16)
}
})
.collect();
batches_processed += 1;
match save_as_float {
true => {
for float_val in half_data {
match float_val {
F16OrBF16::F16(f16_val) => output_file.write_all(&f16_val.to_f32().to_le_bytes())?,
F16OrBF16::BF16(bf16_val) => output_file.write_all(&bf16_val.to_f32().to_le_bytes())?,
}
}
}
false => {
for float_val in half_data {
match float_val {
F16OrBF16::F16(f16_val) => output_file.write_all(&f16_val.to_le_bytes())?,
F16OrBF16::BF16(bf16_val) => output_file.write_all(&bf16_val.to_le_bytes())?,
}
}
}
}
// Print the number of points processed
println!("Processed {} points out of {}", batches_processed * batch_size, num_points);
}
Err(ref e) if e.kind() == io::ErrorKind::UnexpectedEof => {
println!("Conversion completed! {} of times f16 wins | overflow count {}, {} of times bf16 wins | overflow count{}",
num_f16_wins, f16_overflow, num_fb16_wins, bf16_overflow);
break;
}
Err(err) => {
println!("Error: {}", err);
break;
}
};
}
Ok(())
}
/// Prints the usage information
fn print_usage() {
println!("Usage: program_name input_file output_file [f16] [save_as_float] [batch_size]]");
println!("specify f16 to downscale to f16. otherwise, downscale to bf16.");
println!("specify save_as_float to downcast to f16 or bf16, and upcast to float before saving the output data. otherwise, the data will be saved as half type.");
println!("specify the batch_size as a int, the default value is 100000.");
}
|
mod handlers;
use stremio_addon_sdk::server::ServerOptions;
use stremio_addon_sdk::server::serve_serverless;
use stremio_addon_sdk::export::serverless::now::*;
use handlers::build;
mod manifest;
use manifest::get_manifest;
fn handler(req: Request) -> Result<impl IntoResponse, NowError> {
let manifest = get_manifest();
let build = build(manifest);
let options = ServerOptions::default();
serve_serverless(req, build, options)
}
|
// src/environment.rs
use super::object::*;
use std::cell::*;
use std::collections::*;
use std::rc::*;
pub fn new_enclosed_environment(outer: Option<Rc<RefCell<Environment>>>) -> Environment {
let mut env = new_environment();
env.outer = outer;
env
}
pub fn new_environment() -> Environment {
Environment {
store: HashMap::new(),
outer: None,
}
}
#[derive(Debug)]
pub struct Environment {
pub store: HashMap<String, Object>,
pub outer: Option<Rc<RefCell<Environment>>>,
}
impl Environment {
pub fn get(&self, name: &str) -> Option<Object> {
if let Some(v) = self.store.get(name) {
return Some(v.clone());
} else if let Some(o) = &self.outer {
return o.borrow().get(name);
}
None
}
pub fn set(&mut self, name: String, val: Object) -> Object {
self.store.insert(name, val.clone());
val
}
}
|
use std::hash::{Hash, Hasher};
macro_rules! finite {
(@op => $opname:ty, $opnamety:ty, $func:tt, $name:tt, $ty:ty) => {
impl $opname for $name {
type Output = Option<$ty>;
fn $func(self, other: Self) -> Option<$ty> {
let result = (self.0).$func(other.0);
if result.is_finite() {
Some(result)
} else {
None
}
}
}
impl $opnamety for $name {
type Output = $ty;
fn $func(self, other: $ty) -> $ty {
(self.0).$func(other)
}
}
};
($name:tt, $ty:ty) => (
finite!(@finish => $name, $ty, stringify!($ty));
);
(@finish => $name:tt, $ty:ty, $tyname:expr) => {
#[doc = "A finite `"]
#[doc = $tyname]
#[doc = "`. May not be infinite nor NaN."]
#[derive(Debug, Clone, Copy)]
pub struct $name($ty);
impl $name {
#[doc = "Create a new finite `"]
#[doc = $tyname]
#[doc = "`. Will return `None` if given value is infinite or NaN."]
pub fn new(n: $ty) -> Option<Self> {
if n.is_finite() {
Some(Self(n))
} else {
None
}
}
pub fn inner(self) -> $ty {
self.0
}
#[inline(always)]
pub fn checked_add(self, other: $ty) -> Option<Self> {
Self::new(std::ops::Add::add(self, other))
}
#[inline(always)]
pub fn checked_sub(self, other: $ty) -> Option<Self> {
Self::new(std::ops::Sub::sub(self, other))
}
#[inline(always)]
pub fn checked_mul(self, other: $ty) -> Option<Self> {
Self::new(std::ops::Mul::mul(self, other))
}
#[inline(always)]
pub fn checked_div(self, other: $ty) -> Option<Self> {
Self::new(std::ops::Div::div(self, other))
}
}
impl PartialEq for $name {
fn eq(&self, other: &Self) -> bool {
self.0 == other.0
}
}
impl PartialEq<$ty> for $name {
fn eq(&self, other: &$ty) -> bool {
&self.0 == other
}
}
impl Eq for $name {}
impl PartialOrd for $name {
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(&other.0)
}
}
impl PartialOrd<$ty> for $name {
fn partial_cmp(&self, other: &$ty) -> Option<std::cmp::Ordering> {
self.0.partial_cmp(other)
}
}
impl Ord for $name {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.0.partial_cmp(&other.0).expect("must be finite")
}
}
finite!(@op => std::ops::Add, std::ops::Add<$ty>, add, $name, $ty);
finite!(@op => std::ops::Sub, std::ops::Sub<$ty>, sub, $name, $ty);
finite!(@op => std::ops::Div, std::ops::Div<$ty>, div, $name, $ty);
finite!(@op => std::ops::Mul, std::ops::Mul<$ty>, mul, $name, $ty);
impl std::convert::TryFrom<$ty> for $name {
type Error = $crate::TryFromFloatError;
fn try_from(value: $ty) -> Result<Self, Self::Error> {
match Self::new(value) {
Some(v) => Ok(v),
None => Err($crate::TryFromFloatError(value.classify()))
}
}
}
}
}
pub struct TryFromFloatError(std::num::FpCategory);
finite!(FiniteF32, f32);
finite!(FiniteF64, f64);
impl Hash for FiniteF32 {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_u32(unsafe { std::mem::transmute::<f32, u32>(self.0) });
}
}
impl Hash for FiniteF64 {
fn hash<H: Hasher>(&self, state: &mut H) {
state.write_u64(unsafe { std::mem::transmute::<f64, u64>(self.0) });
}
}
#[cfg(test)]
mod tests {
use super::*;
use std::{f32, f64};
#[test]
fn smoke() {
assert!(FiniteF32::new(1f32).is_some());
assert!(FiniteF64::new(42f64).is_some());
assert!(FiniteF32::new(f32::NAN).is_none());
assert!(FiniteF64::new(f64::NAN).is_none());
assert!(FiniteF32::new(f32::INFINITY).is_none());
assert!(FiniteF64::new(f64::INFINITY).is_none());
assert!(FiniteF32::new(f32::NEG_INFINITY).is_none());
assert!(FiniteF64::new(f64::NEG_INFINITY).is_none());
}
#[test]
fn cmp32() {
let finite = FiniteF32::new(1f32).unwrap();
assert_eq!(finite < 32f32, true);
assert_eq!(finite == 1f32, true);
assert_eq!(finite > -1f32, true);
assert_eq!(finite > f32::NAN, false);
assert_eq!(finite > f32::NEG_INFINITY, true);
assert_eq!(finite < f32::INFINITY, true);
}
#[test]
fn cmp64() {
let finite = FiniteF64::new(1f64).unwrap();
assert_eq!(finite < 64f64, true);
assert_eq!(finite == 1f64, true);
assert_eq!(finite > -1f64, true);
assert_eq!(finite > f64::NAN, false);
assert_eq!(finite > f64::NEG_INFINITY, true);
assert_eq!(finite < f64::INFINITY, true);
}
#[test]
fn add32() {
let finite = FiniteF32::new(1f32).unwrap();
assert_eq!(finite + 32f32, 33f32);
assert_eq!(finite - 32f32, -31f32);
assert_eq!(finite + f32::INFINITY, f32::INFINITY);
assert_eq!(finite - f32::INFINITY, f32::NEG_INFINITY);
}
#[test]
fn add64() {
let finite = FiniteF64::new(1f64).unwrap();
assert_eq!(finite + 32f64, 33f64);
assert_eq!(finite - 32f64, -31f64);
assert_eq!(finite + f64::INFINITY, f64::INFINITY);
assert!(finite.checked_add(f64::INFINITY).is_none());
assert_eq!(finite - f64::INFINITY, f64::NEG_INFINITY);
assert!(finite.checked_sub(f64::INFINITY).is_none());
}
#[test]
fn hash() {
let mut map = std::collections::HashMap::new();
let f = FiniteF32::new(32f32).unwrap();
map.insert(f, "oh yes");
assert_eq!(map[&f], "oh yes");
}
}
|
extern crate inputparser;
use crate::inputparser::{input,ErHandle::*};
fn reciprocal_char(c: char) -> char {
match c {
'a'..='z' => (25 - (c as u8 - 'a' as u8) + 'a' as u8) as char,
'A'..='Z' => (25 - (c as u8 - 'A' as u8) + 'A' as u8) as char,
'0'..='9' => (9 - (c as u8 - '0' as u8) + '0' as u8) as char,
_ => c,
}
}
fn main() {
println!("Enter the string: ");
let i: String = input(Def);
let reciprocated: String = i.chars().map(reciprocal_char).collect();
println!("Here's your string: {}", reciprocated);
}
|
pub mod shader;
pub mod vao;
pub mod framebuffer;
pub mod texture;
|
//! Tokio global executor runtime.
use crate::core::Runtime;
use std::future::Future;
/// Spawns tasks on global tokio executor.
#[derive(Debug, Clone, Copy)]
pub struct TokioGlobal;
impl Runtime for TokioGlobal {
fn spawn<F>(&self, future: F)
where
F: Future<Output = ()> + Send + 'static,
{
tokio::spawn(future);
}
}
impl Default for TokioGlobal {
#[must_use]
fn default() -> Self {
Self
}
}
|
use std::fmt;
use std::time::{Duration, Instant};
use futures::{Async, Future, Stream};
use tokio_core::reactor::Handle;
use tower_h2::{HttpService, BoxBody};
use tower_grpc as grpc;
use conduit_proxy_controller_grpc::telemetry::{ReportRequest, ReportResponse};
use conduit_proxy_controller_grpc::telemetry::client::Telemetry as TelemetrySvc;
use ::timeout::{Timeout, TimeoutFuture};
type TelemetryStream<F, B> = grpc::client::unary::ResponseFuture<
ReportResponse, TimeoutFuture<F>, B>;
#[derive(Debug)]
pub struct Telemetry<T, S: HttpService> {
reports: T,
in_flight: Option<(Instant, TelemetryStream<S::Future, S::ResponseBody>)>,
report_timeout: Duration,
handle: Handle,
}
impl<T, S> Telemetry<T, S>
where
S: HttpService<RequestBody = BoxBody, ResponseBody = ::tower_h2::RecvBody>,
S::Error: fmt::Debug,
T: Stream<Item = ReportRequest>,
T::Error: ::std::fmt::Debug,
{
pub fn new(reports: T, report_timeout: Duration, handle: &Handle) -> Self {
Telemetry {
reports,
in_flight: None,
report_timeout,
handle: handle.clone(),
}
}
pub fn poll_rpc(&mut self, client: &mut S)
{
let client = Timeout::new(client.lift_ref(), self.report_timeout, &self.handle);
let mut svc = TelemetrySvc::new(client);
//let _ctxt = ::logging::context("Telemetry.Report".into());
loop {
if let Some((t0, mut fut)) = self.in_flight.take() {
match fut.poll() {
Ok(Async::NotReady) => {
// TODO: can we just move this logging logic to `Timeout`?
trace!("report in flight to controller for {:?}", t0.elapsed());
self.in_flight = Some((t0, fut))
}
Ok(Async::Ready(_)) => {
trace!("report sent to controller in {:?}", t0.elapsed())
}
Err(err) => warn!("controller error: {:?}", err),
}
}
let controller_ready = self.in_flight.is_none() && match svc.poll_ready() {
Ok(Async::Ready(_)) => true,
Ok(Async::NotReady) => {
trace!("controller unavailable");
false
}
Err(err) => {
warn!("controller error: {:?}", err);
false
}
};
match self.reports.poll() {
Ok(Async::NotReady) => {
return;
}
Ok(Async::Ready(None)) => {
debug!("report stream complete");
return;
}
Err(err) => {
warn!("report stream error: {:?}", err);
}
Ok(Async::Ready(Some(report))) => {
// Attempt to send the report. Continue looping so that `reports` is
// polled until it's not ready.
if !controller_ready {
info!(
"report dropped; requests={} accepts={} connects={}",
report.requests.len(),
report.server_transports.len(),
report.client_transports.len(),
);
} else {
trace!(
"report sent; requests={} accepts={} connects={}",
report.requests.len(),
report.server_transports.len(),
report.client_transports.len(),
);
let rep = svc.report(grpc::Request::new(report));
self.in_flight = Some((Instant::now(), rep));
}
}
}
}
}
}
|
use std::io;
//if the number is power of 2, then it will halt, otherwise never.
fn main(){
//println!("{}",std::u64::MIN);
let mut num_str : String = String::new();
io::stdin().read_line(&mut num_str).unwrap();
//let mut num : u64
let mut num : u64 = num_str.trim().parse().unwrap();
if(num < 2){
println!("NIE");
println!("TAK");
}
else {
num = num - 1;
while(num > 0){
if((num & 1) == 0){
println!("NIE");
return;
}
num = num >> 1;
}
println!("TAK");
}
} |
// Copyright (c) 2018, ilammy
//
// Licensed under the Apache License, Version 2.0 (see LICENSE in the
// root directory). This file may be copied, distributed, and modified
// only in accordance with the terms specified by the license.
use exonum::storage::{Fork, MapIndex, Snapshot};
use service::SERVICE_ID;
/// Numeric identifier of the act.
pub type ActId = u32;
/// Numeric identifier of the act clause.
pub type ClauseId = u32;
encoding_struct! {
/// A single lawful act.
struct Act {
/// Numeric identifier of the act (unique throughout the body of law).
id: ActId,
/// Human-readable name of the act.
name: &str,
/// Whether this act has been repealed.
repealed: bool,
/// Contents of the act.
clauses: Vec<Clause>,
/// Revision of the act (incremented with each modification).
revision: u32,
}
}
impl Act {
/// Update clauses of this act.
///
/// Returns unmodified act if the new clauses are not consistent with previous state.
pub fn update_clauses(self, clauses: Vec<Clause>) -> Result<Self, Self> {
// TODO: check clauses for consistency
Ok(Self::new(
self.id(),
self.name(),
false,
clauses,
self.revision() + 1,
))
}
/// Mark act as repealed as of given moment.
///
/// Returns repealed act if everything is fine, or an Err with
/// unmodified act if the has already been repealed.
pub fn repeal(self) -> Result<Self, Self> {
if self.repealed() {
return Err(self);
}
return Ok(Self::new(
self.id(),
self.name(),
true,
self.clauses(),
self.revision() + 1,
));
}
}
encoding_struct! {
/// A single clause of a lawful act.
struct Clause {
/// Numeric identifier of the act clause (unique throughout the act).
id: ClauseId,
/// Human-readable content of the clause.
body: &str,
}
}
pub struct BodyOfLaw<T> {
view: T,
}
impl<T: AsRef<Snapshot>> BodyOfLaw<T> {
/// Make a new read-only view of the body of law.
pub fn new(view: T) -> Self {
BodyOfLaw { view }
}
/// Get all acts in the body.
pub fn acts(&self) -> MapIndex<&Snapshot, ActId, Act> {
MapIndex::new("body_of_law.acts", self.view.as_ref())
}
/// Get a particular act by its ID.
pub fn act(&self, id: &ActId) -> Option<Act> {
self.acts().get(id)
}
}
impl<'a> BodyOfLaw<&'a mut Fork> {
pub fn acts_mut(&mut self) -> MapIndex<&mut Fork, ActId, Act> {
MapIndex::new("body_of_law.acts", &mut self.view)
}
}
|
pub mod funcs;
pub mod wallpaper;
pub mod image_generator;
use std::error::Error;
pub type Result<T> = std::result::Result<T, Box<dyn Error>>; |
#[path="../support/mod.rs"]
mod support;
use citrus_ecs::{element::*, entity::*, scene_editor::*, scene_serde::*};
use serde::*;
use imgui_glium_renderer::imgui as imgui;
#[derive(Clone, Serialize, Deserialize)]
struct A {
val: i32
}
impl Element for A {
fn update(&mut self, _man: &mut Manager, _owner: EntAddr) {
println!("A: val = {}", self.val);
self.val += 10;
}
fn fill_ui(&mut self, ui: &imgui::Ui, _man: &mut Manager) {
ui.text("Ayyyy!");
}
}
#[derive(Clone, Serialize, Deserialize)]
struct B {
val: i32,
other: EntAddr,
ele: EleAddr<A>
}
impl Element for B {
fn update(&mut self, _man: &mut Manager, _owner: EntAddr) {
println!("B: val = {}", self.val);
self.val += 10;
}
fn fill_ui(&mut self, ui: &imgui::Ui, man: &mut Manager) {
citrus_ecs::editor_helpers::select_entity(&mut self.other, "other", ui, man);
citrus_ecs::editor_helpers::select_element(&mut self.ele, "ele", ui, man);
}
}
fn main() {
let mut ma = Manager::new();
let mut se = SceneSerde::new();
let mut ed = SceneEditor::new();
let a = ma.create_entity("Baba booie".to_string());
let b = ma.create_entity("Child".to_string());
ma.reparent(a, b).unwrap();
se.register_element_creator(A { val: 0 }, "PosRot");
se.register_element_creator(B { val: 2, other: EntAddr::new(), ele: EleAddr::new() }, "Element B");
let system = support::init(file!());
system.main_loop(move |_, ui| {
ed.render(ui, &mut se, &mut ma);
ma.resolve();
});
} |
use super::BaseHandler;
use pyo3::prelude::*;
use std::sync::{Arc, Mutex};
use streamson_lib::handler;
#[pyclass(extends=BaseHandler)]
#[derive(Clone)]
pub struct BufferHandler {
pub buffer_inner: Arc<Mutex<handler::Buffer>>,
}
#[pymethods]
impl BufferHandler {
/// Create instance of Buffer handler
#[new]
#[args(use_path = "true", max_size = "None")]
pub fn new(use_path: bool, max_size: Option<usize>) -> (Self, BaseHandler) {
let buffer_inner = Arc::new(Mutex::new(
handler::Buffer::new()
.set_use_path(use_path)
.set_max_buffer_size(max_size),
));
(
Self {
buffer_inner: buffer_inner.clone(),
},
BaseHandler {
inner: Arc::new(Mutex::new(handler::Group::new().add_handler(buffer_inner))),
},
)
}
/// Remove first element from the buffer
pub fn pop_front(&mut self) -> Option<(Option<String>, Vec<u8>)> {
self.buffer_inner.lock().unwrap().pop()
}
}
|
use bevy::prelude::*;
use bevy_rapier2d::physics::{ColliderHandleComponent, RigidBodyHandleComponent};
use bevy_rapier2d::rapier::dynamics::RigidBodySet;
use bevy_rapier2d::rapier::geometry::ColliderSet;
use bevy_rapier2d::rapier::math::Isometry;
use crate::physics::*;
use crate::*;
/// stores units that are within attack (melee or missle) range of the
/// associated unit, used to determining unit behaviour.
#[derive(Debug, Default)]
pub struct NearbyUnitsComponent {
melee_range: Vec<Entity>,
missle_range: Vec<Entity>,
}
/// helper function
/// this processes interactions one unit at a time within its own scope
/// so we don't double-borrow the Unit Component
fn process_unit_proximity(
unit_id: Entity,
target_id: Entity,
nearbys: &mut Query<&mut NearbyUnitsComponent>,
e_or_e: EnterOrExit,
range_type: AttackType,
) {
let mut nbs = nearbys
.get_component_mut::<NearbyUnitsComponent>(unit_id)
.unwrap();
let vec = if range_type == AttackType::Melee {
&mut nbs.melee_range
} else {
&mut nbs.missle_range
};
if e_or_e == EnterOrExit::Enter {
vec.push(target_id);
} else {
vec.retain(|e| e != &target_id);
}
}
/// helper function
fn process_unit_command(
unit_id: Entity,
cmd: UnitUiCommand,
units: &mut Query<&mut UnitComponent>,
) {
use UnitUiCommand::*;
let mut unit = units.get_component_mut::<UnitComponent>(unit_id).unwrap();
match cmd {
Attack(target, speed) => {
unit.is_running = speed == UnitUiSpeedCommand::Run;
unit.current_command = if let AttackType::Melee = unit.primary_attack_type() {
UnitUserCommand::AttackMelee(target)
} else {
UnitUserCommand::AttackMissile(target)
}
}
Move(pos, speed) => {
unit.current_command = UnitUserCommand::Move(pos);
unit.is_running = speed == UnitUiSpeedCommand::Run;
}
Stop => {
unit.current_command = UnitUserCommand::None_;
}
ToggleGuardMode => unit.guard_mode_enabled = !unit.guard_mode_enabled,
ToggleFireAtWill => unit.fire_at_will = !unit.fire_at_will,
ToggleSpeed => unit.is_running = !unit.is_running,
}
log::debug!("unit current command: {:?}", unit.current_command);
}
/// handles events that changes the commands and state for each unit.
/// processes the following inputs:
/// - unit proximity interactions
/// - TODO user commands
pub fn unit_event_system(
mut commands: Commands,
game_speed: Res<GameSpeed>,
mut state: Local<UnitInteractionState>,
events: Res<Events<UnitInteractionEvent>>,
mut units: Query<&mut UnitComponent>,
mut nearbys: Query<&mut NearbyUnitsComponent>,
) {
// TODO maybe this should be running?
if game_speed.is_paused() {
return;
}
let mut dead_units = vec![];
// process state updates for units that have new events
for event in state.event_reader.iter(&events) {
log::debug!("event: {:?}", &event);
match event.clone() {
UnitInteractionEvent::Proximity(contact) => {
match contact {
ContactType::UnitFiringRangeEnter { range_of, target } => {
process_unit_proximity(
range_of,
target,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Ranged,
);
}
ContactType::UnitFiringRangeExit { range_of, target } => {
process_unit_proximity(
range_of,
target,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Ranged,
);
}
ContactType::UnitUnitMeleeExit(e1, e2) => {
// separate scopes so we don't double-borrow the Unit component
process_unit_proximity(
e1,
e2,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Melee,
);
process_unit_proximity(
e2,
e1,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Melee,
);
}
ContactType::UnitUnitMeleeEnter(e1, e2) => {
process_unit_proximity(
e1,
e2,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Melee,
);
process_unit_proximity(
e2,
e1,
&mut nearbys,
contact.enter_or_exit(),
AttackType::Melee,
);
}
}
}
UnitInteractionEvent::Ui(entity, cmd) => {
process_unit_command(entity, cmd, &mut units);
}
UnitInteractionEvent::UnitWaypointReached(e1) => {
let mut unit = units.get_component_mut::<UnitComponent>(e1).unwrap();
unit.current_command = UnitUserCommand::None_;
}
UnitInteractionEvent::UnitDied(e) => {
// the e here is the unit that died, but we also need to cancel existing attack commands
// for this unit. We could maybe do a reverse lookup? but for now just store and iterate
// over all units to find ones
dead_units.push(e);
}
}
}
for mut unit in units.iter_mut() {
for dead in dead_units.iter() {
// clear actively fighting target, if there was any
if let Some(target) = &unit.state.current_actively_fighting() {
if dead == target {
unit.state.clear_target();
}
}
// clear current command if it was on the dead unit
if let UnitUserCommand::AttackMelee(target) | UnitUserCommand::AttackMissile(target) =
&unit.current_command
{
if dead == target {
unit.current_command = UnitUserCommand::None_;
}
}
}
}
for mut nearby in nearbys.iter_mut() {
for dead in dead_units.iter() {
nearby.melee_range.retain(|e| e != dead);
nearby.missle_range.retain(|e| e != dead);
}
}
for dead in dead_units.iter() {
commands.despawn_recursive(dead.clone());
}
}
/// Returns None if no targets available
/// TODO make this fancier
pub fn pick_missile_target(available_targets: &Vec<Entity>) -> Option<Entity> {
available_targets.get(0).map(|e| e.clone())
}
/// Returns None if no targets available
/// TODO make this fancier
pub fn pick_melee_target(available_targets: &Vec<Entity>) -> Option<Entity> {
available_targets.get(0).map(|e| e.clone())
}
pub fn calculate_next_unit_state_and_target(
current_command: &UnitUserCommand,
enemies_within_melee_range: &Vec<Entity>,
enemies_within_missile_range: &Vec<Entity>,
guard_mode_enabled: bool,
fire_at_will_enabled: bool,
missile_attack_available: bool,
can_fire_while_moving: bool,
currently_fighting: Option<Entity>,
) -> UnitState {
let next_melee_target = || pick_melee_target(enemies_within_melee_range);
let next_missile_target = || pick_missile_target(enemies_within_missile_range);
match current_command {
UnitUserCommand::AttackMelee(cmd_target) => {
if enemies_within_melee_range.contains(&cmd_target) {
// priority target should be the user command
UnitState::Melee(Some(cmd_target.clone()))
} else if currently_fighting.is_some() {
// keep fighting the same person as last round
UnitState::Melee(currently_fighting)
} else if let Some(next_target) = next_melee_target() {
// pick someone else
UnitState::Melee(Some(next_target))
} else {
// no one else nearby, target still alive outside of melee range
if guard_mode_enabled {
UnitState::Moving
} else {
// TODO clear command
UnitState::Idle
}
}
}
UnitUserCommand::AttackMissile(cmd_target) => {
if let Some(next_melee) = next_melee_target() {
UnitState::Melee(Some(next_melee))
} else if !missile_attack_available {
// out of ammo
UnitState::Idle
} else if enemies_within_missile_range.contains(&cmd_target) {
// prioritize user-given target
UnitState::Firing(Some(cmd_target.clone()))
} else {
// target is not within missle range
if guard_mode_enabled {
// guard mode, don't move
let next_target = next_missile_target();
if fire_at_will_enabled && next_target.is_some() {
// if other targets within missle range & fire at will on
UnitState::Firing(next_target)
} else {
UnitState::Idle
}
} else {
// no guard mode, chase target
let next_target = next_missile_target();
if can_fire_while_moving && fire_at_will_enabled && next_target.is_some() {
// special case for horse archers
UnitState::FiringAndMoving(next_target)
} else {
UnitState::Moving
}
}
}
}
UnitUserCommand::Move(_) => {
let melee_target = next_melee_target();
let missile_target = next_missile_target();
if melee_target.is_some() {
UnitState::Melee(melee_target)
} else if can_fire_while_moving && missile_attack_available && missile_target.is_some()
{
UnitState::FiringAndMoving(missile_target)
} else {
UnitState::Moving
}
}
UnitUserCommand::None_ => {
let next_melee = next_melee_target();
if next_melee.is_some() {
UnitState::Melee(next_melee)
} else {
let next_missile = next_missile_target();
if missile_attack_available && fire_at_will_enabled && next_missile.is_some() {
UnitState::Firing(next_missile)
} else {
UnitState::Idle
}
}
}
}
}
/// Updates each units state machine
pub fn unit_state_machine_system(
game_speed: Res<GameSpeed>,
mut units: Query<(
&mut UnitComponent,
&NearbyUnitsComponent,
&MissileWeaponComponent,
)>,
) {
if game_speed.is_paused() {
return;
}
for (mut unit, nearbys, missile) in units.iter_mut() {
let new_state = calculate_next_unit_state_and_target(
&unit.current_command,
&nearbys.melee_range,
&nearbys.missle_range,
unit.guard_mode_enabled,
unit.fire_at_will,
missile.is_missile_attack_available(),
unit.can_fire_while_moving(),
unit.state.current_actively_fighting(),
);
if unit.state != new_state {
log::debug!(
"Unit state transition {:?}->{:?} with command {:?}",
unit.state,
new_state,
unit.current_command
);
}
unit.state = new_state;
}
}
/// for each unit, calculates the position of its waypoint
pub fn unit_waypoint_system(
game_speed: Res<GameSpeed>,
mut unit_query: Query<(&UnitComponent, &mut WaypointComponent)>,
target_query: Query<&Transform>,
) {
if game_speed.is_paused() {
return;
}
for (unit, mut waypoint) in unit_query.iter_mut() {
match &unit.current_command {
UnitUserCommand::AttackMelee(target) | UnitUserCommand::AttackMissile(target) => {
let target_translation = target_query
.get_component::<Transform>(target.clone())
.expect("Target translation")
.translation;
*waypoint = WaypointComponent::Position(
(target_translation.x, target_translation.y).into(),
);
}
UnitUserCommand::Move(wp) => {
// TODO this is unnessecary, but maybe its where its where we put in some pathfinding to determine the next step?
*waypoint = WaypointComponent::Position(wp.clone());
}
UnitUserCommand::None_ => {}
}
}
}
// TODO have a separate component for waypoint position for all command types
// that is updated in a separate system, so its calculated separately from the unit movement system
// so we don't run into unique borrow issues
pub fn unit_movement_system(
game_speed: Res<GameSpeed>,
time: Res<Time>,
mut bodies: ResMut<RigidBodySet>,
mut colliders: ResMut<ColliderSet>,
mut unit_events: ResMut<Events<UnitInteractionEvent>>,
mut unit_query: Query<(
Entity,
&mut UnitComponent,
&mut Transform,
&mut RigidBodyHandleComponent,
&mut ColliderHandleComponent,
&WaypointComponent,
)>,
) {
if game_speed.is_paused() {
return;
}
for (entity, unit, transform, body_handle, collider_handle, waypoint) in unit_query.iter_mut() {
let translation = transform.translation;
// TODO remove transform here, use rigid body pos
let unit_pos: XyPos = (translation.x, translation.y).into();
let mut body = bodies.get_mut(body_handle.handle()).expect("body");
let collider = colliders
.get_mut(collider_handle.handle())
.expect("collider");
// if the unit is going somewhere
if let UnitState::Moving | UnitState::FiringAndMoving(_) = &unit.state {
if let Some(dest) = match &unit.current_command {
UnitUserCommand::AttackMelee(_) | UnitUserCommand::AttackMissile(_) => {
if let WaypointComponent::Position(xy) = waypoint {
Some(xy)
} else {
log::error!("attack command without a waypoint!");
None
}
}
UnitUserCommand::Move(_) => {
if let WaypointComponent::Position(xy) = waypoint {
Some(xy)
} else {
log::error!("attack command without a waypoint!");
None
}
}
UnitUserCommand::None_ => None,
} {
let relative_position = dest.clone() - unit_pos;
let unit_distance = unit.current_speed() * time.delta_seconds();
// using length_squared() for totally premature optimization
let rel_distance_sq = relative_position.length_squared();
// if we need to keep moving
if unit_distance.powi(2) < rel_distance_sq {
// get direction
let direction = relative_position.normalize();
// move body
let pos = Isometry::translation(
body.position().translation.vector.x + (direction.x * unit_distance),
body.position().translation.vector.y + (direction.y * unit_distance),
);
body.set_position(pos, true);
collider.set_position_debug(pos);
} else {
// can reach destination, set position to waypoint, transition to idle
let pos = Isometry::translation(dest.x, dest.y);
body.set_position(pos, true);
collider.set_position_debug(pos);
unit_events.send(UnitInteractionEvent::UnitWaypointReached(entity));
}
}
}
}
}
#[cfg(test)]
mod test {
#[test]
fn test_unit_state_machine() {}
}
|
use std::hash::Hash;
use std::fmt::Debug;
use crate::machine::*;
#[derive(Debug)]
pub struct HistoryMachine<A, S, C> {
pub machine: Machine<A, S, C>,
pub past: Vec<(S, C)>,
pub future: Vec<(S, C)>,
}
impl<A: Copy, S: Eq + Hash + Copy, C: Debug + Copy> HistoryMachine<A, S, C> {
/// Create a new state machine
pub fn new(machine: Machine<A, S, C>) -> Self {
HistoryMachine { machine, future: vec![], past: vec![] }
}
/// Send an action to the state machines
pub fn transition(&mut self, action: &A) {
self.past.push((
self.machine.value,
self.machine.context
));
self.machine.transition(action);
}
pub fn undo(&mut self) {
if self.past.len() > 0 {
if let Some((state, context)) = self.past.pop() {
self.future.push((
self.machine.value,
self.machine.context
));
self.machine.set_state(state);
self.machine.set_context(context);
}
}
}
pub fn redo(&mut self) {
if self.future.len() > 0 {
if let Some((state, context)) = self.future.pop() {
self.past.push((
self.machine.value,
self.machine.context
));
self.machine.set_state(state);
self.machine.set_context(context);
}
}
}
}
|
// Super Palindromes
// https://leetcode.com/explore/challenge/card/may-leetcoding-challenge-2021/599/week-2-may-8th-may-14th/3736/
//
impl Solution {
fn is_palindrome(number: i64) -> bool {
let radix: i64 = 10;
let mut rev: i64 = 0;
let mut n: i64 = number.abs();
let mut pop: i64 = 0;
while n != 0 {
pop = n % radix;
n /= radix;
if rev > (std::i64::MAX / radix) || (rev == std::i64::MAX / radix && pop > 7) {
return false;
}
rev = rev * radix + pop;
}
rev == number
}
fn is_super_palindrome(number: i64) -> bool {
if Solution::is_palindrome(number) {
let sqrt_num = (number as f64).sqrt();
if sqrt_num.fract() == 0.0 {
return Solution::is_palindrome(sqrt_num as i64);
}
}
return false;
}
pub fn superpalindromes_in_range(left: String, right: String) -> i32 {
let left: i64 = left.parse().unwrap();
let right: i64 = right.parse().unwrap();
let mut counter: i32 = 0;
for num in (left..right) {
if Solution::is_super_palindrome(num) {
counter += 1;
}
}
counter
}
}
|
use std::collections::HashMap;
use std::fs::File;
use std::io::Read;
// Used in tests
#[allow(dead_code)]
static TEST_CASE: &str = "eedadn\n\
drvtee\n\
eandsr\n\
raavrd\n\
atevrs\n\
tsrnev\n\
sdttsa\n\
rasrtv\n\
nssdts\n\
ntnada\n\
svetve\n\
tesnvt\n\
vntsnd\n\
vrdear\n\
dvrsen\n\
enarar";
fn most_frequent_letter(counter: &HashMap<char, u32>, take_max: bool) -> char {
if take_max {
*counter.iter()
.max_by(|a, b| a.1.cmp(&b.1))
.map(|(k, _v)| k)
.unwrap()
} else {
*counter.iter()
.min_by(|a, b| a.1.cmp(&b.1))
.map(|(k, _v)| k)
.unwrap()
}
}
fn frequency_based_decoding(text: &str, take_max: bool) -> String {
let lines = text.lines();
let size = lines.last().unwrap().len();
let mut letter_counts: Vec<HashMap<char, u32>> = (0..size).map(|_| HashMap::new()).collect();
for line in text.lines() {
// println!("{}", line);
for (i, c) in line.chars().enumerate() {
*(letter_counts[i].entry(c).or_insert(0)) += 1;
}
}
(0..size).map(|i| most_frequent_letter(&letter_counts[i], take_max)).collect()
}
fn part1(text: &str) -> String {
frequency_based_decoding(text, true)
}
fn part2(text: &str) -> String {
frequency_based_decoding(text, false)
}
fn main() {
let mut file = File::open("input06.txt").unwrap();
let mut text = String::new();
file.read_to_string(&mut text).unwrap();
println!("Part 1: {}", part1(&text));
println!("Part 2: {}", part2(&text));
}
#[test]
fn test_part1() {
assert_eq!(part1(TEST_CASE), "easter");
}
#[test]
fn test_part2() {
assert_eq!(part2(TEST_CASE), "advent");
}
|
use std::sync::mpsc::{channel, Sender, Receiver};
use clock;
use interface;
#[derive(Clone, Copy, Debug)]
pub enum Message {
Time(clock::Time),
Signature(clock::Signature),
Tempo(clock::Tempo),
Reset,
NudgeTempo(clock::NudgeTempo),
Tap,
/*
Stop,
NudgeClock,
Configure
*/
}
#[derive(Debug)]
pub struct Metronome {
pub tx: Sender<Message>,
pub rx: Receiver<Message>
}
impl Metronome {
pub fn new() -> Self {
let (tx, rx) = channel();
Self {
tx,
rx
}
}
pub fn run (self) {
let terminal_tx = interface::Terminal::start(self.tx.clone());
let clock_tx = clock::Clock::start(self.tx.clone());
for control_message in self.rx {
match control_message {
// sent by interface
Message::Reset => {
clock_tx.send(clock::Message::Reset).unwrap();
},
// sent by interface
Message::NudgeTempo(nudge) => {
clock_tx.send(clock::Message::NudgeTempo(nudge)).unwrap();
},
// sent by interface
Message::Tap => {
clock_tx.send(clock::Message::Tap).unwrap();
},
// sent by clock
Message::Signature(signature) => {
clock_tx.send(clock::Message::Signature(signature)).unwrap();
terminal_tx.send(interface::Message::Signature(signature)).unwrap();
},
// sent by clock
Message::Tempo(tempo) => {
clock_tx.send(clock::Message::Tempo(tempo)).unwrap();
terminal_tx.send(interface::Message::Tempo(tempo)).unwrap();
},
// sent by clock
Message::Time(time) => {
terminal_tx.send(interface::Message::Time(time)).unwrap();
}
}
}
}
}
|
use regex::Regex;
fn main() {
/*let a = [1, 2, 3];
println!("{:?}", a);
let doubled:Vec<i32> = a.iter().map(|&x| x * 2).collect();
println!("{:?}", doubled);*/
let re_test = Regex::new("^[a-zA-Z]+$").unwrap();
let test_pass1 = "aVEASCasd";
let test_fail1 = "aVEASCas3d";
println!("Passed -> {}", re_test.is_match(test_pass1));
println!("Failed -> {}", !re_test.is_match(test_fail1));
let re = Regex::new(r"(\d{4})-(\d{2})-(\d{2})").unwrap();
let text = "2012-03-14, 2013-01-01 and 2014-07-05";
for cap in re.captures_iter(text) {
println!("Month: {} Day: {} Year: {}", &cap[2], &cap[3], &cap[1]);
}
}
|
use super::super::common::{screen};
pub fn start_server() {
// TODO
} |
#[doc = "Register `MISR` reader"]
pub type R = crate::R<MISR_SPEC>;
#[doc = "Field `TAMP1MF` reader - TAMP1MF:"]
pub type TAMP1MF_R = crate::BitReader<TAMP1MF_A>;
#[doc = "TAMP1MF:\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum TAMP1MF_A {
#[doc = "0: No tamper detected - Masked"]
Idle = 0,
#[doc = "1: Tamper detected - Masked"]
Tamper = 1,
}
impl From<TAMP1MF_A> for bool {
#[inline(always)]
fn from(variant: TAMP1MF_A) -> Self {
variant as u8 != 0
}
}
impl TAMP1MF_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> TAMP1MF_A {
match self.bits {
false => TAMP1MF_A::Idle,
true => TAMP1MF_A::Tamper,
}
}
#[doc = "No tamper detected - Masked"]
#[inline(always)]
pub fn is_idle(&self) -> bool {
*self == TAMP1MF_A::Idle
}
#[doc = "Tamper detected - Masked"]
#[inline(always)]
pub fn is_tamper(&self) -> bool {
*self == TAMP1MF_A::Tamper
}
}
#[doc = "Field `TAMP2MF` reader - TAMP2MF"]
pub use TAMP1MF_R as TAMP2MF_R;
#[doc = "Field `TAMP3MF` reader - TAMP3MF"]
pub use TAMP1MF_R as TAMP3MF_R;
#[doc = "Field `ITAMP3MF` reader - ITAMP3MF"]
pub type ITAMP3MF_R = crate::BitReader<ITAMP3MF_A>;
#[doc = "ITAMP3MF\n\nValue on reset: 0"]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum ITAMP3MF_A {
#[doc = "0: No tamper detected - Masked"]
Idle = 0,
#[doc = "1: Internal tamper detected - Masked"]
Tamper = 1,
}
impl From<ITAMP3MF_A> for bool {
#[inline(always)]
fn from(variant: ITAMP3MF_A) -> Self {
variant as u8 != 0
}
}
impl ITAMP3MF_R {
#[doc = "Get enumerated values variant"]
#[inline(always)]
pub fn variant(&self) -> ITAMP3MF_A {
match self.bits {
false => ITAMP3MF_A::Idle,
true => ITAMP3MF_A::Tamper,
}
}
#[doc = "No tamper detected - Masked"]
#[inline(always)]
pub fn is_idle(&self) -> bool {
*self == ITAMP3MF_A::Idle
}
#[doc = "Internal tamper detected - Masked"]
#[inline(always)]
pub fn is_tamper(&self) -> bool {
*self == ITAMP3MF_A::Tamper
}
}
#[doc = "Field `ITAMP5MF` reader - ITAMP5MF"]
pub use ITAMP3MF_R as ITAMP5MF_R;
#[doc = "Field `ITAMP6MF` reader - ITAMP6MF"]
pub use ITAMP3MF_R as ITAMP6MF_R;
#[doc = "Field `ITAMP8MF` reader - ITAMP8MF"]
pub use ITAMP3MF_R as ITAMP8MF_R;
impl R {
#[doc = "Bit 0 - TAMP1MF:"]
#[inline(always)]
pub fn tamp1mf(&self) -> TAMP1MF_R {
TAMP1MF_R::new((self.bits & 1) != 0)
}
#[doc = "Bit 1 - TAMP2MF"]
#[inline(always)]
pub fn tamp2mf(&self) -> TAMP2MF_R {
TAMP2MF_R::new(((self.bits >> 1) & 1) != 0)
}
#[doc = "Bit 2 - TAMP3MF"]
#[inline(always)]
pub fn tamp3mf(&self) -> TAMP3MF_R {
TAMP3MF_R::new(((self.bits >> 2) & 1) != 0)
}
#[doc = "Bit 18 - ITAMP3MF"]
#[inline(always)]
pub fn itamp3mf(&self) -> ITAMP3MF_R {
ITAMP3MF_R::new(((self.bits >> 18) & 1) != 0)
}
#[doc = "Bit 20 - ITAMP5MF"]
#[inline(always)]
pub fn itamp5mf(&self) -> ITAMP5MF_R {
ITAMP5MF_R::new(((self.bits >> 20) & 1) != 0)
}
#[doc = "Bit 21 - ITAMP6MF"]
#[inline(always)]
pub fn itamp6mf(&self) -> ITAMP6MF_R {
ITAMP6MF_R::new(((self.bits >> 21) & 1) != 0)
}
#[doc = "Bit 23 - ITAMP8MF"]
#[inline(always)]
pub fn itamp8mf(&self) -> ITAMP8MF_R {
ITAMP8MF_R::new(((self.bits >> 23) & 1) != 0)
}
}
#[doc = "TAMP masked interrupt status register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`misr::R`](R). See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct MISR_SPEC;
impl crate::RegisterSpec for MISR_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`misr::R`](R) reader structure"]
impl crate::Readable for MISR_SPEC {}
#[doc = "`reset()` method sets MISR to value 0"]
impl crate::Resettable for MISR_SPEC {
const RESET_VALUE: Self::Ux = 0;
}
|
#![allow(dead_code, unused_variables, unused_imports, unused_must_use,)]
#[macro_use]
extern crate clap;
extern crate time;
extern crate serde;
extern crate serde_json;
extern crate schedule_recv;
extern crate crossroad_server; // Local crate
use serde::ser;
use schedule_recv as sched;
use time::*;
use std::net::{TcpListener, TcpStream, ToSocketAddrs};
use std::fmt::Display;
use std::io::{self, BufRead, Write, BufReader, BufWriter};
use std::thread;
use std::thread::{JoinHandle};
use std::sync::{Arc, Mutex};
use std::sync::mpsc::{channel, Sender, Receiver};
use std::fs::File;
use std::path::Path;
use std::fs::OpenOptions;
use std::collections::HashMap;
use crossroad_server::crossroad::*;
use crossroad_server::traffic_protocol::*;
use crossroad_server::traffic_controls::*;
use crossroad_server::default_crossroad;
use crossroad_server::error::{Result, Error, JsonError};
fn main() {
let matches = clap_app!(myapp =>
(version: "1.0")
(author: "Rutger S.")
(about: "Awesome crossroad simulator!")
(@arg ip: +required "Runs the server on this ip")
(@arg port: -p --port +takes_value "Sets the port")
(@arg json: -j --json +takes_value "Determines how the json output is encoded. Takes none, null or empty as the value.
none: Sends only the {banan} json vec.
null: Sends the complete {banen, busbanen, stoplichten} json, where the empty ones will be null.
empty: Sends the complete {banen, busbanen, stoplichten} json, where the empty ones will be []\n")
).get_matches();
let j_str = matches.value_of("json").unwrap_or("none");
match JsonCompatLevel::from_str(&j_str) {
Some(compat_level) => unsafe {
crossroad_server::traffic_protocol::JSON_COMPAT_LEVEL = compat_level;
},
None => println!("Incorrect -j value!"),
}
let ip = matches.value_of("ip").unwrap();
let port = matches.value_of("port").unwrap_or("9990");
let address = format!("{}:{}", ip, port);
println!("\nJson compatibility level = {:?} ", j_str);
run_server(&*address).unwrap();
}
fn run_server<A>(address: A) -> io::Result<()> where A: ToSocketAddrs + Display {
let listener = try!(TcpListener::bind(&address));
println!("Server listening on: {}", address);
// Infinite loop.
for tcp_stream in listener.incoming().filter_map(|i| i.ok()) {
thread::spawn(move || {
println!("Connecting a new client");
match handle_client(tcp_stream) {
Ok(_) => println!("Client disconnected normally."),
Err(v) => println!("Client error {:?}", v),
};
});
}
Ok(())
}
fn handle_client(client_stream: TcpStream) -> io::Result<()> {
let (log_file_recv, log_file_sent) = create_log_files(&client_stream).expect("log files");
// Convert stream to buffered streams
let client_reader = BufReader::new(try!(client_stream.try_clone()));
let client_writer = BufWriter::new(client_stream);
// Main thread uses this channel to send (json) updates to the client.
let (out_transmitter, out_receiver) = channel::<String>();
let (exit_main_loop_tx, exit_main_loop_rx) = channel();
// Getting updates from the simulator(client) via a socket, so make it safe with reference counter + a mutex.
let client_baan_sensor_states = Arc::new(Mutex::new(SensorStates::new()));
// Run seperate threads
let client_receiver_handle = spawn_client_sensor_receiver(client_reader, client_baan_sensor_states.clone(), log_file_recv);
let client_updater_handle = spawn_client_updater(client_writer, out_receiver, log_file_sent);
let verkeersregelinstallatie_handle = spawn_main_loop(out_transmitter, exit_main_loop_rx, client_baan_sensor_states.clone());
println!("Connection established");
// Wait for threads to exit
if let Err(v) = client_updater_handle.join().and(client_receiver_handle.join()) {
println!("client disconnected, error {:?}", v);
}
exit_main_loop_tx.send(0);
verkeersregelinstallatie_handle.join();
Ok(())
}
fn create_log_files(client_stream: &TcpStream) -> io::Result<(File, File)> {
let ip = try!(client_stream.local_addr().map(|sock| sock.ip()));
let file_name = format!("{}_{}", time::now().strftime("%e-%m-%G_%k%M_").unwrap(), ip);
let path_in = format!("{}_{}.log", file_name, "received");
let path_out = format!("{}_{}.log", file_name, "sent");
let mut o = OpenOptions::new();
let u = o.create(true).append(true);
let log_file_recv = try!(u.open(Path::new(&path_in)));
let log_file_sent = try!(u.open(Path::new(&path_out)));
Ok((log_file_recv, log_file_sent))
}
fn spawn_main_loop( out_tx: Sender<String>,
exit_rx: Receiver<u8>,
sensor_shared_state: Arc<Mutex<SensorStates>>)
-> JoinHandle<Result<()>>
{
thread::spawn(move || {
let traffic_lights = default_crossroad::create_traffic_lights();
let traffic_controls = default_crossroad::create_traffic_controls(&traffic_lights);
let crossroad = default_crossroad::create_crossroad(&traffic_controls);
let mut crossroad_state = CrossroadState::AllRed;
let mut time = 0; // seconds
let frequency_scheduler = sched::periodic_ms(1000);
if true { // TESTS
// crossroad.send_all_bulk(&out_tx, JsonState::Groen);
// crossroad.send_all(&out_tx, JsonState::Geel);
// crossroad.send_all_bulk(&out_tx, JsonState::Rood);
}
loop {
time = time + 1;
frequency_scheduler.recv().unwrap();
if let Ok(exit_loop) = exit_rx.try_recv() {
break;
}
print!("\n {:?} ", time);
match crossroad.run_loop(time, &mut crossroad_state, sensor_shared_state.clone(), &out_tx) {
Some(newstate) => crossroad_state = newstate,
None => (),
};
}
Ok(())
})
}
fn spawn_client_sensor_receiver(mut reader: BufReader<TcpStream>, sensor_data: Arc<Mutex<SensorStates>>, mut log_file: File) -> JoinHandle<Result<()>> {
thread::spawn(move || {
loop {
let mut line = String::new();
try!(reader.read_line(&mut line));
let ref mut traffic_state = *sensor_data.lock().unwrap();
log_file.write(format!("\n{}\n", time::now().strftime("%T").unwrap()).as_bytes());
log_file.write_all(&line.as_bytes());
match serde_json::from_str::<ProtocolJson>(&line) {
Ok(protocol_obj) => {
if let Some(ref banen) = protocol_obj.banen {
if banen.len() > 0 {
traffic_state.update(banen);
//println!("Client->Server: received baan sensor update: {:?} new_state = {:?}", banen, traffic_state)
}
}
if let Some(ref busbanen) = protocol_obj.busbanen {
if busbanen.len() > 0 {
traffic_state.update_bussen(busbanen);
println!("Client->Server: received BUSBAAN sensor update: {:?} new_state = {:?}", busbanen, traffic_state)
}
}
},
Err(err) => println!("Client->Server: received faulty json string {:?}", line),
}
}
})
}
fn spawn_client_updater(mut writer: BufWriter<TcpStream>, rx: Receiver<String>, mut log_file: File) -> thread::JoinHandle<Result<()>> {
thread::spawn(move || {
loop {
match rx.recv() {
Ok(msg) => {
log_file.write(format!("\n\n{}\n", time::now().strftime("%T").unwrap()).as_bytes());
log_file.write_all(&msg.as_bytes());
try!(writer.write(format!("{}\r\n", &msg).as_bytes()));
try!(writer.flush());
println!("Server->Client: sent new stoplicht state {:?}", msg);
},
Err(err) => {
println!("{:?}", err);
return Ok(());
}
};
}
})
}
#[test]
fn send_json() {
let stoplicht = &StoplichtJson::empty();
let stringified = serde_json::to_string(stoplicht).unwrap();
println!("before:\n{:?}\n\nafter:\n{:?}", stoplicht, stringified);
}
#[test]
fn main_loop() {
let (out_transmitter, out_receiver) = channel::<String>();
let (exit_main_loop_tx, exit_main_loop_rx) = channel();
let client_baan_sensor_states = Arc::new(Mutex::new(SensorStates::new()));
let sensor_shared_state = client_baan_sensor_states.clone();
{
let ref mut init_state = *sensor_shared_state.lock().unwrap();
let now = time::now();
init_state._debug_update_directly(vec![
/*
Sensor { id: 6, bezet: true, last_update: now - Duration::seconds(1000) },
Sensor { id: 5, bezet: true, last_update: now - Duration::seconds(5) },
Sensor { id: 11, bezet: true, last_update: now - Duration::seconds(10) },
Sensor { id: 4, bezet: true, last_update: now - Duration::seconds(50) },
Sensor { id: 9, bezet: true, last_update: now - Duration::seconds(14) },
Sensor { id: 7, bezet: true, last_update: now - Duration::seconds(5) },
Sensor { id: 13, bezet: true, last_update: now - Duration::seconds(6) },*/
]);
}
let sensor_shared_state_copy = client_baan_sensor_states.clone();
thread::spawn(move || {
thread::sleep_ms(13000);
{
println!("Sending simulated state #1: sensor 13 = true");
let ref mut traffic_state = *sensor_shared_state_copy.lock().unwrap();
traffic_state._debug_update_directly(vec![Sensor { id: 13, bezet: true, last_update: time::now() },]);
}
thread::sleep_ms(16000);
{
println!("Sending simulated state #2: sensor 13 = false");
let ref mut traffic_state = *sensor_shared_state_copy.lock().unwrap();
traffic_state._debug_update_directly(vec![Sensor { id: 13, bezet: false, last_update: time::now() },]);
}
thread::sleep_ms(25000);
{
println!("Sending simulated state #3: sensor 9 = true");
let ref mut traffic_state = *sensor_shared_state_copy.lock().unwrap();
traffic_state._debug_update_directly(vec![Sensor { id: 9, bezet: true, last_update: time::now() },]);
}
});
let verkeer = spawn_main_loop(out_transmitter, exit_main_loop_rx, client_baan_sensor_states.clone());
loop {
match out_receiver.recv() {
Ok(msg) => {
println!("Server->Client: sent new stoplicht state {:?}", msg)
},
Err(err) => {
println!("{:?}", err);
break;
}
};
}
}
#[test]
fn time_max() {
let mut a = vec![];
a.push(time::now());
println!("{:?}", a);
thread::sleep_ms(2000);
a.push(time::now());
println!("{:?}", a);
thread::sleep_ms(2000);
a.push(time::now());
println!("{:?}", a);
let b = a.iter().min();
println!("\n\n{:?}", b);
}
|
#![allow(unused_variables)]
#![allow(dead_code)]
// to get **argv (in c++)
use std::env;
use std::fs;
fn main() {
let args: Vec<String> = env::args().collect();
let config = Config::new(&args).expect("Some error ocurred");
// If not found a CASE_INSENSITIVE in env, will put 0
let case_sensitive = env::var("CASE_INSENSITIVES").unwrap_or_else(|op| "0".to_string());
println!("{:?}", case_sensitive);
println!("Searching for {}", config.query);
println!("In file {}", config.filename);
let contents =
fs::read_to_string(config.filename).expect("Something went wrong reading the file");
// --snip--
}
struct Config {
query: String,
filename: String,
}
impl Config {
fn new(args: &[String]) -> Result<Config, &str> {
if args.len() < 3 {
panic!("Not enough arguments");
}
let query = args[1].clone();
let filename = args[2].clone();
Ok(Config { query, filename })
}
}
fn parse_config(args: &[String]) -> Config {
let query = args[1].clone();
let filename = args[2].clone();
Config { query, filename }
}
fn read_file(filename: &String) -> String {
// --snip--
println!("In file {}", filename);
let contents = fs::read_to_string(filename);
match contents {
Ok(content) => content,
Err(reason) => panic!(reason),
}
}
|
mod helpers;
use helpers as h;
use helpers::{Playground, Stub::*};
use std::path::PathBuf;
#[test]
fn has_default_configuration_file() {
let expected = "config.toml";
Playground::setup("config_test_1", |dirs, _| {
nu!(cwd: dirs.root(), "config");
assert_eq!(
dirs.config_path().join(expected),
nu::config_path().unwrap().join(expected)
);
})
}
#[test]
fn shows_path_of_configuration_file() {
let expected = "config.toml";
Playground::setup("config_test_2", |dirs, _| {
let actual = nu!(
cwd: dirs.test(),
"config --path | echo $it"
);
assert_eq!(PathBuf::from(actual), dirs.config_path().join(expected));
});
}
#[test]
fn use_different_configuration() {
Playground::setup("config_test_3", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"test_3.toml",
r#"
caballero_1 = "Andrés N. Robalino"
caballero_2 = "Jonathan Turner"
caballero_3 = "Yehuda katz"
"#,
)]);
let actual = nu!(
cwd: dirs.root(),
"config --get caballero_1 --load {}/test_3.toml | echo $it",
dirs.test()
);
assert_eq!(actual, "Andrés N. Robalino");
});
h::delete_file_at(nu::config_path().unwrap().join("test_3.toml"));
}
#[test]
fn sets_configuration_value() {
Playground::setup("config_test_4", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"test_4.toml",
r#"
caballero_1 = "Andrés N. Robalino"
caballero_2 = "Jonathan Turner"
caballero_3 = "Yehuda katz"
"#,
)]);
nu!(
cwd: dirs.test(),
"config --load test_4.toml --set [caballero_4 jonas]"
);
let actual = nu!(
cwd: dirs.root(),
r#"open "{}/test_4.toml" | get caballero_4 | echo $it"#,
dirs.config_path()
);
assert_eq!(actual, "jonas");
});
h::delete_file_at(nu::config_path().unwrap().join("test_4.toml"));
}
#[test]
fn removes_configuration_value() {
Playground::setup("config_test_5", |dirs, sandbox| {
sandbox.with_files(vec![FileWithContent(
"test_5.toml",
r#"
caballeros = [1, 1, 1]
podershell = [1, 1, 1]
"#,
)]);
nu!(
cwd: dirs.test(),
"config --load test_5.toml --remove podershell"
);
let actual = nu_error!(
cwd: dirs.root(),
r#"open "{}/test_5.toml" | get podershell | echo $it"#,
dirs.config_path()
);
assert!(actual.contains("Unknown column"));
});
h::delete_file_at(nu::config_path().unwrap().join("test_5.toml"));
}
|
use crate::cell::{ Merge };
impl Merge for usize {
fn is_valid(&self, value: &Self) -> bool {
self == value
}
fn merge(&self, other: &Self) -> Self {
other.clone()
}
}
//impl Bool for usize {
//fn to_bool(self) -> bool {
//self != 0
//}
//}
|
#[doc = "Reader of register TX_WATCHDOG"]
pub type R = crate::R<u32, super::TX_WATCHDOG>;
#[doc = "Writer for register TX_WATCHDOG"]
pub type W = crate::W<u32, super::TX_WATCHDOG>;
#[doc = "Register TX_WATCHDOG `reset()`'s with value 0"]
impl crate::ResetValue for super::TX_WATCHDOG {
type Type = u32;
#[inline(always)]
fn reset_value() -> Self::Type {
0
}
}
#[doc = "Reader of field `WD_COUNTER`"]
pub type WD_COUNTER_R = crate::R<u32, u32>;
#[doc = "Write proxy for field `WD_COUNTER`"]
pub struct WD_COUNTER_W<'a> {
w: &'a mut W,
}
impl<'a> WD_COUNTER_W<'a> {
#[doc = r"Writes raw bits to the field"]
#[inline(always)]
pub unsafe fn bits(self, value: u32) -> &'a mut W {
self.w.bits = (self.w.bits & !0xffff_ffff) | ((value as u32) & 0xffff_ffff);
self.w
}
}
impl R {
#[doc = "Bits 0:31 - Start value of the TX watchdog. With the reset value of 0x0000:0000 the counter is disabled. This is clocked by the AHB-Lite system clock 'clk_sys'."]
#[inline(always)]
pub fn wd_counter(&self) -> WD_COUNTER_R {
WD_COUNTER_R::new((self.bits & 0xffff_ffff) as u32)
}
}
impl W {
#[doc = "Bits 0:31 - Start value of the TX watchdog. With the reset value of 0x0000:0000 the counter is disabled. This is clocked by the AHB-Lite system clock 'clk_sys'."]
#[inline(always)]
pub fn wd_counter(&mut self) -> WD_COUNTER_W {
WD_COUNTER_W { w: self }
}
}
|
//! # The Chain Library
//!
//! This Library contains the `Chain Service` implement:
//!
//! - [Chain](chain::chain::Chain) represent a struct which
mod cell;
pub mod chain;
pub mod switch;
#[cfg(test)]
mod tests;
|
use std::thread;
use rocket::Rocket;
use crate::benchmarking::ControllerBench;
use crate::framework::{Runnable, CompositeRunnable};
use crate::mechatronics::controller::RobotController;
use crate::builder::robot::Robot;
pub struct RobotLauncher {
controller: RobotController,
bfr: Rocket,
bench: Option<ControllerBench>,
monitor: CompositeRunnable
}
impl RobotLauncher {
pub fn new(controller: RobotController, bfr: Rocket, bench: Option<ControllerBench>, monitor: CompositeRunnable) -> Self {
Self {
controller,
bfr,
bench,
monitor,
}
}
/// Launches the robot, taking over the current thread.
/// This method consumes the robot.
pub fn launch(self) -> Robot {
let mut controller = self.controller;
let mut monitor = self.monitor;
let controller_thread = thread::Builder::new().name("Controller Thread".to_string()).spawn(move || controller.start()).unwrap();
let bench_thread = self.bench.map(|bench| thread::Builder::new().name("Bench Thread".to_string()).spawn(move || {
bench.launch();
}).unwrap());
let monitor_thread = thread::Builder::new().name("Monitor Thread".to_string()).spawn(move || monitor.start()).unwrap();
Robot::new(controller_thread, self.bfr, bench_thread, monitor_thread)
}
} |
#![feature(test)]
extern crate test;
use test::Bencher;
#[bench]
fn generate_lorem_ipsum_100(b: &mut Bencher) {
b.iter(|| lipsum::lipsum(100))
}
#[bench]
fn generate_lorem_ipsum_200(b: &mut Bencher) {
b.iter(|| lipsum::lipsum(200))
}
|
println!("{}", "this" "is not allowed");
|
use crate::flamegraph::filter_to_useful_callstacks;
use crate::flamegraph::CallstackCleaner;
use crate::flamegraph::FlamegraphCallstacks;
use crate::linecache::LineCacher;
use crate::python::get_runpy_path;
use super::rangemap::RangeMap;
use super::util::new_hashmap;
use ahash::RandomState as ARandomState;
use im::Vector as ImVector;
use itertools::Itertools;
use serde::Deserialize;
use serde::Serialize;
use std::borrow::Cow;
use std::collections::BTreeMap;
use std::collections::HashMap;
extern "C" {
fn _exit(exit_code: std::os::raw::c_int);
}
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, Serialize, Deserialize)]
pub struct FunctionId(u64);
impl FunctionId {
pub const UNKNOWN: Self = Self(u64::MAX);
pub fn new(id: u64) -> Self {
FunctionId(id)
}
pub fn as_u64(&self) -> u64 {
self.0
}
}
/// A function location in the Python source code, e.g. "example() in foo.py".
#[derive(Clone)]
struct FunctionLocation {
filename: String,
function_name: String,
}
/// Basic usage: first clone, once any locks are released, convert to
/// ReadFunctionLocations.
///
/// The clone should be cheap, ideally, so probably an immutable data structures
/// would be good.
pub trait WriteFunctionLocations {
type Reader: ReadFunctionLocations;
/// Like Clone.clone(), but should be cheap.
fn cheap_clone(&self) -> Self;
/// Convert to ReadFunctionLocations.
fn to_reader(self) -> Self::Reader;
}
pub trait ReadFunctionLocations {
fn get_function_and_filename_and_display_filename(&self, id: FunctionId) -> (&str, &str, &str);
}
/// Stores FunctionLocations, returns a FunctionId
#[derive(Clone)]
pub struct VecFunctionLocations {
functions: ImVector<FunctionLocation>,
}
impl VecFunctionLocations {
/// Create a new tracker.
pub fn new() -> Self {
Self {
functions: ImVector::new(),
}
}
/// Register a function, get back its id.
pub fn add_function(&mut self, filename: String, function_name: String) -> FunctionId {
self.functions.push_back(FunctionLocation {
filename,
function_name,
});
// If we ever have 2 ** 32 or more functions in our program, this will
// break. Seems unlikely, even with long running workers.
FunctionId((self.functions.len() - 1) as u64)
}
}
impl ReadFunctionLocations for VecFunctionLocations {
/// Get the function name and filename.
fn get_function_and_filename_and_display_filename(&self, id: FunctionId) -> (&str, &str, &str) {
if id == FunctionId::UNKNOWN {
return ("UNKNOWN", "UNKNOWN", "UNKNOWN DUE TO BUG");
}
let location = &self.functions[id.0 as usize];
(
&location.function_name,
&location.filename,
// TODO on Jupyter you might want to make display filename different...
&location.filename,
)
}
}
impl WriteFunctionLocations for VecFunctionLocations {
type Reader = Self;
fn cheap_clone(&self) -> Self {
Self {
functions: self.functions.clone(),
}
}
fn to_reader(self) -> Self::Reader {
self
}
}
/// Either the line number, or the bytecode index needed to get it.
#[derive(Copy, Clone, Serialize, Deserialize, Hash, Eq, PartialEq, Debug)]
pub enum LineNumberInfo {
LineNumber(u32),
BytecodeIndex(i32),
}
impl LineNumberInfo {
fn get_line_number(&self) -> u32 {
if let LineNumberInfo::LineNumber(lineno) = self {
*lineno
} else {
debug_assert!(false, "This should never happen.");
0
}
}
}
/// A specific location: file + function + line number.
#[derive(Clone, Debug, PartialEq, Eq, Copy, Hash, Serialize, Deserialize)]
pub struct CallSiteId {
/// The function + filename. We use IDs for performance reasons (faster hashing).
pub function: FunctionId,
/// Line number within the _file_, 1-indexed.
pub line_number: LineNumberInfo,
}
impl CallSiteId {
pub fn new(function: FunctionId, line_number: LineNumberInfo) -> CallSiteId {
CallSiteId {
function,
line_number,
}
}
}
/// The current Python callstack.
#[derive(Derivative, Serialize, Deserialize)]
#[derivative(Clone, PartialEq, Eq, Hash, Debug)]
pub struct Callstack {
calls: Vec<CallSiteId>,
#[derivative(Hash = "ignore", PartialEq = "ignore")]
cached_callstack_id: Option<(u32, CallstackId)>, // first bit is line number
}
impl Callstack {
pub fn new() -> Callstack {
Callstack {
calls: Vec::new(),
cached_callstack_id: None,
}
}
pub fn from_vec(vec: Vec<CallSiteId>) -> Self {
Self {
calls: vec,
cached_callstack_id: None,
}
}
pub fn to_vec(&self) -> Vec<CallSiteId> {
self.calls.clone()
}
pub fn start_call(&mut self, parent_line_number: u32, callsite_id: CallSiteId) {
if parent_line_number != 0 {
if let Some(mut call) = self.calls.last_mut() {
call.line_number = LineNumberInfo::LineNumber(parent_line_number);
}
}
self.calls.push(callsite_id);
self.cached_callstack_id = None;
}
pub fn finish_call(&mut self) {
self.calls.pop();
self.cached_callstack_id = None;
}
pub fn id_for_new_allocation<F>(&mut self, line_number: u32, get_callstack_id: F) -> CallstackId
where
F: FnOnce(&Callstack) -> CallstackId,
{
// If same line number as last callstack, and we have cached callstack
// ID, reuse it:
if let Some((previous_line_number, callstack_id)) = self.cached_callstack_id {
if line_number == previous_line_number {
return callstack_id;
}
}
// Set the new line number:
if line_number != 0 {
if let Some(call) = self.calls.last_mut() {
call.line_number = LineNumberInfo::LineNumber(line_number);
}
}
// Calculate callstack ID, cache it, and then return it;
let callstack_id = get_callstack_id(self);
self.cached_callstack_id = Some((line_number, callstack_id));
callstack_id
}
pub fn as_string<FL: ReadFunctionLocations>(
&self,
to_be_post_processed: bool,
functions: &FL,
separator: &'static str,
linecache: &mut LineCacher,
) -> String {
if self.calls.is_empty() {
return "[No Python stack]".to_string();
}
let calls: Vec<(CallSiteId, (&str, &str, &str))> = self
.calls
.iter()
.map(|id| {
(
*id,
functions.get_function_and_filename_and_display_filename(id.function),
)
})
.collect();
let skip_prefix = if cfg!(feature = "fil4prod") {
0
} else {
// Due to implementation details we have some runpy() frames at the
// start; remove them.
runpy_prefix_length(calls.iter())
};
calls
.into_iter()
.skip(skip_prefix)
.map(|(id, (function, filename, display_filename))| {
if to_be_post_processed {
// Get Python code.
let code = linecache
.get_source_line(filename, id.line_number.get_line_number() as usize);
// Leading whitespace is dropped by SVG, so we'd like to
// replace it with non-breaking space. However, inferno
// trims whitespace
// (https://github.com/jonhoo/inferno/blob/de3f7d94d4718bfee57655c1fddd4d2714bc78d0/src/flamegraph/merge.rs#L126)
// and that causes incorrect "unsorted lines" errors
// which I can't be bothered to fix right now, so for
// now do hack where we shove in some other character
// that can be fixed in post-processing.
let code = code.trim_end().replace(' ', "\u{12e4}");
// Tabs == 8 spaces in Python.
let code = code.replace(
'\t',
"\u{12e4}\u{12e4}\u{12e4}\u{12e4}\u{12e4}\u{12e4}\u{12e4}\u{12e4}",
);
// Semicolons are used as separator in the flamegraph
// input format, so need to replace them with some other
// character. We use "full-width semicolon", and then
// replace it back in post-processing.
let code = code.replace(';', "\u{ff1b}");
// The \u{2800} is to ensure we don't have empty lines,
// and that whitespace doesn't get trimmed from start;
// we'll get rid of this in post-processing.
format!(
"{display_filename}:{line} ({function});\u{2800}{code}",
display_filename = display_filename,
line = id.line_number.get_line_number(),
function = function,
code = &code.trim_end(),
)
} else {
format!(
"{display_filename}:{line} ({function})",
display_filename = display_filename,
line = id.line_number.get_line_number(),
function = function,
)
}
})
.join(separator)
}
}
fn runpy_prefix_length(calls: std::slice::Iter<(CallSiteId, (&str, &str, &str))>) -> usize {
let mut length = 0;
let runpy_path = get_runpy_path();
for (_, (_, filename, _)) in calls {
// On Python 3.11 it uses <frozen runpy> for some reason.
if *filename == runpy_path || *filename == "<frozen runpy>" {
length += 1;
} else {
return length;
}
}
0
}
pub type CallstackId = u32;
/// Maps Functions to integer identifiers used in CallStacks.
pub struct CallstackInterner {
max_id: CallstackId,
callstack_to_id: HashMap<Callstack, u32, ARandomState>,
}
impl CallstackInterner {
pub fn new() -> Self {
CallstackInterner {
max_id: 0,
callstack_to_id: new_hashmap(),
}
}
/// Add a (possibly) new Function, returning its ID.
pub fn get_or_insert_id<F: FnOnce()>(
&mut self,
callstack: Cow<Callstack>,
call_on_new: F,
) -> CallstackId {
let max_id = &mut self.max_id;
if let Some(result) = self.callstack_to_id.get(&*callstack) {
*result
} else {
let new_id = *max_id;
*max_id += 1;
self.callstack_to_id.insert(callstack.into_owned(), new_id);
call_on_new();
new_id
}
}
/// Get map from IDs to Callstacks.
fn get_reverse_map(&self) -> HashMap<CallstackId, &Callstack, ARandomState> {
let mut result = new_hashmap();
for (call_site, csid) in self.callstack_to_id.iter() {
result.insert(*csid, call_site);
}
result
}
}
const MIB: usize = 1024 * 1024;
const HIGH_32BIT: u32 = 1 << 31;
/// A unique identifier for a process.
#[derive(Clone, Copy, Debug, PartialEq, Ord, PartialOrd, Eq, Serialize, Deserialize)]
#[serde(transparent)]
pub struct ProcessUid(pub u32);
pub const PARENT_PROCESS: ProcessUid = ProcessUid(0);
/// A specific call to malloc()/calloc().
#[derive(Clone, Copy, Debug, PartialEq)]
struct Allocation {
callstack_id: CallstackId,
// If high bit is set, this is MiBs (without the high bit being meaningful).
// Otherwise, it's bytes. We only store MiBs for allocations larger than 2
// ** 31 bytes (2GB), which means the loss of resolution isn't meaningful.
// This compression allows us to reduce memory overhead from tracking
// allocations.
compressed_size: u32,
}
impl Allocation {
fn new(callstack_id: CallstackId, size: usize) -> Self {
let compressed_size = if size >= HIGH_32BIT as usize {
// Rounding division by MiB, plus the high bit:
(((size + MIB / 2) / MIB) as u32) | HIGH_32BIT
} else {
size as u32
};
Allocation {
callstack_id,
compressed_size,
}
}
fn size(&self) -> usize {
if self.compressed_size >= HIGH_32BIT {
(self.compressed_size - HIGH_32BIT) as usize * MIB
} else {
self.compressed_size as usize
}
}
}
/// A CallstackCleaner that leaves the callstack unchanged.
pub struct IdentityCleaner;
impl CallstackCleaner for IdentityCleaner {
fn cleanup<'a>(&self, callstack: &'a Callstack) -> Cow<'a, Callstack> {
Cow::Borrowed(callstack)
}
}
/// The main data structure tracking everything.
pub struct AllocationTracker<FL: WriteFunctionLocations> {
// malloc()/calloc():
current_allocations: BTreeMap<ProcessUid, HashMap<usize, Allocation, ARandomState>>,
// anonymous mmap(), i.e. not file backed:
current_anon_mmaps: BTreeMap<ProcessUid, RangeMap<CallstackId>>,
// Map FunctionIds to function + filename strings, so we can store the
// former and save memory.
pub functions: FL,
// Map CallstackIds to Callstacks, so we can store the former and save
// memory:
interner: CallstackInterner,
// Both malloc() and mmap():
current_memory_usage: ImVector<usize>, // Map CallstackId -> total memory usage
peak_memory_usage: ImVector<usize>, // Map CallstackId -> total memory usage
current_allocated_bytes: usize,
peak_allocated_bytes: usize,
// Default directory to write out data lacking other info:
pub default_path: String,
// Allocations that somehow disappeared. Not relevant for sampling profiler.
missing_allocated_bytes: usize,
// free()/realloc() of unknown address. Not relevant for sampling profiler.
failed_deallocations: usize,
}
impl<FL: WriteFunctionLocations> AllocationTracker<FL> {
pub fn new(default_path: String, functions: FL) -> AllocationTracker<FL> {
AllocationTracker {
current_allocations: BTreeMap::from([(PARENT_PROCESS, new_hashmap())]),
current_anon_mmaps: BTreeMap::from([(PARENT_PROCESS, RangeMap::new())]),
interner: CallstackInterner::new(),
current_memory_usage: ImVector::new(),
peak_memory_usage: ImVector::new(),
functions,
current_allocated_bytes: 0,
peak_allocated_bytes: 0,
missing_allocated_bytes: 0,
failed_deallocations: 0,
default_path,
}
}
/// Print a traceback for the given CallstackId.
///
/// Should only be used with VecFunctionLocations, may cause deadlocks with
/// others...
fn print_traceback(&self, message: &'static str, callstack_id: CallstackId) {
let id_to_callstack = self.interner.get_reverse_map();
let callstack = id_to_callstack[&callstack_id];
eprintln!("=fil-profile= {}", message);
eprintln!(
"=| {}",
callstack.as_string(
false,
&self.functions.cheap_clone().to_reader(),
"\n=| ",
&mut LineCacher::default()
)
);
}
pub fn get_current_allocated_bytes(&self) -> usize {
self.current_allocated_bytes
}
pub fn get_peak_allocated_bytes(&self) -> usize {
self.peak_allocated_bytes
}
pub fn get_allocation_size(&self, process: ProcessUid, address: usize) -> usize {
if let Some(allocation) = self
.current_allocations
.get(&process)
.map(|a| a.get(&address))
.flatten()
{
allocation.size()
} else {
0
}
}
/// Check if a new peak has been reached:
pub fn check_if_new_peak(&mut self) {
if self.current_allocated_bytes > self.peak_allocated_bytes {
self.peak_allocated_bytes = self.current_allocated_bytes;
self.peak_memory_usage
.clone_from(&self.current_memory_usage);
}
}
fn add_memory_usage(&mut self, callstack_id: CallstackId, bytes: usize) {
self.current_allocated_bytes += bytes;
let index = callstack_id as usize;
self.current_memory_usage[index] += bytes;
}
fn remove_memory_usage(&mut self, callstack_id: CallstackId, bytes: usize) {
self.current_allocated_bytes -= bytes;
let index = callstack_id as usize;
// TODO what if goes below zero? add a check I guess, in case of bugs.
self.current_memory_usage[index] -= bytes;
}
pub fn get_callstack_id(&mut self, callstack: &Callstack) -> CallstackId {
let current_memory_usage = &mut self.current_memory_usage;
self.interner
.get_or_insert_id(Cow::Borrowed(callstack), || {
current_memory_usage.push_back(0)
})
}
/// Add a new allocation based off the current callstack.
pub fn add_allocation(
&mut self,
process: ProcessUid,
address: usize,
size: usize,
callstack_id: CallstackId,
) {
let alloc = Allocation::new(callstack_id, size);
let compressed_size = alloc.size();
if let Some(previous) = self
.current_allocations
.entry(process)
.or_default()
.insert(address, alloc)
{
// In production use (proposed commercial product) allocations are
// only sampled, so missing allocations are common and not the sign
// of an error.
#[cfg(not(feature = "fil4prod"))]
{
// I've seen this happen on macOS only in some threaded code
// (malloc_on_thread_exit test). Not sure why, but difference was
// only 16 bytes, which shouldn't have real impact on profiling
// outcomes. Apparently also happening on Linux, hope to fix this
// soon (https://github.com/pythonspeed/filprofiler/issues/149).
self.missing_allocated_bytes += previous.size();
// Cleanup the previous allocation, since we never saw its free():
self.remove_memory_usage(previous.callstack_id, previous.size());
if *crate::util::DEBUG_MODE {
self.print_traceback(
"The allocation from this traceback disappeared:",
previous.callstack_id,
);
self.print_traceback(
"The current traceback that overwrote the disappearing allocation:",
alloc.callstack_id,
);
eprintln!(
"|= The current C/Rust backtrace: {:?}",
backtrace::Backtrace::new()
);
}
}
}
self.add_memory_usage(callstack_id, compressed_size as usize);
}
/// Free an existing allocation, return how much was removed, if any.
pub fn free_allocation(&mut self, process: ProcessUid, address: usize) -> Option<usize> {
// Before we reduce memory, let's check if we've previously hit a peak:
self.check_if_new_peak();
if let Some(removed) = self
.current_allocations
.entry(process)
.or_default()
.remove(&address)
{
self.remove_memory_usage(removed.callstack_id, removed.size());
Some(removed.size())
} else {
// This allocation doesn't exist; often this will be something
// allocated before Fil tracking was started, but it might also be a
// bug.
#[cfg(not(feature = "fil4prod"))]
if *crate::util::DEBUG_MODE {
self.failed_deallocations += 1;
eprintln!(
"=fil-profile= Your program attempted to free an allocation at an address we don't know about:"
);
eprintln!("=| {:?}", backtrace::Backtrace::new());
}
None
}
}
/// Add a new anonymous mmap() based of the current callstack.
pub fn add_anon_mmap(
&mut self,
process: ProcessUid,
address: usize,
size: usize,
callstack_id: CallstackId,
) {
self.current_anon_mmaps
.entry(process)
.or_default()
.add(address, size, callstack_id);
self.add_memory_usage(callstack_id, size);
}
pub fn free_anon_mmap(&mut self, process: ProcessUid, address: usize, size: usize) {
// Before we reduce memory, let's check if we've previously hit a peak:
self.check_if_new_peak();
// Now remove, and update totoal memory tracking:
for (callstack_id, removed) in self
.current_anon_mmaps
.entry(process)
.or_default()
.remove(address, size)
{
self.remove_memory_usage(callstack_id, removed);
}
}
/// The process just died, remove all the allocations.
pub fn drop_process(&mut self, process: ProcessUid) {
// Before we reduce memory, let's check if we've previously hit a peak:
self.check_if_new_peak();
// Drop anon mmaps, call remove_memory_usage on all entries.
if let Some(mmaps_for_process) = self.current_anon_mmaps.remove(&process) {
for (size, callstack_id) in mmaps_for_process.into_iter() {
self.remove_memory_usage(callstack_id, size);
}
}
// Drop allocations, call remove_memory_usage on all entries.
if let Some(allocations_for_process) = self.current_allocations.remove(&process) {
for allocation in allocations_for_process.values() {
self.remove_memory_usage(allocation.callstack_id, allocation.size());
}
}
}
/// Combine Callstacks and make them human-readable. Duplicate callstacks
/// have their allocated memory summed.
///
/// We don't return the FlamegraphCallstacks, but rather a factory, because
/// we don't want to hold any locks while doing any potentially expensive
/// WriteFunctionLocations->ReadFunctionLocations conversion; by returning a
/// factory, that can be appropriately delayed by the caller.
pub fn combine_callstacks<CC: CallstackCleaner>(
&mut self,
// If false, will do the current allocations:
peak: bool,
callstack_cleaner: CC,
) -> impl FnOnce() -> FlamegraphCallstacks<HashMap<Callstack, usize, ARandomState>, FL::Reader, CC>
{
// Would be nice to validate if data is consistent. However, there are
// edge cases that make it slightly inconsistent (e.g. see the
// unexpected code path in add_allocation() above), and blowing up
// without giving the user their data just because of a small
// inconsistency doesn't seem ideal. Perhaps if validate() merely
// reported problems, or maybe validate() should only be enabled in
// development mode.
//self.validate();
// We get a LOT of tiny allocations. To reduce overhead of creating
// flamegraph (which currently loads EVERYTHING into memory), just do
// the top 99% of allocations.
let callstacks = if peak {
self.check_if_new_peak();
&self.peak_memory_usage
} else {
&self.current_memory_usage
};
let sum = callstacks.iter().sum();
let id_to_callstack = self.interner.get_reverse_map();
let data = filter_to_useful_callstacks(callstacks.iter().enumerate(), sum)
.into_iter()
.filter_map(|(k, v)| {
id_to_callstack
.get(&(k as CallstackId))
.map(|cs| ((**cs).clone(), v))
})
.collect();
let functions_writer = self.functions.cheap_clone();
// Return a closure, so we can delay doing the ReadFunctionLocations
// conversion if necessary:
|| FlamegraphCallstacks::new(data, functions_writer.to_reader(), callstack_cleaner)
}
/// Clear memory we won't be needing anymore, since we're going to exit out.
pub fn oom_break_glass(&mut self) {
self.current_allocations.clear();
self.peak_memory_usage.clear();
}
/// Validate internal state is in a good state. This won't pass until
/// check_if_new_peak() is called.
fn validate(&self) {
assert!(self.peak_allocated_bytes >= self.current_allocated_bytes);
let current_allocations: usize = self
.current_anon_mmaps
.values()
.map(|maps| maps.size())
.sum::<usize>()
+ self
.current_allocations
.values()
.flat_map(|allocs| allocs.iter())
.map(|(_, alloc)| alloc.size())
.sum::<usize>();
assert!(
current_allocations == self.current_allocated_bytes,
"{} != {}",
current_allocations,
self.current_allocated_bytes
);
assert!(self.current_memory_usage.iter().sum::<usize>() == self.current_allocated_bytes);
assert!(self.peak_memory_usage.iter().sum::<usize>() == self.peak_allocated_bytes);
}
/// Warn of untracked allocations; only relevant if you are profiling _all_
/// allocations, i.e. Fil but not Sciagraph.
pub fn warn_on_problems(&self, peak: bool) {
let allocated_bytes = if peak {
self.get_peak_allocated_bytes()
} else {
self.get_current_allocated_bytes()
};
if self.missing_allocated_bytes > 0 {
eprintln!("=fil-profile= WARNING: {:.2}% ({} bytes) of tracked memory somehow disappeared. If this is a small percentage you can just ignore this warning, since the missing allocations won't impact the profiling results. If the % is high, please run `export FIL_DEBUG=1` to get more output', re-run Fil on your script, and then file a bug report at https://github.com/pythonspeed/filprofiler/issues/new", self.missing_allocated_bytes as f64 * 100.0 / allocated_bytes as f64, self.missing_allocated_bytes);
}
if self.failed_deallocations > 0 {
eprintln!("=fil-profile= WARNING: Encountered {} deallocations of untracked allocations. A certain number are expected in normal operation, of allocations created before Fil started tracking, and even more if you're using the Fil API to turn tracking on and off.", self.failed_deallocations);
}
}
/// Reset internal state in way that doesn't invalidate e.g. thread-local
/// caching of callstack ID.
pub fn reset(&mut self, default_path: String) {
self.current_allocations.clear();
self.current_anon_mmaps = BTreeMap::from([(PARENT_PROCESS, RangeMap::new())]);
for i in self.current_memory_usage.iter_mut() {
*i = 0;
}
self.peak_memory_usage = ImVector::new();
self.current_allocated_bytes = 0;
self.peak_allocated_bytes = 0;
self.default_path = default_path;
self.validate();
}
}
#[cfg(test)]
mod tests {
use crate::memorytracking::{
IdentityCleaner, ProcessUid, ReadFunctionLocations, WriteFunctionLocations, PARENT_PROCESS,
};
use super::LineNumberInfo::LineNumber;
use super::{
Allocation, AllocationTracker, CallSiteId, Callstack, CallstackInterner, FunctionId,
VecFunctionLocations, HIGH_32BIT, MIB,
};
use proptest::prelude::*;
use std::borrow::Cow;
use std::collections::HashMap;
fn new_tracker() -> AllocationTracker<VecFunctionLocations> {
AllocationTracker::new(".".to_string(), VecFunctionLocations::new())
}
proptest! {
// Allocation sizes smaller than 2 ** 31 are round-tripped.
#[test]
fn small_allocation(size in 0..(HIGH_32BIT - 1)) {
let allocation = Allocation::new(0, size as usize);
prop_assert_eq!(size as usize, allocation.size());
}
// Allocation sizes larger than 2 ** 31 are stored as MiBs, with some
// loss of resolution.
#[test]
fn large_allocation(size in (HIGH_32BIT as usize)..(1 << 50)) {
let allocation = Allocation::new(0, size as usize);
let result_size = allocation.size();
let diff = if size < result_size {
result_size - size
} else {
size - result_size
};
prop_assert!(diff <= MIB / 2)
}
// Test for https://github.com/pythonspeed/filprofiler/issues/66
#[test]
fn correct_allocation_size_tracked(size in (1 as usize)..(1<< 50)) {
let mut tracker = new_tracker();
let cs_id = tracker.get_callstack_id(&Callstack::new());
tracker.add_allocation(PARENT_PROCESS, 0, size, cs_id);
tracker.add_anon_mmap(PARENT_PROCESS, 1, size * 2, cs_id);
// We don't track (large) allocations exactly right, but they should
// be quite close:
let ratio = ((size * 3) as f64) / (tracker.current_memory_usage[0] as f64);
prop_assert!(0.999 < ratio);
prop_assert!(ratio < 1.001);
tracker.free_allocation(PARENT_PROCESS, 0);
tracker.free_anon_mmap(PARENT_PROCESS, 1, size * 2);
// Once we've freed everything, it should be _exactly_ 0.
prop_assert_eq!(&im::vector![0], &tracker.current_memory_usage);
tracker.check_if_new_peak();
tracker.validate();
}
#[test]
fn current_allocated_matches_sum_of_allocations(
// Allocated bytes. Will use index as the memory address.
allocated_sizes in prop::collection::vec((0..2 as u32, 1..100 as usize), 10..20),
// Allocations to free.
free_indices in prop::collection::btree_set(0..10 as usize, 1..5)
) {
let mut tracker = new_tracker();
let mut expected_memory_usage = im::vector![];
for i in 0..allocated_sizes.len() {
let (process, allocation_size) = *allocated_sizes.get(i).unwrap();
let process = ProcessUid(process);
let mut cs = Callstack::new();
cs.start_call(0, CallSiteId::new(FunctionId::new(i as u64), LineNumber(0)));
let cs_id = tracker.get_callstack_id(&cs);
tracker.add_allocation(process, i as usize, allocation_size, cs_id);
expected_memory_usage.push_back(allocation_size);
}
let mut expected_sum = allocated_sizes.iter().map(|t| t.1).sum();
let expected_peak : usize = expected_sum;
prop_assert_eq!(tracker.current_allocated_bytes, expected_sum);
prop_assert_eq!(&tracker.current_memory_usage, &expected_memory_usage);
for i in free_indices.iter() {
let (process, expected_removed) = allocated_sizes.get(*i).unwrap();
let process = ProcessUid(*process);
expected_sum -= expected_removed;
let removed = tracker.free_allocation(process, *i);
prop_assert_eq!(removed, Some(*expected_removed));
expected_memory_usage[*i] -= expected_removed;
prop_assert_eq!(tracker.current_allocated_bytes, expected_sum);
prop_assert_eq!(&tracker.current_memory_usage, &expected_memory_usage);
}
prop_assert_eq!(tracker.peak_allocated_bytes, expected_peak);
tracker.check_if_new_peak();
tracker.validate();
}
#[test]
fn current_allocated_anon_maps_matches_sum_of_allocations(
// Allocated bytes. Will use index as the memory address.
allocated_sizes in prop::collection::vec((0..2 as u32, 1..100 as usize), 10..20),
// Allocations to free.
free_indices in prop::collection::btree_set(0..10 as usize, 1..5)
) {
let mut tracker = new_tracker();
let mut expected_memory_usage = im::vector![];
// Make sure addresses don't overlap:
let addresses : Vec<usize> = (0..allocated_sizes.len()).map(|i| i * 10000).collect();
for i in 0..allocated_sizes.len() {
let (process, allocation_size) = *allocated_sizes.get(i).unwrap();
let process = ProcessUid(process);
let mut cs = Callstack::new();
cs.start_call(0, CallSiteId::new(FunctionId::new(i as u64), LineNumber(0)));
let csid = tracker.get_callstack_id(&cs);
tracker.add_anon_mmap(process, addresses[i] as usize, allocation_size, csid);
expected_memory_usage.push_back(allocation_size);
}
let mut expected_sum = allocated_sizes.iter().map(|t|t.1).sum();
let expected_peak : usize = expected_sum;
prop_assert_eq!(tracker.current_allocated_bytes, expected_sum);
prop_assert_eq!(&tracker.current_memory_usage, &expected_memory_usage);
for i in free_indices.iter() {
let (process, allocation_size) = *allocated_sizes.get(*i).unwrap();
let process = ProcessUid(process);
expected_sum -= allocation_size;
tracker.free_anon_mmap(process, addresses[*i], allocation_size);
expected_memory_usage[*i] -= allocation_size;
prop_assert_eq!(tracker.current_allocated_bytes, expected_sum);
prop_assert_eq!(&tracker.current_memory_usage, &expected_memory_usage);
}
prop_assert_eq!(tracker.peak_allocated_bytes, expected_peak);
tracker.check_if_new_peak();
tracker.validate();
}
#[test]
fn drop_process_removes_that_process_allocations_and_mmaps(
// Allocated bytes. Will use index as the memory address.
allocated_sizes in prop::collection::vec((0..2 as u32, 1..100 as usize), 10..20),
allocated_mmaps in prop::collection::vec((0..2 as u32, 1..100 as usize), 10..20),
) {
let mut tracker = new_tracker();
let mut expected_memory_usage : usize = 0;
// Make sure addresses don't overlap:
let mmap_addresses : Vec<usize> = (0..allocated_mmaps.len()).map(|i| i * 10000).collect();
for i in 0..allocated_sizes.len() {
let (process, allocation_size) = *allocated_sizes.get(i).unwrap();
let process = ProcessUid(process);
let mut cs = Callstack::new();
cs.start_call(0, CallSiteId::new(FunctionId::new(i as u64), LineNumber(0)));
let cs_id = tracker.get_callstack_id(&cs);
tracker.add_allocation(process, i as usize, allocation_size, cs_id);
expected_memory_usage += allocation_size;
}
for i in 0..allocated_mmaps.len() {
let (process, allocation_size) = *allocated_mmaps.get(i).unwrap();
let process = ProcessUid(process);
let mut cs = Callstack::new();
cs.start_call(0, CallSiteId::new(FunctionId::new(i as u64), LineNumber(0)));
let csid = tracker.get_callstack_id(&cs);
tracker.add_anon_mmap(process, mmap_addresses[i] as usize, allocation_size, csid);
expected_memory_usage += allocation_size;
}
prop_assert_eq!(tracker.current_allocated_bytes, expected_memory_usage);
let expected_peak = expected_memory_usage;
let to_drop = ProcessUid(1);
tracker.drop_process(to_drop);
expected_memory_usage -= allocated_sizes.iter().filter(|(p, _)| ProcessUid(*p) == to_drop).map(|(_, size)| size).sum::<usize>();
expected_memory_usage -= allocated_mmaps.iter().filter(|(p, _)| ProcessUid(*p) == to_drop).map(|(_, size)| size).sum::<usize>();
prop_assert_eq!(tracker.current_allocated_bytes, expected_memory_usage);
prop_assert_eq!(tracker.peak_allocated_bytes, expected_peak);
tracker.check_if_new_peak();
tracker.validate();
}
}
#[test]
fn untracked_allocation_removal() {
let mut tracker = new_tracker();
assert_eq!(tracker.free_allocation(PARENT_PROCESS, 123), None);
}
#[test]
fn callstack_line_numbers() {
let fid1 = FunctionId::new(1u64);
let fid3 = FunctionId::new(3u64);
let fid5 = FunctionId::new(5u64);
// Parent line number does nothing if it's first call:
let mut cs1 = Callstack::new();
// CallSiteId::new($a, $b) ==>> CallSiteId::new($a, LineNumber($b))
let id1 = CallSiteId::new(fid1, LineNumber(2));
let id2 = CallSiteId::new(fid3, LineNumber(45));
let id3 = CallSiteId::new(fid5, LineNumber(6));
cs1.start_call(123, id1);
assert_eq!(cs1.calls, vec![id1]);
// Parent line number does nothing if it's 0:
cs1.start_call(0, id2);
assert_eq!(cs1.calls, vec![id1, id2]);
// Parent line number overrides previous level if it's non-0:
let mut cs2 = Callstack::new();
cs2.start_call(0, id1);
cs2.start_call(10, id2);
cs2.start_call(12, id3);
assert_eq!(
cs2.calls,
vec![
CallSiteId::new(fid1, LineNumber(10)),
CallSiteId::new(fid3, LineNumber(12)),
id3
]
);
}
#[test]
fn callstackinterner_notices_duplicates() {
let fid1 = FunctionId::new(1u64);
let fid3 = FunctionId::new(3u64);
let mut cs1 = Callstack::new();
cs1.start_call(0, CallSiteId::new(fid1, LineNumber(2)));
let cs1b = cs1.clone();
let mut cs2 = Callstack::new();
cs2.start_call(0, CallSiteId::new(fid3, LineNumber(4)));
let cs3 = Callstack::new();
let cs3b = Callstack::new();
let mut interner = CallstackInterner::new();
let mut new = false;
let id1 = interner.get_or_insert_id(Cow::Borrowed(&cs1), || new = true);
assert!(new);
new = false;
let id1b = interner.get_or_insert_id(Cow::Borrowed(&cs1b), || new = true);
assert!(!new);
new = false;
let id2 = interner.get_or_insert_id(Cow::Borrowed(&cs2), || new = true);
assert!(new);
new = false;
let id3 = interner.get_or_insert_id(Cow::Borrowed(&cs3), || new = true);
assert!(new);
new = false;
let id3b = interner.get_or_insert_id(Cow::Borrowed(&cs3b), || new = true);
assert!(!new);
assert_eq!(id1, id1b);
assert_ne!(id1, id2);
assert_ne!(id1, id3);
assert_ne!(id2, id3);
assert_eq!(id3, id3b);
let mut expected = HashMap::default();
expected.insert(id1, &cs1);
expected.insert(id2, &cs2);
expected.insert(id3, &cs3);
assert_eq!(interner.get_reverse_map(), expected);
}
#[test]
fn callstack_id_for_new_allocation() {
let mut interner = CallstackInterner::new();
let mut cs1 = Callstack::new();
let id0 =
cs1.id_for_new_allocation(0, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
let id0b =
cs1.id_for_new_allocation(0, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_eq!(id0, id0b);
let fid1 = FunctionId::new(1u64);
cs1.start_call(0, CallSiteId::new(fid1, LineNumber(2)));
let id1 =
cs1.id_for_new_allocation(1, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
let id2 =
cs1.id_for_new_allocation(2, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
let id1b =
cs1.id_for_new_allocation(1, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_eq!(id1, id1b);
assert_ne!(id2, id0);
assert_ne!(id2, id1);
cs1.start_call(3, CallSiteId::new(fid1, LineNumber(2)));
let id3 =
cs1.id_for_new_allocation(4, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_ne!(id3, id0);
assert_ne!(id3, id1);
assert_ne!(id3, id2);
cs1.finish_call();
let id2b =
cs1.id_for_new_allocation(2, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_eq!(id2, id2b);
let id1c =
cs1.id_for_new_allocation(1, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_eq!(id1, id1c);
// Check for cache invalidation in start_call:
cs1.start_call(1, CallSiteId::new(fid1, LineNumber(1)));
let id4 =
cs1.id_for_new_allocation(1, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_ne!(id4, id0);
assert_ne!(id4, id1);
assert_ne!(id4, id2);
assert_ne!(id4, id3);
// Check for cache invalidation in finish_call:
cs1.finish_call();
let id1d =
cs1.id_for_new_allocation(1, |cs| interner.get_or_insert_id(Cow::Borrowed(&cs), || ()));
assert_eq!(id1, id1d);
}
#[test]
fn peak_allocations_only_updated_on_new_peaks() {
let fid1 = FunctionId::new(1u64);
let fid3 = FunctionId::new(3u64);
let mut tracker = new_tracker();
let mut cs1 = Callstack::new();
cs1.start_call(0, CallSiteId::new(fid1, LineNumber(2)));
let mut cs2 = Callstack::new();
cs2.start_call(0, CallSiteId::new(fid3, LineNumber(4)));
let cs1_id = tracker.get_callstack_id(&cs1);
tracker.add_allocation(PARENT_PROCESS, 1, 1000, cs1_id);
tracker.check_if_new_peak();
// Peak should now match current allocations:
assert_eq!(tracker.current_memory_usage, im::vector![1000]);
assert_eq!(tracker.current_memory_usage, tracker.peak_memory_usage);
assert_eq!(tracker.peak_allocated_bytes, 1000);
let previous_peak = tracker.peak_memory_usage.clone();
// Free the allocation:
tracker.free_allocation(PARENT_PROCESS, 1);
assert_eq!(tracker.current_allocated_bytes, 0);
assert_eq!(tracker.current_memory_usage, im::vector![0]);
assert_eq!(previous_peak, tracker.peak_memory_usage);
assert_eq!(tracker.peak_allocated_bytes, 1000);
// Add allocation, still less than 1000:
tracker.add_allocation(PARENT_PROCESS, 3, 123, cs1_id);
assert_eq!(tracker.current_memory_usage, im::vector![123]);
tracker.check_if_new_peak();
assert_eq!(previous_peak, tracker.peak_memory_usage);
assert_eq!(tracker.peak_allocated_bytes, 1000);
// Add allocation that goes past previous peak
let cs2_id = tracker.get_callstack_id(&cs2);
tracker.add_allocation(PARENT_PROCESS, 2, 2000, cs2_id);
tracker.check_if_new_peak();
assert_eq!(tracker.current_memory_usage, im::vector![123, 2000]);
assert_eq!(tracker.current_memory_usage, tracker.peak_memory_usage);
assert_eq!(tracker.peak_allocated_bytes, 2123);
let previous_peak = tracker.peak_memory_usage.clone();
// Add anonymous mmap() that doesn't go past previous peak:
tracker.free_allocation(PARENT_PROCESS, 2);
assert_eq!(tracker.current_memory_usage, im::vector![123, 0]);
tracker.add_anon_mmap(PARENT_PROCESS, 50000, 1000, cs2_id);
assert_eq!(tracker.current_memory_usage, im::vector![123, 1000]);
tracker.check_if_new_peak();
assert_eq!(tracker.current_allocated_bytes, 1123);
assert_eq!(tracker.peak_allocated_bytes, 2123);
assert_eq!(tracker.peak_memory_usage, previous_peak);
assert_eq!(tracker.current_allocations.len(), 1);
assert!(tracker.current_allocations[&PARENT_PROCESS].contains_key(&3));
assert!(tracker.current_anon_mmaps[&PARENT_PROCESS].size() > 0);
// Add anonymous mmap() that does go past previous peak:
tracker.add_anon_mmap(PARENT_PROCESS, 600000, 2000, cs2_id);
assert_eq!(tracker.current_memory_usage, im::vector![123, 3000]);
tracker.check_if_new_peak();
assert_eq!(tracker.current_memory_usage, tracker.peak_memory_usage);
assert_eq!(tracker.current_allocated_bytes, 3123);
assert_eq!(tracker.peak_allocated_bytes, 3123);
// Remove mmap():
tracker.free_anon_mmap(PARENT_PROCESS, 50000, 1000);
assert_eq!(tracker.current_memory_usage, im::vector![123, 2000]);
tracker.check_if_new_peak();
assert_eq!(tracker.current_allocated_bytes, 2123);
assert_eq!(tracker.peak_allocated_bytes, 3123);
assert_eq!(tracker.current_anon_mmaps[&PARENT_PROCESS].size(), 2000);
assert!(tracker.current_anon_mmaps[&PARENT_PROCESS]
.as_hashmap()
.contains_key(&600000));
// Partial removal of anonmyous mmap():
tracker.free_anon_mmap(PARENT_PROCESS, 600100, 1000);
assert_eq!(tracker.current_memory_usage, im::vector![123, 1000]);
assert_eq!(tracker.current_allocated_bytes, 1123);
assert_eq!(tracker.peak_allocated_bytes, 3123);
assert_eq!(tracker.current_anon_mmaps[&PARENT_PROCESS].size(), 1000);
tracker.check_if_new_peak();
tracker.validate();
}
#[test]
fn combine_callstacks_and_sum_allocations() {
pyo3::prepare_freethreaded_python();
let mut tracker = new_tracker();
let fid1 = tracker
.functions
.add_function("a".to_string(), "af".to_string());
let fid2 = tracker
.functions
.add_function("b".to_string(), "bf".to_string());
let fid3 = tracker
.functions
.add_function("c".to_string(), "cf".to_string());
let id1 = CallSiteId::new(fid1, LineNumber(1));
// Same function, different line number—should be different item:
let id1_different = CallSiteId::new(fid1, LineNumber(7));
let id2 = CallSiteId::new(fid2, LineNumber(2));
let id3 = CallSiteId::new(fid3, LineNumber(3));
let mut cs1 = Callstack::new();
cs1.start_call(0, id1);
cs1.start_call(0, id2.clone());
let mut cs2 = Callstack::new();
cs2.start_call(0, id3);
let mut cs3 = Callstack::new();
cs3.start_call(0, id1_different);
cs3.start_call(0, id2);
let cs1_id = tracker.get_callstack_id(&cs1);
let cs2_id = tracker.get_callstack_id(&cs2);
let cs3_id = tracker.get_callstack_id(&cs3);
tracker.add_allocation(PARENT_PROCESS, 1, 1000, cs1_id);
tracker.add_allocation(PARENT_PROCESS, 2, 234, cs2_id);
tracker.add_anon_mmap(PARENT_PROCESS, 3, 50000, cs1_id);
tracker.add_allocation(PARENT_PROCESS, 4, 6000, cs3_id);
// Make sure we notice new peak.
tracker.check_if_new_peak();
// 234 allocation is too small, below the 99% total allocations
// threshold, but we always guarantee at least 100 allocations.
// TODO figure out how to test this...
// let mut expected = vec![
// "a:1 (af);TB@@a:1@@TB;b:2 (bf);TB@@b:2@@TB 51000".to_string(),
// "c:3 (cf);TB@@c:3@@TB 234".to_string(),
// "a:7 (af);TB@@a:7@@TB;b:2 (bf);TB@@b:2@@TB 6000".to_string(),
// ];
// let mut result: Vec<String> = tracker.to_lines(true, true).collect();
// result.sort();
// expected.sort();
// assert_eq!(expected, result);
let mut expected2 = vec![
"a:1 (af);b:2 (bf) 51000",
"c:3 (cf) 234",
"a:7 (af);b:2 (bf) 6000",
];
let mut result2: Vec<String> = tracker.combine_callstacks(true, IdentityCleaner)()
.to_lines(false)
.collect();
result2.sort();
expected2.sort();
assert_eq!(expected2, result2);
}
#[test]
fn test_unknown_function_id() {
let func_locations = VecFunctionLocations::new().to_reader();
let (function, filename, display_filename) =
func_locations.get_function_and_filename_and_display_filename(FunctionId::UNKNOWN);
assert_eq!(display_filename, "UNKNOWN DUE TO BUG");
assert_eq!(filename, "UNKNOWN");
assert_eq!(function, "UNKNOWN");
}
// TODO test to_lines(false)
}
|
use super::gc_work::*;
use super::GenCopy;
use crate::plan::barriers::*;
use crate::plan::mutator_context::Mutator;
use crate::plan::mutator_context::MutatorConfig;
use crate::plan::AllocationSemantics as AllocationType;
use crate::util::alloc::allocators::{AllocatorSelector, Allocators};
use crate::util::alloc::BumpAllocator;
use crate::util::OpaquePointer;
use crate::vm::VMBinding;
use crate::MMTK;
use enum_map::enum_map;
use enum_map::EnumMap;
pub fn gencopy_mutator_prepare<VM: VMBinding>(_mutator: &mut Mutator<VM>, _tls: OpaquePointer) {
// Do nothing
}
pub fn gencopy_mutator_release<VM: VMBinding>(mutator: &mut Mutator<VM>, _tls: OpaquePointer) {
// reset nursery allocator
let bump_allocator = unsafe {
mutator
.allocators
.get_allocator_mut(mutator.config.allocator_mapping[AllocationType::Default])
}
.downcast_mut::<BumpAllocator<VM>>()
.unwrap();
bump_allocator.reset();
}
lazy_static! {
pub static ref ALLOCATOR_MAPPING: EnumMap<AllocationType, AllocatorSelector> = enum_map! {
AllocationType::Default => AllocatorSelector::BumpPointer(0),
AllocationType::Immortal | AllocationType::Code | AllocationType::ReadOnly => AllocatorSelector::BumpPointer(1),
AllocationType::Los => AllocatorSelector::LargeObject(0),
};
}
pub fn create_gencopy_mutator<VM: VMBinding>(
mutator_tls: OpaquePointer,
mmtk: &'static MMTK<VM>,
) -> Mutator<VM> {
let gencopy = mmtk.plan.downcast_ref::<GenCopy<VM>>().unwrap();
let config = MutatorConfig {
allocator_mapping: &*ALLOCATOR_MAPPING,
space_mapping: box vec![
(AllocatorSelector::BumpPointer(0), &gencopy.nursery),
(
AllocatorSelector::BumpPointer(1),
gencopy.common.get_immortal(),
),
(AllocatorSelector::LargeObject(0), gencopy.common.get_los()),
],
prepare_func: &gencopy_mutator_prepare,
release_func: &gencopy_mutator_release,
};
Mutator {
allocators: Allocators::<VM>::new(mutator_tls, &*mmtk.plan, &config.space_mapping),
barrier: box ObjectRememberingBarrier::<GenCopyNurseryProcessEdges<VM>>::new(
mmtk,
super::LOGGING_META,
),
mutator_tls,
config,
plan: gencopy,
}
}
|
//! Module containing the [`SetUnion`] lattice and aliases for different datastructures.
use std::cmp::Ordering::{self, *};
use std::collections::{BTreeSet, HashSet};
use crate::cc_traits::{Iter, Len, Set};
use crate::collections::{ArraySet, OptionSet, SingletonSet};
use crate::{Atomize, IsBot, IsTop, LatticeFrom, LatticeOrd, Merge};
/// Set-union lattice.
///
/// Merging set-union lattices is done by unioning the keys.
#[repr(transparent)]
#[derive(Copy, Clone, Debug, Default)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct SetUnion<Set>(pub Set);
impl<Set> SetUnion<Set> {
/// Create a new `SetUnion` from a `Set`.
pub fn new(val: Set) -> Self {
Self(val)
}
/// Create a new `SetUnion` from an `Into<Set>`.
pub fn new_from(val: impl Into<Set>) -> Self {
Self::new(val.into())
}
/// Reveal the inner value as a shared reference.
pub fn as_reveal_ref(&self) -> &Set {
&self.0
}
/// Reveal the inner value as an exclusive reference.
pub fn as_reveal_mut(&mut self) -> &mut Set {
&mut self.0
}
/// Gets the inner by value, consuming self.
pub fn into_reveal(self) -> Set {
self.0
}
}
impl<SetSelf, SetOther, Item> Merge<SetUnion<SetOther>> for SetUnion<SetSelf>
where
SetSelf: Extend<Item> + Len,
SetOther: IntoIterator<Item = Item>,
{
fn merge(&mut self, other: SetUnion<SetOther>) -> bool {
let old_len = self.0.len();
self.0.extend(other.0);
self.0.len() > old_len
}
}
impl<SetSelf, SetOther, Item> LatticeFrom<SetUnion<SetOther>> for SetUnion<SetSelf>
where
SetSelf: FromIterator<Item>,
SetOther: IntoIterator<Item = Item>,
{
fn lattice_from(other: SetUnion<SetOther>) -> Self {
Self(other.0.into_iter().collect())
}
}
impl<SetSelf, SetOther, Item> PartialOrd<SetUnion<SetOther>> for SetUnion<SetSelf>
where
SetSelf: Set<Item, Item = Item> + Iter,
SetOther: Set<Item, Item = Item> + Iter,
{
fn partial_cmp(&self, other: &SetUnion<SetOther>) -> Option<Ordering> {
match self.0.len().cmp(&other.0.len()) {
Greater => {
if other.0.iter().all(|key| self.0.contains(&*key)) {
Some(Greater)
} else {
None
}
}
Equal => {
if self.0.iter().all(|key| other.0.contains(&*key)) {
Some(Equal)
} else {
None
}
}
Less => {
if self.0.iter().all(|key| other.0.contains(&*key)) {
Some(Less)
} else {
None
}
}
}
}
}
impl<SetSelf, SetOther> LatticeOrd<SetUnion<SetOther>> for SetUnion<SetSelf> where
Self: PartialOrd<SetUnion<SetOther>>
{
}
impl<SetSelf, SetOther, Item> PartialEq<SetUnion<SetOther>> for SetUnion<SetSelf>
where
SetSelf: Set<Item, Item = Item> + Iter,
SetOther: Set<Item, Item = Item> + Iter,
{
fn eq(&self, other: &SetUnion<SetOther>) -> bool {
if self.0.len() != other.0.len() {
return false;
}
self.0.iter().all(|key| other.0.contains(&*key))
}
}
impl<SetSelf> Eq for SetUnion<SetSelf> where Self: PartialEq {}
impl<Set> IsBot for SetUnion<Set>
where
Set: Len,
{
fn is_bot(&self) -> bool {
self.0.is_empty()
}
}
impl<Set> IsTop for SetUnion<Set> {
fn is_top(&self) -> bool {
false
}
}
impl<Set, Item> Atomize for SetUnion<Set>
where
Set: Len + IntoIterator<Item = Item> + Extend<Item>,
Set::IntoIter: 'static,
Item: 'static,
{
type Atom = SetUnionOptionSet<Item>;
// TODO: use impl trait.
type AtomIter = Box<dyn Iterator<Item = Self::Atom>>;
fn atomize(self) -> Self::AtomIter {
Box::new(self.0.into_iter().map(SetUnionOptionSet::new_from))
}
}
/// [`std::collections::HashSet`]-backed [`SetUnion`] lattice.
pub type SetUnionHashSet<Item> = SetUnion<HashSet<Item>>;
/// [`std::collections::BTreeSet`]-backed [`SetUnion`] lattice.
pub type SetUnionBTreeSet<Item> = SetUnion<BTreeSet<Item>>;
/// [`Vec`]-backed [`SetUnion`] lattice.
pub type SetUnionVec<Item> = SetUnion<Vec<Item>>;
/// [`crate::collections::ArraySet`]-backed [`SetUnion`] lattice.
pub type SetUnionArray<Item, const N: usize> = SetUnion<ArraySet<Item, N>>;
/// [`crate::collections::SingletonSet`]-backed [`SetUnion`] lattice.
pub type SetUnionSingletonSet<Item> = SetUnion<SingletonSet<Item>>;
/// [`Option`]-backed [`SetUnion`] lattice.
pub type SetUnionOptionSet<Item> = SetUnion<OptionSet<Item>>;
#[cfg(test)]
mod test {
use super::*;
use crate::collections::SingletonSet;
use crate::test::{check_all, check_atomize_each};
#[test]
fn test_set_union() {
let mut my_set_a = SetUnionHashSet::<&str>::new(HashSet::new());
let my_set_b = SetUnionBTreeSet::<&str>::new(BTreeSet::new());
let my_set_c = SetUnionSingletonSet::new(SingletonSet("hello world"));
assert_eq!(Some(Equal), my_set_a.partial_cmp(&my_set_a));
assert_eq!(Some(Equal), my_set_a.partial_cmp(&my_set_b));
assert_eq!(Some(Less), my_set_a.partial_cmp(&my_set_c));
assert_eq!(Some(Equal), my_set_b.partial_cmp(&my_set_a));
assert_eq!(Some(Equal), my_set_b.partial_cmp(&my_set_b));
assert_eq!(Some(Less), my_set_b.partial_cmp(&my_set_c));
assert_eq!(Some(Greater), my_set_c.partial_cmp(&my_set_a));
assert_eq!(Some(Greater), my_set_c.partial_cmp(&my_set_b));
assert_eq!(Some(Equal), my_set_c.partial_cmp(&my_set_c));
assert!(!my_set_a.merge(my_set_b));
assert!(my_set_a.merge(my_set_c));
}
#[test]
fn test_singleton_example() {
let mut my_hash_set = SetUnionHashSet::<&str>::default();
let my_delta_set = SetUnionSingletonSet::new_from("hello world");
let my_array_set = SetUnionArray::new_from(["hello world", "b", "c", "d"]);
assert_eq!(Some(Equal), my_delta_set.partial_cmp(&my_delta_set));
assert_eq!(Some(Less), my_delta_set.partial_cmp(&my_array_set));
assert_eq!(Some(Greater), my_array_set.partial_cmp(&my_delta_set));
assert_eq!(Some(Equal), my_array_set.partial_cmp(&my_array_set));
assert!(my_hash_set.merge(my_array_set)); // Changes
assert!(!my_hash_set.merge(my_delta_set)); // No changes
}
#[test]
fn consistency() {
check_all(&[
SetUnionHashSet::new_from([]),
SetUnionHashSet::new_from([0]),
SetUnionHashSet::new_from([1]),
SetUnionHashSet::new_from([0, 1]),
]);
}
#[test]
fn atomize() {
check_atomize_each(&[
SetUnionHashSet::new_from([]),
SetUnionHashSet::new_from([0]),
SetUnionHashSet::new_from([1]),
SetUnionHashSet::new_from([0, 1]),
SetUnionHashSet::new((0..10).collect()),
]);
}
}
|
// Copyright 2021 lowRISC contributors.
//
// 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
//
// https://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.
//
// SPDX-License-Identifier: Apache-2.0
use crate::manticore_support::Identity;
use crate::manticore_support::NoRsa;
use crate::manticore_support::Reset;
use crate::spi_host;
use crate::spi_host_h1;
use crate::spi_device;
use core::cmp::min;
use core::convert::TryFrom;
use core::fmt::Write;
use libtock::console::Console;
use libtock::result::TockError;
use manticore::io::Cursor as ManticoreCursor;
use manticore::server::pa_rot::PaRot;
use spiutils::io::Cursor as SpiutilsCursor;
use spiutils::io::Write as SpiutilsWrite;
use spiutils::protocol::flash;
use spiutils::protocol::flash::Address;
use spiutils::protocol::flash::AddressMode;
use spiutils::protocol::flash::OpCode;
use spiutils::protocol::payload;
use spiutils::protocol::wire::FromWire;
use spiutils::protocol::wire::FromWireError;
use spiutils::protocol::wire::ToWire;
use spiutils::protocol::wire::ToWireError;
#[derive(Copy, Clone, Debug)]
pub enum SpiProcessorError {
FromWire(FromWireError),
ToWire(ToWireError),
Tock,
Manticore(manticore::server::Error),
UnsupportedContentType(payload::ContentType),
UnsupportedOpCode(OpCode),
InvalidAddress(Option<u32>),
Format(core::fmt::Error),
}
impl From<FromWireError> for SpiProcessorError {
fn from(err: FromWireError) -> Self {
SpiProcessorError::FromWire(err)
}
}
impl From<ToWireError> for SpiProcessorError {
fn from(err: ToWireError) -> Self {
SpiProcessorError::ToWire(err)
}
}
impl From<TockError> for SpiProcessorError {
fn from(_err: TockError) -> Self {
SpiProcessorError::Tock
}
}
impl From<manticore::server::Error> for SpiProcessorError {
fn from(err: manticore::server::Error) -> Self {
SpiProcessorError::Manticore(err)
}
}
impl From<core::fmt::Error> for SpiProcessorError {
fn from(err: core::fmt::Error) -> Self {
SpiProcessorError::Format(err)
}
}
//////////////////////////////////////////////////////////////////////////////
pub struct SpiProcessor<'a> {
pub server: PaRot<'a, Identity, Reset, NoRsa>,
}
const SPI_TX_BUF_SIZE : usize = 512;
pub type SpiProcessorResult<T> = Result<T, SpiProcessorError>;
impl<'a> SpiProcessor<'a> {
fn send_data(&mut self, tx_header: &payload::Header, tx_buf: &mut[u8]) -> SpiProcessorResult<()> {
{
// Scope for tx_cursor (which doesn't implement Drop).
// We need tx_cursor to go out of scope so that we can use tx_buf further down.
let tx_cursor = SpiutilsCursor::new(tx_buf);
tx_header.to_wire(tx_cursor)?;
}
spi_device::get().end_transaction_with_data(tx_buf, true, true)?;
Ok(())
}
fn process_manticore(&mut self, mut data: &[u8]) -> SpiProcessorResult<()> {
let mut console = Console::new();
writeln!(console, "Device: Manticore!")?;
let mut tx_buf : [u8; SPI_TX_BUF_SIZE] = [0xff; SPI_TX_BUF_SIZE];
let payload_len : u16;
{
let mut tx_cursor = ManticoreCursor::new(&mut tx_buf[payload::HEADER_LEN..]);
self.server.process_request(&mut data, &mut tx_cursor)?;
payload_len = u16::try_from(tx_cursor.consumed_len())
.map_err(|_| SpiProcessorError::FromWire(FromWireError::OutOfRange))?;
}
let tx_header = payload::Header {
content: payload::ContentType::Manticore,
content_len: payload_len,
};
self.send_data(&tx_header, &mut tx_buf)?;
writeln!(console, "Device: Data sent")?;
Ok(())
}
fn process_spi_payload(&mut self, mut data: &[u8]) -> SpiProcessorResult<()> {
let mut console = Console::new();
let header = payload::Header::from_wire(&mut data)?;
writeln!(console, "Device: payload header: {:?}", header)?;
match header.content {
payload::ContentType::Manticore => {
self.process_manticore(&data[..header.content_len as usize])
}
_ => {
Err(SpiProcessorError::UnsupportedContentType(header.content))
}
}
}
// Send data via the SPI host.
// The transaction is split into smaller transactions that fit into the SPI host's buffer.
// The write enable status bit is set before each transaction is executed.
// The `pre_transaction_fn` is executed prior to each transaction.
fn spi_host_send<AddrType, F>(&self, header: &flash::Header::<AddrType>, mut data: &[u8], pre_transaction_fn: &F) -> SpiProcessorResult<()>
where AddrType: Address,
F: Fn() -> SpiProcessorResult<()>
{
// We need to update the header so copy it.
let mut header = *header;
loop {
pre_transaction_fn()?;
let mut tx_buf = [0xff; spi_host::MAX_READ_BUFFER_LENGTH];
let tx_len : usize;
let data_len_to_send : usize;
{
let mut tx_cursor = SpiutilsCursor::new(&mut tx_buf);
header.to_wire(&mut tx_cursor)?;
if header.opcode.has_dummy_byte() {
// Skip one dummy byte (send 0x0)
tx_cursor.write_bytes(&[0x0; 1])
.map_err(|err| SpiProcessorError::ToWire(ToWireError::Io(err)))?;
}
data_len_to_send = min(spi_host::MAX_READ_BUFFER_LENGTH - tx_cursor.consumed_len(), data.len());
tx_cursor.write_bytes(&data[..data_len_to_send])
.map_err(|err| SpiProcessorError::ToWire(ToWireError::Io(err)))?;
tx_len = tx_cursor.consumed_len()
}
spi_host_h1::get().set_wait_busy_clear_in_transactions(header.opcode.wait_busy_clear())?;
spi_host::get().read_write_bytes(&mut tx_buf, tx_len)?;
spi_host::get().wait_read_write_done();
// Move data and address forward
data = &data[data_len_to_send..];
if let Some(addr) = header.address {
let delta : u32 = core::convert::TryFrom::<usize>::try_from(data_len_to_send)
.map_err(|_| SpiProcessorError::FromWire(FromWireError::OutOfRange))?;
let next_addr = addr.into() + delta;
header.address = Some(AddrType::try_from(next_addr)
.map_err(|_| SpiProcessorError::FromWire(FromWireError::OutOfRange))?);
}
if data.len() == 0 { break; }
}
Ok(())
}
// Send a "write enable" command via the SPI host.
fn spi_host_write_enable(&self) -> SpiProcessorResult<()> {
let header = flash::Header::<u32> {
opcode: OpCode::WriteEnable,
address: None,
};
// The command has no data.
let data : [u8; 0] = [0; 0];
self.spi_host_send(&header, &data, &|| Ok(()))
}
// Send a "write" type command (e.g. PageProgram, *Erase) via the SPI host.
// This splits the data into smaller transactions as needed and executes
// "enable write" for each transaction.
fn spi_host_write<AddrType>(&self, header: &flash::Header::<AddrType>, data: &[u8]) -> SpiProcessorResult<()>
where AddrType: Address {
self.spi_host_send(header, data, &|| self.spi_host_write_enable())
}
fn clear_device_status(&self, clear_busy: bool, clear_write_enable: bool) -> SpiProcessorResult<()> {
spi_device::get().end_transaction_with_status(clear_busy, clear_write_enable)?;
Ok(())
}
fn process_spi_header<AddrType>(&mut self, header: &flash::Header::<AddrType>, rx_buf: &[u8]) -> SpiProcessorResult<()>
where AddrType: Address {
let mut data: &[u8] = rx_buf;
if header.opcode.has_dummy_byte() {
// Skip dummy byte
data = &rx_buf[1..];
}
match header.opcode {
OpCode::PageProgram => {
match header.get_address() {
Some(0x02000000) => {
if spi_device::get().is_write_enable_set() {
self.process_spi_payload(data)?;
}
self.clear_device_status(true, true)
}
Some(x) if x < 0x02000000 => {
if spi_device::get().is_write_enable_set() {
// Pass through to SPI host
self.spi_host_write(header, data)?;
}
self.clear_device_status(true, true)
}
_ => return Err(SpiProcessorError::InvalidAddress(header.get_address())),
}
}
OpCode::SectorErase | OpCode::BlockErase32KB | OpCode::BlockErase64KB => {
match header.get_address() {
Some(0x02000000) => {
// Nothing to do.
self.clear_device_status(true, true)
}
Some(x) if x < 0x02000000 => {
if spi_device::get().is_write_enable_set() {
// Pass through to SPI host
self.spi_host_write(header, data)?;
}
self.clear_device_status(true, true)
}
_ => return Err(SpiProcessorError::InvalidAddress(header.get_address())),
}
}
OpCode::ChipErase | OpCode::ChipErase2 => {
if spi_device::get().is_write_enable_set() {
// Pass through to SPI host
self.spi_host_write(header, data)?;
}
self.clear_device_status(true, true)
}
_ => return Err(SpiProcessorError::UnsupportedOpCode(header.opcode)),
}
}
pub fn process_spi_packet(&mut self, mut rx_buf: &[u8]) -> SpiProcessorResult<()> {
let mut console = Console::new();
match spi_device::get().get_address_mode() {
AddressMode::ThreeByte => {
let header = flash::Header::<ux::u24>::from_wire(&mut rx_buf)?;
writeln!(console, "Device: flash header (3B): {:?}", header)?;
self.process_spi_header(&header, rx_buf)
}
AddressMode::FourByte => {
let header = flash::Header::<u32>::from_wire(&mut rx_buf)?;
writeln!(console, "Device: flash header (4B): {:?}", header)?;
self.process_spi_header(&header, rx_buf)
}
}
}
}
|
use std::collections::HashMap;
use std::path::PathBuf;
use indicatif::ProgressBar;
use rand::Rng;
use crate::color::RGB;
use crate::kd_tree::{KDTree, PerformanceStats, Point};
use crate::point_tracker::PointTracker;
use crate::topology::{PixelLoc, Topology};
impl Point for RGB {
type Dtype = u8;
const NUM_DIMENSIONS: u8 = 3;
fn get_val(&self, dimension: u8) -> Self::Dtype {
self.vals[dimension as usize]
}
fn dist2(&self, other: &Self) -> f64 {
self.vals
.iter()
.zip(other.vals.iter())
.map(|(&a, &b)| ((a as f64) - (b as f64)).powf(2.0))
.sum()
}
}
pub struct GrowthImage {
pub(crate) topology: Topology,
pub(crate) pixels: Vec<Option<RGB>>,
pub(crate) stats: Vec<Option<PerformanceStats>>,
pub(crate) num_filled_pixels: usize,
pub(crate) stages: Vec<GrowthImageStage>,
pub(crate) active_stage: Option<usize>,
pub(crate) current_stage_iter: usize,
pub(crate) point_tracker: PointTracker,
pub(crate) epsilon: f64,
pub(crate) rng: rand_chacha::ChaCha8Rng,
pub(crate) is_done: bool,
pub(crate) progress_bar: Option<ProgressBar>,
pub(crate) animation_outputs: Vec<GrowthImageAnimation>,
}
#[derive(Debug, Copy, Clone, PartialEq)]
pub enum SaveImageType {
Generated,
Statistics,
ColorPalette,
}
struct SaveImageData {
data: Vec<u8>,
width: u32,
height: u32,
}
#[derive(Clone)]
pub enum RestrictedRegion {
Allowed(Vec<PixelLoc>),
Forbidden(Vec<PixelLoc>),
}
pub struct GrowthImageStage {
pub(crate) palette: KDTree<RGB>,
pub(crate) max_iter: Option<usize>,
pub(crate) grow_from_previous: bool,
pub(crate) selected_seed_points: Vec<PixelLoc>,
pub(crate) num_random_seed_points: u32,
pub(crate) restricted_region: RestrictedRegion,
pub(crate) portals: HashMap<PixelLoc, PixelLoc>,
pub(crate) animation_iter_per_second: f64,
}
pub struct GrowthImageAnimation {
pub(crate) proc: std::process::Child,
pub(crate) fps: f64,
pub(crate) iter_per_frame: usize,
pub(crate) iter_since_frame: usize,
pub(crate) image_type: SaveImageType,
pub(crate) layer: u8,
}
impl GrowthImage {
pub fn is_done(&self) -> bool {
self.is_done
}
pub fn fill_until_done(&mut self) {
while !self.is_done {
self.fill();
}
}
pub fn fill(&mut self) {
let res = self.try_fill();
self.is_done = res.is_none();
if let Some(bar) = &self.progress_bar {
bar.inc(1);
if self.is_done {
bar.finish();
}
}
self._write_to_animations();
}
pub fn get_adjacent_color(&self, loc: PixelLoc) -> Option<RGB> {
let (count, rsum, gsum, bsum) = self
.topology
.iter_adjacent(loc)
.flat_map(|loc| self.topology.get_index(loc))
.flat_map(|index| self.pixels[index])
.fold(
(0u32, 0u32, 0u32, 0u32),
|(count, rsum, gsum, bsum), rgb| {
(
count + 1,
rsum + rgb.r() as u32,
gsum + rgb.g() as u32,
bsum + rgb.b() as u32,
)
},
);
if count > 0 {
Some(RGB {
vals: [
(rsum / count) as u8,
(gsum / count) as u8,
(bsum / count) as u8,
],
})
} else {
None
}
}
fn current_stage_finished(&self) -> bool {
let active_stage = &self.stages[self.active_stage.unwrap()];
let reached_max_stage_iter = match active_stage.max_iter {
Some(max_iter) => self.current_stage_iter >= max_iter,
None => false,
};
let empty_palette = active_stage.palette.num_points() == 0;
let empty_frontier = self.point_tracker.is_done();
reached_max_stage_iter || empty_palette || empty_frontier
}
fn start_stage(&mut self, stage_index: usize) {
// Advance stage number
self.active_stage = Some(stage_index);
self.current_stage_iter = 0;
let active_stage = &self.stages[stage_index];
// Recalculate the iterations per frame for each animation.
self.animation_outputs.iter_mut().for_each(|anim| {
anim.iter_per_frame =
(active_stage.animation_iter_per_second / anim.fps) as usize;
});
// Update the geometry with new portals. Long-term, should
// forbidden points go here as well? Conceptually, they fit
// really well with the geometry tracking class, but the
// implementation is much cleaner with them being part of the
// PointTracker's "used" array.
self.topology.portals = active_stage.portals.clone();
// Remake the PointTracker, so that we can clear any forbidden
// points from the previous stage, as well as removing any
// newly forbidden points from the frontier.
let mut point_tracker = PointTracker::new(self.topology.clone());
match &active_stage.restricted_region {
RestrictedRegion::Allowed(points) => {
point_tracker.mark_all_as_used();
points
.iter()
.for_each(|&loc| point_tracker.mark_as_unused(loc));
}
RestrictedRegion::Forbidden(points) => {
points
.iter()
.for_each(|&loc| point_tracker.mark_as_used(loc));
}
}
// All filled pixels are either forbidden, or forbidden with a
// frontier.
let filled_locs = self
.pixels
.iter()
.enumerate()
.filter(|(_i, p)| p.is_some())
.flat_map(|(i, _p)| self.topology.get_loc(i));
if active_stage.grow_from_previous {
filled_locs.for_each(|loc| point_tracker.fill(loc));
} else {
filled_locs.for_each(|loc| point_tracker.mark_as_used(loc));
};
// Add in any selected seed points
active_stage
.selected_seed_points
.iter()
.for_each(|&loc| point_tracker.add_to_frontier(loc));
// Randomly pick N seed points from those remaining.
// Implementation assumes that N is relatively small, may be
// inefficient for large N.
point_tracker.add_random_to_frontier(
active_stage.num_random_seed_points as usize,
&mut self.rng,
);
// Set the new point tracker as the one to use
self.point_tracker = point_tracker;
}
fn try_fill(&mut self) -> Option<(PixelLoc, RGB)> {
// Start of the first stage
if self.active_stage.is_none() {
self.start_stage(0);
}
// Advance to the next stage, if needed.
while self.current_stage_finished() {
let next_stage = self.active_stage.unwrap() + 1;
if next_stage < self.stages.len() {
self.start_stage(next_stage);
} else {
return None;
}
}
let point_tracker_index = (self.point_tracker.frontier_size() as f32
* self.rng.gen::<f32>()) as usize;
let next_loc =
self.point_tracker.get_frontier_point(point_tracker_index);
self.point_tracker.fill(next_loc);
let next_index = self.topology.get_index(next_loc)?;
let target_color =
self.get_adjacent_color(next_loc).unwrap_or_else(|| RGB {
vals: [
self.rng.gen::<u8>(),
self.rng.gen::<u8>(),
self.rng.gen::<u8>(),
],
});
let active_stage = &mut self.stages[self.active_stage.unwrap()];
let res = active_stage
.palette
.pop_closest(&target_color, self.epsilon);
self.stats[next_index] = Some(res.stats);
let next_color = res.res?;
self.pixels[next_index] = Some(next_color);
self.current_stage_iter += 1;
self.num_filled_pixels += 1;
Some((next_loc, next_color))
}
pub fn write(&self, filename: PathBuf) {
self.write_image(filename, SaveImageType::Generated, 0);
}
pub fn write_image(
&self,
filename: PathBuf,
image_type: SaveImageType,
layer: u8,
) {
self._write_image_data(filename, &self._image_data(image_type, layer));
}
fn _write_to_animations(&mut self) {
// Steal the animation vector to mutate it.
let mut animations = std::mem::take(&mut self.animation_outputs);
// Increment the iterations since last frame write.
animations
.iter_mut()
.for_each(|anim| anim.iter_since_frame += 1);
// Write to it, which requires immutable borrow of other parts
// of self.
animations
.iter_mut()
.filter(|anim| anim.iter_since_frame >= anim.iter_per_frame)
.for_each(|anim| {
let data = self._image_data(anim.image_type, anim.layer);
self._write_image_data_to_writer(
&mut anim.proc.stdin.as_ref().unwrap(),
&data,
);
anim.iter_since_frame = 0;
});
// Put the animation vector back
std::mem::swap(&mut animations, &mut self.animation_outputs);
}
fn _image_data(
&self,
image_type: SaveImageType,
layer: u8,
) -> SaveImageData {
match image_type {
SaveImageType::Generated => self._generated_image_data(layer),
SaveImageType::Statistics => self._statistics_image_data(layer),
SaveImageType::ColorPalette => self._color_palette_image_data(),
}
}
fn _generated_image_data(&self, layer: u8) -> SaveImageData {
let index_range = self.topology.get_layer_bounds(layer).unwrap();
let size = self.topology.layers[layer as usize];
let data = self.pixels[index_range]
.iter()
.map(|p| match p {
Some(rgb) => vec![rgb.r(), rgb.g(), rgb.b(), 255],
None => vec![0, 0, 0, 0],
})
.flat_map(|p| p.into_iter())
.collect();
SaveImageData {
data,
width: size.width,
height: size.height,
}
}
fn _statistics_image_data(&self, layer: u8) -> SaveImageData {
let index_range = self.topology.get_layer_bounds(layer).unwrap();
let size = self.topology.layers[layer as usize];
let max = self.stats[index_range.clone()]
.iter()
.filter_map(|s| *s)
.fold(PerformanceStats::default(), |a, b| PerformanceStats {
nodes_checked: a.nodes_checked.max(b.nodes_checked),
leaf_nodes_checked: a
.leaf_nodes_checked
.max(b.leaf_nodes_checked),
points_checked: a.points_checked.max(b.points_checked),
});
let data = self.stats[index_range]
.iter()
.map(|s| match s {
Some(stats) => vec![
(255.0
* ((stats.nodes_checked as f32).ln()
/ (max.nodes_checked as f32).ln()))
as u8,
(255.0
* ((stats.leaf_nodes_checked as f32).ln()
/ (max.leaf_nodes_checked as f32).ln()))
as u8,
(255.0
* ((stats.points_checked as f32).ln()
/ (max.points_checked as f32).ln()))
as u8,
255,
],
None => vec![0, 0, 0, 0],
})
.flat_map(|p| p.into_iter())
.collect();
SaveImageData {
data,
width: size.width,
height: size.height,
}
}
fn _color_palette_image_data(&self) -> SaveImageData {
let mut data = self.stages[self.active_stage.unwrap_or(0)]
.palette
.iter_points()
.map(|p| match p {
Some(rgb) => vec![rgb.r(), rgb.g(), rgb.b(), 255],
None => vec![0, 0, 0, 0],
})
.flat_map(|p| p.into_iter())
.collect::<Vec<u8>>();
// TODO: Better method here. Currently, the smallest size
// with enough points that roughly matches the aspect
// ratio of layer 0.
let aspect_ratio = (self.topology.layers[0].width as f64)
/ (self.topology.layers[0].height as f64);
let area = self.topology.len() as f64;
let height = (area / aspect_ratio).sqrt();
let width = (height * aspect_ratio).ceil() as u32;
let height = height.ceil() as u32;
// Pad data array out with 0 as needed.
data.resize((4 * width * height) as usize, 0);
SaveImageData {
data,
width,
height,
}
}
fn _write_image_data(&self, filename: PathBuf, data: &SaveImageData) {
let file = std::fs::File::create(filename).unwrap();
let bufwriter = &mut std::io::BufWriter::new(file);
self._write_image_data_to_writer(bufwriter, data);
}
fn _write_image_data_to_writer(
&self,
writer: &mut impl std::io::Write,
data: &SaveImageData,
) {
let mut encoder = png::Encoder::new(writer, data.width, data.height);
encoder.set_color(png::ColorType::RGBA);
encoder.set_depth(png::BitDepth::Eight);
let mut writer = encoder.write_header().unwrap();
writer.write_image_data(&data.data).unwrap();
}
}
impl Drop for GrowthImage {
fn drop(&mut self) {
self.animation_outputs.iter_mut().for_each(|anim| {
anim.proc.wait().unwrap();
});
}
}
|
#[doc = "Register `X1BUFCFG` reader"]
pub type R = crate::R<X1BUFCFG_SPEC>;
#[doc = "Register `X1BUFCFG` writer"]
pub type W = crate::W<X1BUFCFG_SPEC>;
#[doc = "Field `X1_BASE` reader - X1_BASE"]
pub type X1_BASE_R = crate::FieldReader;
#[doc = "Field `X1_BASE` writer - X1_BASE"]
pub type X1_BASE_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 8, O>;
#[doc = "Field `X1_BUF_SIZE` reader - X1_BUF_SIZE"]
pub type X1_BUF_SIZE_R = crate::FieldReader;
#[doc = "Field `X1_BUF_SIZE` writer - X1_BUF_SIZE"]
pub type X1_BUF_SIZE_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 8, O>;
#[doc = "Field `FULL_WM` reader - FULL_WM"]
pub type FULL_WM_R = crate::FieldReader;
#[doc = "Field `FULL_WM` writer - FULL_WM"]
pub type FULL_WM_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 2, O>;
impl R {
#[doc = "Bits 0:7 - X1_BASE"]
#[inline(always)]
pub fn x1_base(&self) -> X1_BASE_R {
X1_BASE_R::new((self.bits & 0xff) as u8)
}
#[doc = "Bits 8:15 - X1_BUF_SIZE"]
#[inline(always)]
pub fn x1_buf_size(&self) -> X1_BUF_SIZE_R {
X1_BUF_SIZE_R::new(((self.bits >> 8) & 0xff) as u8)
}
#[doc = "Bits 24:25 - FULL_WM"]
#[inline(always)]
pub fn full_wm(&self) -> FULL_WM_R {
FULL_WM_R::new(((self.bits >> 24) & 3) as u8)
}
}
impl W {
#[doc = "Bits 0:7 - X1_BASE"]
#[inline(always)]
#[must_use]
pub fn x1_base(&mut self) -> X1_BASE_W<X1BUFCFG_SPEC, 0> {
X1_BASE_W::new(self)
}
#[doc = "Bits 8:15 - X1_BUF_SIZE"]
#[inline(always)]
#[must_use]
pub fn x1_buf_size(&mut self) -> X1_BUF_SIZE_W<X1BUFCFG_SPEC, 8> {
X1_BUF_SIZE_W::new(self)
}
#[doc = "Bits 24:25 - FULL_WM"]
#[inline(always)]
#[must_use]
pub fn full_wm(&mut self) -> FULL_WM_W<X1BUFCFG_SPEC, 24> {
FULL_WM_W::new(self)
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
}
#[doc = "FMAC X1 Buffer Configuration register\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`x1bufcfg::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`x1bufcfg::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct X1BUFCFG_SPEC;
impl crate::RegisterSpec for X1BUFCFG_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`x1bufcfg::R`](R) reader structure"]
impl crate::Readable for X1BUFCFG_SPEC {}
#[doc = "`write(|w| ..)` method takes [`x1bufcfg::W`](W) writer structure"]
impl crate::Writable for X1BUFCFG_SPEC {
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets X1BUFCFG to value 0"]
impl crate::Resettable for X1BUFCFG_SPEC {
const RESET_VALUE: Self::Ux = 0;
}
|
use crate::resources::{Cost, Resource};
use strum_macros::EnumIter;
#[derive(Debug, EnumIter, Copy, Clone, Eq, PartialEq)]
#[allow(dead_code)]
pub enum WonderType {
ColossusOfRhodes,
LighthouseOfAlexandria,
TempleOfArtemis,
HangingGardensOfBabylon,
StatueOfZeus,
MausoleumOfHalicarnassus,
PyramidsOfGiza,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
#[allow(dead_code)]
pub enum WonderSide {
A,
B,
}
#[derive(Debug, Copy, Clone, Eq, PartialEq)]
pub struct WonderBoard {
pub wonder_type: WonderType,
pub wonder_side: WonderSide,
}
#[allow(dead_code)]
impl WonderType {
pub fn name(&self) -> &str {
match self {
WonderType::ColossusOfRhodes => "The Colossus of Rhodes",
WonderType::LighthouseOfAlexandria => "The Lighthouse of Alexandria",
WonderType::TempleOfArtemis => "The Temple of Artemis in Aphesus",
WonderType::HangingGardensOfBabylon => "The Hanging Gardens of Babylon",
WonderType::StatueOfZeus => "The Statue of Zeus in Olympia",
WonderType::MausoleumOfHalicarnassus => "The Mausoleum of Halicarnassus",
WonderType::PyramidsOfGiza => "The Pyramids of Giza",
}
}
fn starting_resource(&self) -> Resource {
match self {
WonderType::ColossusOfRhodes => Resource::Ore,
WonderType::LighthouseOfAlexandria => Resource::Glass,
WonderType::TempleOfArtemis => Resource::Papyrus,
WonderType::HangingGardensOfBabylon => Resource::Clay,
WonderType::StatueOfZeus => Resource::Wood,
WonderType::MausoleumOfHalicarnassus => Resource::Loom,
WonderType::PyramidsOfGiza => Resource::Stone,
}
}
}
#[allow(dead_code)]
impl WonderBoard {
pub fn name(&self) -> &str {
self.wonder_type.name()
}
pub fn starting_resource(&self) -> Resource {
self.wonder_type.starting_resource()
}
pub fn cost(&self, position: u32) -> Cost {
match (&self.wonder_type, &self.wonder_side, position) {
(WonderType::ColossusOfRhodes, WonderSide::A, 0) => Cost::wood(2),
(WonderType::ColossusOfRhodes, WonderSide::A, 1) => Cost::clay(3),
(WonderType::ColossusOfRhodes, WonderSide::A, 2) => Cost::ore(4),
(WonderType::ColossusOfRhodes, WonderSide::A, _) => panic!(),
(WonderType::ColossusOfRhodes, WonderSide::B, 0) => Cost::stone(3),
(WonderType::ColossusOfRhodes, WonderSide::B, 1) => Cost::ore(4),
(WonderType::ColossusOfRhodes, WonderSide::B, _) => panic!(),
(WonderType::LighthouseOfAlexandria, WonderSide::A, 0) => Cost::stone(2),
(WonderType::LighthouseOfAlexandria, WonderSide::A, 1) => Cost::ore(2),
(WonderType::LighthouseOfAlexandria, WonderSide::A, 2) => Cost::glass(2),
(WonderType::LighthouseOfAlexandria, WonderSide::A, _) => panic!(),
(WonderType::LighthouseOfAlexandria, WonderSide::B, 0) => Cost::clay(2),
(WonderType::LighthouseOfAlexandria, WonderSide::B, 1) => Cost::wood(2),
(WonderType::LighthouseOfAlexandria, WonderSide::B, 2) => Cost::stone(3),
(WonderType::LighthouseOfAlexandria, WonderSide::B, _) => panic!(),
_ => todo!(),
}
}
// TODO: power
}
|
use super::{
Register,
Disp,
Scale,
RegSize,
Fault,
parse_reg,
parse_512bit_reg,
parse_256bit_reg,
parse_128bit_reg,
parse_64bit_reg,
parse_32bit_reg,
parse_16bit_reg,
parse_8bit_reg,
parse_mmx_reg,
parse_x87_reg,
parse_vec_reg,
parse_long_ptr_reg,
parse_scale,
parse_const
};
/// All the fun x64 Address Generation forms
#[derive(Clone,Debug,PartialEq,Eq)]
pub enum Mem {
Value(Register),
Direct(Register),
DirectDisp(Register,Disp),
Scaled(Register,Scale,Disp),
Complex(Register,Register,Scale,Disp),
Raw(Disp)
}
impl Mem {
/*
* Make assumptions about Memory
*
*/
pub fn is_value(&self) -> bool {
match self {
&Mem::Value(_) => true,
_ => false
}
}
pub fn is_direct_ref(&self) -> bool {
match self {
&Mem::Direct(_) => true,
_ => false
}
}
pub fn is_raw_ref(&self) -> bool {
match self {
&Mem::Raw(_) => true,
_ => false
}
}
pub fn is_direct_disp_ref(&self) -> bool {
match self {
&Mem::DirectDisp(_,_) => true,
_ => false
}
}
pub fn is_complex_ref(&self) -> bool {
match self {
&Mem::Complex(_,_,_,_) => true,
_ => false
}
}
pub fn is_disp_none(&self) -> bool {
match self {
&Mem::Value(_) |
&Mem::Direct(_) |
&Mem::DirectDisp(_,Disp::None) |
&Mem::Raw(Disp::None) |
&Mem::Scaled(_,_,Disp::None) |
&Mem::Complex(_,_,_,Disp::None) => true,
_ => false
}
}
/*
* Get internal data
*
*/
pub fn get_value(&self) -> Option<Register> {
match self {
&Mem::Value(ref r) => Some(r.clone()),
_ => None
}
}
pub fn get_direct(&self) -> Option<Register> {
match self {
&Mem::Direct(ref r) => Some(r.clone()),
_ => None
}
}
pub fn get_raw(&self) -> Option<Disp> {
match self {
&Mem::Raw(ref e) => Some(e.clone()),
_ => None
}
}
pub fn get_base(&self) -> Option<Register> {
match self {
&Mem::Complex(ref b,_,_,_,) => Some(b.clone()),
_ => None
}
}
pub fn get_index(&self) -> Option<Register> {
match self {
&Mem::Complex(_, ref i, _, _) |
&Mem::Scaled(ref i, _, _) => Some(i.clone()),
_ => None
}
}
/*
* Do actual work
*/
pub fn get_reg_size(&self) -> Result<RegSize,Fault> {
match self {
&Mem::Value(ref r) |
&Mem::Direct(ref r) |
&Mem::Scaled(ref r, _, _) |
&Mem::DirectDisp(ref r, _) => Ok(r.size()),
&Mem::Complex(ref b, ref i, _, _) => {
let base = b.size();
let index = i.size();
if base == index {
Ok(base)
} else {
Err(Fault::NotEqual(b.clone(),i.clone()))
}
}
&Mem::Raw(ref r) => match r.size_of() {
Option::None => Err(Fault::VoidRef),
Option::Some(s) => Ok(s)
}
}
}
}
named!(ob, ws!(tag!(b"[")));
named!(cb, ws!(tag!(b"]")));
named!(add, ws!(tag!(b"+")));
named!(mul, ws!(tag!(b"*")));
named!(parse_mem_value<Mem>, do_parse!(
a: ws!(parse_reg) >>
(Mem::Value(a))
));
named!(parse_mem_direct<Mem>, do_parse!(
ob >>
a: ws!(parse_long_ptr_reg) >>
cb >>
(Mem::Direct(a))
));
type DispLoc = (Register,Disp);
named!(parse_disp_loc<DispLoc>, do_parse!(
a: alt!(
do_parse!(
d: ws!(parse_const) >>
add >>
r: ws!(parse_long_ptr_reg) >>
( (r,d) )
) |
do_parse!(
r: ws!(parse_long_ptr_reg) >>
add >>
d: ws!(parse_const) >>
( (r,d) )
)
) >>
(a)
));
named!(parse_mem_disp<Mem>, do_parse!(
ob >>
a: ws!(parse_disp_loc) >>
cb >>
(Mem::DirectDisp(a.0, a.1))
));
named!(parse_complex_sum<Mem>, do_parse!(
ob >>
a: ws!(parse_long_ptr_reg) >>
add >>
b: ws!(parse_long_ptr_reg) >>
cb >>
(Mem::Complex(a,b,Scale::Val1,Disp::None))
));
named!(parse_complex_disp_sum<Mem>,do_parse!(
ob >>
a: alt!(
do_parse!(
i: ws!(parse_long_ptr_reg) >>
add >>
b: ws!(parse_long_ptr_reg) >>
add >>
d: ws!(parse_const) >>
( (i,b,d) )
) |
do_parse!(
i: ws!(parse_long_ptr_reg) >>
add >>
d: ws!(parse_const) >>
add >>
b: ws!(parse_long_ptr_reg) >>
((i,b,d))
) |
do_parse!(
d: ws!(parse_const) >>
add >>
i: ws!(parse_long_ptr_reg) >>
add >>
b: ws!(parse_long_ptr_reg) >>
((i,b,d))
)
) >>
cb >>
(Mem::Complex(a.0,a.1,Scale::Val1,a.2))
));
type Scaled = (Register,Scale);
named!(parse_with_scaled<Scaled>, do_parse!(
ws!(tag!(b"(")) >>
a: alt!(
do_parse!(
r: ws!(parse_long_ptr_reg) >>
mul >>
s: ws!(parse_scale) >>
((r,s))
)|
do_parse!(
s: ws!(parse_scale) >>
mul >>
r: ws!(parse_long_ptr_reg) >>
((r,s))
)
) >>
ws!(tag!(b")")) >>
(a)
));
named!(parse_complex_scaled_no_disp<Mem>, do_parse!(
ob >>
a: alt!(
do_parse!(
r: ws!(parse_long_ptr_reg) >>
add >>
s: ws!(parse_with_scaled) >>
(Mem::Complex(r,s.0,s.1,Disp::None))
)|
do_parse!(
s: ws!(parse_with_scaled) >>
add >>
r: ws!(parse_long_ptr_reg) >>
(Mem::Complex(r,s.0,s.1,Disp::None))
)
) >>
cb >>
(a)
));
named!(parse_complex_everything<Mem>,do_parse!(
ob >>
a: alt!(
do_parse!(
s: ws!(parse_with_scaled) >>
add >>
d: ws!(parse_disp_loc) >>
((s.0,d.0,s.1,d.1))
) |
do_parse!(
d: ws!(parse_disp_loc) >>
add >>
s: ws!(parse_with_scaled) >>
((d.0,s.0,s.1,d.1))
)|
do_parse!(
c: ws!(parse_const) >>
add >>
s: ws!(parse_with_scaled) >>
add >>
r: ws!(parse_long_ptr_reg) >>
((r,s.0,s.1,c))
)|
do_parse!(
r: ws!(parse_long_ptr_reg) >>
add >>
s: ws!(parse_with_scaled) >>
add >>
c: ws!(parse_const) >>
((r,s.0,s.1,c))
)
) >>
cb >>
(Mem::Complex(a.0,a.1,a.2,a.3))
));
named!(pub parse_mem<Mem>, do_parse!(
a: alt!(
complete!(parse_mem_value) |
complete!(parse_mem_direct) |
complete!(parse_mem_disp) |
complete!(parse_complex_sum) |
complete!(parse_complex_disp_sum) |
complete!(parse_complex_scaled_no_disp) |
complete!(parse_complex_everything)
) >>
(a)
));
#[test]
fn test_mem_parsing() {
macro_rules! gen_test {
(@SHOULDFAIL
Input: $dut: expr;
) => {
let x = parse_mem($dut);
if x.is_err() {
//thumbs up
} else {
panic!("For {:?} this should be an error. Got {:?}", $dut, x);
}
};
(
Input: $dut: expr;
Output: $val: expr;
) => {
let x = parse_mem($dut);
if x.is_done() {
let (_,val) = x.unwrap();
if val != $val {
panic!("For {:?} expected {:?} got {:?}", $dut, $val, val);
}
} else {
panic!("For {:?} expected {:?} got {:?}", $dut, $val, x);
}
};
}
/*
* Raw Value Tests
*/
gen_test! {
Input: b" rax ";
Output: Mem::Value(Register::rax);
}
gen_test! {
Input: b" zmm30 ";
Output: Mem::Value(Register::zmm30);
}
gen_test! {
Input: b" st0 ";
Output: Mem::Value(Register::st0);
}
gen_test! {
Input: b" r8l ";
Output: Mem::Value(Register::r8l);
}
gen_test! {
Input: b" [ rdi ] ";
Output: Mem::Direct(Register::rdi);
}
gen_test! {
Input: b" [r12d] ";
Output: Mem::Direct(Register::r12d);
}
gen_test! {
Input: b" [eax]";
Output: Mem::Direct(Register::eax);
}
gen_test! {@SHOULDFAIL
Input: b" [xmm0] ";
}
gen_test! {@SHOULDFAIL
Input: b" [ mmx5 ]";
}
gen_test! {@SHOULDFAIL
Input: b" [st1]";
}
gen_test! {@SHOULDFAIL
Input: b" [ al ] ";
}
gen_test! {
Input: b" [ rax + 15 ] ";
Output: Mem::DirectDisp(Register::rax, Disp::I8(15i8));
}
gen_test! {
Input: b" [r12w+ -1]";
Output: Mem::DirectDisp(Register::r12w, Disp::I8(-1i8));
}
}
|
#[doc = "Register `GICD_ISENABLER7` reader"]
pub type R = crate::R<GICD_ISENABLER7_SPEC>;
#[doc = "Register `GICD_ISENABLER7` writer"]
pub type W = crate::W<GICD_ISENABLER7_SPEC>;
#[doc = "Field `ISENABLER7` reader - ISENABLER7"]
pub type ISENABLER7_R = crate::FieldReader<u32>;
#[doc = "Field `ISENABLER7` writer - ISENABLER7"]
pub type ISENABLER7_W<'a, REG, const O: u8> = crate::FieldWriter<'a, REG, 32, O, u32>;
impl R {
#[doc = "Bits 0:31 - ISENABLER7"]
#[inline(always)]
pub fn isenabler7(&self) -> ISENABLER7_R {
ISENABLER7_R::new(self.bits)
}
}
impl W {
#[doc = "Bits 0:31 - ISENABLER7"]
#[inline(always)]
#[must_use]
pub fn isenabler7(&mut self) -> ISENABLER7_W<GICD_ISENABLER7_SPEC, 0> {
ISENABLER7_W::new(self)
}
#[doc = "Writes raw bits to the register."]
#[inline(always)]
pub unsafe fn bits(&mut self, bits: u32) -> &mut Self {
self.bits = bits;
self
}
}
#[doc = "For interrupts ID\n\nYou can [`read`](crate::generic::Reg::read) this register and get [`gicd_isenabler7::R`](R). You can [`reset`](crate::generic::Reg::reset), [`write`](crate::generic::Reg::write), [`write_with_zero`](crate::generic::Reg::write_with_zero) this register using [`gicd_isenabler7::W`](W). You can also [`modify`](crate::generic::Reg::modify) this register. See [API](https://docs.rs/svd2rust/#read--modify--write-api)."]
pub struct GICD_ISENABLER7_SPEC;
impl crate::RegisterSpec for GICD_ISENABLER7_SPEC {
type Ux = u32;
}
#[doc = "`read()` method returns [`gicd_isenabler7::R`](R) reader structure"]
impl crate::Readable for GICD_ISENABLER7_SPEC {}
#[doc = "`write(|w| ..)` method takes [`gicd_isenabler7::W`](W) writer structure"]
impl crate::Writable for GICD_ISENABLER7_SPEC {
const ZERO_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
const ONE_TO_MODIFY_FIELDS_BITMAP: Self::Ux = 0;
}
#[doc = "`reset()` method sets GICD_ISENABLER7 to value 0"]
impl crate::Resettable for GICD_ISENABLER7_SPEC {
const RESET_VALUE: Self::Ux = 0;
}
|
#[cfg(feature = "option")]
use crate::complexop::*;
#[cfg(feature = "option")]
use crate::enumtypes::*;
#[cfg(feature = "option")]
use std::collections::HashMap;
#[cfg(feature = "option")]
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub struct Entity(#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>);
#[cfg(feature = "option")]
impl Entity {
pub fn new(value: Option<serde_json::Value>) -> Entity {
Entity(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DirectoryObject {
#[serde(rename = "deletedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AdministrativeUnit(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl AdministrativeUnit {
pub fn new(value: Option<serde_json::Value>) -> AdministrativeUnit {
AdministrativeUnit(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Directory {
#[serde(rename = "deletedItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted_items: Option<Vec<DirectoryObject>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Device {
#[serde(rename = "accountEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_enabled: Option<bool>,
#[serde(rename = "alternativeSecurityIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub alternative_security_ids: Option<Vec<AlternativeSecurityId>>,
#[serde(rename = "approximateLastSignInDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub approximate_last_sign_in_date_time: Option<String>,
#[serde(rename = "complianceExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_expiration_date_time: Option<String>,
#[serde(rename = "deviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "deviceMetadata")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_metadata: Option<String>,
#[serde(rename = "deviceVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_version: Option<i32>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "isCompliant")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_compliant: Option<bool>,
#[serde(rename = "isManaged")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_managed: Option<bool>,
#[serde(rename = "onPremisesLastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_last_sync_date_time: Option<String>,
#[serde(rename = "onPremisesSyncEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_sync_enabled: Option<bool>,
#[serde(rename = "operatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operating_system: Option<String>,
#[serde(rename = "operatingSystemVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operating_system_version: Option<String>,
#[serde(rename = "physicalIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub physical_ids: Option<Vec<String>>,
#[serde(rename = "profileType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub profile_type: Option<String>,
#[serde(rename = "systemLabels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub system_labels: Option<Vec<String>>,
#[serde(rename = "trustType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub trust_type: Option<String>,
#[serde(rename = "memberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "registeredOwners")]
#[serde(skip_serializing_if = "Option::is_none")]
pub registered_owners: Option<Vec<DirectoryObject>>,
#[serde(rename = "registeredUsers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub registered_users: Option<Vec<DirectoryObject>>,
#[serde(rename = "transitiveMemberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transitive_member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Extension {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DirectoryObjectPartnerReference {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "externalPartnerTenantId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_partner_tenant_id: Option<String>,
#[serde(rename = "objectType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub object_type: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DirectoryRole {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "roleTemplateId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_template_id: Option<String>,
#[serde(rename = "members")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<DirectoryObject>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DirectoryRoleTemplate {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Domain {
#[serde(rename = "authenticationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub authentication_type: Option<String>,
#[serde(rename = "availabilityStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub availability_status: Option<String>,
#[serde(rename = "isAdminManaged")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_admin_managed: Option<bool>,
#[serde(rename = "isDefault")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_default: Option<bool>,
#[serde(rename = "isInitial")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_initial: Option<bool>,
#[serde(rename = "isRoot")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_root: Option<bool>,
#[serde(rename = "isVerified")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_verified: Option<bool>,
#[serde(rename = "passwordNotificationWindowInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_notification_window_in_days: Option<i32>,
#[serde(rename = "passwordValidityPeriodInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_validity_period_in_days: Option<i32>,
#[serde(rename = "supportedServices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub supported_services: Option<Vec<String>>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<DomainState>,
#[serde(rename = "serviceConfigurationRecords")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_configuration_records: Option<Vec<DomainDnsRecord>>,
#[serde(rename = "verificationDnsRecords")]
#[serde(skip_serializing_if = "Option::is_none")]
pub verification_dns_records: Option<Vec<DomainDnsRecord>>,
#[serde(rename = "domainNameReferences")]
#[serde(skip_serializing_if = "Option::is_none")]
pub domain_name_references: Option<Vec<DirectoryObject>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsRecord {
#[serde(rename = "isOptional")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_optional: Option<bool>,
#[serde(rename = "label")]
#[serde(skip_serializing_if = "Option::is_none")]
pub label: Option<String>,
#[serde(rename = "recordType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub record_type: Option<String>,
#[serde(rename = "supportedService")]
#[serde(skip_serializing_if = "Option::is_none")]
pub supported_service: Option<String>,
#[serde(rename = "ttl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ttl: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsCnameRecord {
#[serde(rename = "canonicalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub canonical_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsMxRecord {
#[serde(rename = "mailExchange")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_exchange: Option<String>,
#[serde(rename = "preference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preference: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsSrvRecord {
#[serde(rename = "nameTarget")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name_target: Option<String>,
#[serde(rename = "port")]
#[serde(skip_serializing_if = "Option::is_none")]
pub port: Option<i32>,
#[serde(rename = "priority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i32>,
#[serde(rename = "protocol")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protocol: Option<String>,
#[serde(rename = "service")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service: Option<String>,
#[serde(rename = "weight")]
#[serde(skip_serializing_if = "Option::is_none")]
pub weight: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsTxtRecord {
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DomainDnsUnavailableRecord {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct LicenseDetails {
#[serde(rename = "servicePlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_plans: Option<Vec<ServicePlanInfo>>,
#[serde(rename = "skuId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sku_id: Option<String>,
#[serde(rename = "skuPartNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sku_part_number: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Group {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "assignedLicenses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_licenses: Option<Vec<AssignedLicense>>,
#[serde(rename = "classification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classification: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "hasMembersWithLicenseErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_members_with_license_errors: Option<bool>,
#[serde(rename = "groupTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_types: Option<Vec<String>>,
#[serde(rename = "licenseProcessingState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_processing_state: Option<LicenseProcessingState>,
#[serde(rename = "mail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail: Option<String>,
#[serde(rename = "mailEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_enabled: Option<bool>,
#[serde(rename = "mailNickname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_nickname: Option<String>,
#[serde(rename = "onPremisesLastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_last_sync_date_time: Option<String>,
#[serde(rename = "onPremisesProvisioningErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_provisioning_errors: Option<Vec<OnPremisesProvisioningError>>,
#[serde(rename = "onPremisesSecurityIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_security_identifier: Option<String>,
#[serde(rename = "onPremisesSyncEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_sync_enabled: Option<bool>,
#[serde(rename = "preferredDataLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_data_location: Option<String>,
#[serde(rename = "proxyAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub proxy_addresses: Option<Vec<String>>,
#[serde(rename = "renewedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub renewed_date_time: Option<String>,
#[serde(rename = "securityEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_enabled: Option<bool>,
#[serde(rename = "visibility")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option<String>,
#[serde(rename = "allowExternalSenders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_external_senders: Option<bool>,
#[serde(rename = "autoSubscribeNewMembers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub auto_subscribe_new_members: Option<bool>,
#[serde(rename = "isSubscribedByMail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_subscribed_by_mail: Option<bool>,
#[serde(rename = "unseenCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unseen_count: Option<i32>,
#[serde(rename = "isArchived")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_archived: Option<bool>,
#[serde(rename = "members")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<DirectoryObject>>,
#[serde(rename = "memberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "membersWithLicenseErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members_with_license_errors: Option<Vec<DirectoryObject>>,
#[serde(rename = "transitiveMembers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transitive_members: Option<Vec<DirectoryObject>>,
#[serde(rename = "transitiveMemberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transitive_member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "createdOnBehalfOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_on_behalf_of: Option<DirectoryObject>,
#[serde(rename = "owners")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owners: Option<Vec<DirectoryObject>>,
#[serde(rename = "settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<Vec<GroupSetting>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "threads")]
#[serde(skip_serializing_if = "Option::is_none")]
pub threads: Option<Vec<ConversationThread>>,
#[serde(rename = "calendar")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar: Option<Calendar>,
#[serde(rename = "calendarView")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar_view: Option<Vec<Event>>,
#[serde(rename = "events")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[serde(rename = "conversations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conversations: Option<Vec<Conversation>>,
#[serde(rename = "photo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photo: Option<ProfilePhoto>,
#[serde(rename = "photos")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photos: Option<Vec<ProfilePhoto>>,
#[serde(rename = "acceptedSenders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub accepted_senders: Option<Vec<DirectoryObject>>,
#[serde(rename = "rejectedSenders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rejected_senders: Option<Vec<DirectoryObject>>,
#[serde(rename = "drive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive: Option<Drive>,
#[serde(rename = "drives")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drives: Option<Vec<Drive>>,
#[serde(rename = "sites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sites: Option<Vec<Site>>,
#[serde(rename = "planner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub planner: Option<PlannerGroup>,
#[serde(rename = "onenote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub onenote: Option<Onenote>,
#[serde(rename = "groupLifecyclePolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_lifecycle_policies: Option<Vec<GroupLifecyclePolicy>>,
#[serde(rename = "team")]
#[serde(skip_serializing_if = "Option::is_none")]
pub team: Option<Team>,
#[serde(rename = "members@delta")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members_delta: Option<Vec<HashMap<String, String>>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct GroupSetting {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "templateId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub template_id: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<SettingValue>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ConversationThread {
#[serde(rename = "toRecipients")]
#[serde(skip_serializing_if = "Option::is_none")]
pub to_recipients: Option<Vec<Recipient>>,
#[serde(rename = "topic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topic: Option<String>,
#[serde(rename = "hasAttachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_attachments: Option<bool>,
#[serde(rename = "lastDeliveredDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_delivered_date_time: Option<String>,
#[serde(rename = "uniqueSenders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unique_senders: Option<Vec<String>>,
#[serde(rename = "ccRecipients")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_recipients: Option<Vec<Recipient>>,
#[serde(rename = "preview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preview: Option<String>,
#[serde(rename = "isLocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_locked: Option<bool>,
#[serde(rename = "posts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub posts: Option<Vec<Post>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Calendar {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<CalendarColor>,
#[serde(rename = "changeKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_key: Option<String>,
#[serde(rename = "canShare")]
#[serde(skip_serializing_if = "Option::is_none")]
pub can_share: Option<bool>,
#[serde(rename = "canViewPrivateItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub can_view_private_items: Option<bool>,
#[serde(rename = "canEdit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub can_edit: Option<bool>,
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<EmailAddress>,
#[serde(rename = "events")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[serde(rename = "calendarView")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar_view: Option<Vec<Event>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OutlookItem {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "changeKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_key: Option<String>,
#[serde(rename = "categories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<String>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Event {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<String>>,
#[serde(rename = "changeKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_key: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "originalStartTimeZone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub original_start_time_zone: Option<String>,
#[serde(rename = "originalEndTimeZone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub original_end_time_zone: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "responseStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_status: Option<ResponseStatus>,
#[serde(rename = "iCalUId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cal_u_id: Option<String>,
#[serde(rename = "reminderMinutesBeforeStart")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reminder_minutes_before_start: Option<i32>,
#[serde(rename = "isReminderOn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_reminder_on: Option<bool>,
#[serde(rename = "hasAttachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_attachments: Option<bool>,
#[serde(rename = "subject")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<String>,
#[serde(rename = "body")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<ItemBody>,
#[serde(rename = "bodyPreview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body_preview: Option<String>,
#[serde(rename = "importance")]
#[serde(skip_serializing_if = "Option::is_none")]
pub importance: Option<Importance>,
#[serde(rename = "sensitivity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sensitivity: Option<Sensitivity>,
#[serde(rename = "start")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start: Option<String>,
#[serde(rename = "originalStart")]
#[serde(skip_serializing_if = "Option::is_none")]
pub original_start: Option<String>,
#[serde(rename = "end")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end: Option<String>,
#[serde(rename = "location")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<Location>,
#[serde(rename = "locations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locations: Option<Vec<Location>>,
#[serde(rename = "isAllDay")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_all_day: Option<bool>,
#[serde(rename = "isCancelled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_cancelled: Option<bool>,
#[serde(rename = "isOrganizer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_organizer: Option<bool>,
#[serde(rename = "recurrence")]
#[serde(skip_serializing_if = "Option::is_none")]
pub recurrence: Option<PatternedRecurrence>,
#[serde(rename = "responseRequested")]
#[serde(skip_serializing_if = "Option::is_none")]
pub response_requested: Option<bool>,
#[serde(rename = "seriesMasterId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub series_master_id: Option<String>,
#[serde(rename = "showAs")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_as: Option<FreeBusyStatus>,
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _type: Option<EventType>,
#[serde(rename = "attendees")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attendees: Option<Vec<Attendee>>,
#[serde(rename = "organizer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organizer: Option<Recipient>,
#[serde(rename = "webLink")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_link: Option<String>,
#[serde(rename = "onlineMeetingUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub online_meeting_url: Option<String>,
#[serde(rename = "calendar")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar: Option<Calendar>,
#[serde(rename = "instances")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instances: Option<Vec<Event>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "attachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachments: Option<Vec<Attachment>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Conversation {
#[serde(rename = "topic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topic: Option<String>,
#[serde(rename = "hasAttachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_attachments: Option<bool>,
#[serde(rename = "lastDeliveredDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_delivered_date_time: Option<String>,
#[serde(rename = "uniqueSenders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unique_senders: Option<Vec<String>>,
#[serde(rename = "preview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preview: Option<String>,
#[serde(rename = "threads")]
#[serde(skip_serializing_if = "Option::is_none")]
pub threads: Option<Vec<ConversationThread>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ProfilePhoto {
#[serde(rename = "height")]
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i32>,
#[serde(rename = "width")]
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BaseItem {
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "eTag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub e_tag: Option<String>,
#[serde(rename = "lastModifiedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "parentReference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_reference: Option<ItemReference>,
#[serde(rename = "webUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_url: Option<String>,
#[serde(rename = "createdByUser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by_user: Option<User>,
#[serde(rename = "lastModifiedByUser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by_user: Option<User>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Drive {
#[serde(rename = "id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "driveType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive_type: Option<String>,
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<IdentitySet>,
#[serde(rename = "quota")]
#[serde(skip_serializing_if = "Option::is_none")]
pub quota: Option<Quota>,
#[serde(rename = "sharePointIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub share_point_ids: Option<SharepointIds>,
#[serde(rename = "system")]
#[serde(skip_serializing_if = "Option::is_none")]
pub system: Option<SystemFacet>,
#[serde(rename = "items")]
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<DriveItem>>,
#[serde(rename = "list")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list: Option<Box<List>>,
#[serde(rename = "root")]
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<Box<DriveItem>>,
#[serde(rename = "special")]
#[serde(skip_serializing_if = "Option::is_none")]
pub special: Option<Vec<DriveItem>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Site {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "root")]
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<Root>,
#[serde(rename = "sharepointIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sharepoint_ids: Option<SharepointIds>,
#[serde(rename = "siteCollection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub site_collection: Option<SiteCollection>,
#[serde(rename = "analytics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub analytics: Option<ItemAnalytics>,
#[serde(rename = "columns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub columns: Option<Vec<ColumnDefinition>>,
#[serde(rename = "contentTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_types: Option<Vec<ContentType>>,
#[serde(rename = "drive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive: Option<Drive>,
#[serde(rename = "drives")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drives: Option<Vec<Drive>>,
#[serde(rename = "items")]
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<BaseItem>>,
#[serde(rename = "lists")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lists: Option<Vec<List>>,
#[serde(rename = "sites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sites: Option<Vec<Site>>,
#[serde(rename = "onenote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub onenote: Option<Onenote>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerGroup {
#[serde(rename = "plans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plans: Option<Vec<PlannerPlan>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Onenote {
#[serde(rename = "notebooks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notebooks: Option<Vec<Notebook>>,
#[serde(rename = "sections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sections: Option<Vec<OnenoteSection>>,
#[serde(rename = "sectionGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub section_groups: Option<Vec<SectionGroup>>,
#[serde(rename = "pages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pages: Option<Vec<OnenotePage>>,
#[serde(rename = "resources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resources: Option<Vec<OnenoteResource>>,
#[serde(rename = "operations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operations: Option<Vec<OnenoteOperation>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct GroupLifecyclePolicy {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "groupLifetimeInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group_lifetime_in_days: Option<i32>,
#[serde(rename = "managedGroupTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_group_types: Option<String>,
#[serde(rename = "alternateNotificationEmails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub alternate_notification_emails: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Team {
#[serde(rename = "webUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_url: Option<String>,
#[serde(rename = "memberSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_settings: Option<TeamMemberSettings>,
#[serde(rename = "guestSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub guest_settings: Option<TeamGuestSettings>,
#[serde(rename = "messagingSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub messaging_settings: Option<TeamMessagingSettings>,
#[serde(rename = "funSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fun_settings: Option<TeamFunSettings>,
#[serde(rename = "isArchived")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_archived: Option<bool>,
#[serde(rename = "channels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub channels: Option<Vec<Channel>>,
#[serde(rename = "installedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub installed_apps: Option<Vec<TeamsAppInstallation>>,
#[serde(rename = "operations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operations: Option<Vec<TeamsAsyncOperation>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Contract {
#[serde(rename = "contractType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contract_type: Option<String>,
#[serde(rename = "customerId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub customer_id: Option<String>,
#[serde(rename = "defaultDomainName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub default_domain_name: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SubscribedSku {
#[serde(rename = "capabilityStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub capability_status: Option<String>,
#[serde(rename = "consumedUnits")]
#[serde(skip_serializing_if = "Option::is_none")]
pub consumed_units: Option<i32>,
#[serde(rename = "prepaidUnits")]
#[serde(skip_serializing_if = "Option::is_none")]
pub prepaid_units: Option<LicenseUnitsDetail>,
#[serde(rename = "servicePlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service_plans: Option<Vec<ServicePlanInfo>>,
#[serde(rename = "skuId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sku_id: Option<String>,
#[serde(rename = "skuPartNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sku_part_number: Option<String>,
#[serde(rename = "appliesTo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applies_to: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Organization {
#[serde(rename = "assignedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_plans: Option<Vec<AssignedPlan>>,
#[serde(rename = "businessPhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_phones: Option<Vec<String>>,
#[serde(rename = "city")]
#[serde(skip_serializing_if = "Option::is_none")]
pub city: Option<String>,
#[serde(rename = "country")]
#[serde(skip_serializing_if = "Option::is_none")]
pub country: Option<String>,
#[serde(rename = "countryLetterCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub country_letter_code: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "marketingNotificationEmails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub marketing_notification_emails: Option<Vec<String>>,
#[serde(rename = "onPremisesLastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_last_sync_date_time: Option<String>,
#[serde(rename = "onPremisesSyncEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_sync_enabled: Option<bool>,
#[serde(rename = "postalCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub postal_code: Option<String>,
#[serde(rename = "preferredLanguage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_language: Option<String>,
#[serde(rename = "privacyProfile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_profile: Option<PrivacyProfile>,
#[serde(rename = "provisionedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub provisioned_plans: Option<Vec<ProvisionedPlan>>,
#[serde(rename = "securityComplianceNotificationMails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_compliance_notification_mails: Option<Vec<String>>,
#[serde(rename = "securityComplianceNotificationPhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_compliance_notification_phones: Option<Vec<String>>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "street")]
#[serde(skip_serializing_if = "Option::is_none")]
pub street: Option<String>,
#[serde(rename = "technicalNotificationMails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub technical_notification_mails: Option<Vec<String>>,
#[serde(rename = "verifiedDomains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub verified_domains: Option<Vec<VerifiedDomain>>,
#[serde(rename = "mobileDeviceManagementAuthority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_device_management_authority: Option<MdmAuthority>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct User {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "accountEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_enabled: Option<bool>,
#[serde(rename = "ageGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub age_group: Option<String>,
#[serde(rename = "assignedLicenses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_licenses: Option<Vec<AssignedLicense>>,
#[serde(rename = "assignedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_plans: Option<Vec<AssignedPlan>>,
#[serde(rename = "businessPhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_phones: Option<Vec<String>>,
#[serde(rename = "city")]
#[serde(skip_serializing_if = "Option::is_none")]
pub city: Option<String>,
#[serde(rename = "companyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub company_name: Option<String>,
#[serde(rename = "consentProvidedForMinor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub consent_provided_for_minor: Option<String>,
#[serde(rename = "country")]
#[serde(skip_serializing_if = "Option::is_none")]
pub country: Option<String>,
#[serde(rename = "department")]
#[serde(skip_serializing_if = "Option::is_none")]
pub department: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "employeeId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub employee_id: Option<String>,
#[serde(rename = "faxNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fax_number: Option<String>,
#[serde(rename = "givenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
#[serde(rename = "imAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub im_addresses: Option<Vec<String>>,
#[serde(rename = "isResourceAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_resource_account: Option<bool>,
#[serde(rename = "jobTitle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_title: Option<String>,
#[serde(rename = "legalAgeGroupClassification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub legal_age_group_classification: Option<String>,
#[serde(rename = "licenseAssignmentStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_assignment_states: Option<Vec<LicenseAssignmentState>>,
#[serde(rename = "mail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail: Option<String>,
#[serde(rename = "mailNickname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_nickname: Option<String>,
#[serde(rename = "mobilePhone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_phone: Option<String>,
#[serde(rename = "onPremisesDistinguishedName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_distinguished_name: Option<String>,
#[serde(rename = "onPremisesExtensionAttributes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_extension_attributes: Option<OnPremisesExtensionAttributes>,
#[serde(rename = "onPremisesImmutableId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_immutable_id: Option<String>,
#[serde(rename = "onPremisesLastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_last_sync_date_time: Option<String>,
#[serde(rename = "onPremisesProvisioningErrors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_provisioning_errors: Option<Vec<OnPremisesProvisioningError>>,
#[serde(rename = "onPremisesSecurityIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_security_identifier: Option<String>,
#[serde(rename = "onPremisesSyncEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_sync_enabled: Option<bool>,
#[serde(rename = "onPremisesDomainName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_domain_name: Option<String>,
#[serde(rename = "onPremisesSamAccountName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_sam_account_name: Option<String>,
#[serde(rename = "onPremisesUserPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub on_premises_user_principal_name: Option<String>,
#[serde(rename = "otherMails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub other_mails: Option<Vec<String>>,
#[serde(rename = "passwordPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_policies: Option<String>,
#[serde(rename = "passwordProfile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_profile: Option<PasswordProfile>,
#[serde(rename = "officeLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub office_location: Option<String>,
#[serde(rename = "postalCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub postal_code: Option<String>,
#[serde(rename = "preferredLanguage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_language: Option<String>,
#[serde(rename = "provisionedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub provisioned_plans: Option<Vec<ProvisionedPlan>>,
#[serde(rename = "proxyAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub proxy_addresses: Option<Vec<String>>,
#[serde(rename = "showInAddressList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_in_address_list: Option<bool>,
#[serde(rename = "signInSessionsValidFromDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sign_in_sessions_valid_from_date_time: Option<String>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "streetAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub street_address: Option<String>,
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
#[serde(rename = "usageLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_location: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "userType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_type: Option<String>,
#[serde(rename = "mailboxSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mailbox_settings: Option<MailboxSettings>,
#[serde(rename = "aboutMe")]
#[serde(skip_serializing_if = "Option::is_none")]
pub about_me: Option<String>,
#[serde(rename = "birthday")]
#[serde(skip_serializing_if = "Option::is_none")]
pub birthday: Option<String>,
#[serde(rename = "hireDate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hire_date: Option<String>,
#[serde(rename = "interests")]
#[serde(skip_serializing_if = "Option::is_none")]
pub interests: Option<Vec<String>>,
#[serde(rename = "mySite")]
#[serde(skip_serializing_if = "Option::is_none")]
pub my_site: Option<String>,
#[serde(rename = "pastProjects")]
#[serde(skip_serializing_if = "Option::is_none")]
pub past_projects: Option<Vec<String>>,
#[serde(rename = "preferredName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_name: Option<String>,
#[serde(rename = "responsibilities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub responsibilities: Option<Vec<String>>,
#[serde(rename = "schools")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schools: Option<Vec<String>>,
#[serde(rename = "skills")]
#[serde(skip_serializing_if = "Option::is_none")]
pub skills: Option<Vec<String>>,
#[serde(rename = "deviceEnrollmentLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_enrollment_limit: Option<i32>,
#[serde(rename = "ownedDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owned_devices: Option<Vec<DirectoryObject>>,
#[serde(rename = "registeredDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub registered_devices: Option<Vec<DirectoryObject>>,
#[serde(rename = "manager")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manager: Option<DirectoryObject>,
#[serde(rename = "directReports")]
#[serde(skip_serializing_if = "Option::is_none")]
pub direct_reports: Option<Vec<DirectoryObject>>,
#[serde(rename = "memberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "createdObjects")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_objects: Option<Vec<DirectoryObject>>,
#[serde(rename = "ownedObjects")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owned_objects: Option<Vec<DirectoryObject>>,
#[serde(rename = "licenseDetails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_details: Option<Vec<LicenseDetails>>,
#[serde(rename = "transitiveMemberOf")]
#[serde(skip_serializing_if = "Option::is_none")]
pub transitive_member_of: Option<Vec<DirectoryObject>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "outlook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub outlook: Option<OutlookUser>,
#[serde(rename = "messages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub messages: Option<Vec<Message>>,
#[serde(rename = "mailFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_folders: Option<Vec<MailFolder>>,
#[serde(rename = "calendar")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar: Option<Calendar>,
#[serde(rename = "calendars")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendars: Option<Vec<Calendar>>,
#[serde(rename = "calendarGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar_groups: Option<Vec<CalendarGroup>>,
#[serde(rename = "calendarView")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendar_view: Option<Vec<Event>>,
#[serde(rename = "events")]
#[serde(skip_serializing_if = "Option::is_none")]
pub events: Option<Vec<Event>>,
#[serde(rename = "people")]
#[serde(skip_serializing_if = "Option::is_none")]
pub people: Option<Vec<Person>>,
#[serde(rename = "contacts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contacts: Option<Vec<Contact>>,
#[serde(rename = "contactFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contact_folders: Option<Vec<ContactFolder>>,
#[serde(rename = "inferenceClassification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inference_classification: Option<InferenceClassification>,
#[serde(rename = "photo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photo: Option<ProfilePhoto>,
#[serde(rename = "photos")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photos: Option<Vec<ProfilePhoto>>,
#[serde(rename = "drive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive: Option<Box<Drive>>,
#[serde(rename = "drives")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drives: Option<Vec<Drive>>,
#[serde(rename = "planner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub planner: Option<PlannerUser>,
#[serde(rename = "onenote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub onenote: Option<Onenote>,
#[serde(rename = "managedDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_devices: Option<Vec<ManagedDevice>>,
#[serde(rename = "managedAppRegistrations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_app_registrations: Option<Vec<ManagedAppRegistration>>,
#[serde(rename = "deviceManagementTroubleshootingEvents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_management_troubleshooting_events: Option<Vec<DeviceManagementTroubleshootingEvent>>,
#[serde(rename = "activities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activities: Option<Vec<UserActivity>>,
#[serde(rename = "insights")]
#[serde(skip_serializing_if = "Option::is_none")]
pub insights: Option<OfficeGraphInsights>,
#[serde(rename = "settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<UserSettings>,
#[serde(rename = "joinedTeams")]
#[serde(skip_serializing_if = "Option::is_none")]
pub joined_teams: Option<Vec<Group>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OutlookUser {
#[serde(rename = "masterCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub master_categories: Option<Vec<OutlookCategory>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Message {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "@odata.etag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub odata_etag: Option<String>,
#[serde(rename = "receivedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub received_date_time: Option<String>,
#[serde(rename = "sentDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sent_date_time: Option<String>,
#[serde(rename = "hasAttachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_attachments: Option<bool>,
#[serde(rename = "internetMessageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub internet_message_id: Option<String>,
#[serde(rename = "internetMessageHeaders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub internet_message_headers: Option<Vec<InternetMessageHeader>>,
#[serde(rename = "subject")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<String>,
#[serde(rename = "body")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<ItemBody>,
#[serde(rename = "bodyPreview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body_preview: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<String>>,
#[serde(rename = "importance")]
#[serde(skip_serializing_if = "Option::is_none")]
pub importance: Option<Importance>,
#[serde(rename = "parentFolderId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_folder_id: Option<String>,
#[serde(rename = "sender")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sender: Option<Recipient>,
#[serde(rename = "from")]
#[serde(skip_serializing_if = "Option::is_none")]
pub from: Option<Recipient>,
#[serde(rename = "toRecipients")]
#[serde(skip_serializing_if = "Option::is_none")]
pub to_recipients: Option<Vec<Recipient>>,
#[serde(rename = "changeKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_key: Option<String>,
#[serde(rename = "ccRecipients")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cc_recipients: Option<Vec<Recipient>>,
#[serde(rename = "bccRecipients")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bcc_recipients: Option<Vec<Recipient>>,
#[serde(rename = "replyTo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reply_to: Option<Vec<Recipient>>,
#[serde(rename = "conversationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
#[serde(rename = "uniqueBody")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unique_body: Option<ItemBody>,
#[serde(rename = "isDeliveryReceiptRequested")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_delivery_receipt_requested: Option<bool>,
#[serde(rename = "isReadReceiptRequested")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_read_receipt_requested: Option<bool>,
#[serde(rename = "lastModifiedDateTime")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "isRead")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_read: Option<bool>,
#[serde(rename = "isDraft")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_draft: Option<bool>,
#[serde(rename = "webLink")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_link: Option<String>,
#[serde(rename = "inferenceClassification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inference_classification: Option<InferenceClassificationType>,
#[serde(rename = "flag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub flag: Option<FollowupFlag>,
#[serde(rename = "attachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachments: Option<Vec<Attachment>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MailFolder {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "parentFolderId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_folder_id: Option<String>,
#[serde(rename = "childFolderCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub child_folder_count: Option<i32>,
#[serde(rename = "unreadItemCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unread_item_count: Option<i32>,
#[serde(rename = "totalItemCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_item_count: Option<i32>,
#[serde(rename = "messages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub messages: Option<Vec<Message>>,
#[serde(rename = "messageRules")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_rules: Option<Vec<MessageRule>>,
#[serde(rename = "childFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub child_folders: Option<Vec<MailFolder>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct CalendarGroup {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "classId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub class_id: Option<String>,
#[serde(rename = "changeKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_key: Option<String>,
#[serde(rename = "calendars")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calendars: Option<Vec<Calendar>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Person {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "givenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
#[serde(rename = "birthday")]
#[serde(skip_serializing_if = "Option::is_none")]
pub birthday: Option<String>,
#[serde(rename = "personNotes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub person_notes: Option<String>,
#[serde(rename = "isFavorite")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_favorite: Option<bool>,
#[serde(rename = "scoredEmailAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scored_email_addresses: Option<Vec<ScoredEmailAddress>>,
#[serde(rename = "phones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phones: Option<Vec<Phone>>,
#[serde(rename = "postalAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub postal_addresses: Option<Vec<Location>>,
#[serde(rename = "websites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub websites: Option<Vec<Website>>,
#[serde(rename = "jobTitle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_title: Option<String>,
#[serde(rename = "companyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub company_name: Option<String>,
#[serde(rename = "yomiCompany")]
#[serde(skip_serializing_if = "Option::is_none")]
pub yomi_company: Option<String>,
#[serde(rename = "department")]
#[serde(skip_serializing_if = "Option::is_none")]
pub department: Option<String>,
#[serde(rename = "officeLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub office_location: Option<String>,
#[serde(rename = "profession")]
#[serde(skip_serializing_if = "Option::is_none")]
pub profession: Option<String>,
#[serde(rename = "personType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub person_type: Option<PersonType>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "imAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub im_address: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Contact {
#[serde(rename = "parentFolderId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_folder_id: Option<String>,
#[serde(rename = "birthday")]
#[serde(skip_serializing_if = "Option::is_none")]
pub birthday: Option<String>,
#[serde(rename = "fileAs")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_as: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "givenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
#[serde(rename = "initials")]
#[serde(skip_serializing_if = "Option::is_none")]
pub initials: Option<String>,
#[serde(rename = "middleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub middle_name: Option<String>,
#[serde(rename = "nickName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nick_name: Option<String>,
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "yomiGivenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub yomi_given_name: Option<String>,
#[serde(rename = "yomiSurname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub yomi_surname: Option<String>,
#[serde(rename = "yomiCompanyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub yomi_company_name: Option<String>,
#[serde(rename = "generation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub generation: Option<String>,
#[serde(rename = "emailAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_addresses: Option<Vec<EmailAddress>>,
#[serde(rename = "imAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub im_addresses: Option<Vec<String>>,
#[serde(rename = "jobTitle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub job_title: Option<String>,
#[serde(rename = "companyName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub company_name: Option<String>,
#[serde(rename = "department")]
#[serde(skip_serializing_if = "Option::is_none")]
pub department: Option<String>,
#[serde(rename = "officeLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub office_location: Option<String>,
#[serde(rename = "profession")]
#[serde(skip_serializing_if = "Option::is_none")]
pub profession: Option<String>,
#[serde(rename = "businessHomePage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_home_page: Option<String>,
#[serde(rename = "assistantName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assistant_name: Option<String>,
#[serde(rename = "manager")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manager: Option<String>,
#[serde(rename = "homePhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub home_phones: Option<Vec<String>>,
#[serde(rename = "mobilePhone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_phone: Option<String>,
#[serde(rename = "businessPhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_phones: Option<Vec<String>>,
#[serde(rename = "homeAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub home_address: Option<PhysicalAddress>,
#[serde(rename = "businessAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_address: Option<PhysicalAddress>,
#[serde(rename = "otherAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub other_address: Option<PhysicalAddress>,
#[serde(rename = "spouseName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub spouse_name: Option<String>,
#[serde(rename = "personalNotes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub personal_notes: Option<String>,
#[serde(rename = "children")]
#[serde(skip_serializing_if = "Option::is_none")]
pub children: Option<Vec<String>>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
#[serde(rename = "photo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photo: Option<ProfilePhoto>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ContactFolder {
#[serde(rename = "parentFolderId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_folder_id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "contacts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contacts: Option<Vec<Contact>>,
#[serde(rename = "childFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub child_folders: Option<Vec<ContactFolder>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct InferenceClassification {
#[serde(rename = "overrides")]
#[serde(skip_serializing_if = "Option::is_none")]
pub overrides: Option<Vec<InferenceClassificationOverride>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerUser {
#[serde(rename = "tasks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tasks: Option<Vec<PlannerTask>>,
#[serde(rename = "plans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plans: Option<Vec<PlannerPlan>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDevice {
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "deviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_name: Option<String>,
#[serde(rename = "managedDeviceOwnerType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_device_owner_type: Option<ManagedDeviceOwnerType>,
#[serde(rename = "deviceActionResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_action_results: Option<Vec<DeviceActionResult>>,
#[serde(rename = "enrolledDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enrolled_date_time: Option<String>,
#[serde(rename = "lastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_date_time: Option<String>,
#[serde(rename = "operatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operating_system: Option<String>,
#[serde(rename = "complianceState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_state: Option<ComplianceState>,
#[serde(rename = "jailBroken")]
#[serde(skip_serializing_if = "Option::is_none")]
pub jail_broken: Option<String>,
#[serde(rename = "managementAgent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub management_agent: Option<ManagementAgentType>,
#[serde(rename = "osVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<String>,
#[serde(rename = "easActivated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eas_activated: Option<bool>,
#[serde(rename = "easDeviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eas_device_id: Option<String>,
#[serde(rename = "easActivationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub eas_activation_date_time: Option<String>,
#[serde(rename = "azureADRegistered")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_a_d_registered: Option<bool>,
#[serde(rename = "deviceEnrollmentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_enrollment_type: Option<DeviceEnrollmentType>,
#[serde(rename = "activationLockBypassCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activation_lock_bypass_code: Option<String>,
#[serde(rename = "emailAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_address: Option<String>,
#[serde(rename = "azureADDeviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_a_d_device_id: Option<String>,
#[serde(rename = "deviceRegistrationState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_registration_state: Option<DeviceRegistrationState>,
#[serde(rename = "deviceCategoryDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_category_display_name: Option<String>,
#[serde(rename = "isSupervised")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_supervised: Option<bool>,
#[serde(rename = "exchangeLastSuccessfulSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_last_successful_sync_date_time: Option<String>,
#[serde(rename = "exchangeAccessState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_access_state: Option<DeviceManagementExchangeAccessState>,
#[serde(rename = "exchangeAccessStateReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_access_state_reason: Option<DeviceManagementExchangeAccessStateReason>,
#[serde(rename = "remoteAssistanceSessionUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_assistance_session_url: Option<String>,
#[serde(rename = "remoteAssistanceSessionErrorDetails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_assistance_session_error_details: Option<String>,
#[serde(rename = "isEncrypted")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_encrypted: Option<bool>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "model")]
#[serde(skip_serializing_if = "Option::is_none")]
pub model: Option<String>,
#[serde(rename = "manufacturer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manufacturer: Option<String>,
#[serde(rename = "imei")]
#[serde(skip_serializing_if = "Option::is_none")]
pub imei: Option<String>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
#[serde(rename = "serialNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub serial_number: Option<String>,
#[serde(rename = "phoneNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<String>,
#[serde(rename = "androidSecurityPatchLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub android_security_patch_level: Option<String>,
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "configurationManagerClientEnabledFeatures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_manager_client_enabled_features:
Option<ConfigurationManagerClientEnabledFeatures>,
#[serde(rename = "wiFiMacAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_mac_address: Option<String>,
#[serde(rename = "deviceHealthAttestationState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_health_attestation_state: Option<DeviceHealthAttestationState>,
#[serde(rename = "subscriberCarrier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subscriber_carrier: Option<String>,
#[serde(rename = "meid")]
#[serde(skip_serializing_if = "Option::is_none")]
pub meid: Option<String>,
#[serde(rename = "totalStorageSpaceInBytes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_storage_space_in_bytes: Option<i64>,
#[serde(rename = "freeStorageSpaceInBytes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub free_storage_space_in_bytes: Option<i64>,
#[serde(rename = "managedDeviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_device_name: Option<String>,
#[serde(rename = "partnerReportedThreatState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_reported_threat_state: Option<ManagedDevicePartnerReportedHealthState>,
#[serde(rename = "deviceConfigurationStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_configuration_states: Option<Vec<DeviceConfigurationState>>,
#[serde(rename = "deviceCategory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_category: Option<DeviceCategory>,
#[serde(rename = "deviceCompliancePolicyStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_policy_states: Option<Vec<DeviceCompliancePolicyState>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppRegistration {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_date_time: Option<String>,
#[serde(rename = "applicationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_version: Option<String>,
#[serde(rename = "managementSdkVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub management_sdk_version: Option<String>,
#[serde(rename = "platformVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub platform_version: Option<String>,
#[serde(rename = "deviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_type: Option<String>,
#[serde(rename = "deviceTag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_tag: Option<String>,
#[serde(rename = "deviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_name: Option<String>,
#[serde(rename = "flaggedReasons")]
#[serde(skip_serializing_if = "Option::is_none")]
pub flagged_reasons: Option<Vec<ManagedAppFlaggedReason>>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "appIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_identifier: Option<MobileAppIdentifier>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(rename = "appliedPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applied_policies: Option<Vec<ManagedAppPolicy>>,
#[serde(rename = "intendedPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub intended_policies: Option<Vec<ManagedAppPolicy>>,
#[serde(rename = "operations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operations: Option<Vec<ManagedAppOperation>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceManagementTroubleshootingEvent {
#[serde(rename = "eventDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_date_time: Option<String>,
#[serde(rename = "correlationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub correlation_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct UserActivity {
#[serde(rename = "visualElements")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visual_elements: Option<VisualInfo>,
#[serde(rename = "activitySourceHost")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_source_host: Option<String>,
#[serde(rename = "activationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activation_url: Option<String>,
#[serde(rename = "appActivityId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_activity_id: Option<String>,
#[serde(rename = "appDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_display_name: Option<String>,
#[serde(rename = "contentUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_url: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "fallbackUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fallback_url: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "userTimezone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_timezone: Option<String>,
#[serde(rename = "contentInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_info: Option<Json>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
#[serde(rename = "historyItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub history_items: Option<Vec<ActivityHistoryItem>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OfficeGraphInsights {
#[serde(rename = "trending")]
#[serde(skip_serializing_if = "Option::is_none")]
pub trending: Option<Vec<Trending>>,
#[serde(rename = "shared")]
#[serde(skip_serializing_if = "Option::is_none")]
pub shared: Option<Vec<SharedInsight>>,
#[serde(rename = "used")]
#[serde(skip_serializing_if = "Option::is_none")]
pub used: Option<Vec<UsedInsight>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct UserSettings {
#[serde(rename = "contributionToContentDiscoveryDisabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contribution_to_content_discovery_disabled: Option<bool>,
#[serde(rename = "contributionToContentDiscoveryAsOrganizationDisabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contribution_to_content_discovery_as_organization_disabled: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct GroupSettingTemplate {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Vec<SettingTemplateValue>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SchemaExtension {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "targetTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_types: Option<Vec<String>>,
#[serde(rename = "properties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub properties: Option<Vec<ExtensionSchemaProperty>>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Attachment {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "contentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i32>,
#[serde(rename = "isInline")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_inline: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OutlookCategory {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<CategoryColor>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MessageRule {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "sequence")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sequence: Option<i32>,
#[serde(rename = "conditions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conditions: Option<MessageRulePredicates>,
#[serde(rename = "actions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub actions: Option<MessageRuleActions>,
#[serde(rename = "exceptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exceptions: Option<MessageRulePredicates>,
#[serde(rename = "isEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_enabled: Option<bool>,
#[serde(rename = "hasError")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_error: Option<bool>,
#[serde(rename = "isReadOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_read_only: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SingleValueLegacyExtendedProperty {
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MultiValueLegacyExtendedProperty {
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Vec<String>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MailSearchFolder {
#[serde(rename = "isSupported")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_supported: Option<bool>,
#[serde(rename = "includeNestedFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub include_nested_folders: Option<bool>,
#[serde(rename = "sourceFolderIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_folder_ids: Option<Vec<String>>,
#[serde(rename = "filterQuery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter_query: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct FileAttachment {
#[serde(rename = "contentId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_id: Option<String>,
#[serde(rename = "contentLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_location: Option<String>,
#[serde(rename = "contentBytes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_bytes: Option<Vec<u8>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ItemAttachment {
#[serde(rename = "item")]
#[serde(skip_serializing_if = "Option::is_none")]
pub item: Option<OutlookItem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EventMessage {
#[serde(rename = "meetingMessageType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub meeting_message_type: Option<MeetingMessageType>,
#[serde(rename = "event")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event: Option<Event>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ReferenceAttachment(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl ReferenceAttachment {
pub fn new(value: Option<serde_json::Value>) -> ReferenceAttachment {
ReferenceAttachment(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OpenTypeExtension {
#[serde(rename = "extensionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extension_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Post {
#[serde(rename = "body")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body: Option<ItemBody>,
#[serde(rename = "receivedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub received_date_time: Option<String>,
#[serde(rename = "hasAttachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_attachments: Option<bool>,
#[serde(rename = "from")]
#[serde(skip_serializing_if = "Option::is_none")]
pub from: Option<Recipient>,
#[serde(rename = "sender")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sender: Option<Recipient>,
#[serde(rename = "conversationThreadId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_thread_id: Option<String>,
#[serde(rename = "newParticipants")]
#[serde(skip_serializing_if = "Option::is_none")]
pub new_participants: Option<Vec<Recipient>>,
#[serde(rename = "conversationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_id: Option<String>,
#[serde(rename = "extensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub extensions: Option<Vec<Extension>>,
#[serde(rename = "inReplyTo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub in_reply_to: Option<Box<Post>>,
#[serde(rename = "attachments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attachments: Option<Vec<Attachment>>,
#[serde(rename = "singleValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_value_extended_properties: Option<String>,
#[serde(rename = "multiValueExtendedProperties")]
#[serde(skip_serializing_if = "Option::is_none")]
pub multi_value_extended_properties: Option<Vec<MultiValueLegacyExtendedProperty>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct InferenceClassificationOverride {
#[serde(rename = "classifyAs")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classify_as: Option<InferenceClassificationType>,
#[serde(rename = "senderEmailAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sender_email_address: Option<EmailAddress>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct BaseItemVersion {
#[serde(rename = "lastModifiedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "publication")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publication: Option<PublicationFacet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ColumnDefinition {
#[serde(rename = "boolean")]
#[serde(skip_serializing_if = "Option::is_none")]
pub boolean: Option<BooleanColumn>,
#[serde(rename = "calculated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calculated: Option<CalculatedColumn>,
#[serde(rename = "choice")]
#[serde(skip_serializing_if = "Option::is_none")]
pub choice: Option<ChoiceColumn>,
#[serde(rename = "columnGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_group: Option<String>,
#[serde(rename = "currency")]
#[serde(skip_serializing_if = "Option::is_none")]
pub currency: Option<CurrencyColumn>,
#[serde(rename = "dateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub date_time: Option<String>,
#[serde(rename = "defaultValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub default_value: Option<DefaultColumnValue>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "enforceUniqueValues")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enforce_unique_values: Option<bool>,
#[serde(rename = "hidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hidden: Option<bool>,
#[serde(rename = "indexed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub indexed: Option<bool>,
#[serde(rename = "lookup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lookup: Option<LookupColumn>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "number")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number: Option<NumberColumn>,
#[serde(rename = "personOrGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub person_or_group: Option<PersonOrGroupColumn>,
#[serde(rename = "readOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub read_only: Option<bool>,
#[serde(rename = "required")]
#[serde(skip_serializing_if = "Option::is_none")]
pub required: Option<bool>,
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<TextColumn>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ColumnLink {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ContentType {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<String>,
#[serde(rename = "hidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hidden: Option<bool>,
#[serde(rename = "inheritedFrom")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inherited_from: Option<ItemReference>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "order")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<ContentTypeOrder>,
#[serde(rename = "parentId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_id: Option<String>,
#[serde(rename = "readOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub read_only: Option<bool>,
#[serde(rename = "sealed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sealed: Option<bool>,
#[serde(rename = "columnLinks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_links: Option<Vec<ColumnLink>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DriveItem {
#[serde(rename = "@odata.context")]
#[serde(skip_serializing_if = "Option::is_none")]
odata_context: Option<String>,
#[serde(rename = "@odata.type")]
#[serde(skip_serializing_if = "Option::is_none")]
odata_type: Option<String>,
#[serde(rename = "id")]
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "eTag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub e_tag: Option<String>,
#[serde(rename = "lastModifiedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "parentReference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_reference: Option<ItemReference>,
#[serde(rename = "webUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_url: Option<String>,
#[serde(rename = "createdByUser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by_user: Option<Box<User>>,
#[serde(rename = "lastModifiedByUser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by_user: Option<Box<User>>,
#[serde(rename = "audio")]
#[serde(skip_serializing_if = "Option::is_none")]
pub audio: Option<Audio>,
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Vec<u8>>,
#[serde(rename = "cTag")]
#[serde(skip_serializing_if = "Option::is_none")]
pub c_tag: Option<String>,
#[serde(rename = "deleted")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deleted: Option<Deleted>,
#[serde(rename = "file")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file: Option<File>,
#[serde(rename = "fileSystemInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_system_info: Option<FileSystemInfo>,
#[serde(rename = "folder")]
#[serde(skip_serializing_if = "Option::is_none")]
pub folder: Option<Folder>,
#[serde(rename = "image")]
#[serde(skip_serializing_if = "Option::is_none")]
pub image: Option<Image>,
#[serde(rename = "location")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<GeoCoordinates>,
#[serde(rename = "package")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package: Option<Package>,
#[serde(rename = "photo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub photo: Option<Photo>,
#[serde(rename = "publication")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publication: Option<PublicationFacet>,
#[serde(rename = "remoteItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_item: Option<RemoteItem>,
#[serde(rename = "root")]
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<Root>,
#[serde(rename = "searchResult")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_result: Option<SearchResult>,
#[serde(rename = "shared")]
#[serde(skip_serializing_if = "Option::is_none")]
pub shared: Option<Shared>,
#[serde(rename = "sharepointIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sharepoint_ids: Option<SharepointIds>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "specialFolder")]
#[serde(skip_serializing_if = "Option::is_none")]
pub special_folder: Option<SpecialFolder>,
#[serde(rename = "video")]
#[serde(skip_serializing_if = "Option::is_none")]
pub video: Option<Video>,
#[serde(rename = "webDavUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_dav_url: Option<String>,
#[serde(rename = "analytics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub analytics: Option<ItemAnalytics>,
#[serde(rename = "children")]
#[serde(skip_serializing_if = "Option::is_none")]
pub children: Option<Vec<DriveItem>>,
#[serde(rename = "listItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list_item: Option<ListItem>,
#[serde(rename = "permissions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub permissions: Option<Vec<Permission>>,
#[serde(rename = "subscriptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subscriptions: Option<Vec<Subscription>>,
#[serde(rename = "thumbnails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub thumbnails: Option<Vec<ThumbnailSet>>,
#[serde(rename = "versions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub versions: Option<Vec<DriveItemVersion>>,
#[serde(rename = "workbook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub workbook: Option<Workbook>,
#[serde(rename = "@microsoft.graph.conflictBehavior")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_behavior: Option<String>,
#[serde(rename = "@microsoft.graph.downloadUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub download_url: Option<String>,
#[serde(rename = "@microsoft.graph.sourceUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_url: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct List {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "list")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list: Option<ListInfo>,
#[serde(rename = "sharepointIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sharepoint_ids: Option<SharepointIds>,
#[serde(rename = "system")]
#[serde(skip_serializing_if = "Option::is_none")]
pub system: Option<SystemFacet>,
#[serde(rename = "columns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub columns: Option<Vec<ColumnDefinition>>,
#[serde(rename = "contentTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_types: Option<Vec<ContentType>>,
#[serde(rename = "drive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive: Option<Drive>,
#[serde(rename = "items")]
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<ListItem>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ItemAnalytics {
#[serde(rename = "itemActivityStats")]
#[serde(skip_serializing_if = "Option::is_none")]
pub item_activity_stats: Option<Vec<ItemActivityStat>>,
#[serde(rename = "allTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub all_time: Option<ItemActivityStat>,
#[serde(rename = "lastSevenDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_seven_days: Option<ItemActivityStat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ListItem {
#[serde(rename = "contentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<ContentTypeInfo>,
#[serde(rename = "sharepointIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sharepoint_ids: Option<SharepointIds>,
#[serde(rename = "analytics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub analytics: Option<ItemAnalytics>,
#[serde(rename = "driveItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive_item: Option<Box<DriveItem>>,
#[serde(rename = "fields")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fields: Option<FieldValueSet>,
#[serde(rename = "versions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub versions: Option<Vec<ListItemVersion>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Permission {
#[serde(rename = "grantedTo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub granted_to: Option<IdentitySet>,
#[serde(rename = "inheritedFrom")]
#[serde(skip_serializing_if = "Option::is_none")]
pub inherited_from: Option<ItemReference>,
#[serde(rename = "invitation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invitation: Option<SharingInvitation>,
#[serde(rename = "link")]
#[serde(skip_serializing_if = "Option::is_none")]
pub link: Option<SharingLink>,
#[serde(rename = "roles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub roles: Option<Vec<String>>,
#[serde(rename = "shareId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub share_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Subscription {
#[serde(rename = "resource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<String>,
#[serde(rename = "changeType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub change_type: Option<String>,
#[serde(rename = "clientState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_state: Option<String>,
#[serde(rename = "notificationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_url: Option<String>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "applicationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_id: Option<String>,
#[serde(rename = "creatorId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub creator_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ThumbnailSet {
#[serde(rename = "large")]
#[serde(skip_serializing_if = "Option::is_none")]
pub large: Option<Thumbnail>,
#[serde(rename = "medium")]
#[serde(skip_serializing_if = "Option::is_none")]
pub medium: Option<Thumbnail>,
#[serde(rename = "small")]
#[serde(skip_serializing_if = "Option::is_none")]
pub small: Option<Thumbnail>,
#[serde(rename = "source")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source: Option<Thumbnail>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DriveItemVersion {
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Vec<u8>>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Workbook {
#[serde(rename = "application")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application: Option<WorkbookApplication>,
#[serde(rename = "names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<WorkbookNamedItem>>,
#[serde(rename = "tables")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tables: Option<Vec<WorkbookTable>>,
#[serde(rename = "worksheets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheets: Option<Vec<WorkbookWorksheet>>,
#[serde(rename = "comments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub comments: Option<Vec<WorkbookComment>>,
#[serde(rename = "functions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub functions: Option<WorkbookFunctions>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct FieldValueSet(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl FieldValueSet {
pub fn new(value: Option<serde_json::Value>) -> FieldValueSet {
FieldValueSet(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ItemActivity {
#[serde(rename = "access")]
#[serde(skip_serializing_if = "Option::is_none")]
pub access: Option<AccessAction>,
#[serde(rename = "activityDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_date_time: Option<String>,
#[serde(rename = "actor")]
#[serde(skip_serializing_if = "Option::is_none")]
pub actor: Option<IdentitySet>,
#[serde(rename = "driveItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive_item: Option<DriveItem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ItemActivityStat {
#[serde(rename = "startDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_date_time: Option<String>,
#[serde(rename = "endDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub end_date_time: Option<String>,
#[serde(rename = "access")]
#[serde(skip_serializing_if = "Option::is_none")]
pub access: Option<ItemActionStat>,
#[serde(rename = "create")]
#[serde(skip_serializing_if = "Option::is_none")]
pub create: Option<ItemActionStat>,
#[serde(rename = "delete")]
#[serde(skip_serializing_if = "Option::is_none")]
pub delete: Option<ItemActionStat>,
#[serde(rename = "edit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edit: Option<ItemActionStat>,
#[serde(rename = "move")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _move: Option<ItemActionStat>,
#[serde(rename = "isTrending")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_trending: Option<bool>,
#[serde(rename = "incompleteData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub incomplete_data: Option<IncompleteData>,
#[serde(rename = "activities")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activities: Option<Vec<ItemActivity>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ListItemVersion {
#[serde(rename = "fields")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fields: Option<FieldValueSet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SharedDriveItem {
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<IdentitySet>,
#[serde(rename = "driveItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drive_item: Option<DriveItem>,
#[serde(rename = "items")]
#[serde(skip_serializing_if = "Option::is_none")]
pub items: Option<Vec<DriveItem>>,
#[serde(rename = "list")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list: Option<List>,
#[serde(rename = "listItem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub list_item: Option<ListItem>,
#[serde(rename = "root")]
#[serde(skip_serializing_if = "Option::is_none")]
pub root: Option<DriveItem>,
#[serde(rename = "site")]
#[serde(skip_serializing_if = "Option::is_none")]
pub site: Option<Site>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookApplication {
#[serde(rename = "calculationMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub calculation_mode: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookNamedItem {
#[serde(rename = "comment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub comment: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "scope")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scope: Option<String>,
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _type: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Json>,
#[serde(rename = "visible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
#[serde(rename = "worksheet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheet: Option<WorkbookWorksheet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookTable {
#[serde(rename = "highlightFirstColumn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub highlight_first_column: Option<bool>,
#[serde(rename = "highlightLastColumn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub highlight_last_column: Option<bool>,
#[serde(rename = "legacyId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub legacy_id: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "showBandedColumns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_banded_columns: Option<bool>,
#[serde(rename = "showBandedRows")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_banded_rows: Option<bool>,
#[serde(rename = "showFilterButton")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_filter_button: Option<bool>,
#[serde(rename = "showHeaders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_headers: Option<bool>,
#[serde(rename = "showTotals")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_totals: Option<bool>,
#[serde(rename = "style")]
#[serde(skip_serializing_if = "Option::is_none")]
pub style: Option<String>,
#[serde(rename = "columns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub columns: Option<Vec<WorkbookTableColumn>>,
#[serde(rename = "rows")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rows: Option<Vec<WorkbookTableRow>>,
#[serde(rename = "sort")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sort: Option<WorkbookTableSort>,
#[serde(rename = "worksheet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheet: Option<WorkbookWorksheet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookWorksheet {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "position")]
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<i32>,
#[serde(rename = "visibility")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visibility: Option<String>,
#[serde(rename = "charts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub charts: Option<Vec<WorkbookChart>>,
#[serde(rename = "names")]
#[serde(skip_serializing_if = "Option::is_none")]
pub names: Option<Vec<WorkbookNamedItem>>,
#[serde(rename = "pivotTables")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pivot_tables: Option<Vec<WorkbookPivotTable>>,
#[serde(rename = "protection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection: Option<WorkbookWorksheetProtection>,
#[serde(rename = "tables")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tables: Option<Vec<WorkbookTable>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookComment {
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<String>,
#[serde(rename = "contentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
#[serde(rename = "replies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub replies: Option<Vec<WorkbookCommentReply>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookFunctions(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChart {
#[serde(rename = "height")]
#[serde(skip_serializing_if = "Option::is_none")]
pub height: Option<i64>,
#[serde(rename = "left")]
#[serde(skip_serializing_if = "Option::is_none")]
pub left: Option<i64>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "top")]
#[serde(skip_serializing_if = "Option::is_none")]
pub top: Option<i64>,
#[serde(rename = "width")]
#[serde(skip_serializing_if = "Option::is_none")]
pub width: Option<i64>,
#[serde(rename = "axes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub axes: Option<WorkbookChartAxes>,
#[serde(rename = "dataLabels")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_labels: Option<WorkbookChartDataLabels>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartAreaFormat>,
#[serde(rename = "legend")]
#[serde(skip_serializing_if = "Option::is_none")]
pub legend: Option<WorkbookChartLegend>,
#[serde(rename = "series")]
#[serde(skip_serializing_if = "Option::is_none")]
pub series: Option<Vec<WorkbookChartSeries>>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<WorkbookChartTitle>,
#[serde(rename = "worksheet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheet: Option<WorkbookWorksheet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAxes {
#[serde(rename = "categoryAxis")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category_axis: Option<WorkbookChartAxis>,
#[serde(rename = "seriesAxis")]
#[serde(skip_serializing_if = "Option::is_none")]
pub series_axis: Option<WorkbookChartAxis>,
#[serde(rename = "valueAxis")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value_axis: Option<WorkbookChartAxis>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartDataLabels {
#[serde(rename = "position")]
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<String>,
#[serde(rename = "separator")]
#[serde(skip_serializing_if = "Option::is_none")]
pub separator: Option<String>,
#[serde(rename = "showBubbleSize")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_bubble_size: Option<bool>,
#[serde(rename = "showCategoryName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_category_name: Option<bool>,
#[serde(rename = "showLegendKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_legend_key: Option<bool>,
#[serde(rename = "showPercentage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_percentage: Option<bool>,
#[serde(rename = "showSeriesName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_series_name: Option<bool>,
#[serde(rename = "showValue")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_value: Option<bool>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartDataLabelFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAreaFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartLegend {
#[serde(rename = "overlay")]
#[serde(skip_serializing_if = "Option::is_none")]
pub overlay: Option<bool>,
#[serde(rename = "position")]
#[serde(skip_serializing_if = "Option::is_none")]
pub position: Option<String>,
#[serde(rename = "visible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartLegendFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartSeries {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartSeriesFormat>,
#[serde(rename = "points")]
#[serde(skip_serializing_if = "Option::is_none")]
pub points: Option<Vec<WorkbookChartPoint>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartTitle {
#[serde(rename = "overlay")]
#[serde(skip_serializing_if = "Option::is_none")]
pub overlay: Option<bool>,
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "visible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartTitleFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartFill(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl WorkbookChartFill {
pub fn new(value: Option<serde_json::Value>) -> WorkbookChartFill {
WorkbookChartFill(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartFont {
#[serde(rename = "bold")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bold: Option<bool>,
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
#[serde(rename = "italic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub italic: Option<bool>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "underline")]
#[serde(skip_serializing_if = "Option::is_none")]
pub underline: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAxis {
#[serde(rename = "majorUnit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub major_unit: Option<Json>,
#[serde(rename = "maximum")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum: Option<Json>,
#[serde(rename = "minimum")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum: Option<Json>,
#[serde(rename = "minorUnit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minor_unit: Option<Json>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartAxisFormat>,
#[serde(rename = "majorGridlines")]
#[serde(skip_serializing_if = "Option::is_none")]
pub major_gridlines: Option<WorkbookChartGridlines>,
#[serde(rename = "minorGridlines")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minor_gridlines: Option<WorkbookChartGridlines>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<WorkbookChartAxisTitle>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAxisFormat {
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
#[serde(rename = "line")]
#[serde(skip_serializing_if = "Option::is_none")]
pub line: Option<WorkbookChartLineFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartGridlines {
#[serde(rename = "visible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartGridlinesFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAxisTitle {
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<String>,
#[serde(rename = "visible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub visible: Option<bool>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartAxisTitleFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartLineFormat {
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartAxisTitleFormat {
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartDataLabelFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartGridlinesFormat {
#[serde(rename = "line")]
#[serde(skip_serializing_if = "Option::is_none")]
pub line: Option<WorkbookChartLineFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartLegendFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartPoint {
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Json>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookChartPointFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartPointFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartSeriesFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
#[serde(rename = "line")]
#[serde(skip_serializing_if = "Option::is_none")]
pub line: Option<WorkbookChartLineFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookChartTitleFormat {
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookChartFill>,
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookChartFont>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookCommentReply {
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<String>,
#[serde(rename = "contentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_type: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookFilter {
#[serde(rename = "criteria")]
#[serde(skip_serializing_if = "Option::is_none")]
pub criteria: Option<WorkbookFilterCriteria>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookFormatProtection {
#[serde(rename = "formulaHidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formula_hidden: Option<bool>,
#[serde(rename = "locked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locked: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookFunctionResult {
#[serde(rename = "error")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<String>,
#[serde(rename = "value")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value: Option<Json>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookPivotTable {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "worksheet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheet: Option<WorkbookWorksheet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRange {
#[serde(rename = "address")]
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<String>,
#[serde(rename = "addressLocal")]
#[serde(skip_serializing_if = "Option::is_none")]
pub address_local: Option<String>,
#[serde(rename = "cellCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cell_count: Option<i32>,
#[serde(rename = "columnCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_count: Option<i32>,
#[serde(rename = "columnHidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_hidden: Option<bool>,
#[serde(rename = "columnIndex")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_index: Option<i32>,
#[serde(rename = "formulas")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas: Option<Json>,
#[serde(rename = "formulasLocal")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas_local: Option<Json>,
#[serde(rename = "formulasR1C1")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas_r1_c1: Option<Json>,
#[serde(rename = "hidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub hidden: Option<bool>,
#[serde(rename = "numberFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_format: Option<Json>,
#[serde(rename = "rowCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub row_count: Option<i32>,
#[serde(rename = "rowHidden")]
#[serde(skip_serializing_if = "Option::is_none")]
pub row_hidden: Option<bool>,
#[serde(rename = "rowIndex")]
#[serde(skip_serializing_if = "Option::is_none")]
pub row_index: Option<i32>,
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<Json>,
#[serde(rename = "valueTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value_types: Option<Json>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Json>,
#[serde(rename = "format")]
#[serde(skip_serializing_if = "Option::is_none")]
pub format: Option<WorkbookRangeFormat>,
#[serde(rename = "sort")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sort: Option<WorkbookRangeSort>,
#[serde(rename = "worksheet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub worksheet: Option<WorkbookWorksheet>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeFormat {
#[serde(rename = "columnWidth")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_width: Option<i64>,
#[serde(rename = "horizontalAlignment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub horizontal_alignment: Option<String>,
#[serde(rename = "rowHeight")]
#[serde(skip_serializing_if = "Option::is_none")]
pub row_height: Option<i64>,
#[serde(rename = "verticalAlignment")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vertical_alignment: Option<String>,
#[serde(rename = "wrapText")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wrap_text: Option<bool>,
#[serde(rename = "borders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub borders: Option<Vec<WorkbookRangeBorder>>,
#[serde(rename = "fill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fill: Option<WorkbookRangeFill>,
#[serde(rename = "font")]
#[serde(skip_serializing_if = "Option::is_none")]
pub font: Option<WorkbookRangeFont>,
#[serde(rename = "protection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection: Option<WorkbookFormatProtection>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeSort(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl WorkbookRangeSort {
pub fn new(value: Option<serde_json::Value>) -> WorkbookRangeSort {
WorkbookRangeSort(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeBorder {
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
#[serde(rename = "sideIndex")]
#[serde(skip_serializing_if = "Option::is_none")]
pub side_index: Option<String>,
#[serde(rename = "style")]
#[serde(skip_serializing_if = "Option::is_none")]
pub style: Option<String>,
#[serde(rename = "weight")]
#[serde(skip_serializing_if = "Option::is_none")]
pub weight: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeFill {
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeFont {
#[serde(rename = "bold")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bold: Option<bool>,
#[serde(rename = "color")]
#[serde(skip_serializing_if = "Option::is_none")]
pub color: Option<String>,
#[serde(rename = "italic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub italic: Option<bool>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "underline")]
#[serde(skip_serializing_if = "Option::is_none")]
pub underline: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookRangeView {
#[serde(rename = "cellAddresses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cell_addresses: Option<Json>,
#[serde(rename = "columnCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub column_count: Option<i32>,
#[serde(rename = "formulas")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas: Option<Json>,
#[serde(rename = "formulasLocal")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas_local: Option<Json>,
#[serde(rename = "formulasR1C1")]
#[serde(skip_serializing_if = "Option::is_none")]
pub formulas_r1_c1: Option<Json>,
#[serde(rename = "index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i32>,
#[serde(rename = "numberFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_format: Option<Json>,
#[serde(rename = "rowCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub row_count: Option<i32>,
#[serde(rename = "text")]
#[serde(skip_serializing_if = "Option::is_none")]
pub text: Option<Json>,
#[serde(rename = "valueTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub value_types: Option<Json>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Json>,
#[serde(rename = "rows")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rows: Option<Vec<WorkbookRangeView>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookTableColumn {
#[serde(rename = "index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i32>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Json>,
#[serde(rename = "filter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub filter: Option<WorkbookFilter>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookTableRow {
#[serde(rename = "index")]
#[serde(skip_serializing_if = "Option::is_none")]
pub index: Option<i32>,
#[serde(rename = "values")]
#[serde(skip_serializing_if = "Option::is_none")]
pub values: Option<Json>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookTableSort {
#[serde(rename = "fields")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fields: Option<Vec<WorkbookSortField>>,
#[serde(rename = "matchCase")]
#[serde(skip_serializing_if = "Option::is_none")]
pub match_case: Option<bool>,
#[serde(rename = "method")]
#[serde(skip_serializing_if = "Option::is_none")]
pub method: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WorkbookWorksheetProtection {
#[serde(rename = "options")]
#[serde(skip_serializing_if = "Option::is_none")]
pub options: Option<WorkbookWorksheetProtectionOptions>,
#[serde(rename = "protected")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protected: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Invitation {
#[serde(rename = "invitedUserDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_user_display_name: Option<String>,
#[serde(rename = "invitedUserType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_user_type: Option<String>,
#[serde(rename = "invitedUserEmailAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_user_email_address: Option<String>,
#[serde(rename = "invitedUserMessageInfo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_user_message_info: Option<InvitedUserMessageInfo>,
#[serde(rename = "sendInvitationMessage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub send_invitation_message: Option<bool>,
#[serde(rename = "inviteRedirectUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invite_redirect_url: Option<String>,
#[serde(rename = "inviteRedeemUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invite_redeem_url: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<String>,
#[serde(rename = "invitedUser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub invited_user: Option<User>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerTask {
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "planId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_id: Option<String>,
#[serde(rename = "bucketId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bucket_id: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "orderHint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order_hint: Option<String>,
#[serde(rename = "assigneePriority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignee_priority: Option<String>,
#[serde(rename = "percentComplete")]
#[serde(skip_serializing_if = "Option::is_none")]
pub percent_complete: Option<i32>,
#[serde(rename = "startDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_date_time: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "dueDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub due_date_time: Option<String>,
#[serde(rename = "hasDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub has_description: Option<bool>,
#[serde(rename = "previewType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preview_type: Option<PlannerPreviewType>,
#[serde(rename = "completedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_date_time: Option<String>,
#[serde(rename = "completedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_by: Option<IdentitySet>,
#[serde(rename = "referenceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reference_count: Option<i32>,
#[serde(rename = "checklistItemCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub checklist_item_count: Option<i32>,
#[serde(rename = "activeChecklistItemCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_checklist_item_count: Option<i32>,
#[serde(rename = "appliedCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applied_categories: Option<PlannerAppliedCategories>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<PlannerAssignments>,
#[serde(rename = "conversationThreadId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conversation_thread_id: Option<String>,
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<PlannerTaskDetails>,
#[serde(rename = "assignedToTaskBoardFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_to_task_board_format: Option<PlannerAssignedToTaskBoardTaskFormat>,
#[serde(rename = "progressTaskBoardFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub progress_task_board_format: Option<PlannerProgressTaskBoardTaskFormat>,
#[serde(rename = "bucketTaskBoardFormat")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bucket_task_board_format: Option<PlannerBucketTaskBoardTaskFormat>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerPlan {
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "tasks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tasks: Option<Vec<PlannerTask>>,
#[serde(rename = "buckets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub buckets: Option<Vec<PlannerBucket>>,
#[serde(rename = "details")]
#[serde(skip_serializing_if = "Option::is_none")]
pub details: Option<PlannerPlanDetails>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Planner {
#[serde(rename = "tasks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tasks: Option<Vec<PlannerTask>>,
#[serde(rename = "plans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plans: Option<Vec<PlannerPlan>>,
#[serde(rename = "buckets")]
#[serde(skip_serializing_if = "Option::is_none")]
pub buckets: Option<Vec<PlannerBucket>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerBucket {
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "planId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub plan_id: Option<String>,
#[serde(rename = "orderHint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order_hint: Option<String>,
#[serde(rename = "tasks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tasks: Option<Vec<PlannerTask>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerTaskDetails {
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "previewType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preview_type: Option<PlannerPreviewType>,
#[serde(rename = "references")]
#[serde(skip_serializing_if = "Option::is_none")]
pub references: Option<PlannerExternalReferences>,
#[serde(rename = "checklist")]
#[serde(skip_serializing_if = "Option::is_none")]
pub checklist: Option<PlannerChecklistItems>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerAssignedToTaskBoardTaskFormat {
#[serde(rename = "unassignedOrderHint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unassigned_order_hint: Option<String>,
#[serde(rename = "orderHintsByAssignee")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order_hints_by_assignee: Option<PlannerOrderHintsByAssignee>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerProgressTaskBoardTaskFormat {
#[serde(rename = "orderHint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order_hint: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerBucketTaskBoardTaskFormat {
#[serde(rename = "orderHint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order_hint: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct PlannerPlanDetails {
#[serde(rename = "sharedWith")]
#[serde(skip_serializing_if = "Option::is_none")]
pub shared_with: Option<PlannerUserIds>,
#[serde(rename = "categoryDescriptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category_descriptions: Option<PlannerCategoryDescriptions>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteEntityBaseModel {
#[serde(rename = "self")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _self: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteEntitySchemaObjectModel {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteEntityHierarchyModel {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Notebook {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_by: Option<IdentitySet>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "self")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _self: Option<String>,
#[serde(rename = "isDefault")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_default: Option<bool>,
#[serde(rename = "userRole")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_role: Option<OnenoteUserRole>,
#[serde(rename = "isShared")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_shared: Option<bool>,
#[serde(rename = "sectionsUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sections_url: Option<String>,
#[serde(rename = "sectionGroupsUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub section_groups_url: Option<String>,
#[serde(rename = "links")]
#[serde(skip_serializing_if = "Option::is_none")]
pub links: Option<NotebookLinks>,
#[serde(rename = "sections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sections: Option<Vec<OnenoteSection>>,
#[serde(rename = "sectionGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub section_groups: Option<Vec<SectionGroup>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteSection {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "isDefault")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_default: Option<bool>,
#[serde(rename = "links")]
#[serde(skip_serializing_if = "Option::is_none")]
pub links: Option<SectionLinks>,
#[serde(rename = "pagesUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pages_url: Option<String>,
#[serde(rename = "parentNotebook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_notebook: Option<Notebook>,
#[serde(rename = "parentSectionGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_section_group: Option<SectionGroup>,
#[serde(rename = "pages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pages: Option<Vec<OnenotePage>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SectionGroup {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "sectionsUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sections_url: Option<String>,
#[serde(rename = "sectionGroupsUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub section_groups_url: Option<String>,
#[serde(rename = "parentNotebook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_notebook: Option<Notebook>,
#[serde(rename = "parentSectionGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_section_group: Option<Box<SectionGroup>>,
#[serde(rename = "sections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sections: Option<Vec<OnenoteSection>>,
#[serde(rename = "sectionGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub section_groups: Option<Vec<SectionGroup>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenotePage {
#[serde(skip_serializing_if = "Option::is_none")]
pub id: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "createdByAppId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by_app_id: Option<String>,
#[serde(rename = "links")]
#[serde(skip_serializing_if = "Option::is_none")]
pub links: Option<PageLinks>,
#[serde(rename = "contentUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_url: Option<String>,
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Vec<u8>>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "level")]
#[serde(skip_serializing_if = "Option::is_none")]
pub level: Option<i32>,
#[serde(rename = "order")]
#[serde(skip_serializing_if = "Option::is_none")]
pub order: Option<i32>,
#[serde(rename = "userTags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_tags: Option<Vec<String>>,
#[serde(rename = "parentSection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_section: Option<OnenoteSection>,
#[serde(rename = "parentNotebook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub parent_notebook: Option<Notebook>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteResource {
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Vec<u8>>,
#[serde(rename = "contentUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_url: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Operation {
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<OperationStatus>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastActionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_action_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnenoteOperation {
#[serde(rename = "resourceLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_location: Option<String>,
#[serde(rename = "resourceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_id: Option<String>,
#[serde(rename = "error")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<OnenoteOperationError>,
#[serde(rename = "percentComplete")]
#[serde(skip_serializing_if = "Option::is_none")]
pub percent_complete: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ReportRoot(#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>);
#[cfg(feature = "option")]
impl ReportRoot {
pub fn new(value: Option<serde_json::Value>) -> ReportRoot {
ReportRoot(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EducationRoot {
#[serde(rename = "classes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<EducationClass>>,
#[serde(rename = "schools")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schools: Option<Vec<EducationSchool>>,
#[serde(rename = "users")]
#[serde(skip_serializing_if = "Option::is_none")]
pub users: Option<Vec<EducationUser>>,
#[serde(rename = "me")]
#[serde(skip_serializing_if = "Option::is_none")]
pub me: Option<EducationUser>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EducationClass {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "mailNickname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_nickname: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "classCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub class_code: Option<String>,
#[serde(rename = "externalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_name: Option<String>,
#[serde(rename = "externalId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_id: Option<String>,
#[serde(rename = "externalSource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_source: Option<EducationExternalSource>,
#[serde(rename = "term")]
#[serde(skip_serializing_if = "Option::is_none")]
pub term: Option<EducationTerm>,
#[serde(rename = "schools")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schools: Option<Vec<EducationSchool>>,
#[serde(rename = "members")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<EducationUser>>,
#[serde(rename = "teachers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teachers: Option<Vec<EducationUser>>,
#[serde(rename = "group")]
#[serde(skip_serializing_if = "Option::is_none")]
pub group: Option<Group>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EducationOrganization {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "externalSource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_source: Option<EducationExternalSource>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EducationSchool {
#[serde(rename = "principalEmail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub principal_email: Option<String>,
#[serde(rename = "principalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub principal_name: Option<String>,
#[serde(rename = "externalPrincipalId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_principal_id: Option<String>,
#[serde(rename = "lowestGrade")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lowest_grade: Option<String>,
#[serde(rename = "highestGrade")]
#[serde(skip_serializing_if = "Option::is_none")]
pub highest_grade: Option<String>,
#[serde(rename = "schoolNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub school_number: Option<String>,
#[serde(rename = "externalId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_id: Option<String>,
#[serde(rename = "phone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub phone: Option<String>,
#[serde(rename = "fax")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fax: Option<String>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "address")]
#[serde(skip_serializing_if = "Option::is_none")]
pub address: Option<PhysicalAddress>,
#[serde(rename = "classes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<EducationClass>>,
#[serde(rename = "users")]
#[serde(skip_serializing_if = "Option::is_none")]
pub users: Option<Vec<EducationUser>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EducationUser {
#[serde(rename = "primaryRole")]
#[serde(skip_serializing_if = "Option::is_none")]
pub primary_role: Option<EducationUserRole>,
#[serde(rename = "middleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub middle_name: Option<String>,
#[serde(rename = "externalSource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_source: Option<EducationExternalSource>,
#[serde(rename = "residenceAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub residence_address: Option<PhysicalAddress>,
#[serde(rename = "mailingAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mailing_address: Option<PhysicalAddress>,
#[serde(rename = "student")]
#[serde(skip_serializing_if = "Option::is_none")]
pub student: Option<EducationStudent>,
#[serde(rename = "teacher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teacher: Option<EducationTeacher>,
#[serde(rename = "createdBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_by: Option<IdentitySet>,
#[serde(rename = "accountEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_enabled: Option<bool>,
#[serde(rename = "assignedLicenses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_licenses: Option<Vec<AssignedLicense>>,
#[serde(rename = "assignedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_plans: Option<Vec<AssignedPlan>>,
#[serde(rename = "businessPhones")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_phones: Option<Vec<String>>,
#[serde(rename = "department")]
#[serde(skip_serializing_if = "Option::is_none")]
pub department: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "givenName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub given_name: Option<String>,
#[serde(rename = "mail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail: Option<String>,
#[serde(rename = "mailNickname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mail_nickname: Option<String>,
#[serde(rename = "mobilePhone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_phone: Option<String>,
#[serde(rename = "passwordPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_policies: Option<String>,
#[serde(rename = "passwordProfile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_profile: Option<PasswordProfile>,
#[serde(rename = "officeLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub office_location: Option<String>,
#[serde(rename = "preferredLanguage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub preferred_language: Option<String>,
#[serde(rename = "provisionedPlans")]
#[serde(skip_serializing_if = "Option::is_none")]
pub provisioned_plans: Option<Vec<ProvisionedPlan>>,
#[serde(rename = "refreshTokensValidFromDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub refresh_tokens_valid_from_date_time: Option<String>,
#[serde(rename = "showInAddressList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub show_in_address_list: Option<bool>,
#[serde(rename = "surname")]
#[serde(skip_serializing_if = "Option::is_none")]
pub surname: Option<String>,
#[serde(rename = "usageLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usage_location: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "userType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_type: Option<String>,
#[serde(rename = "schools")]
#[serde(skip_serializing_if = "Option::is_none")]
pub schools: Option<Vec<EducationSchool>>,
#[serde(rename = "classes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classes: Option<Vec<EducationClass>>,
#[serde(rename = "user")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user: Option<User>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceAppManagement {
#[serde(rename = "microsoftStoreForBusinessLastSuccessfulSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_store_for_business_last_successful_sync_date_time: Option<String>,
#[serde(rename = "isEnabledForMicrosoftStoreForBusiness")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_enabled_for_microsoft_store_for_business: Option<bool>,
#[serde(rename = "microsoftStoreForBusinessLanguage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_store_for_business_language: Option<String>,
#[serde(rename = "microsoftStoreForBusinessLastCompletedApplicationSyncTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_store_for_business_last_completed_application_sync_time: Option<String>,
#[serde(rename = "mobileApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_apps: Option<Vec<MobileApp>>,
#[serde(rename = "mobileAppCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_app_categories: Option<Vec<MobileAppCategory>>,
#[serde(rename = "mobileAppConfigurations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_app_configurations: Option<Vec<ManagedDeviceMobileAppConfiguration>>,
#[serde(rename = "vppTokens")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_tokens: Option<Vec<VppToken>>,
#[serde(rename = "managedAppPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_app_policies: Option<Vec<ManagedAppPolicy>>,
#[serde(rename = "iosManagedAppProtections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ios_managed_app_protections: Option<Vec<IosManagedAppProtection>>,
#[serde(rename = "androidManagedAppProtections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub android_managed_app_protections: Option<Vec<AndroidManagedAppProtection>>,
#[serde(rename = "defaultManagedAppProtections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub default_managed_app_protections: Option<Vec<DefaultManagedAppProtection>>,
#[serde(rename = "targetedManagedAppConfigurations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub targeted_managed_app_configurations: Option<Vec<TargetedManagedAppConfiguration>>,
#[serde(rename = "mdmWindowsInformationProtectionPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mdm_windows_information_protection_policies:
Option<Vec<MdmWindowsInformationProtectionPolicy>>,
#[serde(rename = "windowsInformationProtectionPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_information_protection_policies: Option<Vec<WindowsInformationProtectionPolicy>>,
#[serde(rename = "managedAppRegistrations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_app_registrations: Option<Vec<ManagedAppRegistration>>,
#[serde(rename = "managedAppStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_app_statuses: Option<Vec<ManagedAppStatus>>,
#[serde(rename = "managedEBooks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_e_books: Option<Vec<ManagedEBook>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileApp {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
#[serde(rename = "largeIcon")]
#[serde(skip_serializing_if = "Option::is_none")]
pub large_icon: Option<MimeContent>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "isFeatured")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_featured: Option<bool>,
#[serde(rename = "privacyInformationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_information_url: Option<String>,
#[serde(rename = "informationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub information_url: Option<String>,
#[serde(rename = "owner")]
#[serde(skip_serializing_if = "Option::is_none")]
pub owner: Option<String>,
#[serde(rename = "developer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub developer: Option<String>,
#[serde(rename = "notes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notes: Option<String>,
#[serde(rename = "publishingState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publishing_state: Option<MobileAppPublishingState>,
#[serde(rename = "categories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub categories: Option<Vec<MobileAppCategory>>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<MobileAppAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileAppCategory {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfiguration {
#[serde(rename = "targetedMobileApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub targeted_mobile_apps: Option<Vec<String>>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<ManagedDeviceMobileAppConfigurationAssignment>>,
#[serde(rename = "deviceStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_statuses: Option<Vec<ManagedDeviceMobileAppConfigurationDeviceStatus>>,
#[serde(rename = "userStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_statuses: Option<Vec<ManagedDeviceMobileAppConfigurationUserStatus>>,
#[serde(rename = "deviceStatusSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_status_summary: Option<ManagedDeviceMobileAppConfigurationDeviceSummary>,
#[serde(rename = "userStatusSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_status_summary: Option<ManagedDeviceMobileAppConfigurationUserSummary>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct VppToken {
#[serde(rename = "organizationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organization_name: Option<String>,
#[serde(rename = "vppTokenAccountType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_token_account_type: Option<VppTokenAccountType>,
#[serde(rename = "appleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_id: Option<String>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "lastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_date_time: Option<String>,
#[serde(rename = "token")]
#[serde(skip_serializing_if = "Option::is_none")]
pub token: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<VppTokenState>,
#[serde(rename = "lastSyncStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_status: Option<VppTokenSyncStatus>,
#[serde(rename = "automaticallyUpdateApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub automatically_update_apps: Option<bool>,
#[serde(rename = "countryOrRegion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub country_or_region: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppPolicy {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppProtection {
#[serde(rename = "periodOfflineBeforeAccessCheck")]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_offline_before_access_check: Option<String>,
#[serde(rename = "periodOnlineBeforeAccessCheck")]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_online_before_access_check: Option<String>,
#[serde(rename = "allowedInboundDataTransferSources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_inbound_data_transfer_sources: Option<ManagedAppDataTransferLevel>,
#[serde(rename = "allowedOutboundDataTransferDestinations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_outbound_data_transfer_destinations: Option<ManagedAppDataTransferLevel>,
#[serde(rename = "organizationalCredentialsRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub organizational_credentials_required: Option<bool>,
#[serde(rename = "allowedOutboundClipboardSharingLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_outbound_clipboard_sharing_level: Option<ManagedAppClipboardSharingLevel>,
#[serde(rename = "dataBackupBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_backup_blocked: Option<bool>,
#[serde(rename = "deviceComplianceRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_required: Option<bool>,
#[serde(rename = "managedBrowserToOpenLinksRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_browser_to_open_links_required: Option<bool>,
#[serde(rename = "saveAsBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub save_as_blocked: Option<bool>,
#[serde(rename = "periodOfflineBeforeWipeIsEnforced")]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_offline_before_wipe_is_enforced: Option<String>,
#[serde(rename = "pinRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_required: Option<bool>,
#[serde(rename = "maximumPinRetries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maximum_pin_retries: Option<i32>,
#[serde(rename = "simplePinBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub simple_pin_blocked: Option<bool>,
#[serde(rename = "minimumPinLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_pin_length: Option<i32>,
#[serde(rename = "pinCharacterSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_character_set: Option<ManagedAppPinCharacterSet>,
#[serde(rename = "periodBeforePinReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub period_before_pin_reset: Option<String>,
#[serde(rename = "allowedDataStorageLocations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_data_storage_locations: Option<Vec<ManagedAppDataStorageLocation>>,
#[serde(rename = "contactSyncBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub contact_sync_blocked: Option<bool>,
#[serde(rename = "printBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub print_blocked: Option<bool>,
#[serde(rename = "fingerprintBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub fingerprint_blocked: Option<bool>,
#[serde(rename = "disableAppPinIfDevicePinIsSet")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_app_pin_if_device_pin_is_set: Option<bool>,
#[serde(rename = "minimumRequiredOsVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_os_version: Option<String>,
#[serde(rename = "minimumWarningOsVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_warning_os_version: Option<String>,
#[serde(rename = "minimumRequiredAppVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_app_version: Option<String>,
#[serde(rename = "minimumWarningAppVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_warning_app_version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TargetedManagedAppProtection {
#[serde(rename = "isAssigned")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_assigned: Option<bool>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<TargetedManagedAppPolicyAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosManagedAppProtection {
#[serde(rename = "appDataEncryptionType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_data_encryption_type: Option<ManagedAppDataEncryptionType>,
#[serde(rename = "minimumRequiredSdkVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_sdk_version: Option<String>,
#[serde(rename = "deployedAppCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_app_count: Option<i32>,
#[serde(rename = "faceIdBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub face_id_blocked: Option<bool>,
#[serde(rename = "apps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps: Option<Vec<ManagedMobileApp>>,
#[serde(rename = "deploymentSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployment_summary: Option<ManagedAppPolicyDeploymentSummary>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidManagedAppProtection {
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "disableAppEncryptionIfDeviceEncryptionIsEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_app_encryption_if_device_encryption_is_enabled: Option<bool>,
#[serde(rename = "encryptAppData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encrypt_app_data: Option<bool>,
#[serde(rename = "deployedAppCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_app_count: Option<i32>,
#[serde(rename = "minimumRequiredPatchVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_patch_version: Option<String>,
#[serde(rename = "minimumWarningPatchVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_warning_patch_version: Option<String>,
#[serde(rename = "apps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps: Option<Vec<ManagedMobileApp>>,
#[serde(rename = "deploymentSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployment_summary: Option<ManagedAppPolicyDeploymentSummary>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DefaultManagedAppProtection {
#[serde(rename = "appDataEncryptionType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_data_encryption_type: Option<ManagedAppDataEncryptionType>,
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "encryptAppData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encrypt_app_data: Option<bool>,
#[serde(rename = "disableAppEncryptionIfDeviceEncryptionIsEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_app_encryption_if_device_encryption_is_enabled: Option<bool>,
#[serde(rename = "minimumRequiredSdkVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_sdk_version: Option<String>,
#[serde(rename = "customSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_settings: Option<Vec<KeyValuePair>>,
#[serde(rename = "deployedAppCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_app_count: Option<i32>,
#[serde(rename = "minimumRequiredPatchVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_required_patch_version: Option<String>,
#[serde(rename = "minimumWarningPatchVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_warning_patch_version: Option<String>,
#[serde(rename = "faceIdBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub face_id_blocked: Option<bool>,
#[serde(rename = "apps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps: Option<Vec<ManagedMobileApp>>,
#[serde(rename = "deploymentSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployment_summary: Option<ManagedAppPolicyDeploymentSummary>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppConfiguration {
#[serde(rename = "customSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub custom_settings: Option<Vec<KeyValuePair>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TargetedManagedAppConfiguration {
#[serde(rename = "deployedAppCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployed_app_count: Option<i32>,
#[serde(rename = "isAssigned")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_assigned: Option<bool>,
#[serde(rename = "apps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps: Option<Vec<ManagedMobileApp>>,
#[serde(rename = "deploymentSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deployment_summary: Option<ManagedAppPolicyDeploymentSummary>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<TargetedManagedAppPolicyAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsInformationProtection {
#[serde(rename = "enforcementLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enforcement_level: Option<WindowsInformationProtectionEnforcementLevel>,
#[serde(rename = "enterpriseDomain")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_domain: Option<String>,
#[serde(rename = "enterpriseProtectedDomainNames")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_protected_domain_names:
Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "protectionUnderLockConfigRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protection_under_lock_config_required: Option<bool>,
#[serde(rename = "dataRecoveryCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub data_recovery_certificate: Option<WindowsInformationProtectionDataRecoveryCertificate>,
#[serde(rename = "revokeOnUnenrollDisabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revoke_on_unenroll_disabled: Option<bool>,
#[serde(rename = "rightsManagementServicesTemplateId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rights_management_services_template_id: Option<String>,
#[serde(rename = "azureRightsManagementServicesAllowed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_rights_management_services_allowed: Option<bool>,
#[serde(rename = "iconsVisible")]
#[serde(skip_serializing_if = "Option::is_none")]
pub icons_visible: Option<bool>,
#[serde(rename = "protectedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protected_apps: Option<Vec<WindowsInformationProtectionApp>>,
#[serde(rename = "exemptApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exempt_apps: Option<Vec<WindowsInformationProtectionApp>>,
#[serde(rename = "enterpriseNetworkDomainNames")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_network_domain_names:
Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "enterpriseProxiedDomains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_proxied_domains:
Option<Vec<WindowsInformationProtectionProxiedDomainCollection>>,
#[serde(rename = "enterpriseIPRanges")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_i_p_ranges: Option<Vec<WindowsInformationProtectionIPRangeCollection>>,
#[serde(rename = "enterpriseIPRangesAreAuthoritative")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_i_p_ranges_are_authoritative: Option<bool>,
#[serde(rename = "enterpriseProxyServers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_proxy_servers: Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "enterpriseInternalProxyServers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_internal_proxy_servers:
Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "enterpriseProxyServersAreAuthoritative")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_proxy_servers_are_authoritative: Option<bool>,
#[serde(rename = "neutralDomainResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub neutral_domain_resources: Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "indexingEncryptedStoresOrItemsBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub indexing_encrypted_stores_or_items_blocked: Option<bool>,
#[serde(rename = "smbAutoEncryptedFileExtensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smb_auto_encrypted_file_extensions:
Option<Vec<WindowsInformationProtectionResourceCollection>>,
#[serde(rename = "isAssigned")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_assigned: Option<bool>,
#[serde(rename = "protectedAppLockerFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub protected_app_locker_files: Option<Vec<WindowsInformationProtectionAppLockerFile>>,
#[serde(rename = "exemptAppLockerFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exempt_app_locker_files: Option<Vec<WindowsInformationProtectionAppLockerFile>>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<TargetedManagedAppPolicyAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MdmWindowsInformationProtectionPolicy(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl MdmWindowsInformationProtectionPolicy {
pub fn new(value: Option<serde_json::Value>) -> MdmWindowsInformationProtectionPolicy {
MdmWindowsInformationProtectionPolicy(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsInformationProtectionPolicy {
#[serde(rename = "revokeOnMdmHandoffDisabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub revoke_on_mdm_handoff_disabled: Option<bool>,
#[serde(rename = "mdmEnrollmentUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mdm_enrollment_url: Option<String>,
#[serde(rename = "windowsHelloForBusinessBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_hello_for_business_blocked: Option<bool>,
#[serde(rename = "pinMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_minimum_length: Option<i32>,
#[serde(rename = "pinUppercaseLetters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_uppercase_letters: Option<WindowsInformationProtectionPinCharacterRequirements>,
#[serde(rename = "pinLowercaseLetters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_lowercase_letters: Option<WindowsInformationProtectionPinCharacterRequirements>,
#[serde(rename = "pinSpecialCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_special_characters: Option<WindowsInformationProtectionPinCharacterRequirements>,
#[serde(rename = "pinExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_expiration_days: Option<i32>,
#[serde(rename = "numberOfPastPinsRemembered")]
#[serde(skip_serializing_if = "Option::is_none")]
pub number_of_past_pins_remembered: Option<i32>,
#[serde(rename = "passwordMaximumAttemptCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_maximum_attempt_count: Option<i32>,
#[serde(rename = "minutesOfInactivityBeforeDeviceLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minutes_of_inactivity_before_device_lock: Option<i32>,
#[serde(rename = "daysWithoutContactBeforeUnenroll")]
#[serde(skip_serializing_if = "Option::is_none")]
pub days_without_contact_before_unenroll: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppStatus {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedEBook {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "publisher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub publisher: Option<String>,
#[serde(rename = "publishedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub published_date_time: Option<String>,
#[serde(rename = "largeCover")]
#[serde(skip_serializing_if = "Option::is_none")]
pub large_cover: Option<MimeContent>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "informationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub information_url: Option<String>,
#[serde(rename = "privacyInformationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_information_url: Option<String>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<ManagedEBookAssignment>>,
#[serde(rename = "installSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub install_summary: Option<EBookInstallSummary>,
#[serde(rename = "deviceStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_states: Option<Vec<DeviceInstallState>>,
#[serde(rename = "userStateSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_state_summary: Option<Vec<UserInstallStateSummary>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileAppAssignment {
#[serde(rename = "intent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub intent: Option<InstallIntent>,
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
#[serde(rename = "settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<MobileAppAssignmentSettings>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileAppContentFile {
#[serde(rename = "azureStorageUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_storage_uri: Option<String>,
#[serde(rename = "isCommitted")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_committed: Option<bool>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "sizeEncrypted")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size_encrypted: Option<i64>,
#[serde(rename = "azureStorageUriExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_storage_uri_expiration_date_time: Option<String>,
#[serde(rename = "manifest")]
#[serde(skip_serializing_if = "Option::is_none")]
pub manifest: Option<Vec<u8>>,
#[serde(rename = "uploadState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub upload_state: Option<MobileAppContentFileUploadState>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfigurationAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfigurationDeviceStatus {
#[serde(rename = "deviceDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_display_name: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "deviceModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_model: Option<String>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfigurationUserStatus {
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "devicesCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub devices_count: Option<i32>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfigurationDeviceSummary {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceMobileAppConfigurationUserSummary {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MacOSOfficeSuiteApp(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl MacOSOfficeSuiteApp {
pub fn new(value: Option<serde_json::Value>) -> MacOSOfficeSuiteApp {
MacOSOfficeSuiteApp(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedApp {
#[serde(rename = "appAvailability")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_availability: Option<ManagedAppAvailability>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAndroidStoreApp {
#[serde(rename = "packageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package_id: Option<String>,
#[serde(rename = "appStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_url: Option<String>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<AndroidMinimumOperatingSystem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedIOSStoreApp {
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
#[serde(rename = "appStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_url: Option<String>,
#[serde(rename = "applicableDeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_type: Option<IosDeviceType>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<IosMinimumOperatingSystem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedMobileLobApp {
#[serde(rename = "committedContentVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub committed_content_version: Option<String>,
#[serde(rename = "fileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "contentVersions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_versions: Option<Vec<MobileAppContent>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileAppContent {
#[serde(rename = "files")]
#[serde(skip_serializing_if = "Option::is_none")]
pub files: Option<Vec<MobileAppContentFile>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAndroidLobApp {
#[serde(rename = "packageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package_id: Option<String>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<AndroidMinimumOperatingSystem>,
#[serde(rename = "versionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_name: Option<String>,
#[serde(rename = "versionCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_code: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedIOSLobApp {
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
#[serde(rename = "applicableDeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_type: Option<IosDeviceType>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<IosMinimumOperatingSystem>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "versionNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_number: Option<String>,
#[serde(rename = "buildNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub build_number: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileLobApp {
#[serde(rename = "committedContentVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub committed_content_version: Option<String>,
#[serde(rename = "fileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_name: Option<String>,
#[serde(rename = "size")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size: Option<i64>,
#[serde(rename = "contentVersions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content_versions: Option<Vec<MobileAppContent>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsMobileMSI {
#[serde(rename = "commandLine")]
#[serde(skip_serializing_if = "Option::is_none")]
pub command_line: Option<String>,
#[serde(rename = "productCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_code: Option<String>,
#[serde(rename = "productVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_version: Option<String>,
#[serde(rename = "ignoreVersionDetection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ignore_version_detection: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsUniversalAppX {
#[serde(rename = "applicableArchitectures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_architectures: Option<WindowsArchitecture>,
#[serde(rename = "applicableDeviceTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_types: Option<WindowsDeviceType>,
#[serde(rename = "identityName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_name: Option<String>,
#[serde(rename = "identityPublisherHash")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_publisher_hash: Option<String>,
#[serde(rename = "identityResourceIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_resource_identifier: Option<String>,
#[serde(rename = "isBundle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_bundle: Option<bool>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<WindowsMinimumOperatingSystem>,
#[serde(rename = "identityVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub identity_version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidLobApp {
#[serde(rename = "packageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package_id: Option<String>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<AndroidMinimumOperatingSystem>,
#[serde(rename = "versionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_name: Option<String>,
#[serde(rename = "versionCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_code: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosLobApp {
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
#[serde(rename = "applicableDeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_type: Option<IosDeviceType>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<IosMinimumOperatingSystem>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "versionNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version_number: Option<String>,
#[serde(rename = "buildNumber")]
#[serde(skip_serializing_if = "Option::is_none")]
pub build_number: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MicrosoftStoreForBusinessApp {
#[serde(rename = "usedLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub used_license_count: Option<i32>,
#[serde(rename = "totalLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_license_count: Option<i32>,
#[serde(rename = "productKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_key: Option<String>,
#[serde(rename = "licenseType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_type: Option<MicrosoftStoreForBusinessLicenseType>,
#[serde(rename = "packageIdentityName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package_identity_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WebApp {
#[serde(rename = "appUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_url: Option<String>,
#[serde(rename = "useManagedBrowser")]
#[serde(skip_serializing_if = "Option::is_none")]
pub use_managed_browser: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidStoreApp {
#[serde(rename = "packageId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub package_id: Option<String>,
#[serde(rename = "appStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_url: Option<String>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<AndroidMinimumOperatingSystem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosVppApp {
#[serde(rename = "usedLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub used_license_count: Option<i32>,
#[serde(rename = "totalLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_license_count: Option<i32>,
#[serde(rename = "releaseDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub release_date_time: Option<String>,
#[serde(rename = "appStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_url: Option<String>,
#[serde(rename = "licensingType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub licensing_type: Option<VppLicensingType>,
#[serde(rename = "applicableDeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_type: Option<IosDeviceType>,
#[serde(rename = "vppTokenOrganizationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_token_organization_name: Option<String>,
#[serde(rename = "vppTokenAccountType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_token_account_type: Option<VppTokenAccountType>,
#[serde(rename = "vppTokenAppleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_token_apple_id: Option<String>,
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosStoreApp {
#[serde(rename = "bundleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bundle_id: Option<String>,
#[serde(rename = "appStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_url: Option<String>,
#[serde(rename = "applicableDeviceType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applicable_device_type: Option<IosDeviceType>,
#[serde(rename = "minimumSupportedOperatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub minimum_supported_operating_system: Option<IosMinimumOperatingSystem>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosMobileAppConfiguration {
#[serde(rename = "encodedSettingXml")]
#[serde(skip_serializing_if = "Option::is_none")]
pub encoded_setting_xml: Option<Vec<u8>>,
#[serde(rename = "settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<Vec<AppConfigurationSettingItem>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceManagement {
#[serde(rename = "subscriptionState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subscription_state: Option<DeviceManagementSubscriptionState>,
#[serde(rename = "settings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings: Option<DeviceManagementSettings>,
#[serde(rename = "intuneBrand")]
#[serde(skip_serializing_if = "Option::is_none")]
pub intune_brand: Option<IntuneBrand>,
#[serde(rename = "termsAndConditions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub terms_and_conditions: Option<Vec<TermsAndConditions>>,
#[serde(rename = "applePushNotificationCertificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_push_notification_certificate: Option<ApplePushNotificationCertificate>,
#[serde(rename = "managedDeviceOverview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_device_overview: Option<ManagedDeviceOverview>,
#[serde(rename = "detectedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub detected_apps: Option<Vec<DetectedApp>>,
#[serde(rename = "managedDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_devices: Option<Vec<ManagedDevice>>,
#[serde(rename = "deviceConfigurations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_configurations: Option<Vec<DeviceConfiguration>>,
#[serde(rename = "deviceCompliancePolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_policies: Option<Vec<DeviceCompliancePolicy>>,
#[serde(rename = "softwareUpdateStatusSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub software_update_status_summary: Option<SoftwareUpdateStatusSummary>,
#[serde(rename = "deviceCompliancePolicyDeviceStateSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_policy_device_state_summary:
Option<DeviceCompliancePolicyDeviceStateSummary>,
#[serde(rename = "deviceCompliancePolicySettingStateSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_policy_setting_state_summaries:
Option<Vec<DeviceCompliancePolicySettingStateSummary>>,
#[serde(rename = "deviceConfigurationDeviceStateSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_configuration_device_state_summaries: Option<DeviceConfigurationDeviceStateSummary>,
#[serde(rename = "iosUpdateStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ios_update_statuses: Option<Vec<IosUpdateDeviceStatus>>,
#[serde(rename = "deviceCategories")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_categories: Option<Vec<DeviceCategory>>,
#[serde(rename = "exchangeConnectors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_connectors: Option<Vec<DeviceManagementExchangeConnector>>,
#[serde(rename = "deviceEnrollmentConfigurations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_enrollment_configurations: Option<Vec<DeviceEnrollmentConfiguration>>,
#[serde(rename = "conditionalAccessSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conditional_access_settings: Option<OnPremisesConditionalAccessSettings>,
#[serde(rename = "mobileThreatDefenseConnectors")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_threat_defense_connectors: Option<Vec<MobileThreatDefenseConnector>>,
#[serde(rename = "deviceManagementPartners")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_management_partners: Option<Vec<DeviceManagementPartner>>,
#[serde(rename = "notificationMessageTemplates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_message_templates: Option<Vec<NotificationMessageTemplate>>,
#[serde(rename = "roleDefinitions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_definitions: Option<Vec<RoleDefinition>>,
#[serde(rename = "roleAssignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_assignments: Option<Vec<DeviceAndAppManagementRoleAssignment>>,
#[serde(rename = "resourceOperations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_operations: Option<Vec<ResourceOperation>>,
#[serde(rename = "telecomExpenseManagementPartners")]
#[serde(skip_serializing_if = "Option::is_none")]
pub telecom_expense_management_partners: Option<Vec<TelecomExpenseManagementPartner>>,
#[serde(rename = "remoteAssistancePartners")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_assistance_partners: Option<Vec<RemoteAssistancePartner>>,
#[serde(rename = "windowsInformationProtectionAppLearningSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_information_protection_app_learning_summaries:
Option<Vec<WindowsInformationProtectionAppLearningSummary>>,
#[serde(rename = "windowsInformationProtectionNetworkLearningSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_information_protection_network_learning_summaries:
Option<Vec<WindowsInformationProtectionNetworkLearningSummary>>,
#[serde(rename = "troubleshootingEvents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub troubleshooting_events: Option<Vec<DeviceManagementTroubleshootingEvent>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TermsAndConditions {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "bodyText")]
#[serde(skip_serializing_if = "Option::is_none")]
pub body_text: Option<String>,
#[serde(rename = "acceptanceStatement")]
#[serde(skip_serializing_if = "Option::is_none")]
pub acceptance_statement: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<TermsAndConditionsAssignment>>,
#[serde(rename = "acceptanceStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub acceptance_statuses: Option<Vec<TermsAndConditionsAcceptanceStatus>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ApplePushNotificationCertificate {
#[serde(rename = "appleIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_identifier: Option<String>,
#[serde(rename = "topicIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub topic_identifier: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "certificate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificate: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedDeviceOverview {
#[serde(rename = "enrolledDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enrolled_device_count: Option<i32>,
#[serde(rename = "mdmEnrolledCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mdm_enrolled_count: Option<i32>,
#[serde(rename = "dualEnrolledDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub dual_enrolled_device_count: Option<i32>,
#[serde(rename = "deviceOperatingSystemSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_operating_system_summary: Option<DeviceOperatingSystemSummary>,
#[serde(rename = "deviceExchangeAccessStateSummary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_exchange_access_state_summary: Option<DeviceExchangeAccessStateSummary>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DetectedApp {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(rename = "sizeInByte")]
#[serde(skip_serializing_if = "Option::is_none")]
pub size_in_byte: Option<i64>,
#[serde(rename = "deviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_count: Option<i32>,
#[serde(rename = "managedDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_devices: Option<Vec<ManagedDevice>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfiguration {
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<DeviceConfigurationAssignment>>,
#[serde(rename = "deviceStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_statuses: Option<Vec<DeviceConfigurationDeviceStatus>>,
#[serde(rename = "userStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_statuses: Option<Vec<DeviceConfigurationUserStatus>>,
#[serde(rename = "deviceStatusOverview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_status_overview: Option<DeviceConfigurationDeviceOverview>,
#[serde(rename = "userStatusOverview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_status_overview: Option<DeviceConfigurationUserOverview>,
#[serde(rename = "deviceSettingStateSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_setting_state_summaries: Option<Vec<SettingStateDeviceSummary>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCompliancePolicy {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "scheduledActionsForRule")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scheduled_actions_for_rule: Option<Vec<DeviceComplianceScheduledActionForRule>>,
#[serde(rename = "deviceStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_statuses: Option<Vec<DeviceComplianceDeviceStatus>>,
#[serde(rename = "userStatuses")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_statuses: Option<Vec<DeviceComplianceUserStatus>>,
#[serde(rename = "deviceStatusOverview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_status_overview: Option<DeviceComplianceDeviceOverview>,
#[serde(rename = "userStatusOverview")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_status_overview: Option<DeviceComplianceUserOverview>,
#[serde(rename = "deviceSettingStateSummaries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_setting_state_summaries: Option<Vec<SettingStateDeviceSummary>>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<DeviceCompliancePolicyAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SoftwareUpdateStatusSummary {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "compliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_device_count: Option<i32>,
#[serde(rename = "nonCompliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_device_count: Option<i32>,
#[serde(rename = "remediatedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_device_count: Option<i32>,
#[serde(rename = "errorDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_device_count: Option<i32>,
#[serde(rename = "unknownDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_device_count: Option<i32>,
#[serde(rename = "conflictDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_device_count: Option<i32>,
#[serde(rename = "notApplicableDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_device_count: Option<i32>,
#[serde(rename = "compliantUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_user_count: Option<i32>,
#[serde(rename = "nonCompliantUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_user_count: Option<i32>,
#[serde(rename = "remediatedUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_user_count: Option<i32>,
#[serde(rename = "errorUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_user_count: Option<i32>,
#[serde(rename = "unknownUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_user_count: Option<i32>,
#[serde(rename = "conflictUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_user_count: Option<i32>,
#[serde(rename = "notApplicableUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_user_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCompliancePolicyDeviceStateSummary {
#[serde(rename = "inGracePeriodCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub in_grace_period_count: Option<i32>,
#[serde(rename = "configManagerCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub config_manager_count: Option<i32>,
#[serde(rename = "unknownDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_device_count: Option<i32>,
#[serde(rename = "notApplicableDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_device_count: Option<i32>,
#[serde(rename = "compliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_device_count: Option<i32>,
#[serde(rename = "remediatedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_device_count: Option<i32>,
#[serde(rename = "nonCompliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_device_count: Option<i32>,
#[serde(rename = "errorDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_device_count: Option<i32>,
#[serde(rename = "conflictDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_device_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCompliancePolicySettingStateSummary {
#[serde(rename = "setting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting: Option<String>,
#[serde(rename = "settingName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_name: Option<String>,
#[serde(rename = "platformType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub platform_type: Option<PolicyPlatformType>,
#[serde(rename = "unknownDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_device_count: Option<i32>,
#[serde(rename = "notApplicableDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_device_count: Option<i32>,
#[serde(rename = "compliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_device_count: Option<i32>,
#[serde(rename = "remediatedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_device_count: Option<i32>,
#[serde(rename = "nonCompliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_device_count: Option<i32>,
#[serde(rename = "errorDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_device_count: Option<i32>,
#[serde(rename = "conflictDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_device_count: Option<i32>,
#[serde(rename = "deviceComplianceSettingStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_compliance_setting_states: Option<Vec<DeviceComplianceSettingState>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationDeviceStateSummary {
#[serde(rename = "unknownDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_device_count: Option<i32>,
#[serde(rename = "notApplicableDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_device_count: Option<i32>,
#[serde(rename = "compliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_device_count: Option<i32>,
#[serde(rename = "remediatedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_device_count: Option<i32>,
#[serde(rename = "nonCompliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_device_count: Option<i32>,
#[serde(rename = "errorDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_device_count: Option<i32>,
#[serde(rename = "conflictDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_device_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosUpdateDeviceStatus {
#[serde(rename = "installStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub install_status: Option<IosUpdatesInstallStatus>,
#[serde(rename = "osVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<String>,
#[serde(rename = "deviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "deviceDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_display_name: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "deviceModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_model: Option<String>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCategory {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceManagementExchangeConnector {
#[serde(rename = "lastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<DeviceManagementExchangeConnectorStatus>,
#[serde(rename = "primarySmtpAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub primary_smtp_address: Option<String>,
#[serde(rename = "serverName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub server_name: Option<String>,
#[serde(rename = "connectorServerName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub connector_server_name: Option<String>,
#[serde(rename = "exchangeConnectorType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_connector_type: Option<DeviceManagementExchangeConnectorType>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
#[serde(rename = "exchangeAlias")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_alias: Option<String>,
#[serde(rename = "exchangeOrganization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub exchange_organization: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceEnrollmentConfiguration {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "priority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub priority: Option<i32>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "assignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assignments: Option<Vec<EnrollmentConfigurationAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct OnPremisesConditionalAccessSettings {
#[serde(rename = "enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "includedGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub included_groups: Option<Vec<String>>,
#[serde(rename = "excludedGroups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub excluded_groups: Option<Vec<String>>,
#[serde(rename = "overrideDefaultRule")]
#[serde(skip_serializing_if = "Option::is_none")]
pub override_default_rule: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MobileThreatDefenseConnector {
#[serde(rename = "lastHeartbeatDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_heartbeat_date_time: Option<String>,
#[serde(rename = "partnerState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_state: Option<MobileThreatPartnerTenantState>,
#[serde(rename = "androidEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub android_enabled: Option<bool>,
#[serde(rename = "iosEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ios_enabled: Option<bool>,
#[serde(rename = "androidDeviceBlockedOnMissingPartnerData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub android_device_blocked_on_missing_partner_data: Option<bool>,
#[serde(rename = "iosDeviceBlockedOnMissingPartnerData")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ios_device_blocked_on_missing_partner_data: Option<bool>,
#[serde(rename = "partnerUnsupportedOsVersionBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_unsupported_os_version_blocked: Option<bool>,
#[serde(rename = "partnerUnresponsivenessThresholdInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_unresponsiveness_threshold_in_days: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceManagementPartner {
#[serde(rename = "lastHeartbeatDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_heartbeat_date_time: Option<String>,
#[serde(rename = "partnerState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_state: Option<DeviceManagementPartnerTenantState>,
#[serde(rename = "partnerAppType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub partner_app_type: Option<DeviceManagementPartnerAppType>,
#[serde(rename = "singleTenantAppId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub single_tenant_app_id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "isConfigured")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_configured: Option<bool>,
#[serde(rename = "whenPartnerDevicesWillBeRemovedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub when_partner_devices_will_be_removed_date_time: Option<String>,
#[serde(rename = "whenPartnerDevicesWillBeMarkedAsNonCompliantDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub when_partner_devices_will_be_marked_as_non_compliant_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct NotificationMessageTemplate {
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "defaultLocale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub default_locale: Option<String>,
#[serde(rename = "brandingOptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub branding_options: Option<NotificationTemplateBrandingOptions>,
#[serde(rename = "localizedNotificationMessages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub localized_notification_messages: Option<Vec<LocalizedNotificationMessage>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct RoleDefinition {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "rolePermissions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_permissions: Option<Vec<RolePermission>>,
#[serde(rename = "isBuiltIn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_built_in: Option<bool>,
#[serde(rename = "roleAssignments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_assignments: Option<Vec<RoleAssignment>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct RoleAssignment {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "resourceScopes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_scopes: Option<Vec<String>>,
#[serde(rename = "roleDefinition")]
#[serde(skip_serializing_if = "Option::is_none")]
pub role_definition: Option<RoleDefinition>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceAndAppManagementRoleAssignment {
#[serde(rename = "members")]
#[serde(skip_serializing_if = "Option::is_none")]
pub members: Option<Vec<String>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ResourceOperation {
#[serde(rename = "resourceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_name: Option<String>,
#[serde(rename = "actionName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub action_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TelecomExpenseManagementPartner {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "appAuthorized")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_authorized: Option<bool>,
#[serde(rename = "enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "lastConnectionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_connection_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct RemoteAssistancePartner {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "onboardingUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub onboarding_url: Option<String>,
#[serde(rename = "onboardingStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub onboarding_status: Option<RemoteAssistanceOnboardingStatus>,
#[serde(rename = "lastConnectionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_connection_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsInformationProtectionAppLearningSummary {
#[serde(rename = "applicationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_name: Option<String>,
#[serde(rename = "applicationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_type: Option<ApplicationType>,
#[serde(rename = "deviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsInformationProtectionNetworkLearningSummary {
#[serde(rename = "url")]
#[serde(skip_serializing_if = "Option::is_none")]
pub url: Option<String>,
#[serde(rename = "deviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TermsAndConditionsAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TermsAndConditionsAcceptanceStatus {
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "acceptedVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub accepted_version: Option<i32>,
#[serde(rename = "acceptedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub accepted_date_time: Option<String>,
#[serde(rename = "termsAndConditions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub terms_and_conditions: Option<TermsAndConditions>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationState {
#[serde(rename = "settingStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_states: Option<Vec<DeviceConfigurationSettingState>>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "platformType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub platform_type: Option<PolicyPlatformType>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<ComplianceStatus>,
#[serde(rename = "settingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCompliancePolicyState {
#[serde(rename = "settingStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_states: Option<Vec<DeviceCompliancePolicySettingState>>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<i32>,
#[serde(rename = "platformType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub platform_type: Option<PolicyPlatformType>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<ComplianceStatus>,
#[serde(rename = "settingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationDeviceStatus {
#[serde(rename = "deviceDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_display_name: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "deviceModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_model: Option<String>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationUserStatus {
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "devicesCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub devices_count: Option<i32>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationDeviceOverview {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceConfigurationUserOverview {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SettingStateDeviceSummary {
#[serde(rename = "settingName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_name: Option<String>,
#[serde(rename = "instancePath")]
#[serde(skip_serializing_if = "Option::is_none")]
pub instance_path: Option<String>,
#[serde(rename = "unknownDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unknown_device_count: Option<i32>,
#[serde(rename = "notApplicableDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_device_count: Option<i32>,
#[serde(rename = "compliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_device_count: Option<i32>,
#[serde(rename = "remediatedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediated_device_count: Option<i32>,
#[serde(rename = "nonCompliantDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub non_compliant_device_count: Option<i32>,
#[serde(rename = "errorDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_device_count: Option<i32>,
#[serde(rename = "conflictDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conflict_device_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceCompliancePolicyAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceScheduledActionForRule {
#[serde(rename = "ruleName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rule_name: Option<String>,
#[serde(rename = "scheduledActionConfigurations")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scheduled_action_configurations: Option<Vec<DeviceComplianceActionItem>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceDeviceStatus {
#[serde(rename = "deviceDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_display_name: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "deviceModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_model: Option<String>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceUserStatus {
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "devicesCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub devices_count: Option<i32>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<ComplianceStatus>,
#[serde(rename = "lastReportedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_reported_date_time: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceDeviceOverview {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceUserOverview {
#[serde(rename = "pendingCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pending_count: Option<i32>,
#[serde(rename = "notApplicableCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_applicable_count: Option<i32>,
#[serde(rename = "successCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub success_count: Option<i32>,
#[serde(rename = "errorCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_count: Option<i32>,
#[serde(rename = "failedCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_count: Option<i32>,
#[serde(rename = "lastUpdateDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_update_date_time: Option<String>,
#[serde(rename = "configurationVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_version: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceActionItem {
#[serde(rename = "gracePeriodHours")]
#[serde(skip_serializing_if = "Option::is_none")]
pub grace_period_hours: Option<i32>,
#[serde(rename = "actionType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub action_type: Option<DeviceComplianceActionType>,
#[serde(rename = "notificationTemplateId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_template_id: Option<String>,
#[serde(rename = "notificationMessageCCList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_message_c_c_list: Option<Vec<String>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidCustomConfiguration {
#[serde(rename = "omaSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub oma_settings: Option<Vec<OmaSetting>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidGeneralDeviceConfiguration {
#[serde(rename = "appsBlockClipboardSharing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_block_clipboard_sharing: Option<bool>,
#[serde(rename = "appsBlockCopyPaste")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_block_copy_paste: Option<bool>,
#[serde(rename = "appsBlockYouTube")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_block_you_tube: Option<bool>,
#[serde(rename = "bluetoothBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_blocked: Option<bool>,
#[serde(rename = "cameraBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub camera_blocked: Option<bool>,
#[serde(rename = "cellularBlockDataRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_data_roaming: Option<bool>,
#[serde(rename = "cellularBlockMessaging")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_messaging: Option<bool>,
#[serde(rename = "cellularBlockVoiceRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_voice_roaming: Option<bool>,
#[serde(rename = "cellularBlockWiFiTethering")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_wi_fi_tethering: Option<bool>,
#[serde(rename = "compliantAppsList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_apps_list: Option<Vec<AppListItem>>,
#[serde(rename = "compliantAppListType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_app_list_type: Option<AppListType>,
#[serde(rename = "diagnosticDataBlockSubmission")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostic_data_block_submission: Option<bool>,
#[serde(rename = "locationServicesBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location_services_blocked: Option<bool>,
#[serde(rename = "googleAccountBlockAutoSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub google_account_block_auto_sync: Option<bool>,
#[serde(rename = "googlePlayStoreBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub google_play_store_blocked: Option<bool>,
#[serde(rename = "kioskModeBlockSleepButton")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_block_sleep_button: Option<bool>,
#[serde(rename = "kioskModeBlockVolumeButtons")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_block_volume_buttons: Option<bool>,
#[serde(rename = "kioskModeApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_apps: Option<Vec<AppListItem>>,
#[serde(rename = "nfcBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nfc_blocked: Option<bool>,
#[serde(rename = "passwordBlockFingerprintUnlock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_fingerprint_unlock: Option<bool>,
#[serde(rename = "passwordBlockTrustAgents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_trust_agents: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<AndroidRequiredPasswordType>,
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "powerOffBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub power_off_blocked: Option<bool>,
#[serde(rename = "factoryResetBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub factory_reset_blocked: Option<bool>,
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "deviceSharingAllowed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_sharing_allowed: Option<bool>,
#[serde(rename = "storageBlockGoogleBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_block_google_backup: Option<bool>,
#[serde(rename = "storageBlockRemovableStorage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_block_removable_storage: Option<bool>,
#[serde(rename = "storageRequireDeviceEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_device_encryption: Option<bool>,
#[serde(rename = "storageRequireRemovableStorageEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_removable_storage_encryption: Option<bool>,
#[serde(rename = "voiceAssistantBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_assistant_blocked: Option<bool>,
#[serde(rename = "voiceDialingBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_dialing_blocked: Option<bool>,
#[serde(rename = "webBrowserBlockPopups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_block_popups: Option<bool>,
#[serde(rename = "webBrowserBlockAutofill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_block_autofill: Option<bool>,
#[serde(rename = "webBrowserBlockJavaScript")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_block_java_script: Option<bool>,
#[serde(rename = "webBrowserBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_blocked: Option<bool>,
#[serde(rename = "webBrowserCookieSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_cookie_settings: Option<WebBrowserCookieSettings>,
#[serde(rename = "wiFiBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_blocked: Option<bool>,
#[serde(rename = "appsInstallAllowList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_install_allow_list: Option<Vec<AppListItem>>,
#[serde(rename = "appsLaunchBlockList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_launch_block_list: Option<Vec<AppListItem>>,
#[serde(rename = "appsHideList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_hide_list: Option<Vec<AppListItem>>,
#[serde(rename = "securityRequireVerifyApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_verify_apps: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidWorkProfileCustomConfiguration {
#[serde(rename = "omaSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub oma_settings: Option<Vec<OmaSetting>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidWorkProfileGeneralDeviceConfiguration {
#[serde(rename = "passwordBlockFingerprintUnlock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_fingerprint_unlock: Option<bool>,
#[serde(rename = "passwordBlockTrustAgents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_trust_agents: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<AndroidWorkProfileRequiredPasswordType>,
#[serde(rename = "workProfileDataSharingType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_data_sharing_type: Option<AndroidWorkProfileCrossProfileDataSharingType>,
#[serde(rename = "workProfileBlockNotificationsWhileDeviceLocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_notifications_while_device_locked: Option<bool>,
#[serde(rename = "workProfileBlockAddingAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_adding_accounts: Option<bool>,
#[serde(rename = "workProfileBluetoothEnableContactSharing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_bluetooth_enable_contact_sharing: Option<bool>,
#[serde(rename = "workProfileBlockScreenCapture")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_screen_capture: Option<bool>,
#[serde(rename = "workProfileBlockCrossProfileCallerId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_cross_profile_caller_id: Option<bool>,
#[serde(rename = "workProfileBlockCamera")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_camera: Option<bool>,
#[serde(rename = "workProfileBlockCrossProfileContactsSearch")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_cross_profile_contacts_search: Option<bool>,
#[serde(rename = "workProfileBlockCrossProfileCopyPaste")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_block_cross_profile_copy_paste: Option<bool>,
#[serde(rename = "workProfileDefaultAppPermissionPolicy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_default_app_permission_policy:
Option<AndroidWorkProfileDefaultAppPermissionPolicyType>,
#[serde(rename = "workProfilePasswordBlockFingerprintUnlock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_block_fingerprint_unlock: Option<bool>,
#[serde(rename = "workProfilePasswordBlockTrustAgents")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_block_trust_agents: Option<bool>,
#[serde(rename = "workProfilePasswordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_expiration_days: Option<i32>,
#[serde(rename = "workProfilePasswordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_minimum_length: Option<i32>,
#[serde(rename = "workProfilePasswordMinNumericCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_numeric_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinNonLetterCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_non_letter_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinLetterCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_letter_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinLowerCaseCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_lower_case_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinUpperCaseCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_upper_case_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinSymbolCharacters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_min_symbol_characters: Option<i32>,
#[serde(rename = "workProfilePasswordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "workProfilePasswordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_previous_password_block_count: Option<i32>,
#[serde(rename = "workProfilePasswordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "workProfilePasswordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_password_required_type: Option<AndroidWorkProfileRequiredPasswordType>,
#[serde(rename = "workProfileRequirePassword")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_profile_require_password: Option<bool>,
#[serde(rename = "securityRequireVerifyApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_verify_apps: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosCertificateProfile(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl IosCertificateProfile {
pub fn new(value: Option<serde_json::Value>) -> IosCertificateProfile {
IosCertificateProfile(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosCustomConfiguration {
#[serde(rename = "payloadName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload_name: Option<String>,
#[serde(rename = "payloadFileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload_file_name: Option<String>,
#[serde(rename = "payload")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload: Option<Vec<u8>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosGeneralDeviceConfiguration {
#[serde(rename = "accountBlockModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_block_modification: Option<bool>,
#[serde(rename = "activationLockAllowWhenSupervised")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activation_lock_allow_when_supervised: Option<bool>,
#[serde(rename = "airDropBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub air_drop_blocked: Option<bool>,
#[serde(rename = "airDropForceUnmanagedDropTarget")]
#[serde(skip_serializing_if = "Option::is_none")]
pub air_drop_force_unmanaged_drop_target: Option<bool>,
#[serde(rename = "airPlayForcePairingPasswordForOutgoingRequests")]
#[serde(skip_serializing_if = "Option::is_none")]
pub air_play_force_pairing_password_for_outgoing_requests: Option<bool>,
#[serde(rename = "appleWatchBlockPairing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_watch_block_pairing: Option<bool>,
#[serde(rename = "appleWatchForceWristDetection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_watch_force_wrist_detection: Option<bool>,
#[serde(rename = "appleNewsBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_news_blocked: Option<bool>,
#[serde(rename = "appsSingleAppModeList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_single_app_mode_list: Option<Vec<AppListItem>>,
#[serde(rename = "appsVisibilityList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_visibility_list: Option<Vec<AppListItem>>,
#[serde(rename = "appsVisibilityListType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_visibility_list_type: Option<AppListType>,
#[serde(rename = "appStoreBlockAutomaticDownloads")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_block_automatic_downloads: Option<bool>,
#[serde(rename = "appStoreBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_blocked: Option<bool>,
#[serde(rename = "appStoreBlockInAppPurchases")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_block_in_app_purchases: Option<bool>,
#[serde(rename = "appStoreBlockUIAppInstallation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_block_u_i_app_installation: Option<bool>,
#[serde(rename = "appStoreRequirePassword")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_store_require_password: Option<bool>,
#[serde(rename = "bluetoothBlockModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_block_modification: Option<bool>,
#[serde(rename = "cameraBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub camera_blocked: Option<bool>,
#[serde(rename = "cellularBlockDataRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_data_roaming: Option<bool>,
#[serde(rename = "cellularBlockGlobalBackgroundFetchWhileRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_global_background_fetch_while_roaming: Option<bool>,
#[serde(rename = "cellularBlockPerAppDataModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_per_app_data_modification: Option<bool>,
#[serde(rename = "cellularBlockPersonalHotspot")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_personal_hotspot: Option<bool>,
#[serde(rename = "cellularBlockVoiceRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_voice_roaming: Option<bool>,
#[serde(rename = "certificatesBlockUntrustedTlsCertificates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificates_block_untrusted_tls_certificates: Option<bool>,
#[serde(rename = "classroomAppBlockRemoteScreenObservation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classroom_app_block_remote_screen_observation: Option<bool>,
#[serde(rename = "classroomAppForceUnpromptedScreenObservation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub classroom_app_force_unprompted_screen_observation: Option<bool>,
#[serde(rename = "compliantAppsList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_apps_list: Option<Vec<AppListItem>>,
#[serde(rename = "compliantAppListType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_app_list_type: Option<AppListType>,
#[serde(rename = "configurationProfileBlockChanges")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_profile_block_changes: Option<bool>,
#[serde(rename = "definitionLookupBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub definition_lookup_blocked: Option<bool>,
#[serde(rename = "deviceBlockEnableRestrictions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_block_enable_restrictions: Option<bool>,
#[serde(rename = "deviceBlockEraseContentAndSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_block_erase_content_and_settings: Option<bool>,
#[serde(rename = "deviceBlockNameModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_block_name_modification: Option<bool>,
#[serde(rename = "diagnosticDataBlockSubmission")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostic_data_block_submission: Option<bool>,
#[serde(rename = "diagnosticDataBlockSubmissionModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostic_data_block_submission_modification: Option<bool>,
#[serde(rename = "documentsBlockManagedDocumentsInUnmanagedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub documents_block_managed_documents_in_unmanaged_apps: Option<bool>,
#[serde(rename = "documentsBlockUnmanagedDocumentsInManagedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub documents_block_unmanaged_documents_in_managed_apps: Option<bool>,
#[serde(rename = "emailInDomainSuffixes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_in_domain_suffixes: Option<Vec<String>>,
#[serde(rename = "enterpriseAppBlockTrust")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_app_block_trust: Option<bool>,
#[serde(rename = "enterpriseAppBlockTrustModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_app_block_trust_modification: Option<bool>,
#[serde(rename = "faceTimeBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub face_time_blocked: Option<bool>,
#[serde(rename = "findMyFriendsBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub find_my_friends_blocked: Option<bool>,
#[serde(rename = "gamingBlockGameCenterFriends")]
#[serde(skip_serializing_if = "Option::is_none")]
pub gaming_block_game_center_friends: Option<bool>,
#[serde(rename = "gamingBlockMultiplayer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub gaming_block_multiplayer: Option<bool>,
#[serde(rename = "gameCenterBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub game_center_blocked: Option<bool>,
#[serde(rename = "hostPairingBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub host_pairing_blocked: Option<bool>,
#[serde(rename = "iBooksStoreBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_books_store_blocked: Option<bool>,
#[serde(rename = "iBooksStoreBlockErotica")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_books_store_block_erotica: Option<bool>,
#[serde(rename = "iCloudBlockActivityContinuation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_activity_continuation: Option<bool>,
#[serde(rename = "iCloudBlockBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_backup: Option<bool>,
#[serde(rename = "iCloudBlockDocumentSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_document_sync: Option<bool>,
#[serde(rename = "iCloudBlockManagedAppsSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_managed_apps_sync: Option<bool>,
#[serde(rename = "iCloudBlockPhotoLibrary")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_photo_library: Option<bool>,
#[serde(rename = "iCloudBlockPhotoStreamSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_photo_stream_sync: Option<bool>,
#[serde(rename = "iCloudBlockSharedPhotoStream")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_block_shared_photo_stream: Option<bool>,
#[serde(rename = "iCloudRequireEncryptedBackup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_cloud_require_encrypted_backup: Option<bool>,
#[serde(rename = "iTunesBlockExplicitContent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_tunes_block_explicit_content: Option<bool>,
#[serde(rename = "iTunesBlockMusicService")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_tunes_block_music_service: Option<bool>,
#[serde(rename = "iTunesBlockRadio")]
#[serde(skip_serializing_if = "Option::is_none")]
pub i_tunes_block_radio: Option<bool>,
#[serde(rename = "keyboardBlockAutoCorrect")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keyboard_block_auto_correct: Option<bool>,
#[serde(rename = "keyboardBlockDictation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keyboard_block_dictation: Option<bool>,
#[serde(rename = "keyboardBlockPredictive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keyboard_block_predictive: Option<bool>,
#[serde(rename = "keyboardBlockShortcuts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keyboard_block_shortcuts: Option<bool>,
#[serde(rename = "keyboardBlockSpellCheck")]
#[serde(skip_serializing_if = "Option::is_none")]
pub keyboard_block_spell_check: Option<bool>,
#[serde(rename = "kioskModeAllowAssistiveSpeak")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_assistive_speak: Option<bool>,
#[serde(rename = "kioskModeAllowAssistiveTouchSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_assistive_touch_settings: Option<bool>,
#[serde(rename = "kioskModeAllowAutoLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_auto_lock: Option<bool>,
#[serde(rename = "kioskModeAllowColorInversionSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_color_inversion_settings: Option<bool>,
#[serde(rename = "kioskModeAllowRingerSwitch")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_ringer_switch: Option<bool>,
#[serde(rename = "kioskModeAllowScreenRotation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_screen_rotation: Option<bool>,
#[serde(rename = "kioskModeAllowSleepButton")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_sleep_button: Option<bool>,
#[serde(rename = "kioskModeAllowTouchscreen")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_touchscreen: Option<bool>,
#[serde(rename = "kioskModeAllowVoiceOverSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_voice_over_settings: Option<bool>,
#[serde(rename = "kioskModeAllowVolumeButtons")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_volume_buttons: Option<bool>,
#[serde(rename = "kioskModeAllowZoomSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_allow_zoom_settings: Option<bool>,
#[serde(rename = "kioskModeAppStoreUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_app_store_url: Option<String>,
#[serde(rename = "kioskModeBuiltInAppId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_built_in_app_id: Option<String>,
#[serde(rename = "kioskModeRequireAssistiveTouch")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_require_assistive_touch: Option<bool>,
#[serde(rename = "kioskModeRequireColorInversion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_require_color_inversion: Option<bool>,
#[serde(rename = "kioskModeRequireMonoAudio")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_require_mono_audio: Option<bool>,
#[serde(rename = "kioskModeRequireVoiceOver")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_require_voice_over: Option<bool>,
#[serde(rename = "kioskModeRequireZoom")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_require_zoom: Option<bool>,
#[serde(rename = "kioskModeManagedAppId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_mode_managed_app_id: Option<String>,
#[serde(rename = "lockScreenBlockControlCenter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_control_center: Option<bool>,
#[serde(rename = "lockScreenBlockNotificationView")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_notification_view: Option<bool>,
#[serde(rename = "lockScreenBlockPassbook")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_passbook: Option<bool>,
#[serde(rename = "lockScreenBlockTodayView")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_today_view: Option<bool>,
#[serde(rename = "mediaContentRatingAustralia")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_australia: Option<MediaContentRatingAustralia>,
#[serde(rename = "mediaContentRatingCanada")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_canada: Option<MediaContentRatingCanada>,
#[serde(rename = "mediaContentRatingFrance")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_france: Option<MediaContentRatingFrance>,
#[serde(rename = "mediaContentRatingGermany")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_germany: Option<MediaContentRatingGermany>,
#[serde(rename = "mediaContentRatingIreland")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_ireland: Option<MediaContentRatingIreland>,
#[serde(rename = "mediaContentRatingJapan")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_japan: Option<MediaContentRatingJapan>,
#[serde(rename = "mediaContentRatingNewZealand")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_new_zealand: Option<MediaContentRatingNewZealand>,
#[serde(rename = "mediaContentRatingUnitedKingdom")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_united_kingdom: Option<MediaContentRatingUnitedKingdom>,
#[serde(rename = "mediaContentRatingUnitedStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_united_states: Option<MediaContentRatingUnitedStates>,
#[serde(rename = "networkUsageRules")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_usage_rules: Option<Vec<IosNetworkUsageRule>>,
#[serde(rename = "mediaContentRatingApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub media_content_rating_apps: Option<RatingAppsType>,
#[serde(rename = "messagesBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub messages_blocked: Option<bool>,
#[serde(rename = "notificationsBlockSettingsModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notifications_block_settings_modification: Option<bool>,
#[serde(rename = "passcodeBlockFingerprintUnlock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_block_fingerprint_unlock: Option<bool>,
#[serde(rename = "passcodeBlockFingerprintModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_block_fingerprint_modification: Option<bool>,
#[serde(rename = "passcodeBlockModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_block_modification: Option<bool>,
#[serde(rename = "passcodeBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_block_simple: Option<bool>,
#[serde(rename = "passcodeExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_expiration_days: Option<i32>,
#[serde(rename = "passcodeMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minimum_length: Option<i32>,
#[serde(rename = "passcodeMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passcodeMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passcodeMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minimum_character_set_count: Option<i32>,
#[serde(rename = "passcodePreviousPasscodeBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_previous_passcode_block_count: Option<i32>,
#[serde(rename = "passcodeSignInFailureCountBeforeWipe")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_sign_in_failure_count_before_wipe: Option<i32>,
#[serde(rename = "passcodeRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passcodeRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_required: Option<bool>,
#[serde(rename = "podcastsBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub podcasts_blocked: Option<bool>,
#[serde(rename = "safariBlockAutofill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_block_autofill: Option<bool>,
#[serde(rename = "safariBlockJavaScript")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_block_java_script: Option<bool>,
#[serde(rename = "safariBlockPopups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_block_popups: Option<bool>,
#[serde(rename = "safariBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_blocked: Option<bool>,
#[serde(rename = "safariCookieSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_cookie_settings: Option<WebBrowserCookieSettings>,
#[serde(rename = "safariManagedDomains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_managed_domains: Option<Vec<String>>,
#[serde(rename = "safariPasswordAutoFillDomains")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_password_auto_fill_domains: Option<Vec<String>>,
#[serde(rename = "safariRequireFraudWarning")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safari_require_fraud_warning: Option<bool>,
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "siriBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub siri_blocked: Option<bool>,
#[serde(rename = "siriBlockedWhenLocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub siri_blocked_when_locked: Option<bool>,
#[serde(rename = "siriBlockUserGeneratedContent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub siri_block_user_generated_content: Option<bool>,
#[serde(rename = "siriRequireProfanityFilter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub siri_require_profanity_filter: Option<bool>,
#[serde(rename = "spotlightBlockInternetResults")]
#[serde(skip_serializing_if = "Option::is_none")]
pub spotlight_block_internet_results: Option<bool>,
#[serde(rename = "voiceDialingBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_dialing_blocked: Option<bool>,
#[serde(rename = "wallpaperBlockModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wallpaper_block_modification: Option<bool>,
#[serde(rename = "wiFiConnectOnlyToConfiguredNetworks")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_connect_only_to_configured_networks: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosUpdateConfiguration {
#[serde(rename = "activeHoursStart")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_hours_start: Option<String>,
#[serde(rename = "activeHoursEnd")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_hours_end: Option<String>,
#[serde(rename = "scheduledInstallDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub scheduled_install_days: Option<Vec<DayOfWeek>>,
#[serde(rename = "utcTimeOffsetInMinutes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub utc_time_offset_in_minutes: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MacOSCustomConfiguration {
#[serde(rename = "payloadName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload_name: Option<String>,
#[serde(rename = "payloadFileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload_file_name: Option<String>,
#[serde(rename = "payload")]
#[serde(skip_serializing_if = "Option::is_none")]
pub payload: Option<Vec<u8>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MacOSGeneralDeviceConfiguration {
#[serde(rename = "compliantAppsList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_apps_list: Option<Vec<AppListItem>>,
#[serde(rename = "compliantAppListType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_app_list_type: Option<AppListType>,
#[serde(rename = "emailInDomainSuffixes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_in_domain_suffixes: Option<Vec<String>>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AppleDeviceFeaturesConfigurationBase(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl AppleDeviceFeaturesConfigurationBase {
pub fn new(value: Option<serde_json::Value>) -> AppleDeviceFeaturesConfigurationBase {
AppleDeviceFeaturesConfigurationBase(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosDeviceFeaturesConfiguration {
#[serde(rename = "assetTagTemplate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub asset_tag_template: Option<String>,
#[serde(rename = "lockScreenFootnote")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_footnote: Option<String>,
#[serde(rename = "homeScreenDockIcons")]
#[serde(skip_serializing_if = "Option::is_none")]
pub home_screen_dock_icons: Option<Vec<IosHomeScreenItem>>,
#[serde(rename = "homeScreenPages")]
#[serde(skip_serializing_if = "Option::is_none")]
pub home_screen_pages: Option<Vec<IosHomeScreenPage>>,
#[serde(rename = "notificationSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub notification_settings: Option<Vec<IosNotificationSettings>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MacOSDeviceFeaturesConfiguration(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl MacOSDeviceFeaturesConfiguration {
pub fn new(value: Option<serde_json::Value>) -> MacOSDeviceFeaturesConfiguration {
MacOSDeviceFeaturesConfiguration(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10EndpointProtectionConfiguration {
#[serde(rename = "firewallBlockStatefulFTP")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_block_stateful_f_t_p: Option<bool>,
#[serde(rename = "firewallIdleTimeoutForSecurityAssociationInSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_idle_timeout_for_security_association_in_seconds: Option<i32>,
#[serde(rename = "firewallPreSharedKeyEncodingMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_pre_shared_key_encoding_method: Option<FirewallPreSharedKeyEncodingMethodType>,
#[serde(rename = "firewallIPSecExemptionsAllowNeighborDiscovery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_i_p_sec_exemptions_allow_neighbor_discovery: Option<bool>,
#[serde(rename = "firewallIPSecExemptionsAllowICMP")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_i_p_sec_exemptions_allow_i_c_m_p: Option<bool>,
#[serde(rename = "firewallIPSecExemptionsAllowRouterDiscovery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_i_p_sec_exemptions_allow_router_discovery: Option<bool>,
#[serde(rename = "firewallIPSecExemptionsAllowDHCP")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_i_p_sec_exemptions_allow_d_h_c_p: Option<bool>,
#[serde(rename = "firewallCertificateRevocationListCheckMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_certificate_revocation_list_check_method:
Option<FirewallCertificateRevocationListCheckMethodType>,
#[serde(rename = "firewallMergeKeyingModuleSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_merge_keying_module_settings: Option<bool>,
#[serde(rename = "firewallPacketQueueingMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_packet_queueing_method: Option<FirewallPacketQueueingMethodType>,
#[serde(rename = "firewallProfileDomain")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_profile_domain: Option<WindowsFirewallNetworkProfile>,
#[serde(rename = "firewallProfilePublic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_profile_public: Option<WindowsFirewallNetworkProfile>,
#[serde(rename = "firewallProfilePrivate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_profile_private: Option<WindowsFirewallNetworkProfile>,
#[serde(rename = "defenderAttackSurfaceReductionExcludedPaths")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_attack_surface_reduction_excluded_paths: Option<Vec<String>>,
#[serde(rename = "defenderGuardedFoldersAllowedAppPaths")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_guarded_folders_allowed_app_paths: Option<Vec<String>>,
#[serde(rename = "defenderAdditionalGuardedFolders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_additional_guarded_folders: Option<Vec<String>>,
#[serde(rename = "defenderExploitProtectionXml")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_exploit_protection_xml: Option<Vec<u8>>,
#[serde(rename = "defenderExploitProtectionXmlFileName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_exploit_protection_xml_file_name: Option<String>,
#[serde(rename = "defenderSecurityCenterBlockExploitProtectionOverride")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_security_center_block_exploit_protection_override: Option<bool>,
#[serde(rename = "appLockerApplicationControl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_locker_application_control: Option<AppLockerApplicationControlType>,
#[serde(rename = "smartScreenEnableInShell")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smart_screen_enable_in_shell: Option<bool>,
#[serde(rename = "smartScreenBlockOverrideForFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smart_screen_block_override_for_files: Option<bool>,
#[serde(rename = "applicationGuardEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_enabled: Option<bool>,
#[serde(rename = "applicationGuardBlockFileTransfer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_block_file_transfer: Option<ApplicationGuardBlockFileTransferType>,
#[serde(rename = "applicationGuardBlockNonEnterpriseContent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_block_non_enterprise_content: Option<bool>,
#[serde(rename = "applicationGuardAllowPersistence")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_allow_persistence: Option<bool>,
#[serde(rename = "applicationGuardForceAuditing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_force_auditing: Option<bool>,
#[serde(rename = "applicationGuardBlockClipboardSharing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_block_clipboard_sharing:
Option<ApplicationGuardBlockClipboardSharingType>,
#[serde(rename = "applicationGuardAllowPrintToPDF")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_allow_print_to_p_d_f: Option<bool>,
#[serde(rename = "applicationGuardAllowPrintToXPS")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_allow_print_to_x_p_s: Option<bool>,
#[serde(rename = "applicationGuardAllowPrintToLocalPrinters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_allow_print_to_local_printers: Option<bool>,
#[serde(rename = "applicationGuardAllowPrintToNetworkPrinters")]
#[serde(skip_serializing_if = "Option::is_none")]
pub application_guard_allow_print_to_network_printers: Option<bool>,
#[serde(rename = "bitLockerDisableWarningForOtherDiskEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_disable_warning_for_other_disk_encryption: Option<bool>,
#[serde(rename = "bitLockerEnableStorageCardEncryptionOnMobile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_enable_storage_card_encryption_on_mobile: Option<bool>,
#[serde(rename = "bitLockerEncryptDevice")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_encrypt_device: Option<bool>,
#[serde(rename = "bitLockerRemovableDrivePolicy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_removable_drive_policy: Option<BitLockerRemovableDrivePolicy>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10GeneralConfiguration {
#[serde(rename = "enterpriseCloudPrintDiscoveryEndPoint")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_discovery_end_point: Option<String>,
#[serde(rename = "enterpriseCloudPrintOAuthAuthority")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_o_auth_authority: Option<String>,
#[serde(rename = "enterpriseCloudPrintOAuthClientIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_o_auth_client_identifier: Option<String>,
#[serde(rename = "enterpriseCloudPrintResourceIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_resource_identifier: Option<String>,
#[serde(rename = "enterpriseCloudPrintDiscoveryMaxLimit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_discovery_max_limit: Option<i32>,
#[serde(rename = "enterpriseCloudPrintMopriaDiscoveryResourceIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enterprise_cloud_print_mopria_discovery_resource_identifier: Option<String>,
#[serde(rename = "searchBlockDiacritics")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_block_diacritics: Option<bool>,
#[serde(rename = "searchDisableAutoLanguageDetection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_disable_auto_language_detection: Option<bool>,
#[serde(rename = "searchDisableIndexingEncryptedItems")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_disable_indexing_encrypted_items: Option<bool>,
#[serde(rename = "searchEnableRemoteQueries")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_enable_remote_queries: Option<bool>,
#[serde(rename = "searchDisableIndexerBackoff")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_disable_indexer_backoff: Option<bool>,
#[serde(rename = "searchDisableIndexingRemovableDrive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_disable_indexing_removable_drive: Option<bool>,
#[serde(rename = "searchEnableAutomaticIndexSizeManangement")]
#[serde(skip_serializing_if = "Option::is_none")]
pub search_enable_automatic_index_size_manangement: Option<bool>,
#[serde(rename = "diagnosticsDataSubmissionMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostics_data_submission_mode: Option<DiagnosticDataSubmissionMode>,
#[serde(rename = "oneDriveDisableFileSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub one_drive_disable_file_sync: Option<bool>,
#[serde(rename = "smartScreenEnableAppInstallControl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smart_screen_enable_app_install_control: Option<bool>,
#[serde(rename = "personalizationDesktopImageUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub personalization_desktop_image_url: Option<String>,
#[serde(rename = "personalizationLockScreenImageUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub personalization_lock_screen_image_url: Option<String>,
#[serde(rename = "bluetoothAllowedServices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_allowed_services: Option<Vec<String>>,
#[serde(rename = "bluetoothBlockAdvertising")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_block_advertising: Option<bool>,
#[serde(rename = "bluetoothBlockDiscoverableMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_block_discoverable_mode: Option<bool>,
#[serde(rename = "bluetoothBlockPrePairing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_block_pre_pairing: Option<bool>,
#[serde(rename = "edgeBlockAutofill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_autofill: Option<bool>,
#[serde(rename = "edgeBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_blocked: Option<bool>,
#[serde(rename = "edgeCookiePolicy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_cookie_policy: Option<EdgeCookiePolicy>,
#[serde(rename = "edgeBlockDeveloperTools")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_developer_tools: Option<bool>,
#[serde(rename = "edgeBlockSendingDoNotTrackHeader")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_sending_do_not_track_header: Option<bool>,
#[serde(rename = "edgeBlockExtensions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_extensions: Option<bool>,
#[serde(rename = "edgeBlockInPrivateBrowsing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_in_private_browsing: Option<bool>,
#[serde(rename = "edgeBlockJavaScript")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_java_script: Option<bool>,
#[serde(rename = "edgeBlockPasswordManager")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_password_manager: Option<bool>,
#[serde(rename = "edgeBlockAddressBarDropdown")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_address_bar_dropdown: Option<bool>,
#[serde(rename = "edgeBlockCompatibilityList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_compatibility_list: Option<bool>,
#[serde(rename = "edgeClearBrowsingDataOnExit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_clear_browsing_data_on_exit: Option<bool>,
#[serde(rename = "edgeAllowStartPagesModification")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_allow_start_pages_modification: Option<bool>,
#[serde(rename = "edgeDisableFirstRunPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_disable_first_run_page: Option<bool>,
#[serde(rename = "edgeBlockLiveTileDataCollection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_live_tile_data_collection: Option<bool>,
#[serde(rename = "edgeSyncFavoritesWithInternetExplorer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_sync_favorites_with_internet_explorer: Option<bool>,
#[serde(rename = "cellularBlockDataWhenRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_data_when_roaming: Option<bool>,
#[serde(rename = "cellularBlockVpn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_vpn: Option<bool>,
#[serde(rename = "cellularBlockVpnWhenRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_vpn_when_roaming: Option<bool>,
#[serde(rename = "defenderBlockEndUserAccess")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_block_end_user_access: Option<bool>,
#[serde(rename = "defenderDaysBeforeDeletingQuarantinedMalware")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_days_before_deleting_quarantined_malware: Option<i32>,
#[serde(rename = "defenderDetectedMalwareActions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_detected_malware_actions: Option<DefenderDetectedMalwareActions>,
#[serde(rename = "defenderSystemScanSchedule")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_system_scan_schedule: Option<WeeklySchedule>,
#[serde(rename = "defenderFilesAndFoldersToExclude")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_files_and_folders_to_exclude: Option<Vec<String>>,
#[serde(rename = "defenderFileExtensionsToExclude")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_file_extensions_to_exclude: Option<Vec<String>>,
#[serde(rename = "defenderScanMaxCpu")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_max_cpu: Option<i32>,
#[serde(rename = "defenderMonitorFileActivity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_monitor_file_activity: Option<DefenderMonitorFileActivity>,
#[serde(rename = "defenderProcessesToExclude")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_processes_to_exclude: Option<Vec<String>>,
#[serde(rename = "defenderPromptForSampleSubmission")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_prompt_for_sample_submission: Option<DefenderPromptForSampleSubmission>,
#[serde(rename = "defenderRequireBehaviorMonitoring")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_require_behavior_monitoring: Option<bool>,
#[serde(rename = "defenderRequireCloudProtection")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_require_cloud_protection: Option<bool>,
#[serde(rename = "defenderRequireNetworkInspectionSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_require_network_inspection_system: Option<bool>,
#[serde(rename = "defenderRequireRealTimeMonitoring")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_require_real_time_monitoring: Option<bool>,
#[serde(rename = "defenderScanArchiveFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_archive_files: Option<bool>,
#[serde(rename = "defenderScanDownloads")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_downloads: Option<bool>,
#[serde(rename = "defenderScanNetworkFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_network_files: Option<bool>,
#[serde(rename = "defenderScanIncomingMail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_incoming_mail: Option<bool>,
#[serde(rename = "defenderScanMappedNetworkDrivesDuringFullScan")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_mapped_network_drives_during_full_scan: Option<bool>,
#[serde(rename = "defenderScanRemovableDrivesDuringFullScan")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_removable_drives_during_full_scan: Option<bool>,
#[serde(rename = "defenderScanScriptsLoadedInInternetExplorer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_scripts_loaded_in_internet_explorer: Option<bool>,
#[serde(rename = "defenderSignatureUpdateIntervalInHours")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_signature_update_interval_in_hours: Option<i32>,
#[serde(rename = "defenderScanType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scan_type: Option<DefenderScanType>,
#[serde(rename = "defenderScheduledScanTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scheduled_scan_time: Option<String>,
#[serde(rename = "defenderScheduledQuickScanTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_scheduled_quick_scan_time: Option<String>,
#[serde(rename = "defenderCloudBlockLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub defender_cloud_block_level: Option<DefenderCloudBlockLevelType>,
#[serde(rename = "lockScreenAllowTimeoutConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_allow_timeout_configuration: Option<bool>,
#[serde(rename = "lockScreenBlockActionCenterNotifications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_action_center_notifications: Option<bool>,
#[serde(rename = "lockScreenBlockCortana")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_cortana: Option<bool>,
#[serde(rename = "lockScreenBlockToastNotifications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_block_toast_notifications: Option<bool>,
#[serde(rename = "lockScreenTimeoutInSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub lock_screen_timeout_in_seconds: Option<i32>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordRequireWhenResumeFromIdleState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_require_when_resume_from_idle_state: Option<bool>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "privacyAdvertisingId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_advertising_id: Option<StateManagementSetting>,
#[serde(rename = "privacyAutoAcceptPairingAndConsentPrompts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_auto_accept_pairing_and_consent_prompts: Option<bool>,
#[serde(rename = "privacyBlockInputPersonalization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub privacy_block_input_personalization: Option<bool>,
#[serde(rename = "startBlockUnpinningAppsFromTaskbar")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_block_unpinning_apps_from_taskbar: Option<bool>,
#[serde(rename = "startMenuAppListVisibility")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_app_list_visibility: Option<WindowsStartMenuAppListVisibilityType>,
#[serde(rename = "startMenuHideChangeAccountSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_change_account_settings: Option<bool>,
#[serde(rename = "startMenuHideFrequentlyUsedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_frequently_used_apps: Option<bool>,
#[serde(rename = "startMenuHideHibernate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_hibernate: Option<bool>,
#[serde(rename = "startMenuHideLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_lock: Option<bool>,
#[serde(rename = "startMenuHidePowerButton")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_power_button: Option<bool>,
#[serde(rename = "startMenuHideRecentJumpLists")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_recent_jump_lists: Option<bool>,
#[serde(rename = "startMenuHideRecentlyAddedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_recently_added_apps: Option<bool>,
#[serde(rename = "startMenuHideRestartOptions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_restart_options: Option<bool>,
#[serde(rename = "startMenuHideShutDown")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_shut_down: Option<bool>,
#[serde(rename = "startMenuHideSignOut")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_sign_out: Option<bool>,
#[serde(rename = "startMenuHideSleep")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_sleep: Option<bool>,
#[serde(rename = "startMenuHideSwitchAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_switch_account: Option<bool>,
#[serde(rename = "startMenuHideUserTile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_hide_user_tile: Option<bool>,
#[serde(rename = "startMenuLayoutEdgeAssetsXml")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_layout_edge_assets_xml: Option<Vec<u8>>,
#[serde(rename = "startMenuLayoutXml")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_layout_xml: Option<Vec<u8>>,
#[serde(rename = "startMenuMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_mode: Option<WindowsStartMenuModeType>,
#[serde(rename = "startMenuPinnedFolderDocuments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_documents: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderDownloads")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_downloads: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderFileExplorer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_file_explorer: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderHomeGroup")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_home_group: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderMusic")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_music: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderNetwork")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_network: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderPersonalFolder")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_personal_folder: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderPictures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_pictures: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_settings: Option<VisibilitySetting>,
#[serde(rename = "startMenuPinnedFolderVideos")]
#[serde(skip_serializing_if = "Option::is_none")]
pub start_menu_pinned_folder_videos: Option<VisibilitySetting>,
#[serde(rename = "settingsBlockSettingsApp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_settings_app: Option<bool>,
#[serde(rename = "settingsBlockSystemPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_system_page: Option<bool>,
#[serde(rename = "settingsBlockDevicesPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_devices_page: Option<bool>,
#[serde(rename = "settingsBlockNetworkInternetPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_network_internet_page: Option<bool>,
#[serde(rename = "settingsBlockPersonalizationPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_personalization_page: Option<bool>,
#[serde(rename = "settingsBlockAccountsPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_accounts_page: Option<bool>,
#[serde(rename = "settingsBlockTimeLanguagePage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_time_language_page: Option<bool>,
#[serde(rename = "settingsBlockEaseOfAccessPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_ease_of_access_page: Option<bool>,
#[serde(rename = "settingsBlockPrivacyPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_privacy_page: Option<bool>,
#[serde(rename = "settingsBlockUpdateSecurityPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_update_security_page: Option<bool>,
#[serde(rename = "settingsBlockAppsPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_apps_page: Option<bool>,
#[serde(rename = "settingsBlockGamingPage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_gaming_page: Option<bool>,
#[serde(rename = "windowsSpotlightBlockConsumerSpecificFeatures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_consumer_specific_features: Option<bool>,
#[serde(rename = "windowsSpotlightBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_blocked: Option<bool>,
#[serde(rename = "windowsSpotlightBlockOnActionCenter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_on_action_center: Option<bool>,
#[serde(rename = "windowsSpotlightBlockTailoredExperiences")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_tailored_experiences: Option<bool>,
#[serde(rename = "windowsSpotlightBlockThirdPartyNotifications")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_third_party_notifications: Option<bool>,
#[serde(rename = "windowsSpotlightBlockWelcomeExperience")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_welcome_experience: Option<bool>,
#[serde(rename = "windowsSpotlightBlockWindowsTips")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_block_windows_tips: Option<bool>,
#[serde(rename = "windowsSpotlightConfigureOnLockScreen")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_spotlight_configure_on_lock_screen: Option<WindowsSpotlightEnablementSettings>,
#[serde(rename = "networkProxyApplySettingsDeviceWide")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_proxy_apply_settings_device_wide: Option<bool>,
#[serde(rename = "networkProxyDisableAutoDetect")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_proxy_disable_auto_detect: Option<bool>,
#[serde(rename = "networkProxyAutomaticConfigurationUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_proxy_automatic_configuration_url: Option<String>,
#[serde(rename = "networkProxyServer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_proxy_server: Option<Windows10NetworkProxyServer>,
#[serde(rename = "accountsBlockAddingNonMicrosoftAccountEmail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub accounts_block_adding_non_microsoft_account_email: Option<bool>,
#[serde(rename = "antiTheftModeBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub anti_theft_mode_blocked: Option<bool>,
#[serde(rename = "bluetoothBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_blocked: Option<bool>,
#[serde(rename = "cameraBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub camera_blocked: Option<bool>,
#[serde(rename = "connectedDevicesServiceBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub connected_devices_service_blocked: Option<bool>,
#[serde(rename = "certificatesBlockManualRootCertificateInstallation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub certificates_block_manual_root_certificate_installation: Option<bool>,
#[serde(rename = "copyPasteBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub copy_paste_blocked: Option<bool>,
#[serde(rename = "cortanaBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cortana_blocked: Option<bool>,
#[serde(rename = "deviceManagementBlockFactoryResetOnMobile")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_management_block_factory_reset_on_mobile: Option<bool>,
#[serde(rename = "deviceManagementBlockManualUnenroll")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_management_block_manual_unenroll: Option<bool>,
#[serde(rename = "safeSearchFilter")]
#[serde(skip_serializing_if = "Option::is_none")]
pub safe_search_filter: Option<SafeSearchFilterType>,
#[serde(rename = "edgeBlockPopups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_popups: Option<bool>,
#[serde(rename = "edgeBlockSearchSuggestions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_search_suggestions: Option<bool>,
#[serde(rename = "edgeBlockSendingIntranetTrafficToInternetExplorer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_sending_intranet_traffic_to_internet_explorer: Option<bool>,
#[serde(rename = "edgeSendIntranetTrafficToInternetExplorer")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_send_intranet_traffic_to_internet_explorer: Option<bool>,
#[serde(rename = "edgeRequireSmartScreen")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_require_smart_screen: Option<bool>,
#[serde(rename = "edgeEnterpriseModeSiteListLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_enterprise_mode_site_list_location: Option<String>,
#[serde(rename = "edgeFirstRunUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_first_run_url: Option<String>,
#[serde(rename = "edgeSearchEngine")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_search_engine: Option<EdgeSearchEngineBase>,
#[serde(rename = "edgeHomepageUrls")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_homepage_urls: Option<Vec<String>>,
#[serde(rename = "edgeBlockAccessToAboutFlags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub edge_block_access_to_about_flags: Option<bool>,
#[serde(rename = "smartScreenBlockPromptOverride")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smart_screen_block_prompt_override: Option<bool>,
#[serde(rename = "smartScreenBlockPromptOverrideForFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub smart_screen_block_prompt_override_for_files: Option<bool>,
#[serde(rename = "webRtcBlockLocalhostIpAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_rtc_block_localhost_ip_address: Option<bool>,
#[serde(rename = "internetSharingBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub internet_sharing_blocked: Option<bool>,
#[serde(rename = "settingsBlockAddProvisioningPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_add_provisioning_package: Option<bool>,
#[serde(rename = "settingsBlockRemoveProvisioningPackage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_remove_provisioning_package: Option<bool>,
#[serde(rename = "settingsBlockChangeSystemTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_change_system_time: Option<bool>,
#[serde(rename = "settingsBlockEditDeviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_edit_device_name: Option<bool>,
#[serde(rename = "settingsBlockChangeRegion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_change_region: Option<bool>,
#[serde(rename = "settingsBlockChangeLanguage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_change_language: Option<bool>,
#[serde(rename = "settingsBlockChangePowerSleep")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_change_power_sleep: Option<bool>,
#[serde(rename = "locationServicesBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location_services_blocked: Option<bool>,
#[serde(rename = "microsoftAccountBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_account_blocked: Option<bool>,
#[serde(rename = "microsoftAccountBlockSettingsSync")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_account_block_settings_sync: Option<bool>,
#[serde(rename = "nfcBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nfc_blocked: Option<bool>,
#[serde(rename = "resetProtectionModeBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub reset_protection_mode_blocked: Option<bool>,
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "storageBlockRemovableStorage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_block_removable_storage: Option<bool>,
#[serde(rename = "storageRequireMobileDeviceEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_mobile_device_encryption: Option<bool>,
#[serde(rename = "usbBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub usb_blocked: Option<bool>,
#[serde(rename = "voiceRecordingBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub voice_recording_blocked: Option<bool>,
#[serde(rename = "wiFiBlockAutomaticConnectHotspots")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_block_automatic_connect_hotspots: Option<bool>,
#[serde(rename = "wiFiBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_blocked: Option<bool>,
#[serde(rename = "wiFiBlockManualConfiguration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_block_manual_configuration: Option<bool>,
#[serde(rename = "wiFiScanInterval")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wi_fi_scan_interval: Option<i32>,
#[serde(rename = "wirelessDisplayBlockProjectionToThisDevice")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wireless_display_block_projection_to_this_device: Option<bool>,
#[serde(rename = "wirelessDisplayBlockUserInputFromReceiver")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wireless_display_block_user_input_from_receiver: Option<bool>,
#[serde(rename = "wirelessDisplayRequirePinForPairing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wireless_display_require_pin_for_pairing: Option<bool>,
#[serde(rename = "windowsStoreBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_store_blocked: Option<bool>,
#[serde(rename = "appsAllowTrustedAppsSideloading")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_allow_trusted_apps_sideloading: Option<StateManagementSetting>,
#[serde(rename = "windowsStoreBlockAutoUpdate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_store_block_auto_update: Option<bool>,
#[serde(rename = "developerUnlockSetting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub developer_unlock_setting: Option<StateManagementSetting>,
#[serde(rename = "sharedUserAppDataAllowed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub shared_user_app_data_allowed: Option<bool>,
#[serde(rename = "appsBlockWindowsStoreOriginatedApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_block_windows_store_originated_apps: Option<bool>,
#[serde(rename = "windowsStoreEnablePrivateStoreOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_store_enable_private_store_only: Option<bool>,
#[serde(rename = "storageRestrictAppDataToSystemVolume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_restrict_app_data_to_system_volume: Option<bool>,
#[serde(rename = "storageRestrictAppInstallToSystemVolume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_restrict_app_install_to_system_volume: Option<bool>,
#[serde(rename = "gameDvrBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub game_dvr_blocked: Option<bool>,
#[serde(rename = "experienceBlockDeviceDiscovery")]
#[serde(skip_serializing_if = "Option::is_none")]
pub experience_block_device_discovery: Option<bool>,
#[serde(rename = "experienceBlockErrorDialogWhenNoSIM")]
#[serde(skip_serializing_if = "Option::is_none")]
pub experience_block_error_dialog_when_no_s_i_m: Option<bool>,
#[serde(rename = "experienceBlockTaskSwitcher")]
#[serde(skip_serializing_if = "Option::is_none")]
pub experience_block_task_switcher: Option<bool>,
#[serde(rename = "logonBlockFastUserSwitching")]
#[serde(skip_serializing_if = "Option::is_none")]
pub logon_block_fast_user_switching: Option<bool>,
#[serde(rename = "tenantLockdownRequireNetworkDuringOutOfBoxExperience")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tenant_lockdown_require_network_during_out_of_box_experience: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsDefenderAdvancedThreatProtectionConfiguration {
#[serde(rename = "allowSampleSharing")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_sample_sharing: Option<bool>,
#[serde(rename = "enableExpeditedTelemetryReporting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enable_expedited_telemetry_reporting: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EditionUpgradeConfiguration {
#[serde(rename = "licenseType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license_type: Option<EditionUpgradeLicenseType>,
#[serde(rename = "targetEdition")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_edition: Option<Windows10EditionType>,
#[serde(rename = "license")]
#[serde(skip_serializing_if = "Option::is_none")]
pub license: Option<String>,
#[serde(rename = "productKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub product_key: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10CustomConfiguration {
#[serde(rename = "omaSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub oma_settings: Option<Vec<OmaSetting>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10EnterpriseModernAppManagementConfiguration {
#[serde(rename = "uninstallBuiltInApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub uninstall_built_in_apps: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SharedPCConfiguration {
#[serde(rename = "accountManagerPolicy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub account_manager_policy: Option<SharedPCAccountManagerPolicy>,
#[serde(rename = "allowedAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allowed_accounts: Option<SharedPCAllowedAccountType>,
#[serde(rename = "allowLocalStorage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_local_storage: Option<bool>,
#[serde(rename = "disableAccountManager")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_account_manager: Option<bool>,
#[serde(rename = "disableEduPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_edu_policies: Option<bool>,
#[serde(rename = "disablePowerPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_power_policies: Option<bool>,
#[serde(rename = "disableSignInOnResume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub disable_sign_in_on_resume: Option<bool>,
#[serde(rename = "enabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled: Option<bool>,
#[serde(rename = "idleTimeBeforeSleepInSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub idle_time_before_sleep_in_seconds: Option<i32>,
#[serde(rename = "kioskAppDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_app_display_name: Option<String>,
#[serde(rename = "kioskAppUserModelId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub kiosk_app_user_model_id: Option<String>,
#[serde(rename = "maintenanceStartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maintenance_start_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10SecureAssessmentConfiguration {
#[serde(rename = "launchUri")]
#[serde(skip_serializing_if = "Option::is_none")]
pub launch_uri: Option<String>,
#[serde(rename = "configurationAccount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_account: Option<String>,
#[serde(rename = "allowPrinting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_printing: Option<bool>,
#[serde(rename = "allowScreenCapture")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_screen_capture: Option<bool>,
#[serde(rename = "allowTextSuggestion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub allow_text_suggestion: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsPhone81CustomConfiguration {
#[serde(rename = "omaSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub oma_settings: Option<Vec<OmaSetting>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsUpdateForBusinessConfiguration {
#[serde(rename = "deliveryOptimizationMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub delivery_optimization_mode: Option<WindowsDeliveryOptimizationMode>,
#[serde(rename = "prereleaseFeatures")]
#[serde(skip_serializing_if = "Option::is_none")]
pub prerelease_features: Option<PrereleaseFeatures>,
#[serde(rename = "automaticUpdateMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub automatic_update_mode: Option<AutomaticUpdateMode>,
#[serde(rename = "microsoftUpdateServiceAllowed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_update_service_allowed: Option<bool>,
#[serde(rename = "driversExcluded")]
#[serde(skip_serializing_if = "Option::is_none")]
pub drivers_excluded: Option<bool>,
#[serde(rename = "installationSchedule")]
#[serde(skip_serializing_if = "Option::is_none")]
pub installation_schedule: Option<WindowsUpdateInstallScheduleType>,
#[serde(rename = "qualityUpdatesDeferralPeriodInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub quality_updates_deferral_period_in_days: Option<i32>,
#[serde(rename = "featureUpdatesDeferralPeriodInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feature_updates_deferral_period_in_days: Option<i32>,
#[serde(rename = "qualityUpdatesPaused")]
#[serde(skip_serializing_if = "Option::is_none")]
pub quality_updates_paused: Option<bool>,
#[serde(rename = "featureUpdatesPaused")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feature_updates_paused: Option<bool>,
#[serde(rename = "qualityUpdatesPauseExpiryDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub quality_updates_pause_expiry_date_time: Option<String>,
#[serde(rename = "featureUpdatesPauseExpiryDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feature_updates_pause_expiry_date_time: Option<String>,
#[serde(rename = "businessReadyUpdatesOnly")]
#[serde(skip_serializing_if = "Option::is_none")]
pub business_ready_updates_only: Option<WindowsUpdateType>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows81GeneralConfiguration {
#[serde(rename = "accountsBlockAddingNonMicrosoftAccountEmail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub accounts_block_adding_non_microsoft_account_email: Option<bool>,
#[serde(rename = "applyOnlyToWindows81")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apply_only_to_windows81: Option<bool>,
#[serde(rename = "browserBlockAutofill")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_autofill: Option<bool>,
#[serde(rename = "browserBlockAutomaticDetectionOfIntranetSites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_automatic_detection_of_intranet_sites: Option<bool>,
#[serde(rename = "browserBlockEnterpriseModeAccess")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_enterprise_mode_access: Option<bool>,
#[serde(rename = "browserBlockJavaScript")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_java_script: Option<bool>,
#[serde(rename = "browserBlockPlugins")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_plugins: Option<bool>,
#[serde(rename = "browserBlockPopups")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_popups: Option<bool>,
#[serde(rename = "browserBlockSendingDoNotTrackHeader")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_sending_do_not_track_header: Option<bool>,
#[serde(rename = "browserBlockSingleWordEntryOnIntranetSites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_block_single_word_entry_on_intranet_sites: Option<bool>,
#[serde(rename = "browserRequireSmartScreen")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_require_smart_screen: Option<bool>,
#[serde(rename = "browserEnterpriseModeSiteListLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_enterprise_mode_site_list_location: Option<String>,
#[serde(rename = "browserInternetSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_internet_security_level: Option<InternetSiteSecurityLevel>,
#[serde(rename = "browserIntranetSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_intranet_security_level: Option<SiteSecurityLevel>,
#[serde(rename = "browserLoggingReportLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_logging_report_location: Option<String>,
#[serde(rename = "browserRequireHighSecurityForRestrictedSites")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_require_high_security_for_restricted_sites: Option<bool>,
#[serde(rename = "browserRequireFirewall")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_require_firewall: Option<bool>,
#[serde(rename = "browserRequireFraudWarning")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_require_fraud_warning: Option<bool>,
#[serde(rename = "browserTrustedSitesSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub browser_trusted_sites_security_level: Option<SiteSecurityLevel>,
#[serde(rename = "cellularBlockDataRoaming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_data_roaming: Option<bool>,
#[serde(rename = "diagnosticsBlockDataSubmission")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostics_block_data_submission: Option<bool>,
#[serde(rename = "passwordBlockPicturePasswordAndPin")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_picture_password_and_pin: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "storageRequireDeviceEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_device_encryption: Option<bool>,
#[serde(rename = "updatesRequireAutomaticUpdates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub updates_require_automatic_updates: Option<bool>,
#[serde(rename = "userAccountControlSettings")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_account_control_settings: Option<WindowsUserAccountControlSettings>,
#[serde(rename = "workFoldersUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub work_folders_url: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsPhone81GeneralConfiguration {
#[serde(rename = "applyOnlyToWindowsPhone81")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apply_only_to_windows_phone81: Option<bool>,
#[serde(rename = "appsBlockCopyPaste")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apps_block_copy_paste: Option<bool>,
#[serde(rename = "bluetoothBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bluetooth_blocked: Option<bool>,
#[serde(rename = "cameraBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub camera_blocked: Option<bool>,
#[serde(rename = "cellularBlockWifiTethering")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cellular_block_wifi_tethering: Option<bool>,
#[serde(rename = "compliantAppsList")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_apps_list: Option<Vec<AppListItem>>,
#[serde(rename = "compliantAppListType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliant_app_list_type: Option<AppListType>,
#[serde(rename = "diagnosticDataBlockSubmission")]
#[serde(skip_serializing_if = "Option::is_none")]
pub diagnostic_data_block_submission: Option<bool>,
#[serde(rename = "emailBlockAddingAccounts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email_block_adding_accounts: Option<bool>,
#[serde(rename = "locationServicesBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location_services_blocked: Option<bool>,
#[serde(rename = "microsoftAccountBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub microsoft_account_blocked: Option<bool>,
#[serde(rename = "nfcBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub nfc_blocked: Option<bool>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeScreenTimeout")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_screen_timeout: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordSignInFailureCountBeforeFactoryReset")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_sign_in_failure_count_before_factory_reset: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "screenCaptureBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub screen_capture_blocked: Option<bool>,
#[serde(rename = "storageBlockRemovableStorage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_block_removable_storage: Option<bool>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
#[serde(rename = "webBrowserBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_browser_blocked: Option<bool>,
#[serde(rename = "wifiBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wifi_blocked: Option<bool>,
#[serde(rename = "wifiBlockAutomaticConnectHotspots")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wifi_block_automatic_connect_hotspots: Option<bool>,
#[serde(rename = "wifiBlockHotspotReporting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub wifi_block_hotspot_reporting: Option<bool>,
#[serde(rename = "windowsStoreBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_store_blocked: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10TeamGeneralConfiguration {
#[serde(rename = "azureOperationalInsightsBlockTelemetry")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_operational_insights_block_telemetry: Option<bool>,
#[serde(rename = "azureOperationalInsightsWorkspaceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_operational_insights_workspace_id: Option<String>,
#[serde(rename = "azureOperationalInsightsWorkspaceKey")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_operational_insights_workspace_key: Option<String>,
#[serde(rename = "connectAppBlockAutoLaunch")]
#[serde(skip_serializing_if = "Option::is_none")]
pub connect_app_block_auto_launch: Option<bool>,
#[serde(rename = "maintenanceWindowBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maintenance_window_blocked: Option<bool>,
#[serde(rename = "maintenanceWindowDurationInHours")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maintenance_window_duration_in_hours: Option<i32>,
#[serde(rename = "maintenanceWindowStartTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub maintenance_window_start_time: Option<String>,
#[serde(rename = "miracastChannel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub miracast_channel: Option<MiracastChannel>,
#[serde(rename = "miracastBlocked")]
#[serde(skip_serializing_if = "Option::is_none")]
pub miracast_blocked: Option<bool>,
#[serde(rename = "miracastRequirePin")]
#[serde(skip_serializing_if = "Option::is_none")]
pub miracast_require_pin: Option<bool>,
#[serde(rename = "settingsBlockMyMeetingsAndFiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_my_meetings_and_files: Option<bool>,
#[serde(rename = "settingsBlockSessionResume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_session_resume: Option<bool>,
#[serde(rename = "settingsBlockSigninSuggestions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_block_signin_suggestions: Option<bool>,
#[serde(rename = "settingsDefaultVolume")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_default_volume: Option<i32>,
#[serde(rename = "settingsScreenTimeoutInMinutes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_screen_timeout_in_minutes: Option<i32>,
#[serde(rename = "settingsSessionTimeoutInMinutes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_session_timeout_in_minutes: Option<i32>,
#[serde(rename = "settingsSleepTimeoutInMinutes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub settings_sleep_timeout_in_minutes: Option<i32>,
#[serde(rename = "welcomeScreenBlockAutomaticWakeUp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub welcome_screen_block_automatic_wake_up: Option<bool>,
#[serde(rename = "welcomeScreenBackgroundImageUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub welcome_screen_background_image_url: Option<String>,
#[serde(rename = "welcomeScreenMeetingInformation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub welcome_screen_meeting_information: Option<WelcomeScreenMeetingInformation>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidCompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<AndroidRequiredPasswordType>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "securityPreventInstallAppsFromUnknownSources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_prevent_install_apps_from_unknown_sources: Option<bool>,
#[serde(rename = "securityDisableUsbDebugging")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_disable_usb_debugging: Option<bool>,
#[serde(rename = "securityRequireVerifyApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_verify_apps: Option<bool>,
#[serde(rename = "deviceThreatProtectionEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_enabled: Option<bool>,
#[serde(rename = "deviceThreatProtectionRequiredSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_required_security_level: Option<DeviceThreatProtectionLevel>,
#[serde(rename = "securityBlockJailbrokenDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_block_jailbroken_devices: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "minAndroidSecurityPatchLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_android_security_patch_level: Option<String>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
#[serde(rename = "securityRequireSafetyNetAttestationBasicIntegrity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_safety_net_attestation_basic_integrity: Option<bool>,
#[serde(rename = "securityRequireSafetyNetAttestationCertifiedDevice")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_safety_net_attestation_certified_device: Option<bool>,
#[serde(rename = "securityRequireGooglePlayServices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_google_play_services: Option<bool>,
#[serde(rename = "securityRequireUpToDateSecurityProviders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_up_to_date_security_providers: Option<bool>,
#[serde(rename = "securityRequireCompanyPortalAppIntegrity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_company_portal_app_integrity: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidWorkProfileCompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<AndroidRequiredPasswordType>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "securityPreventInstallAppsFromUnknownSources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_prevent_install_apps_from_unknown_sources: Option<bool>,
#[serde(rename = "securityDisableUsbDebugging")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_disable_usb_debugging: Option<bool>,
#[serde(rename = "securityRequireVerifyApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_verify_apps: Option<bool>,
#[serde(rename = "deviceThreatProtectionEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_enabled: Option<bool>,
#[serde(rename = "deviceThreatProtectionRequiredSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_required_security_level: Option<DeviceThreatProtectionLevel>,
#[serde(rename = "securityBlockJailbrokenDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_block_jailbroken_devices: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "minAndroidSecurityPatchLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub min_android_security_patch_level: Option<String>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
#[serde(rename = "securityRequireSafetyNetAttestationBasicIntegrity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_safety_net_attestation_basic_integrity: Option<bool>,
#[serde(rename = "securityRequireSafetyNetAttestationCertifiedDevice")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_safety_net_attestation_certified_device: Option<bool>,
#[serde(rename = "securityRequireGooglePlayServices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_google_play_services: Option<bool>,
#[serde(rename = "securityRequireUpToDateSecurityProviders")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_up_to_date_security_providers: Option<bool>,
#[serde(rename = "securityRequireCompanyPortalAppIntegrity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_require_company_portal_app_integrity: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosCompliancePolicy {
#[serde(rename = "passcodeBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_block_simple: Option<bool>,
#[serde(rename = "passcodeExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_expiration_days: Option<i32>,
#[serde(rename = "passcodeMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minimum_length: Option<i32>,
#[serde(rename = "passcodeMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passcodePreviousPasscodeBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_previous_passcode_block_count: Option<i32>,
#[serde(rename = "passcodeMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_minimum_character_set_count: Option<i32>,
#[serde(rename = "passcodeRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passcodeRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub passcode_required: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "securityBlockJailbrokenDevices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_block_jailbroken_devices: Option<bool>,
#[serde(rename = "deviceThreatProtectionEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_enabled: Option<bool>,
#[serde(rename = "deviceThreatProtectionRequiredSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_required_security_level: Option<DeviceThreatProtectionLevel>,
#[serde(rename = "managedEmailProfileRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_email_profile_required: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct MacOSCompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "systemIntegrityProtectionEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub system_integrity_protection_enabled: Option<bool>,
#[serde(rename = "deviceThreatProtectionEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_enabled: Option<bool>,
#[serde(rename = "deviceThreatProtectionRequiredSecurityLevel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_threat_protection_required_security_level: Option<DeviceThreatProtectionLevel>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
#[serde(rename = "firewallEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_enabled: Option<bool>,
#[serde(rename = "firewallBlockAllIncoming")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_block_all_incoming: Option<bool>,
#[serde(rename = "firewallEnableStealthMode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub firewall_enable_stealth_mode: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10CompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordRequiredToUnlockFromIdle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_to_unlock_from_idle: Option<bool>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "requireHealthyDeviceReport")]
#[serde(skip_serializing_if = "Option::is_none")]
pub require_healthy_device_report: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "mobileOsMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_os_minimum_version: Option<String>,
#[serde(rename = "mobileOsMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_os_maximum_version: Option<String>,
#[serde(rename = "earlyLaunchAntiMalwareDriverEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub early_launch_anti_malware_driver_enabled: Option<bool>,
#[serde(rename = "bitLockerEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_enabled: Option<bool>,
#[serde(rename = "secureBootEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub secure_boot_enabled: Option<bool>,
#[serde(rename = "codeIntegrityEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_integrity_enabled: Option<bool>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows10MobileCompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordRequireToUnlockFromIdle")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_require_to_unlock_from_idle: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "earlyLaunchAntiMalwareDriverEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub early_launch_anti_malware_driver_enabled: Option<bool>,
#[serde(rename = "bitLockerEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub bit_locker_enabled: Option<bool>,
#[serde(rename = "secureBootEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub secure_boot_enabled: Option<bool>,
#[serde(rename = "codeIntegrityEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub code_integrity_enabled: Option<bool>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Windows81CompliancePolicy {
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsPhone81CompliancePolicy {
#[serde(rename = "passwordBlockSimple")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_block_simple: Option<bool>,
#[serde(rename = "passwordExpirationDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_expiration_days: Option<i32>,
#[serde(rename = "passwordMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_length: Option<i32>,
#[serde(rename = "passwordMinutesOfInactivityBeforeLock")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minutes_of_inactivity_before_lock: Option<i32>,
#[serde(rename = "passwordMinimumCharacterSetCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_minimum_character_set_count: Option<i32>,
#[serde(rename = "passwordRequiredType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required_type: Option<RequiredPasswordType>,
#[serde(rename = "passwordPreviousPasswordBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_previous_password_block_count: Option<i32>,
#[serde(rename = "passwordRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub password_required: Option<bool>,
#[serde(rename = "osMinimumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_minimum_version: Option<String>,
#[serde(rename = "osMaximumVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_maximum_version: Option<String>,
#[serde(rename = "storageRequireEncryption")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_require_encryption: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceComplianceSettingState {
#[serde(rename = "setting")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting: Option<String>,
#[serde(rename = "settingName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub setting_name: Option<String>,
#[serde(rename = "deviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "deviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_name: Option<String>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "userEmail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_email: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "deviceModel")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_model: Option<String>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<ComplianceStatus>,
#[serde(rename = "complianceGracePeriodExpirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_grace_period_expiration_date_time: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EnrollmentConfigurationAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceEnrollmentLimitConfiguration {
#[serde(rename = "limit")]
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceEnrollmentPlatformRestrictionsConfiguration {
#[serde(rename = "iosRestriction")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ios_restriction: Option<DeviceEnrollmentPlatformRestriction>,
#[serde(rename = "windowsRestriction")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_restriction: Option<DeviceEnrollmentPlatformRestriction>,
#[serde(rename = "windowsMobileRestriction")]
#[serde(skip_serializing_if = "Option::is_none")]
pub windows_mobile_restriction: Option<DeviceEnrollmentPlatformRestriction>,
#[serde(rename = "androidRestriction")]
#[serde(skip_serializing_if = "Option::is_none")]
pub android_restriction: Option<DeviceEnrollmentPlatformRestriction>,
#[serde(rename = "macOSRestriction")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mac_o_s_restriction: Option<DeviceEnrollmentPlatformRestriction>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceEnrollmentWindowsHelloForBusinessConfiguration {
#[serde(rename = "pinMinimumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_minimum_length: Option<i32>,
#[serde(rename = "pinMaximumLength")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_maximum_length: Option<i32>,
#[serde(rename = "pinUppercaseCharactersUsage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_uppercase_characters_usage: Option<WindowsHelloForBusinessPinUsage>,
#[serde(rename = "pinLowercaseCharactersUsage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_lowercase_characters_usage: Option<WindowsHelloForBusinessPinUsage>,
#[serde(rename = "pinSpecialCharactersUsage")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_special_characters_usage: Option<WindowsHelloForBusinessPinUsage>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<Enablement>,
#[serde(rename = "securityDeviceRequired")]
#[serde(skip_serializing_if = "Option::is_none")]
pub security_device_required: Option<bool>,
#[serde(rename = "unlockWithBiometricsEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub unlock_with_biometrics_enabled: Option<bool>,
#[serde(rename = "remotePassportEnabled")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remote_passport_enabled: Option<bool>,
#[serde(rename = "pinPreviousBlockCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_previous_block_count: Option<i32>,
#[serde(rename = "pinExpirationInDays")]
#[serde(skip_serializing_if = "Option::is_none")]
pub pin_expiration_in_days: Option<i32>,
#[serde(rename = "enhancedBiometricsState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enhanced_biometrics_state: Option<Enablement>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedMobileApp {
#[serde(rename = "mobileAppIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub mobile_app_identifier: Option<MobileAppIdentifier>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TargetedManagedAppPolicyAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppOperation {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "state")]
#[serde(skip_serializing_if = "Option::is_none")]
pub state: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppPolicyDeploymentSummary {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "configurationDeployedUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_deployed_user_count: Option<i32>,
#[serde(rename = "lastRefreshTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_refresh_time: Option<String>,
#[serde(rename = "configurationDeploymentSummaryPerApp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration_deployment_summary_per_app:
Option<Vec<ManagedAppPolicyDeploymentSummaryPerApp>>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct WindowsInformationProtectionAppLockerFile {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "fileHash")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_hash: Option<String>,
#[serde(rename = "file")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file: Option<Vec<u8>>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosManagedAppRegistration(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl IosManagedAppRegistration {
pub fn new(value: Option<serde_json::Value>) -> IosManagedAppRegistration {
IosManagedAppRegistration(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AndroidManagedAppRegistration(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl AndroidManagedAppRegistration {
pub fn new(value: Option<serde_json::Value>) -> AndroidManagedAppRegistration {
AndroidManagedAppRegistration(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedAppStatusRaw {
#[serde(rename = "content")]
#[serde(skip_serializing_if = "Option::is_none")]
pub content: Option<Json>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct LocalizedNotificationMessage {
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "locale")]
#[serde(skip_serializing_if = "Option::is_none")]
pub locale: Option<String>,
#[serde(rename = "subject")]
#[serde(skip_serializing_if = "Option::is_none")]
pub subject: Option<String>,
#[serde(rename = "messageTemplate")]
#[serde(skip_serializing_if = "Option::is_none")]
pub message_template: Option<String>,
#[serde(rename = "isDefault")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_default: Option<bool>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceAndAppManagementRoleDefinition(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl DeviceAndAppManagementRoleDefinition {
pub fn new(value: Option<serde_json::Value>) -> DeviceAndAppManagementRoleDefinition {
DeviceAndAppManagementRoleDefinition(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ManagedEBookAssignment {
#[serde(rename = "target")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target: Option<DeviceAndAppManagementAssignmentTarget>,
#[serde(rename = "installIntent")]
#[serde(skip_serializing_if = "Option::is_none")]
pub install_intent: Option<InstallIntent>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EBookInstallSummary {
#[serde(rename = "installedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub installed_device_count: Option<i32>,
#[serde(rename = "failedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_device_count: Option<i32>,
#[serde(rename = "notInstalledDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_installed_device_count: Option<i32>,
#[serde(rename = "installedUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub installed_user_count: Option<i32>,
#[serde(rename = "failedUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_user_count: Option<i32>,
#[serde(rename = "notInstalledUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_installed_user_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DeviceInstallState {
#[serde(rename = "deviceName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_name: Option<String>,
#[serde(rename = "deviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "lastSyncDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_sync_date_time: Option<String>,
#[serde(rename = "installState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub install_state: Option<InstallState>,
#[serde(rename = "errorCode")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error_code: Option<String>,
#[serde(rename = "osVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<String>,
#[serde(rename = "osDescription")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_description: Option<String>,
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct UserInstallStateSummary {
#[serde(rename = "userName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_name: Option<String>,
#[serde(rename = "installedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub installed_device_count: Option<i32>,
#[serde(rename = "failedDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failed_device_count: Option<i32>,
#[serde(rename = "notInstalledDeviceCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub not_installed_device_count: Option<i32>,
#[serde(rename = "deviceStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_states: Option<Vec<DeviceInstallState>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosVppEBookAssignment(
#[serde(skip_serializing_if = "Option::is_none")] Option<serde_json::Value>,
);
#[cfg(feature = "option")]
impl IosVppEBookAssignment {
pub fn new(value: Option<serde_json::Value>) -> IosVppEBookAssignment {
IosVppEBookAssignment(value)
}
pub fn value(&self) -> Option<&serde_json::Value> {
self.0.as_ref()
}
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IosVppEBook {
#[serde(rename = "vppTokenId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_token_id: Option<String>,
#[serde(rename = "appleId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub apple_id: Option<String>,
#[serde(rename = "vppOrganizationName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vpp_organization_name: Option<String>,
#[serde(rename = "genres")]
#[serde(skip_serializing_if = "Option::is_none")]
pub genres: Option<Vec<String>>,
#[serde(rename = "language")]
#[serde(skip_serializing_if = "Option::is_none")]
pub language: Option<String>,
#[serde(rename = "seller")]
#[serde(skip_serializing_if = "Option::is_none")]
pub seller: Option<String>,
#[serde(rename = "totalLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub total_license_count: Option<i32>,
#[serde(rename = "usedLicenseCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub used_license_count: Option<i32>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct EnrollmentTroubleshootingEvent {
#[serde(rename = "managedDeviceIdentifier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub managed_device_identifier: Option<String>,
#[serde(rename = "operatingSystem")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operating_system: Option<String>,
#[serde(rename = "osVersion")]
#[serde(skip_serializing_if = "Option::is_none")]
pub os_version: Option<String>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "deviceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_id: Option<String>,
#[serde(rename = "enrollmentType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enrollment_type: Option<DeviceEnrollmentType>,
#[serde(rename = "failureCategory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_category: Option<DeviceEnrollmentFailureReason>,
#[serde(rename = "failureReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub failure_reason: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct ActivityHistoryItem {
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<Status>,
#[serde(rename = "activeDurationSeconds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_duration_seconds: Option<i32>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "lastActiveDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_active_date_time: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "expirationDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub expiration_date_time: Option<String>,
#[serde(rename = "startedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub started_date_time: Option<String>,
#[serde(rename = "userTimezone")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_timezone: Option<String>,
#[serde(rename = "activity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity: Option<UserActivity>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Security {
#[serde(rename = "alerts")]
#[serde(skip_serializing_if = "Option::is_none")]
pub alerts: Option<Vec<Alert>>,
#[serde(rename = "secureScoreControlProfiles")]
#[serde(skip_serializing_if = "Option::is_none")]
pub secure_score_control_profiles: Option<Vec<SecureScoreControlProfile>>,
#[serde(rename = "secureScores")]
#[serde(skip_serializing_if = "Option::is_none")]
pub secure_scores: Option<Vec<SecureScore>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Alert {
#[serde(rename = "activityGroupName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_group_name: Option<String>,
#[serde(rename = "assignedTo")]
#[serde(skip_serializing_if = "Option::is_none")]
pub assigned_to: Option<String>,
#[serde(rename = "azureSubscriptionId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_subscription_id: Option<String>,
#[serde(rename = "azureTenantId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_tenant_id: Option<String>,
#[serde(rename = "category")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
#[serde(rename = "closedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub closed_date_time: Option<String>,
#[serde(rename = "cloudAppStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub cloud_app_states: Option<Vec<CloudAppSecurityState>>,
#[serde(rename = "comments")]
#[serde(skip_serializing_if = "Option::is_none")]
pub comments: Option<Vec<String>>,
#[serde(rename = "confidence")]
#[serde(skip_serializing_if = "Option::is_none")]
pub confidence: Option<i32>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "detectionIds")]
#[serde(skip_serializing_if = "Option::is_none")]
pub detection_ids: Option<Vec<String>>,
#[serde(rename = "eventDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub event_date_time: Option<String>,
#[serde(rename = "feedback")]
#[serde(skip_serializing_if = "Option::is_none")]
pub feedback: Option<AlertFeedback>,
#[serde(rename = "fileStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub file_states: Option<Vec<FileSecurityState>>,
#[serde(rename = "historyStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub history_states: Option<Vec<AlertHistoryState>>,
#[serde(rename = "hostStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub host_states: Option<Vec<HostSecurityState>>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "malwareStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub malware_states: Option<Vec<MalwareState>>,
#[serde(rename = "networkConnections")]
#[serde(skip_serializing_if = "Option::is_none")]
pub network_connections: Option<Vec<NetworkConnection>>,
#[serde(rename = "processes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub processes: Option<Vec<Process>>,
#[serde(rename = "recommendedActions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub recommended_actions: Option<Vec<String>>,
#[serde(rename = "registryKeyStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub registry_key_states: Option<Vec<RegistryKeyState>>,
#[serde(rename = "severity")]
#[serde(skip_serializing_if = "Option::is_none")]
pub severity: Option<AlertSeverity>,
#[serde(rename = "sourceMaterials")]
#[serde(skip_serializing_if = "Option::is_none")]
pub source_materials: Option<Vec<String>>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<AlertStatus>,
#[serde(rename = "tags")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tags: Option<Vec<String>>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "triggers")]
#[serde(skip_serializing_if = "Option::is_none")]
pub triggers: Option<Vec<AlertTrigger>>,
#[serde(rename = "userStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_states: Option<Vec<UserSecurityState>>,
#[serde(rename = "vendorInformation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vendor_information: Option<SecurityVendorInformation>,
#[serde(rename = "vulnerabilityStates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vulnerability_states: Option<Vec<VulnerabilityState>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SecureScoreControlProfile {
#[serde(rename = "actionType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub action_type: Option<String>,
#[serde(rename = "actionUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub action_url: Option<String>,
#[serde(rename = "azureTenantId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_tenant_id: Option<String>,
#[serde(rename = "complianceInformation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub compliance_information: Option<Vec<ComplianceInformation>>,
#[serde(rename = "controlCategory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub control_category: Option<String>,
#[serde(rename = "controlStateUpdates")]
#[serde(skip_serializing_if = "Option::is_none")]
pub control_state_updates: Option<Vec<SecureScoreControlStateUpdate>>,
#[serde(rename = "deprecated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub deprecated: Option<bool>,
#[serde(rename = "implementationCost")]
#[serde(skip_serializing_if = "Option::is_none")]
pub implementation_cost: Option<String>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "maxScore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_score: Option<i64>,
#[serde(rename = "rank")]
#[serde(skip_serializing_if = "Option::is_none")]
pub rank: Option<i32>,
#[serde(rename = "remediation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediation: Option<String>,
#[serde(rename = "remediationImpact")]
#[serde(skip_serializing_if = "Option::is_none")]
pub remediation_impact: Option<String>,
#[serde(rename = "service")]
#[serde(skip_serializing_if = "Option::is_none")]
pub service: Option<String>,
#[serde(rename = "threats")]
#[serde(skip_serializing_if = "Option::is_none")]
pub threats: Option<Vec<String>>,
#[serde(rename = "tier")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tier: Option<String>,
#[serde(rename = "title")]
#[serde(skip_serializing_if = "Option::is_none")]
pub title: Option<String>,
#[serde(rename = "userImpact")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_impact: Option<String>,
#[serde(rename = "vendorInformation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vendor_information: Option<SecurityVendorInformation>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SecureScore {
#[serde(rename = "activeUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub active_user_count: Option<i32>,
#[serde(rename = "averageComparativeScores")]
#[serde(skip_serializing_if = "Option::is_none")]
pub average_comparative_scores: Option<Vec<AverageComparativeScore>>,
#[serde(rename = "azureTenantId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub azure_tenant_id: Option<String>,
#[serde(rename = "controlScores")]
#[serde(skip_serializing_if = "Option::is_none")]
pub control_scores: Option<Vec<ControlScore>>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "currentScore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub current_score: Option<i64>,
#[serde(rename = "enabledServices")]
#[serde(skip_serializing_if = "Option::is_none")]
pub enabled_services: Option<Vec<String>>,
#[serde(rename = "licensedUserCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub licensed_user_count: Option<i32>,
#[serde(rename = "maxScore")]
#[serde(skip_serializing_if = "Option::is_none")]
pub max_score: Option<i64>,
#[serde(rename = "vendorInformation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub vendor_information: Option<SecurityVendorInformation>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Trending {
#[serde(rename = "weight")]
#[serde(skip_serializing_if = "Option::is_none")]
pub weight: Option<i64>,
#[serde(rename = "resourceVisualization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_visualization: Option<ResourceVisualization>,
#[serde(rename = "resourceReference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_reference: Option<ResourceReference>,
#[serde(rename = "lastModifiedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_modified_date_time: Option<String>,
#[serde(rename = "resource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<Entity>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SharedInsight {
#[serde(rename = "lastShared")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_shared: Option<SharingDetail>,
#[serde(rename = "sharingHistory")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sharing_history: Option<Vec<SharingDetail>>,
#[serde(rename = "resourceVisualization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_visualization: Option<ResourceVisualization>,
#[serde(rename = "resourceReference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_reference: Option<ResourceReference>,
#[serde(rename = "lastSharedMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_shared_method: Option<Entity>,
#[serde(rename = "resource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<Entity>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct UsedInsight {
#[serde(rename = "lastUsed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_used: Option<UsageDetails>,
#[serde(rename = "resourceVisualization")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_visualization: Option<ResourceVisualization>,
#[serde(rename = "resourceReference")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_reference: Option<ResourceReference>,
#[serde(rename = "resource")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource: Option<Entity>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AppCatalogs {
#[serde(rename = "teamsApps")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_apps: Option<Vec<TeamsApp>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TeamsApp {
#[serde(rename = "externalId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub external_id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "distributionMethod")]
#[serde(skip_serializing_if = "Option::is_none")]
pub distribution_method: Option<TeamsAppDistributionMethod>,
#[serde(rename = "appDefinitions")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_definitions: Option<Vec<TeamsAppDefinition>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct Channel {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "description")]
#[serde(skip_serializing_if = "Option::is_none")]
pub description: Option<String>,
#[serde(rename = "email")]
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
#[serde(rename = "webUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_url: Option<String>,
#[serde(rename = "tabs")]
#[serde(skip_serializing_if = "Option::is_none")]
pub tabs: Option<Vec<TeamsTab>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TeamsAppInstallation {
#[serde(rename = "teamsApp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_app: Option<TeamsApp>,
#[serde(rename = "teamsAppDefinition")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_app_definition: Option<TeamsAppDefinition>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TeamsAsyncOperation {
#[serde(rename = "operationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operation_type: Option<TeamsAsyncOperationType>,
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<TeamsAsyncOperationStatus>,
#[serde(rename = "lastActionDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub last_action_date_time: Option<String>,
#[serde(rename = "attemptsCount")]
#[serde(skip_serializing_if = "Option::is_none")]
pub attempts_count: Option<i32>,
#[serde(rename = "targetResourceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_resource_id: Option<String>,
#[serde(rename = "targetResourceLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_resource_location: Option<String>,
#[serde(rename = "error")]
#[serde(skip_serializing_if = "Option::is_none")]
pub error: Option<OperationError>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TeamsAppDefinition {
#[serde(rename = "teamsAppId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_app_id: Option<String>,
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "version")]
#[serde(skip_serializing_if = "Option::is_none")]
pub version: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TeamsTab {
#[serde(rename = "displayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub display_name: Option<String>,
#[serde(rename = "webUrl")]
#[serde(skip_serializing_if = "Option::is_none")]
pub web_url: Option<String>,
#[serde(rename = "configuration")]
#[serde(skip_serializing_if = "Option::is_none")]
pub configuration: Option<TeamsTabConfiguration>,
#[serde(rename = "teamsApp")]
#[serde(skip_serializing_if = "Option::is_none")]
pub teams_app: Option<TeamsApp>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DataPolicyOperation {
#[serde(rename = "completedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub completed_date_time: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<DataPolicyOperationStatus>,
#[serde(rename = "storageLocation")]
#[serde(skip_serializing_if = "Option::is_none")]
pub storage_location: Option<String>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "submittedDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub submitted_date_time: Option<String>,
#[serde(rename = "progress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub progress: Option<i64>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct IdentityProvider {
#[serde(rename = "type")]
#[serde(skip_serializing_if = "Option::is_none")]
pub _type: Option<String>,
#[serde(rename = "name")]
#[serde(skip_serializing_if = "Option::is_none")]
pub name: Option<String>,
#[serde(rename = "clientId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_id: Option<String>,
#[serde(rename = "clientSecret")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_secret: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct DirectoryAudit {
#[serde(rename = "category")]
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
#[serde(rename = "correlationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub correlation_id: Option<String>,
#[serde(rename = "result")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result: Option<OperationResult>,
#[serde(rename = "resultReason")]
#[serde(skip_serializing_if = "Option::is_none")]
pub result_reason: Option<String>,
#[serde(rename = "activityDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_display_name: Option<String>,
#[serde(rename = "activityDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub activity_date_time: Option<String>,
#[serde(rename = "loggedByService")]
#[serde(skip_serializing_if = "Option::is_none")]
pub logged_by_service: Option<String>,
#[serde(rename = "operationType")]
#[serde(skip_serializing_if = "Option::is_none")]
pub operation_type: Option<String>,
#[serde(rename = "initiatedBy")]
#[serde(skip_serializing_if = "Option::is_none")]
pub initiated_by: Option<AuditActivityInitiator>,
#[serde(rename = "targetResources")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_resources: Option<Vec<TargetResource>>,
#[serde(rename = "additionalDetails")]
#[serde(skip_serializing_if = "Option::is_none")]
pub additional_details: Option<Vec<KeyValue>>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct SignIn {
#[serde(rename = "createdDateTime")]
#[serde(skip_serializing_if = "Option::is_none")]
pub created_date_time: Option<String>,
#[serde(rename = "userDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_display_name: Option<String>,
#[serde(rename = "userPrincipalName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_principal_name: Option<String>,
#[serde(rename = "userId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub user_id: Option<String>,
#[serde(rename = "appId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_id: Option<String>,
#[serde(rename = "appDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub app_display_name: Option<String>,
#[serde(rename = "ipAddress")]
#[serde(skip_serializing_if = "Option::is_none")]
pub ip_address: Option<String>,
#[serde(rename = "status")]
#[serde(skip_serializing_if = "Option::is_none")]
pub status: Option<SignInStatus>,
#[serde(rename = "clientAppUsed")]
#[serde(skip_serializing_if = "Option::is_none")]
pub client_app_used: Option<String>,
#[serde(rename = "deviceDetail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub device_detail: Option<DeviceDetail>,
#[serde(rename = "location")]
#[serde(skip_serializing_if = "Option::is_none")]
pub location: Option<SignInLocation>,
#[serde(rename = "correlationId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub correlation_id: Option<String>,
#[serde(rename = "conditionalAccessStatus")]
#[serde(skip_serializing_if = "Option::is_none")]
pub conditional_access_status: Option<ConditionalAccessStatus>,
#[serde(rename = "appliedConditionalAccessPolicies")]
#[serde(skip_serializing_if = "Option::is_none")]
pub applied_conditional_access_policies: Option<Vec<AppliedConditionalAccessPolicy>>,
#[serde(rename = "isInteractive")]
#[serde(skip_serializing_if = "Option::is_none")]
pub is_interactive: Option<bool>,
#[serde(rename = "riskDetail")]
#[serde(skip_serializing_if = "Option::is_none")]
pub risk_detail: Option<RiskDetail>,
#[serde(rename = "riskLevelAggregated")]
#[serde(skip_serializing_if = "Option::is_none")]
pub risk_level_aggregated: Option<RiskLevel>,
#[serde(rename = "riskLevelDuringSignIn")]
#[serde(skip_serializing_if = "Option::is_none")]
pub risk_level_during_sign_in: Option<RiskLevel>,
#[serde(rename = "riskState")]
#[serde(skip_serializing_if = "Option::is_none")]
pub risk_state: Option<RiskState>,
#[serde(rename = "riskEventTypes")]
#[serde(skip_serializing_if = "Option::is_none")]
pub risk_event_types: Option<Vec<RiskEventType>>,
#[serde(rename = "resourceDisplayName")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_display_name: Option<String>,
#[serde(rename = "resourceId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub resource_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct RestrictedSignIn {
#[serde(rename = "targetTenantId")]
#[serde(skip_serializing_if = "Option::is_none")]
pub target_tenant_id: Option<String>,
}
#[cfg(feature = "option")]
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct AuditLogRoot {
#[serde(rename = "signIns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub sign_ins: Option<Vec<SignIn>>,
#[serde(rename = "directoryAudits")]
#[serde(skip_serializing_if = "Option::is_none")]
pub directory_audits: Option<Vec<DirectoryAudit>>,
#[serde(rename = "restrictedSignIns")]
#[serde(skip_serializing_if = "Option::is_none")]
pub restricted_sign_ins: Option<Vec<RestrictedSignIn>>,
}
|
use azure_core::AppendToUrlQuery;
// This type could also be a DateTime
// but the docs clearly states to treat is
// as opaque so we do not convert it in
// any way.
// see: https://docs.microsoft.com/rest/api/storageservices/get-blob
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct VersionId(String);
impl VersionId {
pub fn new(version_id: String) -> Self {
Self(version_id)
}
}
impl AppendToUrlQuery for &VersionId {
fn append_to_url_query(&self, url: &mut url::Url) {
url.query_pairs_mut().append_pair("version_id", &self.0);
}
}
impl<S> From<S> for VersionId
where
S: Into<String>,
{
fn from(version_id: S) -> Self {
Self::new(version_id.into())
}
}
|
//! A Proxy Protocol Parser written in Rust.
//! Supports both text and binary versions of the header protocol.
mod ip;
pub mod v1;
pub mod v2;
/// The canonical way to determine when a streamed header should be retried in a streaming context.
/// The protocol states that servers may choose to support partial headers or to close the connection if the header is not present all at once.
pub trait PartialResult {
/// Tests whether this `Result` is successful or whether the error is terminal.
/// A terminal error will not result in a success even with more bytes.
/// Retrying with the same -- or more -- input will not change the result.
fn is_complete(&self) -> bool {
!self.is_incomplete()
}
/// Tests whether this `Result` is incomplete.
/// An action that leads to an incomplete result may have a different result with more bytes.
/// Retrying with the same input will not change the result.
fn is_incomplete(&self) -> bool;
}
impl<'a, T, E: PartialResult> PartialResult for Result<T, E> {
fn is_incomplete(&self) -> bool {
match self {
Ok(_) => false,
Err(error) => error.is_incomplete(),
}
}
}
impl<'a> PartialResult for v1::ParseError {
fn is_incomplete(&self) -> bool {
matches!(
self,
v1::ParseError::Partial
| v1::ParseError::MissingPrefix
| v1::ParseError::MissingProtocol
| v1::ParseError::MissingSourceAddress
| v1::ParseError::MissingDestinationAddress
| v1::ParseError::MissingSourcePort
| v1::ParseError::MissingDestinationPort
| v1::ParseError::MissingNewLine
)
}
}
impl<'a> PartialResult for v1::BinaryParseError {
fn is_incomplete(&self) -> bool {
match self {
v1::BinaryParseError::Parse(error) => error.is_incomplete(),
_ => false,
}
}
}
impl<'a> PartialResult for v2::ParseError {
fn is_incomplete(&self) -> bool {
matches!(
self,
v2::ParseError::Incomplete(..) | v2::ParseError::Partial(..)
)
}
}
/// An enumeration of the supported header version's parse results.
/// Useful for parsing either version 1 or version 2 of the PROXY protocol.
///
/// ## Examples
/// ```rust
/// use ppp::{HeaderResult, PartialResult, v1, v2};
///
/// let input = "PROXY UNKNOWN\r\n";
/// let header = HeaderResult::parse(input.as_bytes());
///
/// assert_eq!(header, Ok(v1::Header::new(input, v1::Addresses::Unknown)).into());
/// ```
#[derive(Debug, PartialEq)]
#[must_use = "this `HeaderResult` may contain a V1 or V2 `Err` variant, which should be handled"]
pub enum HeaderResult<'a> {
V1(Result<v1::Header<'a>, v1::BinaryParseError>),
V2(Result<v2::Header<'a>, v2::ParseError>),
}
impl<'a> From<Result<v1::Header<'a>, v1::BinaryParseError>> for HeaderResult<'a> {
fn from(result: Result<v1::Header<'a>, v1::BinaryParseError>) -> Self {
HeaderResult::V1(result)
}
}
impl<'a> From<Result<v2::Header<'a>, v2::ParseError>> for HeaderResult<'a> {
fn from(result: Result<v2::Header<'a>, v2::ParseError>) -> Self {
HeaderResult::V2(result)
}
}
impl<'a> PartialResult for HeaderResult<'a> {
fn is_incomplete(&self) -> bool {
match self {
Self::V1(result) => result.is_incomplete(),
Self::V2(result) => result.is_incomplete(),
}
}
}
impl<'a> HeaderResult<'a> {
/// Parses a PROXY protocol version 2 `Header`.
/// If the input is not a valid version 2 `Header`, attempts to parse a version 1 `Header`.
pub fn parse(input: &'a [u8]) -> HeaderResult<'a> {
let header = v2::Header::try_from(input);
if header.is_complete() && header.is_err() {
v1::Header::try_from(input).into()
} else {
header.into()
}
}
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.